From 2c376ac3ae651dd6c6592cc4cbf72768dc97a93d Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 13 Dec 2017 13:45:13 +0200 Subject: Moved Machine Studio to its own folder. --- .../Tango.MachineStudio.UI.csproj | 283 +++++++++++++++++++++ 1 file changed, 283 insertions(+) create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj') diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj new file mode 100644 index 000000000..67e00db8d --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj @@ -0,0 +1,283 @@ + + + + + Debug + AnyCPU + {116DFDB0-7681-46FE-8BAD-FE8AE09BB076} + WinExe + Tango.MachineStudio.UI + Tango.MachineStudio.UI + v4.6 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + + + AnyCPU + true + full + false + ..\..\Build\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + design.ico + + + + ..\..\packages\Dragablz.0.0.3.197\lib\net45\Dragablz.dll + + + ..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll + + + ..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll + + + ..\..\packages\FontAwesome.WPF.4.7.0.9\lib\net40\FontAwesome.WPF.dll + + + ..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.dll + + + ..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.Extras.dll + + + ..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.Platform.dll + + + ..\..\packages\MahApps.Metro.1.5.0\lib\net45\MahApps.Metro.dll + + + ..\..\packages\MaterialDesignColors.1.1.2\lib\net45\MaterialDesignColors.dll + + + ..\..\packages\MaterialDesignThemes.2.3.1.953\lib\net45\MaterialDesignThemes.Wpf.dll + + + ..\..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll + + + + + + + + ..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\System.Windows.Interactivity.dll + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + DbTableView.xaml + + + + + + + + + + + + + + + + + + + + AddressesView.xaml + + + AddressView.xaml + + + MachinesView.xaml + + + MachineView.xaml + + + OrganizationView.xaml + + + UsersView.xaml + + + UserView.xaml + + + MainView.xaml + + + OrganizationsView.xaml + + + DialogWindow.xaml + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + GlobalVersionInfo.cs + + + App.xaml + Code + + + MainWindow.xaml + Code + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + + + + + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + + + + {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} + Tango.Core + + + {0ecd6da8-7aa6-48d9-8b65-279d176ad9af} + Tango.DAL.Observables + + + {38197109-8610-4d3f-92b9-16d48df94d7c} + Tango.DAL.Remote + + + {bc932dbd-7cdb-488c-99e4-f02cf441f55e} + Tango.Logging + + + {d8f1ad85-526a-4f50-b6dc-d437af63d8d8} + Tango.Settings + + + {8491d07b-c1f6-4b62-a412-41b9fd2d6538} + Tango.SharedUI + + + + + + + + + + + + + + $(TargetDir)linkgen.exe -s "$(TargetPath)" -d "$(TargetDir)Utilities\Machine Studio.lnk" + + \ No newline at end of file -- cgit v1.3.1 From 2a51f05523c1397b77eca5e5188520919205638c Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 13 Dec 2017 15:19:55 +0200 Subject: Successfully separated Machine Studio to modules... --- .../Modules/Tango.MachineStudio.DB/App.config | 13 ++ .../Controls/DbTableView.xaml | 41 ++++ .../Controls/DbTableView.xaml.cs | 38 ++++ .../Tango.MachineStudio.DB/Controls/TableGrid.cs | 58 ++++++ .../Converters/UsersRolesToStringConverter.cs | 37 ++++ .../CustomAttributes/DBViewAttribute.cs | 12 ++ .../INotificationProviderExtensions.cs | 27 +++ .../Managers/RegisteredView.cs | 54 +++++ .../Managers/ViewsManager.cs | 31 +++ .../Properties/AssemblyInfo.cs | 18 ++ .../Properties/Resources.Designer.cs | 62 ++++++ .../Properties/Resources.resx | 117 +++++++++++ .../Properties/Settings.Designer.cs | 30 +++ .../Properties/Settings.settings | 7 + .../Tango.MachineStudio.DB.csproj | 220 +++++++++++++++++++++ .../Tango.MachineStudio.DB/ViewModelLocator.cs | 68 +++++++ .../ViewModels/AddressesViewVM.cs | 17 ++ .../ViewModels/DbTableViewModel.cs | 219 ++++++++++++++++++++ .../ViewModels/DialogOpenMode.cs | 14 ++ .../ViewModels/EntityViewModel.cs | 31 +++ .../ViewModels/MachinesViewVM.cs | 26 +++ .../ViewModels/MainViewVM.cs | 19 ++ .../ViewModels/MultiComboVM.cs | 44 +++++ .../ViewModels/OrganizationsViewVM.cs | 26 +++ .../ViewModels/UsersViewVM.cs | 77 ++++++++ .../Views/DBViews/AddressView.xaml | 34 ++++ .../Views/DBViews/AddressView.xaml.cs | 28 +++ .../Views/DBViews/AddressesView.xaml | 28 +++ .../Views/DBViews/AddressesView.xaml.cs | 31 +++ .../Views/DBViews/MachineView.xaml | 28 +++ .../Views/DBViews/MachineView.xaml.cs | 28 +++ .../Views/DBViews/MachinesView.xaml | 26 +++ .../Views/DBViews/MachinesView.xaml.cs | 32 +++ .../Views/DBViews/OrganizationView.xaml | 26 +++ .../Views/DBViews/OrganizationView.xaml.cs | 28 +++ .../Views/DBViews/OrganizationsView.xaml | 27 +++ .../Views/DBViews/OrganizationsView.xaml.cs | 30 +++ .../Views/DBViews/UserView.xaml | 48 +++++ .../Views/DBViews/UserView.xaml.cs | 34 ++++ .../Views/DBViews/UsersView.xaml | 33 ++++ .../Views/DBViews/UsersView.xaml.cs | 30 +++ .../Tango.MachineStudio.DB/Views/MainDBView.xaml | 74 +++++++ .../Views/MainDBView.xaml.cs | 30 +++ .../Modules/Tango.MachineStudio.DB/packages.config | 10 + .../Notifications/INotificationProvider.cs | 17 ++ .../Properties/AssemblyInfo.cs | 17 ++ .../Properties/Resources.Designer.cs | 62 ++++++ .../Properties/Resources.resx | 117 +++++++++++ .../Properties/Settings.Designer.cs | 30 +++ .../Properties/Settings.settings | 7 + .../Tango.MachineStudio.Common.csproj | 94 +++++++++ .../Tango.MachineStudio.Common/UserControl1.xaml | 12 ++ .../UserControl1.xaml.cs | 28 +++ .../Tango.MachineStudio.Common/packages.config | 5 + .../Tango.MachineStudio.UI/App.config | 4 +- .../MachineStudio/Tango.MachineStudio.UI/App.xaml | 6 - .../Controls/DbTableView.xaml | 41 ---- .../Controls/DbTableView.xaml.cs | 38 ---- .../Tango.MachineStudio.UI/Controls/TableGrid.cs | 58 ------ .../Converters/UsersRolesToStringConverter.cs | 37 ---- .../CustomAttributes/DBViewAttribute.cs | 12 -- .../Managers/DialogsManager.cs | 38 ---- .../Managers/RegisteredView.cs | 54 ----- .../Managers/ViewsManager.cs | 31 --- .../Notifications/DefaultNotificationProvider.cs | 32 +++ .../Notifications/DialogWindow.xaml | 32 +++ .../Notifications/DialogWindow.xaml.cs | 58 ++++++ .../Tango.MachineStudio.UI.csproj | 98 ++------- .../Tango.MachineStudio.UI/ViewModelLocator.cs | 41 +--- .../ViewModels/DBViewModels/AddressesViewVM.cs | 14 -- .../ViewModels/DBViewModels/DbTableViewModel.cs | 214 -------------------- .../ViewModels/DBViewModels/DialogOpenMode.cs | 14 -- .../ViewModels/DBViewModels/MachinesViewVM.cs | 21 -- .../ViewModels/DBViewModels/MultiComboVM.cs | 44 ----- .../ViewModels/DBViewModels/OrganizationsViewVM.cs | 26 --- .../ViewModels/DBViewModels/UsersViewVM.cs | 75 ------- .../ViewModels/EntityViewModel.cs | 31 --- .../Views/DBViews/AddressView.xaml | 34 ---- .../Views/DBViews/AddressView.xaml.cs | 28 --- .../Views/DBViews/AddressesView.xaml | 27 --- .../Views/DBViews/AddressesView.xaml.cs | 31 --- .../Views/DBViews/MachineView.xaml | 28 --- .../Views/DBViews/MachineView.xaml.cs | 28 --- .../Views/DBViews/MachinesView.xaml | 25 --- .../Views/DBViews/MachinesView.xaml.cs | 32 --- .../Views/DBViews/OrganizationView.xaml | 26 --- .../Views/DBViews/OrganizationView.xaml.cs | 28 --- .../Views/DBViews/OrganizationsView.xaml | 26 --- .../Views/DBViews/OrganizationsView.xaml.cs | 30 --- .../Views/DBViews/UserView.xaml | 43 ---- .../Views/DBViews/UserView.xaml.cs | 34 ---- .../Views/DBViews/UsersView.xaml | 27 --- .../Views/DBViews/UsersView.xaml.cs | 30 --- .../Tango.MachineStudio.UI/Views/MainView.xaml | 19 +- .../Windows/DialogWindow.xaml | 32 --- .../Windows/DialogWindow.xaml.cs | 58 ------ .../Tango.MachineStudio.UI/packages.config | 2 +- Software/Visual_Studio/Tango.sln | 33 ++++ 98 files changed, 2479 insertions(+), 1461 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/App.config create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Controls/DbTableView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Controls/DbTableView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Controls/TableGrid.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Converters/UsersRolesToStringConverter.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/CustomAttributes/DBViewAttribute.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ExtensionMethods/INotificationProviderExtensions.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Managers/RegisteredView.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Managers/ViewsManager.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Properties/AssemblyInfo.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Properties/Resources.Designer.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Properties/Resources.resx create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Properties/Settings.Designer.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Properties/Settings.settings create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Tango.MachineStudio.DB.csproj create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModelLocator.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/AddressesViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DialogOpenMode.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/EntityViewModel.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MachinesViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MainViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MultiComboVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/OrganizationsViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/UsersViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/AddressView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/AddressView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/AddressesView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/AddressesView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MachineView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MachineView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MachinesView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MachinesView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/OrganizationView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/OrganizationView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/OrganizationsView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/OrganizationsView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/UserView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/UserView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/UsersView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/UsersView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/MainDBView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/MainDBView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/packages.config create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/INotificationProvider.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Properties/AssemblyInfo.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Properties/Resources.Designer.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Properties/Resources.resx create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Properties/Settings.Designer.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Properties/Settings.settings create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/UserControl1.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/UserControl1.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/packages.config delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Controls/DbTableView.xaml delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Controls/DbTableView.xaml.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Controls/TableGrid.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Converters/UsersRolesToStringConverter.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/CustomAttributes/DBViewAttribute.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Managers/DialogsManager.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Managers/RegisteredView.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Managers/ViewsManager.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/DBViewModels/AddressesViewVM.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/DBViewModels/DbTableViewModel.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/DBViewModels/DialogOpenMode.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/DBViewModels/MachinesViewVM.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/DBViewModels/MultiComboVM.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/DBViewModels/OrganizationsViewVM.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/DBViewModels/UsersViewVM.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/EntityViewModel.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/AddressView.xaml delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/AddressView.xaml.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/AddressesView.xaml delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/AddressesView.xaml.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/MachineView.xaml delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/MachineView.xaml.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/MachinesView.xaml delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/MachinesView.xaml.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/OrganizationView.xaml delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/OrganizationView.xaml.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/OrganizationsView.xaml delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/OrganizationsView.xaml.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/UserView.xaml delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/UserView.xaml.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/UsersView.xaml delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/UsersView.xaml.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows/DialogWindow.xaml delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows/DialogWindow.xaml.cs (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/App.config b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/App.config new file mode 100644 index 000000000..2fb423e8b --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/App.config @@ -0,0 +1,13 @@ + + + + +
+ + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Controls/DbTableView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Controls/DbTableView.xaml new file mode 100644 index 000000000..d1c62ed7e --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Controls/DbTableView.xaml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Controls/DbTableView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Controls/DbTableView.xaml.cs new file mode 100644 index 000000000..9ae14952b --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Controls/DbTableView.xaml.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Markup; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.DB.Controls +{ + /// + /// Interaction logic for DbTableView.xaml + /// + [ContentProperty(nameof(MainContent))] + public partial class DbTableView : UserControl + { + public FrameworkElement MainContent + { + get { return (FrameworkElement)GetValue(MainContentProperty); } + set { SetValue(MainContentProperty, value); } + } + public static readonly DependencyProperty MainContentProperty = + DependencyProperty.Register("MainContent", typeof(FrameworkElement), typeof(DbTableView), new PropertyMetadata(null)); + + public DbTableView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Controls/TableGrid.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Controls/TableGrid.cs new file mode 100644 index 000000000..53a990d4d --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Controls/TableGrid.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; + +namespace Tango.MachineStudio.DB.Controls +{ + public class TableGrid : Grid + { + public TableGrid() + { + ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) }); + ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); + this.Loaded += TableGrid_Loaded; + } + + private void TableGrid_Loaded(object sender, RoutedEventArgs e) + { + InvalidateGrid(); + } + + protected override void OnVisualChildrenChanged(DependencyObject visualAdded, DependencyObject visualRemoved) + { + base.OnVisualChildrenChanged(visualAdded, visualRemoved); + } + + protected override Size ArrangeOverride(Size arrangeSize) + { + return base.ArrangeOverride(arrangeSize); + } + + private void InvalidateGrid() + { + RowDefinitions.Clear(); + RowDefinitions.Add(new RowDefinition() { Height = new GridLength(50, GridUnitType.Pixel) }); + + int currentRow = 0; + + for (int i = 0; i < Children.Count; i++) + { + SetRow(Children[i], currentRow); + + if (i % 2 != 0) + { + SetColumn(Children[i], 1); + (Children[i] as FrameworkElement).Margin = new Thickness(20, 0, 0, 0); + currentRow++; + RowDefinitions.Add(new RowDefinition() { Height = new GridLength(50, GridUnitType.Pixel) }); + } + + (Children[i] as FrameworkElement).VerticalAlignment = VerticalAlignment.Bottom; + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Converters/UsersRolesToStringConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Converters/UsersRolesToStringConverter.cs new file mode 100644 index 000000000..220572db4 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Converters/UsersRolesToStringConverter.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using Tango.DAL.Observables; +using Tango.MachineStudio.DB.ViewModels.DBViewModels; + +namespace Tango.MachineStudio.DB.Converters +{ + public class UsersRolesToStringConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value == null) return ""; + + if (value is IEnumerable) + { + IEnumerable userRoles = value as IEnumerable; + return String.Join(", ", userRoles.Where(x => !x.Deleted).Select(x => x.Role.Name)); + } + else + { + IEnumerable> userRoles = value as IEnumerable>; + return String.Join(", ", userRoles.Where(x => x.IsSelected).Select(x => x.Entity.Name)); + } + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/CustomAttributes/DBViewAttribute.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/CustomAttributes/DBViewAttribute.cs new file mode 100644 index 000000000..4bf920015 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/CustomAttributes/DBViewAttribute.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.DB.CustomAttributes +{ + public class DBViewAttribute : Attribute + { + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ExtensionMethods/INotificationProviderExtensions.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ExtensionMethods/INotificationProviderExtensions.cs new file mode 100644 index 000000000..c38cb8d04 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ExtensionMethods/INotificationProviderExtensions.cs @@ -0,0 +1,27 @@ +using MaterialDesignThemes.Wpf; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using Tango.DAL.Observables; +using Tango.MachineStudio.Common.Notifications; +using Tango.MachineStudio.DB.ViewModels.DBViewModels; +using Tango.MachineStudio.DB.Views.DBViews; + +namespace Tango.MachineStudio.DB.ExtensionMethods +{ + public static class INotificationProviderExtensions + { + public static bool ShowDialog(this INotificationProvider provider, DialogOpenMode mode, DbTableViewModel context) where T : IObservableEntity + { + Type viewType = typeof(INotificationProviderExtensions).Assembly.GetType(typeof(OrganizationView).Namespace + "." + typeof(T).Name + "View"); + return provider.ShowDialog( + (mode == DialogOpenMode.Editing ? PackIconKind.TableEdit : PackIconKind.Plus), + (mode == DialogOpenMode.Editing ? "Edit " : "Add New ") + typeof(T).Name, + Activator.CreateInstance(viewType) as FrameworkElement, + context); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Managers/RegisteredView.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Managers/RegisteredView.cs new file mode 100644 index 000000000..00c7d341a --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Managers/RegisteredView.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using Tango.Core.Commands; + +namespace Tango.MachineStudio.DB.Managers +{ + public class RegisteredView + { + public String Header { get; set; } + public FrameworkElement View { get; set; } + public RelayCommand AddCommand { get; set; } + + public RegisteredView(String header, FrameworkElement view, Action action) + { + Header = header; + View = view; + + if (action != null) + { + AddCommand = new RelayCommand(action); + } + else + { + AddCommand = new RelayCommand(() => + { + if (!ViewsManager.DisplayedViews.Contains(this)) + { + ViewsManager.DisplayedViews.Add(this); + } + else + { + View.BringIntoView(); + View.Focus(); + } + }); + } + } + + public RegisteredView(String header, FrameworkElement view) : this(header, view, null) + { + Header = header; + View = view; + } + + public override string ToString() + { + return Header; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Managers/ViewsManager.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Managers/ViewsManager.cs new file mode 100644 index 000000000..ba68fa358 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Managers/ViewsManager.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using Tango.Core.Commands; +using Tango.MachineStudio.DB.CustomAttributes; +using Tango.MachineStudio.DB.Views.DBViews; + +namespace Tango.MachineStudio.DB.Managers +{ + public static class ViewsManager + { + public static ObservableCollection DisplayedViews { get; set; } + + public static ObservableCollection DbViews { get; set; } + + static ViewsManager() + { + DisplayedViews = new ObservableCollection(); + DbViews = new ObservableCollection(); + + foreach (var type in typeof(ViewsManager).Assembly.GetTypes().Where(x => x.CustomAttributes.Count() > 0 && x.CustomAttributes.First().AttributeType == typeof(DBViewAttribute))) + { + DbViews.Add(new RegisteredView(type.Name.Replace("View", ""), Activator.CreateInstance(type) as FrameworkElement)); + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Properties/AssemblyInfo.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..73a5c7c86 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Properties/AssemblyInfo.cs @@ -0,0 +1,18 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +[assembly: AssemblyTitle("Tango - Machine Studio DB Module")] + +[assembly: ComVisible(false)] + +[assembly:ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Properties/Resources.Designer.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Properties/Resources.Designer.cs new file mode 100644 index 000000000..02b7b332e --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Properties/Resources.Designer.cs @@ -0,0 +1,62 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.MachineStudio.DB.Properties { + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if ((resourceMan == null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Tango.MachineStudio.DB.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Properties/Resources.resx b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Properties/Resources.resx new file mode 100644 index 000000000..af7dbebba --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Properties/Settings.Designer.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Properties/Settings.Designer.cs new file mode 100644 index 000000000..6699c6cbf --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.MachineStudio.DB.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Properties/Settings.settings b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Properties/Settings.settings new file mode 100644 index 000000000..033d7a5e9 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Tango.MachineStudio.DB.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Tango.MachineStudio.DB.csproj new file mode 100644 index 000000000..5ffe9dca9 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Tango.MachineStudio.DB.csproj @@ -0,0 +1,220 @@ + + + + + Debug + AnyCPU + {94F7ACF8-55E1-4A02-B9BC-A818413FDBBF} + library + Tango.MachineStudio.DB + Tango.MachineStudio.DB + v4.6 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + + + true + full + false + ..\..\..\Build\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\..\packages\Dragablz.0.0.3.197\lib\net45\Dragablz.dll + + + ..\..\..\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.dll + + + ..\..\..\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.SqlServer.dll + + + ..\..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.dll + + + ..\..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.Extras.dll + + + ..\..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.Platform.dll + + + ..\..\..\packages\MaterialDesignColors.1.1.2\lib\net45\MaterialDesignColors.dll + + + ..\..\..\packages\MaterialDesignThemes.2.3.1.953\lib\net45\MaterialDesignThemes.Wpf.dll + + + ..\..\..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll + + + + + + ..\..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\System.Windows.Interactivity.dll + + + + + + + + + 4.0 + + + + + + + + + + + + + + + + + + + AddressesView.xaml + + + AddressView.xaml + + + MachinesView.xaml + + + MachineView.xaml + + + OrganizationsView.xaml + + + OrganizationView.xaml + + + UsersView.xaml + + + UserView.xaml + + + MainDBView.xaml + + + MSBuild:Compile + Designer + + + GlobalVersionInfo.cs + + + DbTableView.xaml + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} + Tango.Core + + + {0ecd6da8-7aa6-48d9-8b65-279d176ad9af} + Tango.DAL.Observables + + + {38197109-8610-4d3f-92b9-16d48df94d7c} + Tango.DAL.Remote + + + {8491d07b-c1f6-4b62-a412-41b9fd2d6538} + Tango.SharedUI + + + {cb0b0aa2-bb24-4bca-a720-45e397684e12} + Tango.MachineStudio.Common + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModelLocator.cs new file mode 100644 index 000000000..0f9666137 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModelLocator.cs @@ -0,0 +1,68 @@ +using GalaSoft.MvvmLight; +using GalaSoft.MvvmLight.Ioc; +using Microsoft.Practices.ServiceLocation; +using Tango.MachineStudio.DB.ViewModels; +using Tango.MachineStudio.DB.ViewModels.DBViewModels; + +namespace Tango.MachineStudio.DB +{ + /// + /// This class contains static references to all the view models in the + /// application and provides an entry point for the bindings. + /// + public static class ViewModelLocator + { + /// + /// Initializes a new instance of the ViewModelLocator class. + /// + static ViewModelLocator() + { + ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + } + + public static MainViewVM MainViewVM + { + get + { + return ServiceLocator.Current.GetInstance(); + } + } + + public static MachinesViewVM MachinesViewVM + { + get + { + return ServiceLocator.Current.GetInstance(); + } + } + + public static OrganizationsViewVM OrganizationsViewVM + { + get + { + return ServiceLocator.Current.GetInstance(); + } + } + + public static AddressesViewVM AddressesViewVM + { + get + { + return ServiceLocator.Current.GetInstance(); + } + } + + public static UsersViewVM UsersViewVM + { + get + { + return ServiceLocator.Current.GetInstance(); + } + } + } +} \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/AddressesViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/AddressesViewVM.cs new file mode 100644 index 000000000..c5f95c803 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/AddressesViewVM.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.DAL.Observables; +using Tango.MachineStudio.Common.Notifications; + +namespace Tango.MachineStudio.DB.ViewModels.DBViewModels +{ + public class AddressesViewVM : DbTableViewModel
+ { + public AddressesViewVM(INotificationProvider notification) : base(notification) + { + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs new file mode 100644 index 000000000..db72055df --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs @@ -0,0 +1,219 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.DAL.Observables; +using Tango.MachineStudio.Common.Notifications; +using Tango.MachineStudio.DB.Managers; +using Tango.SharedUI; +using Tango.MachineStudio.DB.ExtensionMethods; + +namespace Tango.MachineStudio.DB.ViewModels.DBViewModels +{ + public abstract class DbTableViewModel : ViewModel where T : IObservableEntity + { + private INotificationProvider _notification; + + /// + /// Initializes a new instance of the class. + /// + public DbTableViewModel(INotificationProvider notification) : base() + { + _notification = notification; + Adapter = ObservablesEntitiesAdapter.Instance; + + AddCommand = new RelayCommand(OnAdd); + EditCommand = new RelayCommand(OnEdit); + DeleteCommand = new RelayCommand(OnDelete); + DialogOKCommand = new RelayCommand(() => OnDialogOKPressed(DialogOpenMode, EditEntity)); + DialogCancelCommand = new RelayCommand(() => OnDialogCancelPressed(DialogOpenMode, EditEntity)); + + IsDialogOpen = false; + } + + private T _editEntity; + /// + /// Gets or sets the edit entity. + /// + public T EditEntity + { + get { return _editEntity; } + set { _editEntity = value; RaisePropertyChangedAuto(); } + } + + private DialogOpenMode _dialogOpenMode; + /// + /// Gets or sets the dialog open mode. + /// + public DialogOpenMode DialogOpenMode + { + get { return _dialogOpenMode; } + set { _dialogOpenMode = value; RaisePropertyChangedAuto(); } + } + + private bool _isDialogOpen; + /// + /// Gets or sets a value indicating whether this instance is dialog open. + /// + public bool IsDialogOpen + { + get { return _isDialogOpen; } + set { _isDialogOpen = value; RaisePropertyChangedAuto(); } + } + + private ObservablesEntitiesAdapter _adapter; + /// + /// Gets or sets the DB adapter. + /// + public ObservablesEntitiesAdapter Adapter + { + get { return _adapter; } + set { _adapter = value; RaisePropertyChangedAuto(); } + } + + private T _selectedEntity; + /// + /// Gets or sets the selected entity. + /// + public T SelectedEntity + { + get { return _selectedEntity; } + set { _selectedEntity = value; RaisePropertyChangedAuto(); } + } + + private String _filter; + /// + /// Gets or sets the search filter. + /// + public String Filter + { + get { return _filter; } + set { _filter = value; RaisePropertyChangedAuto(); OnFilterChanged(value); } + } + + /// + /// Gets or sets the dialog OK command. + /// + public RelayCommand DialogOKCommand { get; set; } + + /// + /// Gets or sets the dialog cancel command. + /// + public RelayCommand DialogCancelCommand { get; set; } + + /// + /// Gets or sets the add command. + /// + public RelayCommand AddCommand { get; set; } + + /// + /// Gets or sets the edit command. + /// + public RelayCommand EditCommand { get; set; } + + /// + /// Gets or sets the delete command. + /// + public RelayCommand DeleteCommand { get; set; } + + /// + /// Called when delete command invoked. + /// + protected virtual void OnDelete() + { + SelectedEntity.Deleted = true; + SelectedEntity.Save(); + } + + /// + /// Called when edit command invoked. + /// + protected virtual void OnEdit() + { + DialogOpenMode = DialogOpenMode.Editing; + EditEntity = GetEditableEntity(DialogOpenMode); + _notification.ShowDialog(DialogOpenMode, this); + IsDialogOpen = true; + } + + /// + /// Called when add command invoked. + /// + protected virtual void OnAdd() + { + DialogOpenMode = DialogOpenMode.Adding; + EditEntity = GetEditableEntity(DialogOpenMode); + _notification.ShowDialog(DialogOpenMode, this); + IsDialogOpen = true; + } + + /// + /// Called when dialog closes with OK button. + /// + /// The mode. + protected virtual void OnDialogOKPressed(DialogOpenMode mode, T entity) + { + if (mode == DialogOpenMode.Editing) + { + entity.ShallowCopyTo(SelectedEntity); + entity = SelectedEntity; + } + + OnBeforeEntitySave(mode, entity); + + entity.Save(); + IsDialogOpen = false; + SelectedEntity = EditEntity; + } + + /// + /// Called when [before entity save]. + /// + /// The mode. + /// The entity. + protected virtual void OnBeforeEntitySave(DialogOpenMode mode,T entity) + { + + } + + /// + /// Called when dialog closes with cancel button. + /// + /// The mode. + protected virtual void OnDialogCancelPressed(DialogOpenMode mode, T entity) + { + IsDialogOpen = false; + } + + /// + /// Gets the editable entity. + /// + /// The mode. + /// + private T GetEditableEntity(DialogOpenMode mode) + { + if (mode == DialogOpenMode.Adding) + { + var newEntity = Activator.CreateInstance(); + InitializeEntity(newEntity); + return newEntity; + } + else + { + return SelectedEntity.ShallowClone(); + } + } + + protected virtual void OnFilterChanged(String filter) + { + + } + + protected virtual void InitializeEntity(T entity) + { + + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DialogOpenMode.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DialogOpenMode.cs new file mode 100644 index 000000000..7a7e9bd41 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DialogOpenMode.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.DB.ViewModels.DBViewModels +{ + public enum DialogOpenMode + { + Editing, + Adding, + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/EntityViewModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/EntityViewModel.cs new file mode 100644 index 000000000..946a73088 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/EntityViewModel.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.SharedUI; + +namespace Tango.MachineStudio.DB.ViewModels +{ + public class EntityViewModel : ViewModel + { + private T _entity; + + public T Entity + { + get { return _entity; } + set { _entity = value; RaisePropertyChanged(nameof(Entity)); } + } + + public EntityViewModel() : base() + { + + } + + public EntityViewModel(T entity) : this() + { + Entity = entity; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MachinesViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MachinesViewVM.cs new file mode 100644 index 000000000..fd2f88c2f --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MachinesViewVM.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.DAL.Observables; +using Tango.MachineStudio.Common.Notifications; +using Tango.SharedUI; + +namespace Tango.MachineStudio.DB.ViewModels.DBViewModels +{ + public class MachinesViewVM : DbTableViewModel + { + public MachinesViewVM(INotificationProvider notification) : base(notification) + { + } + + protected override void InitializeEntity(Machine entity) + { + base.InitializeEntity(entity); + entity.ProductionDate = DateTime.Now; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MainViewVM.cs new file mode 100644 index 000000000..11c0adc0e --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MainViewVM.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.SharedUI; + +namespace Tango.MachineStudio.DB.ViewModels +{ + public class MainViewVM : ViewModel + { + public String Text { get; set; } + + public MainViewVM() : base() + { + Text = "Hi ROy"; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MultiComboVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MultiComboVM.cs new file mode 100644 index 000000000..4a3709050 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MultiComboVM.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.SharedUI; + +namespace Tango.MachineStudio.DB.ViewModels.DBViewModels +{ + public class MultiComboVM : EntityViewModel + { + private Action _onSelectionChanged; + + public event EventHandler SelectionChanged; + + public MultiComboVM(T entity) : base(entity) + { + + } + + public MultiComboVM(T entity, Action onSelectionChanged) : this(entity) + { + _onSelectionChanged = onSelectionChanged; + } + + private bool _isSelected; + + public bool IsSelected + { + get { return _isSelected; } + set { _isSelected = value; RaisePropertyChangedAuto(); OnSelectionChanged(); } + } + + protected virtual void OnSelectionChanged() + { + if (_onSelectionChanged != null) + { + _onSelectionChanged(); + } + + SelectionChanged?.Invoke(this, new EventArgs()); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/OrganizationsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/OrganizationsViewVM.cs new file mode 100644 index 000000000..ff0ec3b77 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/OrganizationsViewVM.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.DAL.Observables; +using Tango.MachineStudio.Common.Notifications; + +namespace Tango.MachineStudio.DB.ViewModels.DBViewModels +{ + public class OrganizationsViewVM : DbTableViewModel + { + public OrganizationsViewVM(INotificationProvider notification) : base(notification) + { + } + + protected override void OnFilterChanged(string filter) + { + Adapter.OrganizationsViewSource.Filter = (x) => + { + var org = x as Organization; + return org.Name.Contains(filter); + }; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/UsersViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/UsersViewVM.cs new file mode 100644 index 000000000..1dde969d6 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/UsersViewVM.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.DAL.Observables; +using Tango.MachineStudio.Common.Notifications; + +namespace Tango.MachineStudio.DB.ViewModels.DBViewModels +{ + public class UsersViewVM : DbTableViewModel + { + private ObservableCollection> _selectedRoles; + + public UsersViewVM(INotificationProvider notification) : base(notification) + { + SelectedRoles = new ObservableCollection>(); + } + + public ObservableCollection> SelectedRoles + { + get { return _selectedRoles; } + set { _selectedRoles = value; RaisePropertyChangedAuto(); } + } + + protected override void OnEdit() + { + SelectedRoles = Adapter.Roles.Select(x => new MultiComboVM(x, () => RaisePropertyChanged(nameof(SelectedRoles)))).ToObservableCollection(); + + foreach (var role in SelectedRoles) + { + if (SelectedEntity.UsersRoles.ToList().Exists(x => x.Role == role.Entity && !x.Deleted)) + { + role.IsSelected = true; + } + } + + base.OnEdit(); + } + + protected override void OnAdd() + { + SelectedRoles = Adapter.Roles.Select(x => new MultiComboVM(x, () => RaisePropertyChanged(nameof(SelectedRoles)))).ToObservableCollection(); + + base.OnAdd(); + } + + protected override void OnBeforeEntitySave(DialogOpenMode mode, User user) + { + base.OnBeforeEntitySave(mode, user); + + foreach (var role in SelectedRoles) + { + var userRole = user.UsersRoles.SingleOrDefault(x => x.Role == role.Entity); + + if (userRole != null) + { + userRole.Deleted = !role.IsSelected; + } + else + { + if (role.IsSelected) + { + user.UsersRoles.Add(new UsersRole() + { + Role = role.Entity, + User = user, + RoleGuid = role.Entity.Guid, + UserGuid = user.Guid + }); + } + } + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/AddressView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/AddressView.xaml new file mode 100644 index 000000000..9c132295b --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/AddressView.xaml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/AddressView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/AddressView.xaml.cs new file mode 100644 index 000000000..cc890eb26 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/AddressView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.DB.Views.DBViews +{ + /// + /// Interaction logic for AddressView.xaml + /// + public partial class AddressView : UserControl + { + public AddressView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/AddressesView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/AddressesView.xaml new file mode 100644 index 000000000..ee46a9c11 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/AddressesView.xaml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/AddressesView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/AddressesView.xaml.cs new file mode 100644 index 000000000..b6ead64e3 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/AddressesView.xaml.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.MachineStudio.DB.CustomAttributes; +using Tango.SharedUI.Controls; + +namespace Tango.MachineStudio.DB.Views.DBViews +{ + /// + /// Interaction logic for MachinesView.xaml + /// + [DBView] + public partial class AddressesView : UserControl + { + public AddressesView() : base() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MachineView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MachineView.xaml new file mode 100644 index 000000000..45ada50ca --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MachineView.xaml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MachineView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MachineView.xaml.cs new file mode 100644 index 000000000..b14dcc6c7 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MachineView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.DB.Views.DBViews +{ + /// + /// Interaction logic for MachineView.xaml + /// + public partial class MachineView : UserControl + { + public MachineView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MachinesView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MachinesView.xaml new file mode 100644 index 000000000..f5913bd2c --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MachinesView.xaml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MachinesView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MachinesView.xaml.cs new file mode 100644 index 000000000..a3865ce4e --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/MachinesView.xaml.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.MachineStudio.DB.CustomAttributes; +using Tango.MachineStudio.DB.Managers; +using Tango.SharedUI.Controls; + +namespace Tango.MachineStudio.DB.Views.DBViews +{ + /// + /// Interaction logic for MachinesView.xaml + /// + [DBView] + public partial class MachinesView : UserControl + { + public MachinesView() : base() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/OrganizationView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/OrganizationView.xaml new file mode 100644 index 000000000..229ddacb2 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/OrganizationView.xaml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/OrganizationView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/OrganizationView.xaml.cs new file mode 100644 index 000000000..a9f4ec880 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/OrganizationView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.DB.Views.DBViews +{ + /// + /// Interaction logic for OrganizationView.xaml + /// + public partial class OrganizationView : UserControl + { + public OrganizationView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/OrganizationsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/OrganizationsView.xaml new file mode 100644 index 000000000..ff5e7df4a --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/OrganizationsView.xaml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/OrganizationsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/OrganizationsView.xaml.cs new file mode 100644 index 000000000..2b76305a5 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/OrganizationsView.xaml.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.MachineStudio.DB.CustomAttributes; + +namespace Tango.MachineStudio.DB.Views.DBViews +{ + /// + /// Interaction logic for OrganizationsView.xaml + /// + [DBView] + public partial class OrganizationsView : UserControl + { + public OrganizationsView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/UserView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/UserView.xaml new file mode 100644 index 000000000..bb5f08f4a --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/UserView.xaml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/UserView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/UserView.xaml.cs new file mode 100644 index 000000000..1c84eed8e --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/UserView.xaml.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.DB.Views.DBViews +{ + /// + /// Interaction logic for UserView.xaml + /// + public partial class UserView : UserControl + { + public UserView() + { + InitializeComponent(); + } + + private void comboRoles_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + comboRoles.SelectedItem = null; + comboRoles.Text = "Press to select"; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/UsersView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/UsersView.xaml new file mode 100644 index 000000000..5b6c2e842 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/UsersView.xaml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/UsersView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/UsersView.xaml.cs new file mode 100644 index 000000000..492e846fe --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/UsersView.xaml.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.MachineStudio.DB.CustomAttributes; + +namespace Tango.MachineStudio.DB.Views.DBViews +{ + /// + /// Interaction logic for UsersView.xaml + /// + [DBView] + public partial class UsersView : UserControl + { + public UsersView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/MainDBView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/MainDBView.xaml new file mode 100644 index 000000000..d3149849f --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/MainDBView.xaml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/MainDBView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/MainDBView.xaml.cs new file mode 100644 index 000000000..9e327b575 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/MainDBView.xaml.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.SharedUI; +using Tango.SharedUI.Controls; + +namespace Tango.MachineStudio.DB.Views +{ + /// + /// Interaction logic for MainView.xaml + /// + public partial class MainDBView : UserControl + { + public MainDBView() : base() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/packages.config b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/packages.config new file mode 100644 index 000000000..ccf9158d8 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/packages.config @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/INotificationProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/INotificationProvider.cs new file mode 100644 index 000000000..e14df21ba --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/INotificationProvider.cs @@ -0,0 +1,17 @@ +using MaterialDesignThemes.Wpf; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; + +namespace Tango.MachineStudio.Common.Notifications +{ + public interface INotificationProvider + { + bool ShowDialog(PackIconKind icon, String title, object context) where T : FrameworkElement; + + bool ShowDialog(PackIconKind icon, String title, FrameworkElement content, object context); + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Properties/AssemblyInfo.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..33d6edb60 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Properties/AssemblyInfo.cs @@ -0,0 +1,17 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +[assembly: AssemblyTitle("Tango - Machine Studio Common Components")] +[assembly: ComVisible(false)] + +[assembly:ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Properties/Resources.Designer.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Properties/Resources.Designer.cs new file mode 100644 index 000000000..2a87dd02a --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Properties/Resources.Designer.cs @@ -0,0 +1,62 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.MachineStudio.Common.Properties { + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if ((resourceMan == null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Tango.MachineStudio.Common.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Properties/Resources.resx b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Properties/Resources.resx new file mode 100644 index 000000000..af7dbebba --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Properties/Settings.Designer.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Properties/Settings.Designer.cs new file mode 100644 index 000000000..8408dc8c8 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.MachineStudio.Common.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Properties/Settings.settings b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Properties/Settings.settings new file mode 100644 index 000000000..033d7a5e9 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj new file mode 100644 index 000000000..906015ef0 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj @@ -0,0 +1,94 @@ + + + + + Debug + AnyCPU + {CB0B0AA2-BB24-4BCA-A720-45E397684E12} + library + Tango.MachineStudio.Common + Tango.MachineStudio.Common + v4.6 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + + + true + full + false + ..\..\Build\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\packages\MaterialDesignColors.1.1.2\lib\net45\MaterialDesignColors.dll + + + ..\..\packages\MaterialDesignThemes.2.3.1.953\lib\net45\MaterialDesignThemes.Wpf.dll + + + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + GlobalVersionInfo.cs + + + + UserControl1.xaml + Code + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/UserControl1.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/UserControl1.xaml new file mode 100644 index 000000000..68210e9f6 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/UserControl1.xaml @@ -0,0 +1,12 @@ + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/UserControl1.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/UserControl1.xaml.cs new file mode 100644 index 000000000..9028e3810 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/UserControl1.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.Common +{ + /// + /// Interaction logic for UserControl1.xaml + /// + public partial class UserControl1 : UserControl + { + public UserControl1() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/packages.config b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/packages.config new file mode 100644 index 000000000..0c779127b --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config index 92aa00bf9..250f57a4d 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config @@ -1,9 +1,9 @@  - +
- + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml index f6f2da415..6974f54be 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml @@ -2,7 +2,6 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:Tango.MachineStudio.UI" - xmlns:converters="clr-namespace:Tango.MachineStudio.UI.Converters" xmlns:dragablz="clr-namespace:Dragablz;assembly=Dragablz" StartupUri="MainWindow.xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" d1p1:Ignorable="d" xmlns:d1p1="http://schemas.openxmlformats.org/markup-compatibility/2006"> @@ -78,11 +77,6 @@ - - - - - diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Controls/DbTableView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Controls/DbTableView.xaml deleted file mode 100644 index be9776721..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Controls/DbTableView.xaml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Controls/DbTableView.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Controls/DbTableView.xaml.cs deleted file mode 100644 index 19bee9e70..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Controls/DbTableView.xaml.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Markup; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; - -namespace Tango.MachineStudio.UI.Controls -{ - /// - /// Interaction logic for DbTableView.xaml - /// - [ContentProperty(nameof(MainContent))] - public partial class DbTableView : UserControl - { - public FrameworkElement MainContent - { - get { return (FrameworkElement)GetValue(MainContentProperty); } - set { SetValue(MainContentProperty, value); } - } - public static readonly DependencyProperty MainContentProperty = - DependencyProperty.Register("MainContent", typeof(FrameworkElement), typeof(DbTableView), new PropertyMetadata(null)); - - public DbTableView() - { - InitializeComponent(); - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Controls/TableGrid.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Controls/TableGrid.cs deleted file mode 100644 index 9b0d20362..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Controls/TableGrid.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; - -namespace Tango.MachineStudio.UI.Controls -{ - public class TableGrid : Grid - { - public TableGrid() - { - ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) }); - ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); - this.Loaded += TableGrid_Loaded; - } - - private void TableGrid_Loaded(object sender, RoutedEventArgs e) - { - InvalidateGrid(); - } - - protected override void OnVisualChildrenChanged(DependencyObject visualAdded, DependencyObject visualRemoved) - { - base.OnVisualChildrenChanged(visualAdded, visualRemoved); - } - - protected override Size ArrangeOverride(Size arrangeSize) - { - return base.ArrangeOverride(arrangeSize); - } - - private void InvalidateGrid() - { - RowDefinitions.Clear(); - RowDefinitions.Add(new RowDefinition() { Height = new GridLength(50, GridUnitType.Pixel) }); - - int currentRow = 0; - - for (int i = 0; i < Children.Count; i++) - { - SetRow(Children[i], currentRow); - - if (i % 2 != 0) - { - SetColumn(Children[i], 1); - (Children[i] as FrameworkElement).Margin = new Thickness(20, 0, 0, 0); - currentRow++; - RowDefinitions.Add(new RowDefinition() { Height = new GridLength(50, GridUnitType.Pixel) }); - } - - (Children[i] as FrameworkElement).VerticalAlignment = VerticalAlignment.Bottom; - } - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Converters/UsersRolesToStringConverter.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Converters/UsersRolesToStringConverter.cs deleted file mode 100644 index 734bc7135..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Converters/UsersRolesToStringConverter.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Data; -using Tango.DAL.Observables; -using Tango.MachineStudio.UI.ViewModels.DBViewModels; - -namespace Tango.MachineStudio.UI.Converters -{ - public class UsersRolesToStringConverter : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) - { - if (value == null) return ""; - - if (value is IEnumerable) - { - IEnumerable userRoles = value as IEnumerable; - return String.Join(", ", userRoles.Where(x => !x.Deleted).Select(x => x.Role.Name)); - } - else - { - IEnumerable> userRoles = value as IEnumerable>; - return String.Join(", ", userRoles.Where(x => x.IsSelected).Select(x => x.Entity.Name)); - } - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) - { - throw new NotImplementedException(); - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/CustomAttributes/DBViewAttribute.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/CustomAttributes/DBViewAttribute.cs deleted file mode 100644 index 39f34c4e9..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/CustomAttributes/DBViewAttribute.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.MachineStudio.UI.CustomAttributes -{ - public class DBViewAttribute : Attribute - { - } -} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Managers/DialogsManager.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Managers/DialogsManager.cs deleted file mode 100644 index 4131f2a56..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Managers/DialogsManager.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using Tango.DAL.Observables; -using Tango.MachineStudio.UI.ViewModels.DBViewModels; -using Tango.MachineStudio.UI.Views.DBViews; -using Tango.MachineStudio.UI.Windows; - -namespace Tango.MachineStudio.UI.Managers -{ - public static class DialogsManager - { - public static bool ShowDialog(String title, object context) where T : FrameworkElement - { - DialogWindow dialog = new DialogWindow(Activator.CreateInstance()); - dialog.DataContext = context; - dialog.InnerTitle = title; - dialog.Owner = Application.Current.MainWindow; - return dialog.ShowDialog().Value; - } - - public static bool ShowDialog(DialogOpenMode mode, DbTableViewModel context) where T : IObservableEntity - { - Type viewType = typeof(DialogsManager).Assembly.GetType(typeof(OrganizationView).Namespace + "." + typeof(T).Name + "View"); - DialogWindow dialog = new DialogWindow(Activator.CreateInstance(viewType) as FrameworkElement); - dialog.InnerTitle = (mode == DialogOpenMode.Editing ? "Edit " : "Add New ") + typeof(T).Name; - dialog.DataContext = context; - dialog.Owner = Application.Current.MainWindow; - MainWindow.Instance.shadowGrid.Visibility = Visibility.Visible; - bool result = dialog.ShowDialog().Value; - MainWindow.Instance.shadowGrid.Visibility = Visibility.Hidden; - return result; - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Managers/RegisteredView.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Managers/RegisteredView.cs deleted file mode 100644 index de66500b9..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Managers/RegisteredView.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using Tango.Core.Commands; - -namespace Tango.MachineStudio.UI.Managers -{ - public class RegisteredView - { - public String Header { get; set; } - public FrameworkElement View { get; set; } - public RelayCommand AddCommand { get; set; } - - public RegisteredView(String header, FrameworkElement view, Action action) - { - Header = header; - View = view; - - if (action != null) - { - AddCommand = new RelayCommand(action); - } - else - { - AddCommand = new RelayCommand(() => - { - if (!ViewsManager.DisplayedViews.Contains(this)) - { - ViewsManager.DisplayedViews.Add(this); - } - else - { - View.BringIntoView(); - View.Focus(); - } - }); - } - } - - public RegisteredView(String header, FrameworkElement view) : this(header, view, null) - { - Header = header; - View = view; - } - - public override string ToString() - { - return Header; - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Managers/ViewsManager.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Managers/ViewsManager.cs deleted file mode 100644 index caa1cb320..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Managers/ViewsManager.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using Tango.Core.Commands; -using Tango.MachineStudio.UI.CustomAttributes; -using Tango.MachineStudio.UI.Views.DBViews; - -namespace Tango.MachineStudio.UI.Managers -{ - public static class ViewsManager - { - public static ObservableCollection DisplayedViews { get; set; } - - public static ObservableCollection DbViews { get; set; } - - static ViewsManager() - { - DisplayedViews = new ObservableCollection(); - DbViews = new ObservableCollection(); - - foreach (var type in typeof(ViewsManager).Assembly.GetTypes().Where(x => x.CustomAttributes.Count() > 0 && x.CustomAttributes.First().AttributeType == typeof(DBViewAttribute))) - { - DbViews.Add(new RegisteredView(type.Name.Replace("View", ""), Activator.CreateInstance(type) as FrameworkElement)); - } - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs new file mode 100644 index 000000000..8e0fd2220 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using MaterialDesignThemes.Wpf; +using Tango.MachineStudio.Common.Notifications; +using Tango.MachineStudio.UI.Windows; + +namespace Tango.MachineStudio.UI.Notifications +{ + public class DefaultNotificationProvider : INotificationProvider + { + public bool ShowDialog(PackIconKind icon, string title, object context) where T : FrameworkElement + { + return ShowDialog(icon, title, Activator.CreateInstance(), context); + } + + public bool ShowDialog(PackIconKind icon, string title, FrameworkElement content, object context) + { + DialogWindow dialog = new DialogWindow(content); + dialog.DataContext = context; + dialog.InnerTitle = title; + dialog.Owner = Application.Current.MainWindow; + MainWindow.Instance.shadowGrid.Visibility = Visibility.Visible; + bool result = dialog.ShowDialog().Value; + MainWindow.Instance.shadowGrid.Visibility = Visibility.Hidden; + return result; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml new file mode 100644 index 000000000..f23776ec2 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml.cs new file mode 100644 index 000000000..c946d2b88 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml.cs @@ -0,0 +1,58 @@ +using MahApps.Metro.Controls; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; +using Tango.Core.Commands; + +namespace Tango.MachineStudio.UI.Windows +{ + /// + /// Interaction logic for DialogWindow.xaml + /// + public partial class DialogWindow : MetroWindow + { + public DialogWindow() + { + InitializeComponent(); + } + + + + public String InnerTitle + { + get { return (String)GetValue(InnerTitleProperty); } + set { SetValue(InnerTitleProperty, value); } + } + public static readonly DependencyProperty InnerTitleProperty = + DependencyProperty.Register("InnerTitle", typeof(String), typeof(DialogWindow), new PropertyMetadata(null)); + + + + public DialogWindow(FrameworkElement content) : this() + { + presenter.Content = content; + } + + private void OnOKClicked(object sender, RoutedEventArgs e) + { + DialogResult = true; + Close(); + } + + private void OnCancelClicked(object sender, RoutedEventArgs e) + { + DialogResult = false; + Close(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj index 67e00db8d..6c008797f 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj @@ -41,10 +41,10 @@ ..\..\packages\Dragablz.0.0.3.197\lib\net45\Dragablz.dll - ..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll + ..\..\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.dll - ..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll + ..\..\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.SqlServer.dll ..\..\packages\FontAwesome.WPF.4.7.0.9\lib\net40\FontAwesome.WPF.dll @@ -96,60 +96,16 @@ MSBuild:Compile Designer - - DbTableView.xaml - - - - - - - - - - - - + - - - - - AddressesView.xaml - - - AddressView.xaml - - - MachinesView.xaml - - - MachineView.xaml - - - OrganizationView.xaml - - - UsersView.xaml - - - UserView.xaml - MainView.xaml - - OrganizationsView.xaml - - + DialogWindow.xaml - - Designer - MSBuild:Compile - MSBuild:Compile Designer @@ -169,43 +125,11 @@ MSBuild:Compile Designer - - MSBuild:Compile - Designer - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - Designer MSBuild:Compile - - Designer - MSBuild:Compile - - + Designer MSBuild:Compile @@ -266,6 +190,14 @@ {8491d07b-c1f6-4b62-a412-41b9fd2d6538} Tango.SharedUI + + {94f7acf8-55e1-4a02-b9bc-a818413fdbbf} + Tango.MachineStudio.DB + + + {cb0b0aa2-bb24-4bca-a720-45e397684e12} + Tango.MachineStudio.Common + @@ -273,9 +205,7 @@ - - - + $(TargetDir)linkgen.exe -s "$(TargetPath)" -d "$(TargetDir)Utilities\Machine Studio.lnk" diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs index 2d3492ba0..1f08e31ca 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs @@ -3,9 +3,10 @@ using GalaSoft.MvvmLight.Ioc; using Microsoft.Practices.ServiceLocation; using System; using Tango.Logging; +using Tango.MachineStudio.Common.Notifications; +using Tango.MachineStudio.UI.Notifications; using Tango.MachineStudio.UI.SupervisingController; using Tango.MachineStudio.UI.ViewModels; -using Tango.MachineStudio.UI.ViewModels.DBViewModels; using Tango.MachineStudio.UI.Views; namespace Tango.MachineStudio.UI @@ -34,11 +35,9 @@ namespace Tango.MachineStudio.UI //// SimpleIoc.Default.Register(); ////} + SimpleIoc.Default.Register(() => new DefaultNotificationProvider()); + SimpleIoc.Default.Register(); - SimpleIoc.Default.Register(); - SimpleIoc.Default.Register(); - SimpleIoc.Default.Register(); - SimpleIoc.Default.Register(); //Register View (Supervising Controller Pattern). if (!ViewModelBase.IsInDesignModeStatic) @@ -55,37 +54,5 @@ namespace Tango.MachineStudio.UI return ServiceLocator.Current.GetInstance(); } } - - public MachinesViewVM MachinesViewVM - { - get - { - return ServiceLocator.Current.GetInstance(); - } - } - - public OrganizationsViewVM OrganizationsViewVM - { - get - { - return ServiceLocator.Current.GetInstance(); - } - } - - public AddressesViewVM AddressesViewVM - { - get - { - return ServiceLocator.Current.GetInstance(); - } - } - - public UsersViewVM UsersViewVM - { - get - { - return ServiceLocator.Current.GetInstance(); - } - } } } \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/DBViewModels/AddressesViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/DBViewModels/AddressesViewVM.cs deleted file mode 100644 index 009de0139..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/DBViewModels/AddressesViewVM.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.DAL.Observables; - -namespace Tango.MachineStudio.UI.ViewModels.DBViewModels -{ - public class AddressesViewVM : DbTableViewModel
- { - - } -} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/DBViewModels/DbTableViewModel.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/DBViewModels/DbTableViewModel.cs deleted file mode 100644 index 2e3a6a6e1..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/DBViewModels/DbTableViewModel.cs +++ /dev/null @@ -1,214 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Core.Commands; -using Tango.DAL.Observables; -using Tango.MachineStudio.UI.Managers; -using Tango.SharedUI; - -namespace Tango.MachineStudio.UI.ViewModels.DBViewModels -{ - public abstract class DbTableViewModel : ViewModel where T : IObservableEntity - { - private T _editEntity; - /// - /// Gets or sets the edit entity. - /// - public T EditEntity - { - get { return _editEntity; } - set { _editEntity = value; RaisePropertyChangedAuto(); } - } - - private DialogOpenMode _dialogOpenMode; - /// - /// Gets or sets the dialog open mode. - /// - public DialogOpenMode DialogOpenMode - { - get { return _dialogOpenMode; } - set { _dialogOpenMode = value; RaisePropertyChangedAuto(); } - } - - private bool _isDialogOpen; - /// - /// Gets or sets a value indicating whether this instance is dialog open. - /// - public bool IsDialogOpen - { - get { return _isDialogOpen; } - set { _isDialogOpen = value; RaisePropertyChangedAuto(); } - } - - private ObservablesEntitiesAdapter _adapter; - /// - /// Gets or sets the DB adapter. - /// - public ObservablesEntitiesAdapter Adapter - { - get { return _adapter; } - set { _adapter = value; RaisePropertyChangedAuto(); } - } - - private T _selectedEntity; - /// - /// Gets or sets the selected entity. - /// - public T SelectedEntity - { - get { return _selectedEntity; } - set { _selectedEntity = value; RaisePropertyChangedAuto(); } - } - - private String _filter; - /// - /// Gets or sets the search filter. - /// - public String Filter - { - get { return _filter; } - set { _filter = value; RaisePropertyChangedAuto(); OnFilterChanged(value); } - } - - /// - /// Gets or sets the dialog OK command. - /// - public RelayCommand DialogOKCommand { get; set; } - - /// - /// Gets or sets the dialog cancel command. - /// - public RelayCommand DialogCancelCommand { get; set; } - - /// - /// Gets or sets the add command. - /// - public RelayCommand AddCommand { get; set; } - - /// - /// Gets or sets the edit command. - /// - public RelayCommand EditCommand { get; set; } - - /// - /// Gets or sets the delete command. - /// - public RelayCommand DeleteCommand { get; set; } - - /// - /// Initializes a new instance of the class. - /// - public DbTableViewModel() : base() - { - Adapter = App.DbAdapter; - - AddCommand = new RelayCommand(OnAdd); - EditCommand = new RelayCommand(OnEdit); - DeleteCommand = new RelayCommand(OnDelete); - DialogOKCommand = new RelayCommand(() => OnDialogOKPressed(DialogOpenMode, EditEntity)); - DialogCancelCommand = new RelayCommand(() => OnDialogCancelPressed(DialogOpenMode, EditEntity)); - - IsDialogOpen = false; - } - - /// - /// Called when delete command invoked. - /// - protected virtual void OnDelete() - { - SelectedEntity.Deleted = true; - SelectedEntity.Save(); - } - - /// - /// Called when edit command invoked. - /// - protected virtual void OnEdit() - { - DialogOpenMode = DialogOpenMode.Editing; - EditEntity = GetEditableEntity(DialogOpenMode); - DialogsManager.ShowDialog(DialogOpenMode, this); - IsDialogOpen = true; - } - - /// - /// Called when add command invoked. - /// - protected virtual void OnAdd() - { - DialogOpenMode = DialogOpenMode.Adding; - EditEntity = GetEditableEntity(DialogOpenMode); - DialogsManager.ShowDialog(DialogOpenMode, this); - IsDialogOpen = true; - } - - /// - /// Called when dialog closes with OK button. - /// - /// The mode. - protected virtual void OnDialogOKPressed(DialogOpenMode mode, T entity) - { - if (mode == DialogOpenMode.Editing) - { - entity.ShallowCopyTo(SelectedEntity); - entity = SelectedEntity; - } - - OnBeforeEntitySave(mode, entity); - - entity.Save(); - IsDialogOpen = false; - SelectedEntity = EditEntity; - } - - /// - /// Called when [before entity save]. - /// - /// The mode. - /// The entity. - protected virtual void OnBeforeEntitySave(DialogOpenMode mode,T entity) - { - - } - - /// - /// Called when dialog closes with cancel button. - /// - /// The mode. - protected virtual void OnDialogCancelPressed(DialogOpenMode mode, T entity) - { - IsDialogOpen = false; - } - - /// - /// Gets the editable entity. - /// - /// The mode. - /// - private T GetEditableEntity(DialogOpenMode mode) - { - if (mode == DialogOpenMode.Adding) - { - var newEntity = Activator.CreateInstance(); - InitializeEntity(newEntity); - return newEntity; - } - else - { - return SelectedEntity.ShallowClone(); - } - } - - protected virtual void OnFilterChanged(String filter) - { - - } - - protected virtual void InitializeEntity(T entity) - { - - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/DBViewModels/DialogOpenMode.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/DBViewModels/DialogOpenMode.cs deleted file mode 100644 index 9c6dbe807..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/DBViewModels/DialogOpenMode.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.MachineStudio.UI.ViewModels.DBViewModels -{ - public enum DialogOpenMode - { - Editing, - Adding, - } -} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/DBViewModels/MachinesViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/DBViewModels/MachinesViewVM.cs deleted file mode 100644 index c008f1124..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/DBViewModels/MachinesViewVM.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Core.Commands; -using Tango.DAL.Observables; -using Tango.SharedUI; - -namespace Tango.MachineStudio.UI.ViewModels.DBViewModels -{ - public class MachinesViewVM : DbTableViewModel - { - protected override void InitializeEntity(Machine entity) - { - base.InitializeEntity(entity); - entity.ProductionDate = DateTime.Now; - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/DBViewModels/MultiComboVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/DBViewModels/MultiComboVM.cs deleted file mode 100644 index 280eab923..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/DBViewModels/MultiComboVM.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.SharedUI; - -namespace Tango.MachineStudio.UI.ViewModels.DBViewModels -{ - public class MultiComboVM : EntityViewModel - { - private Action _onSelectionChanged; - - public event EventHandler SelectionChanged; - - public MultiComboVM(T entity) : base(entity) - { - - } - - public MultiComboVM(T entity, Action onSelectionChanged) : this(entity) - { - _onSelectionChanged = onSelectionChanged; - } - - private bool _isSelected; - - public bool IsSelected - { - get { return _isSelected; } - set { _isSelected = value; RaisePropertyChangedAuto(); OnSelectionChanged(); } - } - - protected virtual void OnSelectionChanged() - { - if (_onSelectionChanged != null) - { - _onSelectionChanged(); - } - - SelectionChanged?.Invoke(this, new EventArgs()); - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/DBViewModels/OrganizationsViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/DBViewModels/OrganizationsViewVM.cs deleted file mode 100644 index 6a2fd73df..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/DBViewModels/OrganizationsViewVM.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.DAL.Observables; - -namespace Tango.MachineStudio.UI.ViewModels.DBViewModels -{ - public class OrganizationsViewVM : DbTableViewModel - { - public OrganizationsViewVM() : base() - { - - } - - protected override void OnFilterChanged(string filter) - { - Adapter.OrganizationsViewSource.Filter = (x) => - { - var org = x as Organization; - return org.Name.Contains(filter); - }; - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/DBViewModels/UsersViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/DBViewModels/UsersViewVM.cs deleted file mode 100644 index 2bf34ce7a..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/DBViewModels/UsersViewVM.cs +++ /dev/null @@ -1,75 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.DAL.Observables; - -namespace Tango.MachineStudio.UI.ViewModels.DBViewModels -{ - public class UsersViewVM : DbTableViewModel - { - private ObservableCollection> _selectedRoles; - public ObservableCollection> SelectedRoles - { - get { return _selectedRoles; } - set { _selectedRoles = value; RaisePropertyChangedAuto(); } - } - - public UsersViewVM() : base() - { - SelectedRoles = new ObservableCollection>(); - } - - protected override void OnEdit() - { - SelectedRoles = Adapter.Roles.Select(x => new MultiComboVM(x, () => RaisePropertyChanged(nameof(SelectedRoles)))).ToObservableCollection(); - - foreach (var role in SelectedRoles) - { - if (SelectedEntity.UsersRoles.ToList().Exists(x => x.Role == role.Entity && !x.Deleted)) - { - role.IsSelected = true; - } - } - - base.OnEdit(); - } - - protected override void OnAdd() - { - SelectedRoles = Adapter.Roles.Select(x => new MultiComboVM(x, () => RaisePropertyChanged(nameof(SelectedRoles)))).ToObservableCollection(); - - base.OnAdd(); - } - - protected override void OnBeforeEntitySave(DialogOpenMode mode, User user) - { - base.OnBeforeEntitySave(mode, user); - - foreach (var role in SelectedRoles) - { - var userRole = user.UsersRoles.SingleOrDefault(x => x.Role == role.Entity); - - if (userRole != null) - { - userRole.Deleted = !role.IsSelected; - } - else - { - if (role.IsSelected) - { - user.UsersRoles.Add(new UsersRole() - { - Role = role.Entity, - User = user, - RoleGuid = role.Entity.Guid, - UserGuid = user.Guid - }); - } - } - } - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/EntityViewModel.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/EntityViewModel.cs deleted file mode 100644 index fff03a1db..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/EntityViewModel.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Core.Commands; -using Tango.SharedUI; - -namespace Tango.MachineStudio.UI.ViewModels -{ - public class EntityViewModel : ViewModel - { - private T _entity; - - public T Entity - { - get { return _entity; } - set { _entity = value; RaisePropertyChanged(nameof(Entity)); } - } - - public EntityViewModel() : base() - { - - } - - public EntityViewModel(T entity) : this() - { - Entity = entity; - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/AddressView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/AddressView.xaml deleted file mode 100644 index 8e1bde374..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/AddressView.xaml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/AddressView.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/AddressView.xaml.cs deleted file mode 100644 index 9c82b9d82..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/AddressView.xaml.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; - -namespace Tango.MachineStudio.UI.Views.DBViews -{ - /// - /// Interaction logic for AddressView.xaml - /// - public partial class AddressView : UserControl - { - public AddressView() - { - InitializeComponent(); - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/AddressesView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/AddressesView.xaml deleted file mode 100644 index d8de4b15b..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/AddressesView.xaml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/AddressesView.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/AddressesView.xaml.cs deleted file mode 100644 index 793b18c82..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/AddressesView.xaml.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; -using Tango.MachineStudio.UI.CustomAttributes; -using Tango.SharedUI.Controls; - -namespace Tango.MachineStudio.UI.Views.DBViews -{ - /// - /// Interaction logic for MachinesView.xaml - /// - [DBView] - public partial class AddressesView : UserControl - { - public AddressesView() : base() - { - InitializeComponent(); - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/MachineView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/MachineView.xaml deleted file mode 100644 index 042676b3c..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/MachineView.xaml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/MachineView.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/MachineView.xaml.cs deleted file mode 100644 index 422268226..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/MachineView.xaml.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; - -namespace Tango.MachineStudio.UI.Views.DBViews -{ - /// - /// Interaction logic for MachineView.xaml - /// - public partial class MachineView : UserControl - { - public MachineView() - { - InitializeComponent(); - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/MachinesView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/MachinesView.xaml deleted file mode 100644 index 2c69d914f..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/MachinesView.xaml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/MachinesView.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/MachinesView.xaml.cs deleted file mode 100644 index a6a6f2b47..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/MachinesView.xaml.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; -using Tango.MachineStudio.UI.CustomAttributes; -using Tango.MachineStudio.UI.Managers; -using Tango.SharedUI.Controls; - -namespace Tango.MachineStudio.UI.Views.DBViews -{ - /// - /// Interaction logic for MachinesView.xaml - /// - [DBView] - public partial class MachinesView : UserControl - { - public MachinesView() : base() - { - InitializeComponent(); - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/OrganizationView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/OrganizationView.xaml deleted file mode 100644 index 31be9356e..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/OrganizationView.xaml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/OrganizationView.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/OrganizationView.xaml.cs deleted file mode 100644 index 8c17d51a7..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/OrganizationView.xaml.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; - -namespace Tango.MachineStudio.UI.Views.DBViews -{ - /// - /// Interaction logic for OrganizationView.xaml - /// - public partial class OrganizationView : UserControl - { - public OrganizationView() - { - InitializeComponent(); - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/OrganizationsView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/OrganizationsView.xaml deleted file mode 100644 index ef446f01c..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/OrganizationsView.xaml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/OrganizationsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/OrganizationsView.xaml.cs deleted file mode 100644 index 2e955de0c..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/OrganizationsView.xaml.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; -using Tango.MachineStudio.UI.CustomAttributes; - -namespace Tango.MachineStudio.UI.Views.DBViews -{ - /// - /// Interaction logic for OrganizationsView.xaml - /// - [DBView] - public partial class OrganizationsView : UserControl - { - public OrganizationsView() - { - InitializeComponent(); - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/UserView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/UserView.xaml deleted file mode 100644 index 62802c5d9..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/UserView.xaml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/UserView.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/UserView.xaml.cs deleted file mode 100644 index 987c93b75..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/UserView.xaml.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; - -namespace Tango.MachineStudio.UI.Views.DBViews -{ - /// - /// Interaction logic for UserView.xaml - /// - public partial class UserView : UserControl - { - public UserView() - { - InitializeComponent(); - } - - private void comboRoles_SelectionChanged(object sender, SelectionChangedEventArgs e) - { - comboRoles.SelectedItem = null; - comboRoles.Text = "Press to select"; - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/UsersView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/UsersView.xaml deleted file mode 100644 index 9225661a0..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/UsersView.xaml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/UsersView.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/UsersView.xaml.cs deleted file mode 100644 index bc60c65cf..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/DBViews/UsersView.xaml.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; -using Tango.MachineStudio.UI.CustomAttributes; - -namespace Tango.MachineStudio.UI.Views.DBViews -{ - /// - /// Interaction logic for UsersView.xaml - /// - [DBView] - public partial class UsersView : UserControl - { - public UsersView() - { - InitializeComponent(); - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml index fbe45d36d..f8424b26d 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml @@ -7,7 +7,7 @@ xmlns:dragablz="clr-namespace:Dragablz;assembly=Dragablz" xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" - xmlns:managers="clr-namespace:Tango.MachineStudio.UI.Managers" + xmlns:db="clr-namespace:Tango.MachineStudio.DB.Views;assembly=Tango.MachineStudio.DB" xmlns:local="clr-namespace:Tango.MachineStudio.UI.Views" mc:Ignorable="d" d:DesignHeight="720" d:DesignWidth="1270" Background="White" DataContext="{Binding MainViewVM, Source={StaticResource Locator}}"> @@ -59,23 +59,10 @@ - - - - - - - - - + + - - - - + + + + + + + + + + diff --git a/Software/Visual_Studio/Tango.ColorPicker/ColorBlendConverter.cs b/Software/Visual_Studio/Tango.ColorPicker/ColorBlendConverter.cs new file mode 100644 index 000000000..3e61fea36 --- /dev/null +++ b/Software/Visual_Studio/Tango.ColorPicker/ColorBlendConverter.cs @@ -0,0 +1,82 @@ +/************************************************************************************* + + Extended WPF Toolkit + + Copyright (C) 2007-2013 Xceed Software Inc. + + This program is provided to you under the terms of the Microsoft Public + License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license + + For more features, controls, and fast professional support, + pick up the Plus Edition at http://xceed.com/wpf_toolkit + + Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids + + ***********************************************************************************/ + +using System; +using System.Windows.Data; +using System.Windows.Media; + +namespace Tango.ColorPicker.Core.Converters +{ + /// + /// This converter allow to blend two colors into one based on a specified ratio + /// + internal class ColorBlendConverter : IValueConverter + { + private double _blendedColorRatio = 0; + + /// + /// The ratio of the blended color. Must be between 0 and 1. + /// + public double BlendedColorRatio + { + get { return _blendedColorRatio; } + + set + { + if (value < 0d || value > 1d) + throw new ArgumentException("BlendedColorRatio must greater than or equal to 0 and lower than or equal to 1 "); + + _blendedColorRatio = value; + } + } + + /// + /// The color to blend with the source color + /// + public Color BlendedColor { get; set; } + + public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + if (value == null || value.GetType() != typeof(Color)) + return null; + + Color color = (Color)value; + return new Color() + { + A = this.BlendValue(color.A, this.BlendedColor.A), + R = this.BlendValue(color.R, this.BlendedColor.R), + G = this.BlendValue(color.G, this.BlendedColor.G), + B = this.BlendValue(color.B, this.BlendedColor.B) + }; + } + + private byte BlendValue(byte original, byte blend) + { + double blendRatio = this.BlendedColorRatio; + double sourceRatio = 1 - blendRatio; + + double result = (((double)original) * sourceRatio) + (((double)blend) * blendRatio); + result = Math.Round(result); + result = Math.Min(255d, Math.Max(0d, result)); + return System.Convert.ToByte(result); + } + + public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/Tango.ColorPicker/ColorCanvas/Implementation/ColorCanvas.cs b/Software/Visual_Studio/Tango.ColorPicker/ColorCanvas/Implementation/ColorCanvas.cs new file mode 100644 index 000000000..da7176f61 --- /dev/null +++ b/Software/Visual_Studio/Tango.ColorPicker/ColorCanvas/Implementation/ColorCanvas.cs @@ -0,0 +1,602 @@ +/************************************************************************************* + + Extended WPF Toolkit + + Copyright (C) 2007-2013 Xceed Software Inc. + + This program is provided to you under the terms of the Microsoft Public + License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license + + For more features, controls, and fast professional support, + pick up the Plus Edition at http://xceed.com/wpf_toolkit + + Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids + + ***********************************************************************************/ + +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Input; +using System.Windows.Media; +using Tango.ColorPicker.Core.Utilities; +using Tango.ColorPicker.Primitives; +using System.IO; +using System; + +namespace Tango +{ + [TemplatePart( Name = PART_ColorShadingCanvas, Type = typeof( Canvas ) )] + [TemplatePart( Name = PART_ColorShadeSelector, Type = typeof( Canvas ) )] + [TemplatePart( Name = PART_SpectrumSlider, Type = typeof( ColorSpectrumSlider ) )] + [TemplatePart( Name = PART_HexadecimalTextBox, Type = typeof( TextBox ) )] + internal class ColorCanvas : Control + { + private const string PART_ColorShadingCanvas = "PART_ColorShadingCanvas"; + private const string PART_ColorShadeSelector = "PART_ColorShadeSelector"; + private const string PART_SpectrumSlider = "PART_SpectrumSlider"; + private const string PART_HexadecimalTextBox = "PART_HexadecimalTextBox"; + + #region Private Members + + private TranslateTransform _colorShadeSelectorTransform = new TranslateTransform(); + private Canvas _colorShadingCanvas; + private Canvas _colorShadeSelector; + private ColorSpectrumSlider _spectrumSlider; + private TextBox _hexadecimalTextBox; + private Point? _currentColorPosition; + private bool _surpressPropertyChanged; + private bool _updateSpectrumSliderValue = true; + + #endregion //Private Members + + #region Properties + + #region SelectedColor + + public static readonly DependencyProperty SelectedColorProperty = DependencyProperty.Register( "SelectedColor", typeof( Color? ), typeof( ColorCanvas ), new FrameworkPropertyMetadata( null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnSelectedColorChanged ) ); + public Color? SelectedColor + { + get + { + return ( Color? )GetValue( SelectedColorProperty ); + } + set + { + SetValue( SelectedColorProperty, value ); + } + } + + private static void OnSelectedColorChanged( DependencyObject o, DependencyPropertyChangedEventArgs e ) + { + ColorCanvas colorCanvas = o as ColorCanvas; + if( colorCanvas != null ) + colorCanvas.OnSelectedColorChanged( ( Color? )e.OldValue, ( Color? )e.NewValue ); + } + + protected virtual void OnSelectedColorChanged( Color? oldValue, Color? newValue ) + { + SetHexadecimalStringProperty( GetFormatedColorString( newValue ), false ); + UpdateRGBValues( newValue ); + UpdateColorShadeSelectorPosition( newValue ); + + RoutedPropertyChangedEventArgs args = new RoutedPropertyChangedEventArgs( oldValue, newValue ); + args.RoutedEvent = SelectedColorChangedEvent; + RaiseEvent( args ); + } + + #endregion //SelectedColor + + #region RGB + + #region A + + public static readonly DependencyProperty AProperty = DependencyProperty.Register( "A", typeof( byte ), typeof( ColorCanvas ), new UIPropertyMetadata( ( byte )255, OnAChanged ) ); + public byte A + { + get + { + return ( byte )GetValue( AProperty ); + } + set + { + SetValue( AProperty, value ); + } + } + + private static void OnAChanged( DependencyObject o, DependencyPropertyChangedEventArgs e ) + { + ColorCanvas colorCanvas = o as ColorCanvas; + if( colorCanvas != null ) + colorCanvas.OnAChanged( ( byte )e.OldValue, ( byte )e.NewValue ); + } + + protected virtual void OnAChanged( byte oldValue, byte newValue ) + { + if( !_surpressPropertyChanged ) + UpdateSelectedColor(); + } + + #endregion //A + + #region R + + public static readonly DependencyProperty RProperty = DependencyProperty.Register( "R", typeof( byte ), typeof( ColorCanvas ), new UIPropertyMetadata( ( byte )0, OnRChanged ) ); + public byte R + { + get + { + return ( byte )GetValue( RProperty ); + } + set + { + SetValue( RProperty, value ); + } + } + + private static void OnRChanged( DependencyObject o, DependencyPropertyChangedEventArgs e ) + { + ColorCanvas colorCanvas = o as ColorCanvas; + if( colorCanvas != null ) + colorCanvas.OnRChanged( ( byte )e.OldValue, ( byte )e.NewValue ); + } + + protected virtual void OnRChanged( byte oldValue, byte newValue ) + { + if( !_surpressPropertyChanged ) + UpdateSelectedColor(); + } + + #endregion //R + + #region G + + public static readonly DependencyProperty GProperty = DependencyProperty.Register( "G", typeof( byte ), typeof( ColorCanvas ), new UIPropertyMetadata( ( byte )0, OnGChanged ) ); + public byte G + { + get + { + return ( byte )GetValue( GProperty ); + } + set + { + SetValue( GProperty, value ); + } + } + + private static void OnGChanged( DependencyObject o, DependencyPropertyChangedEventArgs e ) + { + ColorCanvas colorCanvas = o as ColorCanvas; + if( colorCanvas != null ) + colorCanvas.OnGChanged( ( byte )e.OldValue, ( byte )e.NewValue ); + } + + protected virtual void OnGChanged( byte oldValue, byte newValue ) + { + if( !_surpressPropertyChanged ) + UpdateSelectedColor(); + } + + #endregion //G + + #region B + + public static readonly DependencyProperty BProperty = DependencyProperty.Register( "B", typeof( byte ), typeof( ColorCanvas ), new UIPropertyMetadata( ( byte )0, OnBChanged ) ); + public byte B + { + get + { + return ( byte )GetValue( BProperty ); + } + set + { + SetValue( BProperty, value ); + } + } + + private static void OnBChanged( DependencyObject o, DependencyPropertyChangedEventArgs e ) + { + ColorCanvas colorCanvas = o as ColorCanvas; + if( colorCanvas != null ) + colorCanvas.OnBChanged( ( byte )e.OldValue, ( byte )e.NewValue ); + } + + protected virtual void OnBChanged( byte oldValue, byte newValue ) + { + if( !_surpressPropertyChanged ) + UpdateSelectedColor(); + } + + #endregion //B + + #endregion //RGB + + #region HexadecimalString + + public static readonly DependencyProperty HexadecimalStringProperty = DependencyProperty.Register( "HexadecimalString", typeof( string ), typeof( ColorCanvas ), new UIPropertyMetadata( "", OnHexadecimalStringChanged, OnCoerceHexadecimalString ) ); + public string HexadecimalString + { + get + { + return ( string )GetValue( HexadecimalStringProperty ); + } + set + { + SetValue( HexadecimalStringProperty, value ); + } + } + + private static void OnHexadecimalStringChanged( DependencyObject o, DependencyPropertyChangedEventArgs e ) + { + ColorCanvas colorCanvas = o as ColorCanvas; + if( colorCanvas != null ) + colorCanvas.OnHexadecimalStringChanged( ( string )e.OldValue, ( string )e.NewValue ); + } + + protected virtual void OnHexadecimalStringChanged( string oldValue, string newValue ) + { + string newColorString = GetFormatedColorString( newValue ); + string currentColorString = GetFormatedColorString( SelectedColor ); + if( !currentColorString.Equals( newColorString ) ) + { + Color? col = null; + if( !string.IsNullOrEmpty( newColorString ) ) + { + col = ( Color )ColorConverter.ConvertFromString( newColorString ); + } + UpdateSelectedColor( col ); + } + + SetHexadecimalTextBoxTextProperty( newValue ); + } + + private static object OnCoerceHexadecimalString( DependencyObject d, object basevalue ) + { + var colorCanvas = ( ColorCanvas )d; + if( colorCanvas == null ) + return basevalue; + + return colorCanvas.OnCoerceHexadecimalString( basevalue ); + } + + private object OnCoerceHexadecimalString( object newValue ) + { + var value = newValue as string; + string retValue = value; + + try + { + if( !string.IsNullOrEmpty( retValue ) ) + { + ColorConverter.ConvertFromString( value ); + } + } + catch + { + //When HexadecimalString is changed via Code-Behind and hexadecimal format is bad, throw. + throw new InvalidDataException( "Color provided is not in the correct format." ); + } + + return retValue; + } + + #endregion //HexadecimalString + + #region UsingAlphaChannel + + public static readonly DependencyProperty UsingAlphaChannelProperty = DependencyProperty.Register( "UsingAlphaChannel", typeof( bool ), typeof( ColorCanvas ), new FrameworkPropertyMetadata( true, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, new PropertyChangedCallback( OnUsingAlphaChannelPropertyChanged ) ) ); + public bool UsingAlphaChannel + { + get + { + return ( bool )GetValue( UsingAlphaChannelProperty ); + } + set + { + SetValue( UsingAlphaChannelProperty, value ); + } + } + + private static void OnUsingAlphaChannelPropertyChanged( DependencyObject o, DependencyPropertyChangedEventArgs e ) + { + ColorCanvas colorCanvas = o as ColorCanvas; + if( colorCanvas != null ) + colorCanvas.OnUsingAlphaChannelChanged(); + } + + protected virtual void OnUsingAlphaChannelChanged() + { + SetHexadecimalStringProperty( GetFormatedColorString( SelectedColor ), false ); + } + + #endregion //UsingAlphaChannel + + #endregion //Properties + + #region Constructors + + static ColorCanvas() + { + DefaultStyleKeyProperty.OverrideMetadata( typeof( ColorCanvas ), new FrameworkPropertyMetadata( typeof( ColorCanvas ) ) ); + } + + #endregion //Constructors + + #region Base Class Overrides + + public override void OnApplyTemplate() + { + base.OnApplyTemplate(); + + if( _colorShadingCanvas != null ) + { + _colorShadingCanvas.MouseLeftButtonDown -= ColorShadingCanvas_MouseLeftButtonDown; + _colorShadingCanvas.MouseLeftButtonUp -= ColorShadingCanvas_MouseLeftButtonUp; + _colorShadingCanvas.MouseMove -= ColorShadingCanvas_MouseMove; + _colorShadingCanvas.SizeChanged -= ColorShadingCanvas_SizeChanged; + } + + _colorShadingCanvas = GetTemplateChild( PART_ColorShadingCanvas ) as Canvas; + + if( _colorShadingCanvas != null ) + { + _colorShadingCanvas.MouseLeftButtonDown += ColorShadingCanvas_MouseLeftButtonDown; + _colorShadingCanvas.MouseLeftButtonUp += ColorShadingCanvas_MouseLeftButtonUp; + _colorShadingCanvas.MouseMove += ColorShadingCanvas_MouseMove; + _colorShadingCanvas.SizeChanged += ColorShadingCanvas_SizeChanged; + } + + _colorShadeSelector = GetTemplateChild( PART_ColorShadeSelector ) as Canvas; + + if( _colorShadeSelector != null ) + _colorShadeSelector.RenderTransform = _colorShadeSelectorTransform; + + if( _spectrumSlider != null ) + _spectrumSlider.ValueChanged -= SpectrumSlider_ValueChanged; + + _spectrumSlider = GetTemplateChild( PART_SpectrumSlider ) as ColorSpectrumSlider; + + if( _spectrumSlider != null ) + _spectrumSlider.ValueChanged += SpectrumSlider_ValueChanged; + + if( _hexadecimalTextBox != null ) + _hexadecimalTextBox.LostFocus -= new RoutedEventHandler( HexadecimalTextBox_LostFocus ); + + _hexadecimalTextBox = GetTemplateChild( PART_HexadecimalTextBox ) as TextBox; + + if( _hexadecimalTextBox != null ) + _hexadecimalTextBox.LostFocus += new RoutedEventHandler( HexadecimalTextBox_LostFocus ); + + UpdateRGBValues( SelectedColor ); + UpdateColorShadeSelectorPosition( SelectedColor ); + + // When changing theme, HexadecimalString needs to be set since it is not binded. + SetHexadecimalTextBoxTextProperty( GetFormatedColorString( SelectedColor ) ); + } + + protected override void OnKeyDown( KeyEventArgs e ) + { + base.OnKeyDown( e ); + + //hitting enter on textbox will update Hexadecimal string + if( e.Key == Key.Enter && e.OriginalSource is TextBox ) + { + TextBox textBox = ( TextBox )e.OriginalSource; + if( textBox.Name == PART_HexadecimalTextBox ) + SetHexadecimalStringProperty( textBox.Text, true ); + } + } + + #endregion //Base Class Overrides + + #region Event Handlers + + void ColorShadingCanvas_MouseLeftButtonDown( object sender, MouseButtonEventArgs e ) + { + Point p = e.GetPosition( _colorShadingCanvas ); + UpdateColorShadeSelectorPositionAndCalculateColor( p, true ); + _colorShadingCanvas.CaptureMouse(); + //Prevent from closing ColorCanvas after mouseDown in ListView + e.Handled = true; + } + + void ColorShadingCanvas_MouseLeftButtonUp( object sender, MouseButtonEventArgs e ) + { + _colorShadingCanvas.ReleaseMouseCapture(); + } + + void ColorShadingCanvas_MouseMove( object sender, MouseEventArgs e ) + { + if( e.LeftButton == MouseButtonState.Pressed ) + { + Point p = e.GetPosition( _colorShadingCanvas ); + UpdateColorShadeSelectorPositionAndCalculateColor( p, true ); + Mouse.Synchronize(); + } + } + + void ColorShadingCanvas_SizeChanged( object sender, SizeChangedEventArgs e ) + { + if( _currentColorPosition != null ) + { + Point _newPoint = new Point + { + X = ( ( Point )_currentColorPosition ).X * e.NewSize.Width, + Y = ( ( Point )_currentColorPosition ).Y * e.NewSize.Height + }; + + UpdateColorShadeSelectorPositionAndCalculateColor( _newPoint, false ); + } + } + + void SpectrumSlider_ValueChanged( object sender, RoutedPropertyChangedEventArgs e ) + { + if( (_currentColorPosition != null) && (this.SelectedColor != null) ) + { + CalculateColor( ( Point )_currentColorPosition ); + } + } + + void HexadecimalTextBox_LostFocus( object sender, RoutedEventArgs e ) + { + TextBox textbox = sender as TextBox; + SetHexadecimalStringProperty( textbox.Text, true ); + } + + #endregion //Event Handlers + + #region Events + + public static readonly RoutedEvent SelectedColorChangedEvent = EventManager.RegisterRoutedEvent( "SelectedColorChanged", RoutingStrategy.Bubble, typeof( RoutedPropertyChangedEventHandler ), typeof( ColorCanvas ) ); + public event RoutedPropertyChangedEventHandler SelectedColorChanged + { + add + { + AddHandler( SelectedColorChangedEvent, value ); + } + remove + { + RemoveHandler( SelectedColorChangedEvent, value ); + } + } + + #endregion //Events + + #region Methods + + private void UpdateSelectedColor() + { + SelectedColor = Color.FromArgb( A, R, G, B ); + } + + private void UpdateSelectedColor( Color? color ) + { + SelectedColor = ( ( color != null ) && color.HasValue ) + ? (Color?)Color.FromArgb( color.Value.A, color.Value.R, color.Value.G, color.Value.B ) + : null; + } + + private void UpdateRGBValues( Color? color ) + { + if( ( color == null ) || !color.HasValue ) + return; + + _surpressPropertyChanged = true; + + A = color.Value.A; + R = color.Value.R; + G = color.Value.G; + B = color.Value.B; + + _surpressPropertyChanged = false; + } + + private void UpdateColorShadeSelectorPositionAndCalculateColor( Point p, bool calculateColor ) + { + if( p.Y < 0 ) + p.Y = 0; + + if( p.X < 0 ) + p.X = 0; + + if( p.X > _colorShadingCanvas.ActualWidth ) + p.X = _colorShadingCanvas.ActualWidth; + + if( p.Y > _colorShadingCanvas.ActualHeight ) + p.Y = _colorShadingCanvas.ActualHeight; + + _colorShadeSelectorTransform.X = p.X - ( _colorShadeSelector.Width / 2 ); + _colorShadeSelectorTransform.Y = p.Y - ( _colorShadeSelector.Height / 2 ); + + p.X = p.X / _colorShadingCanvas.ActualWidth; + p.Y = p.Y / _colorShadingCanvas.ActualHeight; + + _currentColorPosition = p; + + if( calculateColor ) + CalculateColor( p ); + } + + private void UpdateColorShadeSelectorPosition( Color? color ) + { + if( (_spectrumSlider == null) || (_colorShadingCanvas == null) || (color == null) || !color.HasValue) + return; + + _currentColorPosition = null; + + HsvColor hsv = ColorUtilities.ConvertRgbToHsv( color.Value.R, color.Value.G, color.Value.B ); + + if( _updateSpectrumSliderValue ) + { + _spectrumSlider.Value = hsv.H; + } + + Point p = new Point( hsv.S, 1 - hsv.V ); + + _currentColorPosition = p; + + _colorShadeSelectorTransform.X = ( p.X * _colorShadingCanvas.Width ) - 5; + _colorShadeSelectorTransform.Y = ( p.Y * _colorShadingCanvas.Height ) - 5; + } + + private void CalculateColor( Point p ) + { + HsvColor hsv = new HsvColor( 360 - _spectrumSlider.Value, 1, 1 ) + { + S = p.X, + V = 1 - p.Y + }; + var currentColor = ColorUtilities.ConvertHsvToRgb( hsv.H, hsv.S, hsv.V ); + currentColor.A = A; + _updateSpectrumSliderValue = false; + SelectedColor = currentColor; + _updateSpectrumSliderValue = true; + SetHexadecimalStringProperty( GetFormatedColorString( SelectedColor ), false ); + } + + private string GetFormatedColorString( Color? colorToFormat ) + { + if( ( colorToFormat == null ) || !colorToFormat.HasValue ) + return string.Empty; + return ColorUtilities.FormatColorString( colorToFormat.ToString(), UsingAlphaChannel ); + } + + private string GetFormatedColorString( string stringToFormat ) + { + return ColorUtilities.FormatColorString( stringToFormat, UsingAlphaChannel ); + } + + private void SetHexadecimalStringProperty( string newValue, bool modifyFromUI ) + { + if( modifyFromUI ) + { + try + { + if( !string.IsNullOrEmpty( newValue ) ) + { + ColorConverter.ConvertFromString( newValue ); + } + HexadecimalString = newValue; + } + catch + { + //When HexadecimalString is changed via UI and hexadecimal format is bad, keep the previous HexadecimalString. + SetHexadecimalTextBoxTextProperty( HexadecimalString ); + } + } + else + { + //When HexadecimalString is changed via Code-Behind, hexadecimal format will be evaluated in OnCoerceHexadecimalString() + HexadecimalString = newValue; + } + } + + private void SetHexadecimalTextBoxTextProperty( string newValue ) + { + if( _hexadecimalTextBox != null ) + _hexadecimalTextBox.Text = newValue; + } + + #endregion //Methods + } +} diff --git a/Software/Visual_Studio/Tango.ColorPicker/ColorCanvas/Implementation/ColorSpectrumSlider.cs b/Software/Visual_Studio/Tango.ColorPicker/ColorCanvas/Implementation/ColorSpectrumSlider.cs new file mode 100644 index 000000000..06233ba35 --- /dev/null +++ b/Software/Visual_Studio/Tango.ColorPicker/ColorCanvas/Implementation/ColorSpectrumSlider.cs @@ -0,0 +1,111 @@ +/************************************************************************************* + + Extended WPF Toolkit + + Copyright (C) 2007-2013 Xceed Software Inc. + + This program is provided to you under the terms of the Microsoft Public + License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license + + For more features, controls, and fast professional support, + pick up the Plus Edition at http://xceed.com/wpf_toolkit + + Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids + + ***********************************************************************************/ + +using System; +using System.Collections.Generic; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Media; +using System.Windows.Shapes; +using Tango.ColorPicker.Core.Utilities; + +namespace Tango +{ + [TemplatePart( Name = PART_SpectrumDisplay, Type = typeof( Rectangle ) )] + internal class ColorSpectrumSlider : Slider + { + private const string PART_SpectrumDisplay = "PART_SpectrumDisplay"; + + #region Private Members + + private Rectangle _spectrumDisplay; + private LinearGradientBrush _pickerBrush; + + #endregion //Private Members + + #region Constructors + + static ColorSpectrumSlider() + { + DefaultStyleKeyProperty.OverrideMetadata( typeof( ColorSpectrumSlider ), new FrameworkPropertyMetadata( typeof( ColorSpectrumSlider ) ) ); + } + + #endregion //Constructors + + #region Dependency Properties + + public static readonly DependencyProperty SelectedColorProperty = DependencyProperty.Register( "SelectedColor", typeof( Color ), typeof( ColorSpectrumSlider ), new PropertyMetadata( System.Windows.Media.Colors.Transparent ) ); + public Color SelectedColor + { + get + { + return ( Color )GetValue( SelectedColorProperty ); + } + set + { + SetValue( SelectedColorProperty, value ); + } + } + + #endregion //Dependency Properties + + #region Base Class Overrides + + public override void OnApplyTemplate() + { + base.OnApplyTemplate(); + + _spectrumDisplay = ( Rectangle )GetTemplateChild( PART_SpectrumDisplay ); + CreateSpectrum(); + OnValueChanged( Double.NaN, Value ); + } + + protected override void OnValueChanged( double oldValue, double newValue ) + { + base.OnValueChanged( oldValue, newValue ); + + Color color = ColorUtilities.ConvertHsvToRgb( 360 - newValue, 1, 1 ); + SelectedColor = color; + } + + #endregion //Base Class Overrides + + #region Methods + + private void CreateSpectrum() + { + _pickerBrush = new LinearGradientBrush(); + _pickerBrush.StartPoint = new Point( 0.5, 0 ); + _pickerBrush.EndPoint = new Point( 0.5, 1 ); + _pickerBrush.ColorInterpolationMode = ColorInterpolationMode.SRgbLinearInterpolation; + + List colorsList = ColorUtilities.GenerateHsvSpectrum(); + + double stopIncrement = ( double )1 / colorsList.Count; + + int i; + for( i = 0; i < colorsList.Count; i++ ) + { + _pickerBrush.GradientStops.Add( new GradientStop( colorsList[ i ], i * stopIncrement ) ); + } + + _pickerBrush.GradientStops[ i - 1 ].Offset = 1.0; + _spectrumDisplay.Fill = _pickerBrush; + } + + #endregion //Methods + } +} diff --git a/Software/Visual_Studio/Tango.ColorPicker/ColorCanvas/Themes/Generic.xaml b/Software/Visual_Studio/Tango.ColorPicker/ColorCanvas/Themes/Generic.xaml new file mode 100644 index 000000000..a54e2f6a5 --- /dev/null +++ b/Software/Visual_Studio/Tango.ColorPicker/ColorCanvas/Themes/Generic.xaml @@ -0,0 +1,602 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/Tango.ColorPicker/ColorPicker/Implementation/ColorItem.cs b/Software/Visual_Studio/Tango.ColorPicker/ColorPicker/Implementation/ColorItem.cs new file mode 100644 index 000000000..dbf1860f7 --- /dev/null +++ b/Software/Visual_Studio/Tango.ColorPicker/ColorPicker/Implementation/ColorItem.cs @@ -0,0 +1,53 @@ +/************************************************************************************* + + Extended WPF Toolkit + + Copyright (C) 2007-2013 Xceed Software Inc. + + This program is provided to you under the terms of the Microsoft Public + License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license + + For more features, controls, and fast professional support, + pick up the Plus Edition at http://xceed.com/wpf_toolkit + + Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids + + ***********************************************************************************/ + +using System.Windows.Media; + +namespace Tango +{ + internal class ColorItem + { + public Color? Color + { + get; + set; + } + public string Name + { + get; + set; + } + + public ColorItem(Color? color, string name) + { + Color = color; + Name = name; + } + + public override bool Equals(object obj) + { + var ci = obj as ColorItem; + if (ci == null) + return false; + return (ci.Color.Equals(Color) && ci.Name.Equals(Name)); + } + + public override int GetHashCode() + { + return this.Color.GetHashCode() ^ this.Name.GetHashCode(); + } + } +} diff --git a/Software/Visual_Studio/Tango.ColorPicker/ColorPicker/Implementation/ColorPicker.cs b/Software/Visual_Studio/Tango.ColorPicker/ColorPicker/Implementation/ColorPicker.cs new file mode 100644 index 000000000..aff0ae661 --- /dev/null +++ b/Software/Visual_Studio/Tango.ColorPicker/ColorPicker/Implementation/ColorPicker.cs @@ -0,0 +1,770 @@ +/************************************************************************************* + + Extended WPF Toolkit + + Copyright (C) 2007-2013 Xceed Software Inc. + + This program is provided to you under the terms of the Microsoft Public + License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license + + For more features, controls, and fast professional support, + pick up the Plus Edition at http://xceed.com/wpf_toolkit + + Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids + + ***********************************************************************************/ + +using System; +using System.Collections.ObjectModel; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; +using System.Windows.Media; +using Tango.ColorPicker.Core.Utilities; +using System.Windows.Controls.Primitives; +using System.Linq; +using System.Collections.Generic; +using System.Windows.Data; +using Tango.ColorPicker; + +namespace Tango +{ + internal enum ColorMode + { + ColorPalette, + ColorCanvas + } + + internal enum ColorSortingMode + { + Alphabetical, + HueSaturationBrightness + } + + [TemplatePart(Name = PART_AvailableColors, Type = typeof(ListBox))] + [TemplatePart(Name = PART_StandardColors, Type = typeof(ListBox))] + [TemplatePart(Name = PART_RecentColors, Type = typeof(ListBox))] + [TemplatePart(Name = PART_ColorPickerToggleButton, Type = typeof(ToggleButton))] + [TemplatePart(Name = PART_ColorPickerPalettePopup, Type = typeof(Popup))] + [TemplatePart(Name = PART_ColorModeButton, Type = typeof(Button))] + public class ColorPickerCombo : Control + { + private const string PART_AvailableColors = "PART_AvailableColors"; + private const string PART_StandardColors = "PART_StandardColors"; + private const string PART_RecentColors = "PART_RecentColors"; + private const string PART_ColorPickerToggleButton = "PART_ColorPickerToggleButton"; + private const string PART_ColorPickerPalettePopup = "PART_ColorPickerPalettePopup"; + private const string PART_ColorModeButton = "PART_ColorModeButton"; + + #region Members + + private ListBox _availableColors; + private ListBox _standardColors; + private ListBox _recentColors; + private ToggleButton _toggleButton; + private Popup _popup; + private Button _colorModeButton; + private Color? _initialColor; + private bool _selectionChanged; + + #endregion //Members + + #region Properties + + #region AdvancedButtonHeader + + public static readonly DependencyProperty AdvancedButtonHeaderProperty = DependencyProperty.Register("AdvancedButtonHeader", typeof(string), typeof(ColorPickerCombo), new UIPropertyMetadata("Advanced")); + public string AdvancedButtonHeader + { + get + { + return (string)GetValue(AdvancedButtonHeaderProperty); + } + set + { + SetValue(AdvancedButtonHeaderProperty, value); + } + } + + #endregion //AdvancedButtonHeader + + #region AvailableColors + + internal static readonly DependencyProperty AvailableColorsProperty = DependencyProperty.Register("AvailableColors", typeof(ObservableCollection), typeof(ColorPickerCombo), new UIPropertyMetadata(CreateAvailableColors())); + internal ObservableCollection AvailableColors + { + get + { + return (ObservableCollection)GetValue(AvailableColorsProperty); + } + set + { + SetValue(AvailableColorsProperty, value); + } + } + + #endregion //AvailableColors + + #region AvailableColorsSortingMode + + internal static readonly DependencyProperty AvailableColorsSortingModeProperty = DependencyProperty.Register("AvailableColorsSortingMode", typeof(ColorSortingMode), typeof(ColorPickerCombo), new UIPropertyMetadata(ColorSortingMode.Alphabetical, OnAvailableColorsSortingModeChanged)); + internal ColorSortingMode AvailableColorsSortingMode + { + get + { + return (ColorSortingMode)GetValue(AvailableColorsSortingModeProperty); + } + set + { + SetValue(AvailableColorsSortingModeProperty, value); + } + } + + private static void OnAvailableColorsSortingModeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + ColorPickerCombo colorPicker = (ColorPickerCombo)d; + if (colorPicker != null) + colorPicker.OnAvailableColorsSortingModeChanged((ColorSortingMode)e.OldValue, (ColorSortingMode)e.NewValue); + } + + private void OnAvailableColorsSortingModeChanged(ColorSortingMode oldValue, ColorSortingMode newValue) + { + ListCollectionView lcv = (ListCollectionView)(CollectionViewSource.GetDefaultView(this.AvailableColors)); + if (lcv != null) + { + lcv.CustomSort = (AvailableColorsSortingMode == ColorSortingMode.HueSaturationBrightness) + ? new ColorSorter() + : null; + } + } + + #endregion //AvailableColorsSortingMode + + #region AvailableColorsHeader + + public static readonly DependencyProperty AvailableColorsHeaderProperty = DependencyProperty.Register("AvailableColorsHeader", typeof(string), typeof(ColorPickerCombo), new UIPropertyMetadata("Available Colors")); + public string AvailableColorsHeader + { + get + { + return (string)GetValue(AvailableColorsHeaderProperty); + } + set + { + SetValue(AvailableColorsHeaderProperty, value); + } + } + + #endregion //AvailableColorsHeader + + #region ButtonStyle + + public static readonly DependencyProperty ButtonStyleProperty = DependencyProperty.Register("ButtonStyle", typeof(Style), typeof(ColorPickerCombo)); + public Style ButtonStyle + { + get + { + return (Style)GetValue(ButtonStyleProperty); + } + set + { + SetValue(ButtonStyleProperty, value); + } + } + + #endregion //ButtonStyle + + #region DisplayColorAndName + + public static readonly DependencyProperty DisplayColorAndNameProperty = DependencyProperty.Register("DisplayColorAndName", typeof(bool), typeof(ColorPickerCombo), new UIPropertyMetadata(false)); + public bool DisplayColorAndName + { + get + { + return (bool)GetValue(DisplayColorAndNameProperty); + } + set + { + SetValue(DisplayColorAndNameProperty, value); + } + } + + #endregion //DisplayColorAndName + + #region ColorMode + + internal static readonly DependencyProperty ColorModeProperty = DependencyProperty.Register("ColorMode", typeof(ColorMode), typeof(ColorPickerCombo), new UIPropertyMetadata(ColorMode.ColorPalette)); + internal ColorMode ColorMode + { + get + { + return (ColorMode)GetValue(ColorModeProperty); + } + set + { + SetValue(ColorModeProperty, value); + } + } + + #endregion //ColorMode + + #region IsOpen + + public static readonly DependencyProperty IsOpenProperty = DependencyProperty.Register("IsOpen", typeof(bool), typeof(ColorPickerCombo), new UIPropertyMetadata(false, OnIsOpenChanged)); + public bool IsOpen + { + get + { + return (bool)GetValue(IsOpenProperty); + } + set + { + SetValue(IsOpenProperty, value); + } + } + + private static void OnIsOpenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + ColorPickerCombo colorPicker = (ColorPickerCombo)d; + if (colorPicker != null) + colorPicker.OnIsOpenChanged((bool)e.OldValue, (bool)e.NewValue); + } + + private void OnIsOpenChanged(bool oldValue, bool newValue) + { + if (newValue) + { + _initialColor = this.SelectedColor; + } + RoutedEventArgs args = new RoutedEventArgs(newValue ? OpenedEvent : ClosedEvent, this); + this.RaiseEvent(args); + } + + #endregion //IsOpen + + #region RecentColors + + internal static readonly DependencyProperty RecentColorsProperty = DependencyProperty.Register("RecentColors", typeof(ObservableCollection), typeof(ColorPickerCombo), new UIPropertyMetadata(null)); + internal ObservableCollection RecentColors + { + get + { + return (ObservableCollection)GetValue(RecentColorsProperty); + } + set + { + SetValue(RecentColorsProperty, value); + } + } + + #endregion //RecentColors + + #region RecentColorsHeader + + public static readonly DependencyProperty RecentColorsHeaderProperty = DependencyProperty.Register("RecentColorsHeader", typeof(string), typeof(ColorPickerCombo), new UIPropertyMetadata("Recent Colors")); + public string RecentColorsHeader + { + get + { + return (string)GetValue(RecentColorsHeaderProperty); + } + set + { + SetValue(RecentColorsHeaderProperty, value); + } + } + + #endregion //RecentColorsHeader + + #region SelectedColor + + public static readonly DependencyProperty SelectedColorProperty = DependencyProperty.Register("SelectedColor", typeof(Color?), typeof(ColorPickerCombo), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, new PropertyChangedCallback(OnSelectedColorPropertyChanged))); + public Color? SelectedColor + { + get + { + return (Color?)GetValue(SelectedColorProperty); + } + set + { + SetValue(SelectedColorProperty, value); + } + } + + private static void OnSelectedColorPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + ColorPickerCombo colorPicker = (ColorPickerCombo)d; + if (colorPicker != null) + colorPicker.OnSelectedColorChanged((Color?)e.OldValue, (Color?)e.NewValue); + } + + private void OnSelectedColorChanged(Color? oldValue, Color? newValue) + { + SelectedColorText = GetFormatedColorString(newValue); + + RoutedPropertyChangedEventArgs args = new RoutedPropertyChangedEventArgs(oldValue, newValue); + args.RoutedEvent = ColorPickerCombo.SelectedColorChangedEvent; + RaiseEvent(args); + } + + #endregion //SelectedColor + + #region SelectedColorText + + public static readonly DependencyProperty SelectedColorTextProperty = DependencyProperty.Register("SelectedColorText", typeof(string), typeof(ColorPickerCombo), new UIPropertyMetadata("")); + public string SelectedColorText + { + get + { + return (string)GetValue(SelectedColorTextProperty); + } + protected set + { + SetValue(SelectedColorTextProperty, value); + } + } + + #endregion //SelectedColorText + + #region ShowAdvancedButton + + public static readonly DependencyProperty ShowAdvancedButtonProperty = DependencyProperty.Register("ShowAdvancedButton", typeof(bool), typeof(ColorPickerCombo), new UIPropertyMetadata(true)); + public bool ShowAdvancedButton + { + get + { + return (bool)GetValue(ShowAdvancedButtonProperty); + } + set + { + SetValue(ShowAdvancedButtonProperty, value); + } + } + + #endregion //ShowAdvancedButton + + #region ShowAvailableColors + + public static readonly DependencyProperty ShowAvailableColorsProperty = DependencyProperty.Register("ShowAvailableColors", typeof(bool), typeof(ColorPickerCombo), new UIPropertyMetadata(true)); + public bool ShowAvailableColors + { + get + { + return (bool)GetValue(ShowAvailableColorsProperty); + } + set + { + SetValue(ShowAvailableColorsProperty, value); + } + } + + #endregion //ShowAvailableColors + + #region ShowRecentColors + + public static readonly DependencyProperty ShowRecentColorsProperty = DependencyProperty.Register("ShowRecentColors", typeof(bool), typeof(ColorPickerCombo), new UIPropertyMetadata(false)); + public bool ShowRecentColors + { + get + { + return (bool)GetValue(ShowRecentColorsProperty); + } + set + { + SetValue(ShowRecentColorsProperty, value); + } + } + + #endregion //DisplayRecentColors + + #region ShowStandardColors + + public static readonly DependencyProperty ShowStandardColorsProperty = DependencyProperty.Register("ShowStandardColors", typeof(bool), typeof(ColorPickerCombo), new UIPropertyMetadata(true)); + public bool ShowStandardColors + { + get + { + return (bool)GetValue(ShowStandardColorsProperty); + } + set + { + SetValue(ShowStandardColorsProperty, value); + } + } + + #endregion //DisplayStandardColors + + #region ShowDropDownButton + + public static readonly DependencyProperty ShowDropDownButtonProperty = DependencyProperty.Register("ShowDropDownButton", typeof(bool), typeof(ColorPickerCombo), new UIPropertyMetadata(true)); + public bool ShowDropDownButton + { + get + { + return (bool)GetValue(ShowDropDownButtonProperty); + } + set + { + SetValue(ShowDropDownButtonProperty, value); + } + } + + #endregion //ShowDropDownButton + + #region StandardButtonHeader + + public static readonly DependencyProperty StandardButtonHeaderProperty = DependencyProperty.Register("StandardButtonHeader", typeof(string), typeof(ColorPickerCombo), new UIPropertyMetadata("Standard")); + public string StandardButtonHeader + { + get + { + return (string)GetValue(StandardButtonHeaderProperty); + } + set + { + SetValue(StandardButtonHeaderProperty, value); + } + } + + #endregion //StandardButtonHeader + + #region StandardColors + + internal static readonly DependencyProperty StandardColorsProperty = DependencyProperty.Register("StandardColors", typeof(ObservableCollection), typeof(ColorPickerCombo), new UIPropertyMetadata(CreateStandardColors())); + internal ObservableCollection StandardColors + { + get + { + return (ObservableCollection)GetValue(StandardColorsProperty); + } + set + { + SetValue(StandardColorsProperty, value); + } + } + + #endregion //StandardColors + + #region StandardColorsHeader + + public static readonly DependencyProperty StandardColorsHeaderProperty = DependencyProperty.Register("StandardColorsHeader", typeof(string), typeof(ColorPickerCombo), new UIPropertyMetadata("Standard Colors")); + public string StandardColorsHeader + { + get + { + return (string)GetValue(StandardColorsHeaderProperty); + } + set + { + SetValue(StandardColorsHeaderProperty, value); + } + } + + #endregion //StandardColorsHeader + + #region UsingAlphaChannel + + public static readonly DependencyProperty UsingAlphaChannelProperty = DependencyProperty.Register("UsingAlphaChannel", typeof(bool), typeof(ColorPickerCombo), new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, new PropertyChangedCallback(OnUsingAlphaChannelPropertyChanged))); + public bool UsingAlphaChannel + { + get + { + return (bool)GetValue(UsingAlphaChannelProperty); + } + set + { + SetValue(UsingAlphaChannelProperty, value); + } + } + + private static void OnUsingAlphaChannelPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + ColorPickerCombo colorPicker = (ColorPickerCombo)d; + if (colorPicker != null) + colorPicker.OnUsingAlphaChannelChanged(); + } + + private void OnUsingAlphaChannelChanged() + { + SelectedColorText = GetFormatedColorString(SelectedColor); + } + + #endregion //UsingAlphaChannel + + #endregion //Properties + + #region Constructors + + static ColorPickerCombo() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(ColorPickerCombo), new FrameworkPropertyMetadata(typeof(ColorPickerCombo))); + } + + public ColorPickerCombo() + { +#if VS2008 + this.RecentColors = new ObservableCollection(); +#else + this.SetCurrentValue(ColorPickerCombo.RecentColorsProperty, new ObservableCollection()); +#endif + + Keyboard.AddKeyDownHandler(this, OnKeyDown); + Mouse.AddPreviewMouseDownOutsideCapturedElementHandler(this, OnMouseDownOutsideCapturedElement); + } + + #endregion //Constructors + + #region Base Class Overrides + + public override void OnApplyTemplate() + { + base.OnApplyTemplate(); + + if (_availableColors != null) + _availableColors.SelectionChanged -= Color_SelectionChanged; + + _availableColors = GetTemplateChild(PART_AvailableColors) as ListBox; + if (_availableColors != null) + _availableColors.SelectionChanged += Color_SelectionChanged; + + if (_standardColors != null) + _standardColors.SelectionChanged -= Color_SelectionChanged; + + _standardColors = GetTemplateChild(PART_StandardColors) as ListBox; + if (_standardColors != null) + _standardColors.SelectionChanged += Color_SelectionChanged; + + if (_recentColors != null) + _recentColors.SelectionChanged -= Color_SelectionChanged; + + _recentColors = GetTemplateChild(PART_RecentColors) as ListBox; + if (_recentColors != null) + _recentColors.SelectionChanged += Color_SelectionChanged; + + if (_popup != null) + _popup.Opened -= Popup_Opened; + + _popup = GetTemplateChild(PART_ColorPickerPalettePopup) as Popup; + if (_popup != null) + _popup.Opened += Popup_Opened; + + _toggleButton = this.Template.FindName(PART_ColorPickerToggleButton, this) as ToggleButton; + + if (_colorModeButton != null) + _colorModeButton.Click -= new RoutedEventHandler(this.ColorModeButton_Clicked); + + _colorModeButton = this.Template.FindName(PART_ColorModeButton, this) as Button; + + if (_colorModeButton != null) + _colorModeButton.Click += new RoutedEventHandler(this.ColorModeButton_Clicked); + } + + protected override void OnMouseUp(MouseButtonEventArgs e) + { + base.OnMouseUp(e); + + // Close ColorPicker on MouseUp to prevent action of mouseUp on controls behind the ColorPicker. + if (_selectionChanged) + { + CloseColorPicker(true); + _selectionChanged = false; + } + } + + #endregion //Base Class Overrides + + #region Event Handlers + + private void OnKeyDown(object sender, KeyEventArgs e) + { + if (!IsOpen) + { + if (KeyboardUtilities.IsKeyModifyingPopupState(e)) + { + IsOpen = true; + // Focus will be on ListBoxItem in Popup_Opened(). + e.Handled = true; + } + } + else + { + if (KeyboardUtilities.IsKeyModifyingPopupState(e)) + { + CloseColorPicker(true); + e.Handled = true; + } + else if (e.Key == Key.Escape) + { + this.SelectedColor = _initialColor; + CloseColorPicker(true); + e.Handled = true; + } + } + } + + private void OnMouseDownOutsideCapturedElement(object sender, MouseButtonEventArgs e) + { + CloseColorPicker(true); + } + + private void Color_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + ListBox lb = (ListBox)sender; + + if (e.AddedItems.Count > 0) + { + var colorItem = (ColorItem)e.AddedItems[0]; + SelectedColor = colorItem.Color; + UpdateRecentColors(colorItem); + _selectionChanged = true; + lb.SelectedIndex = -1; //for now I don't care about keeping track of the selected color + } + } + + private void Popup_Opened(object sender, EventArgs e) + { + if ((_availableColors != null) && ShowAvailableColors) + FocusOnListBoxItem(_availableColors); + else if ((_standardColors != null) && ShowStandardColors) + FocusOnListBoxItem(_standardColors); + else if ((_recentColors != null) && ShowRecentColors) + FocusOnListBoxItem(_recentColors); + } + + private void FocusOnListBoxItem(ListBox listBox) + { + ListBoxItem listBoxItem = (ListBoxItem)listBox.ItemContainerGenerator.ContainerFromItem(listBox.SelectedItem); + if ((listBoxItem == null) && (listBox.Items.Count > 0)) + listBoxItem = (ListBoxItem)listBox.ItemContainerGenerator.ContainerFromItem(listBox.Items[0]); + if (listBoxItem != null) + listBoxItem.Focus(); + } + + private void ColorModeButton_Clicked(object sender, RoutedEventArgs e) + { + this.ColorMode = (this.ColorMode == ColorMode.ColorPalette) ? ColorMode.ColorCanvas : ColorMode.ColorPalette; + } + + #endregion //Event Handlers + + #region Events + + #region SelectedColorChangedEvent + + public static readonly RoutedEvent SelectedColorChangedEvent = EventManager.RegisterRoutedEvent("SelectedColorChanged", RoutingStrategy.Bubble, typeof(RoutedPropertyChangedEventHandler), typeof(ColorPickerCombo)); + public event RoutedPropertyChangedEventHandler SelectedColorChanged + { + add + { + AddHandler(SelectedColorChangedEvent, value); + } + remove + { + RemoveHandler(SelectedColorChangedEvent, value); + } + } + + #endregion + + #region OpenedEvent + + public static readonly RoutedEvent OpenedEvent = EventManager.RegisterRoutedEvent("OpenedEvent", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(ColorPickerCombo)); + public event RoutedEventHandler Opened + { + add + { + AddHandler(OpenedEvent, value); + } + remove + { + RemoveHandler(OpenedEvent, value); + } + } + + #endregion //OpenedEvent + + #region ClosedEvent + + public static readonly RoutedEvent ClosedEvent = EventManager.RegisterRoutedEvent("ClosedEvent", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(ColorPickerCombo)); + public event RoutedEventHandler Closed + { + add + { + AddHandler(ClosedEvent, value); + } + remove + { + RemoveHandler(ClosedEvent, value); + } + } + + #endregion //ClosedEvent + + #endregion //Events + + #region Methods + + private void CloseColorPicker(bool isFocusOnColorPicker) + { + if (IsOpen) + IsOpen = false; + ReleaseMouseCapture(); + + if (isFocusOnColorPicker && (_toggleButton != null)) + _toggleButton.Focus(); + this.UpdateRecentColors(new ColorItem(SelectedColor, SelectedColorText)); + } + + private void UpdateRecentColors(ColorItem colorItem) + { + if (!RecentColors.Contains(colorItem)) + RecentColors.Add(colorItem); + + if (RecentColors.Count > 10) //don't allow more than ten, maybe make a property that can be set by the user. + RecentColors.RemoveAt(0); + } + + private string GetFormatedColorString(Color? colorToFormat) + { + if ((colorToFormat == null) || !colorToFormat.HasValue) + return string.Empty; + + return ColorUtilities.FormatColorString(colorToFormat.Value.GetColorName(), UsingAlphaChannel); + } + + private static ObservableCollection CreateStandardColors() + { + ObservableCollection _standardColors = new ObservableCollection(); + _standardColors.Add(new ColorItem(Colors.Transparent, "Transparent")); + _standardColors.Add(new ColorItem(Colors.White, "White")); + _standardColors.Add(new ColorItem(Colors.Gray, "Gray")); + _standardColors.Add(new ColorItem(Colors.Black, "Black")); + _standardColors.Add(new ColorItem(Colors.Red, "Red")); + _standardColors.Add(new ColorItem(Colors.Green, "Green")); + _standardColors.Add(new ColorItem(Colors.Blue, "Blue")); + _standardColors.Add(new ColorItem(Colors.Yellow, "Yellow")); + _standardColors.Add(new ColorItem(Colors.Orange, "Orange")); + _standardColors.Add(new ColorItem(Colors.Purple, "Purple")); + return _standardColors; + } + + private static ObservableCollection CreateAvailableColors() + { + ObservableCollection _standardColors = new ObservableCollection(); + + foreach (var item in ColorUtilities.KnownColors) + { + if (!String.Equals(item.Key, "Transparent")) + { + var colorItem = new ColorItem(item.Value, item.Key); + if (!_standardColors.Contains(colorItem)) + _standardColors.Add(colorItem); + } + } + + return _standardColors; + } + + #endregion //Methods + } +} diff --git a/Software/Visual_Studio/Tango.ColorPicker/ColorPicker/Implementation/ColorSorter.cs b/Software/Visual_Studio/Tango.ColorPicker/ColorPicker/Implementation/ColorSorter.cs new file mode 100644 index 000000000..fa33faa55 --- /dev/null +++ b/Software/Visual_Studio/Tango.ColorPicker/ColorPicker/Implementation/ColorSorter.cs @@ -0,0 +1,77 @@ +/************************************************************************************* + + Extended WPF Toolkit + + Copyright (C) 2007-2013 Xceed Software Inc. + + This program is provided to you under the terms of the Microsoft Public + License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license + + For more features, controls, and fast professional support, + pick up the Plus Edition at http://xceed.com/wpf_toolkit + + Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids + + ***********************************************************************************/ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Media; + +namespace Tango.ColorPicker +{ + internal class ColorSorter : IComparer + { + public int Compare( object firstItem, object secondItem ) + { + if( firstItem == null || secondItem == null ) + return -1; + + ColorItem colorItem1 = ( ColorItem )firstItem; + ColorItem colorItem2 = ( ColorItem )secondItem; + + if( (colorItem1.Color == null) || !colorItem1.Color.HasValue || + (colorItem2.Color == null) || !colorItem2.Color.HasValue ) + return -1; + + System.Drawing.Color drawingColor1 = System.Drawing.Color.FromArgb( colorItem1.Color.Value.A, colorItem1.Color.Value.R, colorItem1.Color.Value.G, colorItem1.Color.Value.B ); + System.Drawing.Color drawingColor2 = System.Drawing.Color.FromArgb( colorItem2.Color.Value.A, colorItem2.Color.Value.R, colorItem2.Color.Value.G, colorItem2.Color.Value.B ); + + // Compare Hue + double hueColor1 = Math.Round( ( double )drawingColor1.GetHue(), 3 ); + double hueColor2 = Math.Round( ( double )drawingColor2.GetHue(), 3 ); + + if( hueColor1 > hueColor2 ) + return 1; + else if( hueColor1 < hueColor2 ) + return -1; + else + { + // Hue is equal, compare Saturation + double satColor1 = Math.Round( ( double )drawingColor1.GetSaturation(), 3 ); + double satColor2 = Math.Round( ( double )drawingColor2.GetSaturation(), 3 ); + + if( satColor1 > satColor2 ) + return 1; + else if( satColor1 < satColor2 ) + return -1; + else + { + // Saturation is equal, compare Brightness + double brightColor1 = Math.Round( ( double )drawingColor1.GetBrightness(), 3 ); + double brightColor2 = Math.Round( ( double )drawingColor2.GetBrightness(), 3 ); + + if( brightColor1 > brightColor2 ) + return 1; + else if( brightColor1 < brightColor2 ) + return -1; + } + } + + return 0; + } + } +} diff --git a/Software/Visual_Studio/Tango.ColorPicker/ColorPicker/Themes/Generic.xaml b/Software/Visual_Studio/Tango.ColorPicker/ColorPicker/Themes/Generic.xaml new file mode 100644 index 000000000..996da3308 --- /dev/null +++ b/Software/Visual_Studio/Tango.ColorPicker/ColorPicker/Themes/Generic.xaml @@ -0,0 +1,356 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +