From 8a59643571080bfff715f0b0e4bb03e2dee4961a Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 12 Jun 2018 15:47:10 +0300 Subject: Starting splitting PPC to modules. --- .../PPC/Modules/Tango.PPC.Synchronization/App.xaml | 11 ++ .../Images/ppc-module.png | Bin 0 -> 1748 bytes .../Modules/Tango.PPC.Synchronization/MyModule.cs | 83 +++++++++++ .../Properties/AssemblyInfo.cs | 19 +++ .../Properties/Resources.Designer.cs | 71 ++++++++++ .../Properties/Resources.resx | 117 ++++++++++++++++ .../Properties/Settings.Designer.cs | 30 ++++ .../Properties/Settings.settings | 7 + .../Tango.PPC.Synchronization.csproj | 156 +++++++++++++++++++++ .../Tango.PPC.Synchronization/ViewModelLocator.cs | 32 +++++ .../ViewModels/MainViewVM.cs | 24 ++++ .../Tango.PPC.Synchronization/Views/MainView.xaml | 14 ++ .../Views/MainView.xaml.cs | 28 ++++ .../Modules/Tango.PPC.Synchronization/app.config | 61 ++++++++ .../Tango.PPC.Synchronization/packages.config | 7 + 15 files changed, 660 insertions(+) create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/App.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/Images/ppc-module.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/MyModule.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/Properties/AssemblyInfo.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/Properties/Resources.Designer.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/Properties/Resources.resx create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/Properties/Settings.Designer.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/Properties/Settings.settings create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/Tango.PPC.Synchronization.csproj create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/ViewModelLocator.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/ViewModels/MainViewVM.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/Views/MainView.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/Views/MainView.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/app.config create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/packages.config (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization') diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/App.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/App.xaml new file mode 100644 index 000000000..aa78e02a4 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/App.xaml @@ -0,0 +1,11 @@ + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/Images/ppc-module.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/Images/ppc-module.png new file mode 100644 index 000000000..6f27f49be Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/Images/ppc-module.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/MyModule.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/MyModule.cs new file mode 100644 index 000000000..e53b902e0 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/MyModule.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media.Imaging; +using Tango.BL.Enumerations; +using Tango.PPC.Common; +using Tango.PPC.Synchronization.Views; +using Tango.SharedUI.Helpers; + +namespace Tango.PPC.Synchronization +{ + /// + /// Represents a PPC . + /// + /// + public class MyModule : PPCModuleBase + { + /// + /// Gets the module name. + /// + public override string Name + { + get + { + return "My Module"; + } + } + + /// + /// Gets the module description. + /// + public override string Description + { + get + { + return "Some Module Description"; + } + } + + /// + /// Gets the module cover image. + /// + public override BitmapSource Image + { + get + { + return ResourceHelper.GetImageFromResources("Images/ppc-module.png"); + } + } + + /// + /// Gets the module entry point view type. + /// + public override Type MainViewType + { + get + { + return typeof(MainView); + } + } + + /// + /// Gets the permission required to see and load this module. + /// + public override Permissions Permission + { + get + { + return Permissions.RunMachineStudio; + } + } + + /// + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + /// + public override void Dispose() + { + //Dispose module here... + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/Properties/AssemblyInfo.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..a9ea5b8b0 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/Properties/AssemblyInfo.cs @@ -0,0 +1,19 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Tango Module")] + +[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/PPC/Modules/Tango.PPC.Synchronization/Properties/Resources.Designer.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/Properties/Resources.Designer.cs new file mode 100644 index 000000000..61ce72f65 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// 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.PPC.Synchronization.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.PPC.Synchronization.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/PPC/Modules/Tango.PPC.Synchronization/Properties/Resources.resx b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/Properties/Resources.resx new file mode 100644 index 000000000..af7dbebba --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/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/PPC/Modules/Tango.PPC.Synchronization/Properties/Settings.Designer.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/Properties/Settings.Designer.cs new file mode 100644 index 000000000..6b0a60b94 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/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.PPC.Synchronization.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/PPC/Modules/Tango.PPC.Synchronization/Properties/Settings.settings b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/Properties/Settings.settings new file mode 100644 index 000000000..033d7a5e9 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/Tango.PPC.Synchronization.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/Tango.PPC.Synchronization.csproj new file mode 100644 index 000000000..3aeafb1e0 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/Tango.PPC.Synchronization.csproj @@ -0,0 +1,156 @@ + + + + + Debug + AnyCPU + {729455D4-C384-4497-AF5D-0A598F86DAC6} + library + Tango.PPC.Synchronization + Tango.PPC.Synchronization + v4.6 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + + + true + full + false + ..\..\..\Build\Debug\PPC\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + ..\..\..\Build\Release\PPC\ + TRACE + prompt + 4 + + + + ..\..\..\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.dll + True + + + ..\..\..\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.SqlServer.dll + + + ..\..\..\packages\FontAwesome.WPF.4.7.0.9\lib\net40\FontAwesome.WPF.dll + + + ..\..\..\packages\Google.Protobuf.3.4.1\lib\net45\Google.Protobuf.dll + + + + + + ..\..\..\packages\Expression.Blend.Sdk.1.0.2\lib\net45\System.Windows.Interactivity.dll + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + + + PPCVersionInfo.cs + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + MainView.xaml + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + {f441feee-322a-4943-b566-110e12fd3b72} + Tango.BL + + + {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} + Tango.Core + + + {b112d89a-a106-41ae-a0c1-4abc84c477f5} + Tango.DragAndDrop + + + {bc932dbd-7cdb-488c-99e4-f02cf441f55e} + Tango.Logging + + + {e4927038-348d-4295-aaf4-861c58cb3943} + Tango.PMR + + + {d8f1ad85-526a-4f50-b6dc-d437af63d8d8} + Tango.Settings + + + {8491d07b-c1f6-4b62-a412-41b9fd2d6538} + Tango.SharedUI + + + {fd86424c-6e84-491b-8df9-3d0f5c236a2a} + Tango.Touch + + + {74e700b0-1156-4126-be40-ee450d3c3026} + Tango.Transport + + + {0be74eee-22cb-4dba-b896-793b9e1a3ac0} + Tango.PPC.Common + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/ViewModelLocator.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/ViewModelLocator.cs new file mode 100644 index 000000000..155a37a2d --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/ViewModelLocator.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.DI; +using Tango.PPC.Synchronization.ViewModels; + +namespace Tango.PPC.Synchronization +{ + public static class ViewModelLocator + { + /// + /// Initializes a new instance of the ViewModelLocator class. + /// + static ViewModelLocator() + { + TangoIOC.Default.Register(); + } + + /// + /// Gets the main view VM. + /// + public static MainViewVM MainViewVM + { + get + { + return TangoIOC.Default.GetInstance(); + } + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/ViewModels/MainViewVM.cs new file mode 100644 index 000000000..d57b2b615 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/ViewModels/MainViewVM.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.PPC.Common; + +namespace Tango.PPC.Synchronization.ViewModels +{ + /// + /// Represents the main view VM and entry point for . + /// + /// + public class MainViewVM : PPCViewModel + { + /// + /// Called when the application has been started + /// + public override void OnApplicationStarted() + { + //Start initializing here rather then in the constructor. + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/Views/MainView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/Views/MainView.xaml new file mode 100644 index 000000000..2bba2019d --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/Views/MainView.xaml @@ -0,0 +1,14 @@ + + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/Views/MainView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/Views/MainView.xaml.cs new file mode 100644 index 000000000..f2cbbf503 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/Views/MainView.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.PPC.Synchronization.Views +{ + /// + /// Interaction logic for MainView.xaml + /// + public partial class MainView : UserControl + { + public MainView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/app.config b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/app.config new file mode 100644 index 000000000..77b7003e2 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/app.config @@ -0,0 +1,61 @@ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/packages.config b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/packages.config new file mode 100644 index 000000000..80367fdd2 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/packages.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file -- cgit v1.3.1 From ca50e0c8fc88acd06d6e1932e9412464bff95edb Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 12 Jun 2018 19:04:09 +0300 Subject: Working on PPC modules and loading. --- Software/DB/Tango-old.db | Bin 602112 -> 0 bytes Software/DB/Tango.db | Bin 430080 -> 12124160 bytes Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 1572864 -> 1572864 bytes .../PPC/Modules/Tango.PPC.Jobs/JobsModule.cs | 1 + .../PPC/Modules/Tango.PPC.Jobs/ViewModelLocator.cs | 12 ++ .../PPC/Modules/Tango.PPC.Jobs/Views/JobsView.xaml | 4 +- .../Modules/Tango.PPC.Synchronization/MyModule.cs | 1 + .../Application/IPPCApplicationManager.cs | 10 ++ .../DefaultAuthenticationProvider.cs | 24 +++- .../Authentication/IAuthenticationProvider.cs | 2 +- .../PPC/Tango.PPC.Common/IPPCModule.cs | 15 +- .../Visual_Studio/PPC/Tango.PPC.Common/IPPCView.cs | 13 ++ .../Tango.PPC.Common/Modules/IPPCModuleLoader.cs | 42 ++++++ .../Navigation/INavigationManager.cs | 6 + .../PPC/Tango.PPC.Common/PPCModuleBase.cs | 49 ++----- .../PPC/Tango.PPC.Common/PPCViewModel.cs | 25 ++++ .../PPC/Tango.PPC.Common/Tango.PPC.Common.csproj | 2 + .../Modules/DefaultStudioModuleLoader.cs | 146 +++++++++++++++++++ .../Navigation/DefaultNavigationManager.cs | 8 ++ .../PPCApplication/DefaultPPCApplicationManager.cs | 43 +++++- .../PPC/Tango.PPC.UI/Tango.PPC.UI.csproj | 17 +-- .../PPC/Tango.PPC.UI/ViewModelLocator.cs | 23 +-- .../PPC/Tango.PPC.UI/ViewModels/JobsViewVM.cs | 130 ----------------- .../PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs | 23 ++- .../PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs | 15 +- .../PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs | 2 + .../PPC/Tango.PPC.UI/Views/JobsView.xaml | 155 --------------------- .../PPC/Tango.PPC.UI/Views/JobsView.xaml.cs | 66 --------- .../PPC/Tango.PPC.UI/Views/LayoutView.xaml | 2 +- .../PPC/Tango.PPC.UI/Views/LayoutView.xaml.cs | 28 +++- .../PPC/Tango.PPC.UI/ViewsContracts/ILayoutView.cs | 14 ++ 32 files changed, 443 insertions(+), 435 deletions(-) delete mode 100644 Software/DB/Tango-old.db create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/IPPCView.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Modules/IPPCModuleLoader.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Modules/DefaultStudioModuleLoader.cs delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/JobsViewVM.cs delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Views/JobsView.xaml delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Views/JobsView.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/ViewsContracts/ILayoutView.cs (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization') diff --git a/Software/DB/Tango-old.db b/Software/DB/Tango-old.db deleted file mode 100644 index 0693a2623..000000000 Binary files a/Software/DB/Tango-old.db and /dev/null differ diff --git a/Software/DB/Tango.db b/Software/DB/Tango.db index 336f96dcf..59973a131 100644 Binary files a/Software/DB/Tango.db and b/Software/DB/Tango.db differ diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 446be806b..435076d96 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index a7ce079a0..c4bde6923 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/JobsModule.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/JobsModule.cs index de4b89c22..7414a5b7a 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/JobsModule.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/JobsModule.cs @@ -11,6 +11,7 @@ using Tango.SharedUI.Helpers; namespace Tango.PPC.Jobs { + [PPCModule(1)] public class JobsModule : PPCModuleBase { public override string Name diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModelLocator.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModelLocator.cs index 479490486..e9f636b80 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModelLocator.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModelLocator.cs @@ -16,6 +16,7 @@ namespace Tango.PPC.Jobs static ViewModelLocator() { TangoIOC.Default.Register(); + TangoIOC.Default.Register(); } /// @@ -28,5 +29,16 @@ namespace Tango.PPC.Jobs return TangoIOC.Default.GetInstance(); } } + + /// + /// Gets the main view VM. + /// + public static JobsViewVM JobsViewVM + { + get + { + return TangoIOC.Default.GetInstance(); + } + } } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobsView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobsView.xaml index 8da6012bf..4f9b2db1d 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobsView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobsView.xaml @@ -13,8 +13,10 @@ xmlns:entities="clr-namespace:Tango.BL.Entities;assembly=Tango.BL" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:sharedConverters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" + xmlns:views="clr-namespace:Tango.PPC.Jobs.Views" + xmlns:global="clr-namespace:Tango.PPC.Jobs" mc:Ignorable="d" - d:DesignHeight="1280" d:DesignWidth="800"> + d:DesignHeight="1280" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:JobsViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.JobsViewVM}"> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/MyModule.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/MyModule.cs index e53b902e0..5de78a7f0 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/MyModule.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/MyModule.cs @@ -15,6 +15,7 @@ namespace Tango.PPC.Synchronization /// Represents a PPC . /// /// + [PPCModule(2)] public class MyModule : PPCModuleBase { /// diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Application/IPPCApplicationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Application/IPPCApplicationManager.cs index 2a9ca212d..62a8d4d05 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Application/IPPCApplicationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Application/IPPCApplicationManager.cs @@ -15,6 +15,16 @@ namespace Tango.PPC.Common.Application /// public interface IPPCApplicationManager { + /// + /// Occurs when the application has started. + /// + event EventHandler ApplicationStarted; + + /// + /// Occurs when all PPC modules are ready and initialized. + /// + event EventHandler ModulesInitialized; + /// /// Gets or sets the DAL machine. /// diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Authentication/DefaultAuthenticationProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Authentication/DefaultAuthenticationProvider.cs index c8e89ac2f..f49beb32d 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Authentication/DefaultAuthenticationProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Authentication/DefaultAuthenticationProvider.cs @@ -3,30 +3,42 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.BL; using Tango.BL.Entities; +using Tango.Core; namespace Tango.PPC.Common.Authentication { - public class DefaultAuthenticationProvider : IAuthenticationProvider + public class DefaultAuthenticationProvider : ExtendedObject, IAuthenticationProvider { + private User _currentUser; + public User CurrentUser { - get + get { return _currentUser; } + private set { - throw new NotImplementedException(); + _currentUser = value; + RaisePropertyChangedAuto(); } } public event EventHandler CurrentUserChanged; - public User Login(string email, string password) + public Task Login(string email, string password) { - throw new NotImplementedException(); + return Task.Factory.StartNew(() => + { + CurrentUser = ObservablesEntitiesAdapter.Instance.Users.SingleOrDefault(x => x.Email.ToLower() == email && x.Password == password); + CurrentUserChanged?.Invoke(this, CurrentUser); + return CurrentUser; + }); } public void Logout() { - throw new NotImplementedException(); + CurrentUser = null; + CurrentUserChanged?.Invoke(this, CurrentUser); } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Authentication/IAuthenticationProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Authentication/IAuthenticationProvider.cs index 0892932a8..0fca03d49 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Authentication/IAuthenticationProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Authentication/IAuthenticationProvider.cs @@ -28,7 +28,7 @@ namespace Tango.PPC.Common.Authentication /// The email. /// The password. /// - User Login(String email, String password); + Task Login(String email, String password); /// /// Logs-out the current logged-in user. diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/IPPCModule.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/IPPCModule.cs index 6c9bf3892..4226e7aad 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/IPPCModule.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/IPPCModule.cs @@ -16,6 +16,11 @@ namespace Tango.PPC.Common /// public interface IPPCModule : IDisposable { + /// + /// Occurs when the module has been initialized. + /// + event EventHandler Initialized; + /// /// Gets the module name. /// @@ -36,11 +41,6 @@ namespace Tango.PPC.Common /// Type MainViewType { get; } - /// - /// Gets or sets a value indicating whether this module is shown under a new window. - /// - bool InNewWindow { get; set; } - /// /// Gets the permission required to see and load this module. /// @@ -55,10 +55,5 @@ namespace Tango.PPC.Common /// Perform any operations required to initialize this module. /// void Initialize(); - - /// - /// Sets a value indicating whether this module is loaded. - /// - bool IsLoaded { set; get; } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/IPPCView.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/IPPCView.cs new file mode 100644 index 000000000..35018a922 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/IPPCView.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Common +{ + public interface IPPCView + { + + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Modules/IPPCModuleLoader.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Modules/IPPCModuleLoader.cs new file mode 100644 index 000000000..52527fb33 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Modules/IPPCModuleLoader.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Common.Modules +{ + /// + /// Represents a PPC modules loading engine. + /// + public interface IPPCModuleLoader + { + /// + /// Occurs when the user has logged in and user modules are loaded. + /// + event EventHandler ModulesLoaded; + + /// + /// Gets all loaded modules. + /// + ObservableCollection AllModules { get; } + + /// + /// Gets all the user permitted modules. + /// + ObservableCollection UserModules { get; } + + /// + /// Gets the PPC module of type T if loaded. + /// + /// + /// + T GetPPCModule() where T : IPPCModule; + + /// + /// Loads all available PPC modules. + /// + void LoadModules(); + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/INavigationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/INavigationManager.cs index f29476631..60ca12530 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/INavigationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/INavigationManager.cs @@ -16,5 +16,11 @@ namespace Tango.PPC.Common.Navigation /// /// The view. void NavigateTo(NavigationView view); + + /// + /// Navigates to the specified module. + /// + /// + void NavigateTo() where T : IPPCModule; } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCModuleBase.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCModuleBase.cs index 31c3218db..d4d00064c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCModuleBase.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCModuleBase.cs @@ -18,12 +18,11 @@ namespace Tango.PPC.Common public abstract class PPCModuleBase : ExtendedObject, IPPCModule { private bool _isInitialized; - private bool _isLoaded; /// - /// Occurs when the user has navigated into or out of this module. + /// Occurs when the module has been initialized. /// - public event EventHandler IsLoadedChanged; + public event EventHandler Initialized; /// /// Gets the module name. @@ -65,32 +64,6 @@ namespace Tango.PPC.Common } } - /// - /// Sets a value indicating whether this module is loaded. - /// - public bool IsLoaded - { - get - { - return _isLoaded; - } - set - { - _isLoaded = value; - IsLoadedChanged?.Invoke(this, value); - } - } - - private bool _inNewWindow; - /// - /// Gets or sets a value indicating whether this module is shown under a new window. - /// - public bool InNewWindow - { - get { return _inNewWindow; } - set { _inNewWindow = value; RaisePropertyChangedAuto(); } - } - /// /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// @@ -101,8 +74,11 @@ namespace Tango.PPC.Common /// public void Initialize() { - OnInitialized(); - IsInitialized = true; + if (!IsInitialized) + { + OnInitialized(); + IsInitialized = true; + } } /// @@ -110,16 +86,7 @@ namespace Tango.PPC.Common /// protected virtual void OnInitialized() { - - } - - /// - /// Raises the event. - /// - /// if set to true the module is loaded. - protected virtual void OnLoadedChanged(bool loaded) - { - + Initialized?.Invoke(this, new EventArgs()); } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs index d9d7097e0..ffe5c9a4f 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.BL; using Tango.Core.DI; using Tango.PPC.Common.Application; using Tango.PPC.Common.Authentication; @@ -15,6 +16,11 @@ namespace Tango.PPC.Common { public abstract class PPCViewModel : ViewModel { + public ObservablesEntitiesAdapter Adapter + { + get { return ObservablesEntitiesAdapter.Instance; } + } + [TangoInject] public IPPCApplicationManager ApplicationManager { get; set; } @@ -54,4 +60,23 @@ namespace Tango.PPC.Common } } + + public abstract class PPCViewModel : PPCViewModel where T : IPPCView + { + public T View { get; private set; } + + public bool ViewAttached { get; private set; } + + public override void OnApplicationStarted() + { + TangoIOC.Default.GetInstanceWhenAvailable((view) => + { + ViewAttached = true; + View = view; + OnViewAttached(); + }); + } + + public abstract void OnViewAttached(); + } } \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj index 6fad5887f..348f7ed26 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj @@ -92,6 +92,8 @@ PPCVersionInfo.cs + + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Modules/DefaultStudioModuleLoader.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Modules/DefaultStudioModuleLoader.cs new file mode 100644 index 000000000..bb68f05cd --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Modules/DefaultStudioModuleLoader.cs @@ -0,0 +1,146 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; +using Tango.BL.Entities; +using Tango.Logging; +using Tango.PPC.Common.Authentication; +using Tango.PPC.Common.Modules; +using Tango.PPC.Common; +using Tango.PPC.Jobs; + +namespace Tango.PPC.UI.Modules +{ + /// + /// Represents the default PPC . + /// + /// + /// + public class DefaultPPCModuleLoader : ExtendedObject, IPPCModuleLoader + { + private IAuthenticationProvider _authenticationProvider; + private bool _loaded; + + /// + /// Occurs when the user has logged in and user modules are loaded. + /// + public event EventHandler ModulesLoaded; + + /// + /// Initializes a new instance of the class. + /// + /// The authentication provider. + public DefaultPPCModuleLoader(IAuthenticationProvider authenticationProvider) + { + _authenticationProvider = authenticationProvider; + AllModules = new ObservableCollection(); + UserModules = new ObservableCollection(); + _authenticationProvider.CurrentUserChanged += _authenticationProvider_CurrentUserChanged; + } + + /// + /// Handles the authentication provider user changed event. + /// + /// The sender. + /// The e. + private void _authenticationProvider_CurrentUserChanged(object sender, User e) + { + LoadModules(); + } + + private ObservableCollection _allModules; + /// + /// Gets all loaded modules. + /// + public ObservableCollection AllModules + { + get { return _allModules; } + private set { _allModules = value; RaisePropertyChangedAuto(); } + } + + private ObservableCollection _userModules; + /// + /// Gets all the user permitted modules. + /// + public ObservableCollection UserModules + { + get { return _userModules; } + private set { _userModules = value; RaisePropertyChangedAuto(); } + } + + /// + /// Loads all available PPC modules. + /// + public void LoadModules() + { + if (!_loaded) + { + //Preloaded + LogManager.Log(String.Format("Loading module '{0}'...", nameof(JobsModule))); + AllModules.Add(new JobsModule()); + //Preloaded + + AllModules.Clear(); + string assemblyFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + + foreach (var file in Directory.GetFiles(assemblyFolder, "*.dll").Where(x => x.Contains("Tango.PPC"))) + { + try + { + Assembly moduleAssembly = null; + moduleAssembly = Assembly.LoadFrom(file); + + if (moduleAssembly != null) + { + foreach (var moduleType in moduleAssembly.GetTypes().Where(x => !x.IsInterface && typeof(IPPCModule).IsAssignableFrom(x) && !x.IsAbstract)) + { + if (!AllModules.ToList().Exists(x => x.GetType() == moduleType)) + { + try + { + LogManager.Log(String.Format("Loading module '{0}'...", moduleType.Name)); + var module = Activator.CreateInstance(moduleType) as IPPCModule; + AllModules.Add(module); + } + catch (Exception ex) + { + LogManager.Log(ex, "Could not load module " + moduleType.Name); + } + } + } + } + } + catch { } + } + + _loaded = true; + } + + AllModules = AllModules.OrderBy(x => x.GetType().GetCustomAttribute().Index).ToObservableCollection(); + + UserModules.Clear(); + + if (_authenticationProvider.CurrentUser != null) + { + UserModules = AllModules.Where(x => _authenticationProvider.CurrentUser.HasPermission(x.Permission)).ToObservableCollection(); + } + + ModulesLoaded?.Invoke(this, new EventArgs()); + } + + /// + /// Gets the PPC module of type T if loaded. + /// + /// + /// + public T GetPPCModule() where T : IPPCModule + { + return UserModules.OfType().FirstOrDefault(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs index 83cf92f11..12c759c1a 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.PPC.Common; using Tango.PPC.Common.Navigation; using Tango.PPC.UI.Views; using Tango.SharedUI.Controls; @@ -22,5 +23,12 @@ namespace Tango.PPC.UI.Navigation var control = controls.Where(x => x.Elements.ToList().Exists(y => NavigationControl.GetNavigationName(y) == view.ToString())).SingleOrDefault(); control.NavigateTo(view.ToString()); } + + public void NavigateTo() where T : IPPCModule + { + var navigationControl = LayoutView.Instance.NavigationControl; + + + } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs index 6c2afb403..8b772b8bc 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs @@ -14,11 +14,14 @@ using System.Windows; using Tango.Core; using System.IO; using Tango.Core.Helpers; +using Tango.PPC.Common.Modules; namespace Tango.PPC.UI.PPCApplication { public class DefaultPPCApplicationManager : ExtendedObject, IPPCApplicationManager { + private List _notifiedViewModels; + public bool IsShuttingDown { get; private set; } public IMachineOperator ConnectedMachine @@ -61,6 +64,8 @@ namespace Tango.PPC.UI.PPCApplication { if (!DesignMode) { + _notifiedViewModels = new List(); + MainWindow.Instance.ContentRendered += async (_, __) => { await Task.Factory.StartNew(() => @@ -87,13 +92,41 @@ namespace Tango.PPC.UI.PPCApplication { Machine = db.Machines.SingleOrDefault(x => x.SerialNumber == settings.MachineSerialNumber); } - }); + ApplicationStarted?.Invoke(this, new EventArgs()); + foreach (var vm in TangoIOC.Default.GetAllInstancesByBase()) { - vm.OnApplicationStarted(); + if (!_notifiedViewModels.Contains(vm)) + { + vm.OnApplicationStarted(); + _notifiedViewModels.Add(vm); + } } + + TangoIOC.Default.GetInstanceWhenAvailable((loader) => + { + loader.ModulesLoaded += (x, y) => + { + if (loader.UserModules.Count > 0) + { + loader.UserModules.LastOrDefault().Initialized += (e, f) => + { + foreach (var vm in TangoIOC.Default.GetAllInstancesByBase()) + { + if (!_notifiedViewModels.Contains(vm)) + { + vm.OnApplicationStarted(); + _notifiedViewModels.Add(vm); + } + } + + ModulesInitialized?.Invoke(this, new EventArgs()); + }; + } + }; + }); }; } } @@ -107,5 +140,11 @@ namespace Tango.PPC.UI.PPCApplication vm.OnApplicationShuttingDown(); } } + + /// + /// Occurs when the application has started. + /// + public event EventHandler ApplicationStarted; + public event EventHandler ModulesInitialized; } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj index 12b53248e..8d7a35301 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj @@ -92,6 +92,7 @@ PPCVersionInfo.cs + @@ -99,13 +100,10 @@ - - - JobsView.xaml - + LayoutView.xaml @@ -143,10 +141,6 @@ Designer MSBuild:Compile - - Designer - MSBuild:Compile - Designer MSBuild:Compile @@ -178,6 +172,10 @@ ResXFileCodeGenerator Resources.Designer.cs + + DB\Tango.db + PreserveNewest + SettingsSingleFileGenerator @@ -263,6 +261,9 @@ + + + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs index 3a37fe452..b3f2268e4 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs @@ -1,4 +1,5 @@ using System; +using System.Windows; using Tango.Core.DI; using Tango.Integration.Services; using Tango.Logging; @@ -6,12 +7,16 @@ using Tango.PPC.Common.Application; using Tango.PPC.Common.Authentication; using Tango.PPC.Common.Diagnostics; using Tango.PPC.Common.EventLogging; +using Tango.PPC.Common.Modules; using Tango.PPC.Common.Navigation; using Tango.PPC.Common.Notifications; +using Tango.PPC.UI.Modules; using Tango.PPC.UI.Navigation; using Tango.PPC.UI.Notifications; using Tango.PPC.UI.PPCApplication; using Tango.PPC.UI.ViewModels; +using Tango.PPC.UI.Views; +using Tango.PPC.UI.ViewsContracts; using Tango.TFS; namespace Tango.PPC.UI @@ -29,6 +34,7 @@ namespace Tango.PPC.UI { TangoIOC.Default.Unregister(); TangoIOC.Default.Unregister(); + TangoIOC.Default.Unregister(); TangoIOC.Default.Unregister(); TangoIOC.Default.Unregister(); TangoIOC.Default.Unregister(); @@ -38,6 +44,7 @@ namespace Tango.PPC.UI TangoIOC.Default.Register(); TangoIOC.Default.Register(); + TangoIOC.Default.Register(); TangoIOC.Default.Register(); TangoIOC.Default.Register(); TangoIOC.Default.Register(); @@ -48,7 +55,13 @@ namespace Tango.PPC.UI TangoIOC.Default.Register(); TangoIOC.Default.Register(); TangoIOC.Default.Register(); - TangoIOC.Default.Register(); + + + TangoIOC.Default.GetInstance().ApplicationStarted += (_, __) => + { + TangoIOC.Default.Register(LayoutView.Instance); + }; + //TangoIOC.Default.Register(); //TangoIOC.Default.Register(); //TangoIOC.Default.Register(); @@ -81,13 +94,5 @@ namespace Tango.PPC.UI return TangoIOC.Default.GetInstance(); } } - - public static JobsViewVM JobsViewVM - { - get - { - return TangoIOC.Default.GetInstance(); - } - } } } \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/JobsViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/JobsViewVM.cs deleted file mode 100644 index 75ef7a2ac..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/JobsViewVM.cs +++ /dev/null @@ -1,130 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.ComponentModel; -using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using System.Windows.Data; -using Tango.BL; -using Tango.BL.Entities; -using Tango.Core.Commands; -using Tango.DragAndDrop; -using Tango.PPC.Common; -using Tango.PPC.Common.Application; -using Tango.PPC.Common.Authentication; -using Tango.PPC.Common.Navigation; -using Tango.PPC.Common.Notifications; -using Tango.Settings; -using Tango.SharedUI; - -namespace Tango.PPC.UI.ViewModels -{ - public class JobsViewVM : PPCViewModel - { - private ObservablesContext _jobsContext; - - private ObservableCollection _jobs; - public ObservableCollection Jobs - { - get { return _jobs; } - set { _jobs = value; RaisePropertyChangedAuto(); } - } - - private ICollectionView _jobsCollectionView; - /// - /// Gets or sets the jobs collection view. - /// - public ICollectionView JobsCollectionView - { - get { return _jobsCollectionView; } - set - { - _jobsCollectionView = value; - RaisePropertyChangedAuto(); - } - } - - public RelayCommand JobSelectedCommand { get; set; } - - public RelayCommand OnDragAndDropCommand { get; set; } - - public RelayCommand RemoveJobCommand { get; set; } - - private void OnDragAndDropJobs(Job draggedJob, Job droppedJob) - { - Debug.WriteLine(draggedJob.Name + " Dragged on to " + droppedJob.Name); - - if (draggedJob.JobIndex > droppedJob.JobIndex) - { - draggedJob.JobIndex = droppedJob.JobIndex - 1; - } - else - { - draggedJob.JobIndex = droppedJob.JobIndex + 1; - } - - int index = 1; - - foreach (var job in Jobs.OrderBy(x => x.JobIndex)) - { - job.JobIndex = index++; - } - - JobsCollectionView.Refresh(); - } - - private async void JobSelected(Job job) - { - Debug.WriteLine(job.Name); - await NotificationProvider.ShowInfo("Job details not yet implemented..."); - } - - public JobsViewVM() - { - Jobs = new ObservableCollection(); - - JobSelectedCommand = new RelayCommand((x) => JobSelected(x as Job)); - OnDragAndDropCommand = new RelayCommand((e) => - { - Job draggedJob = e.Draggable.DataContext as Job; - Job droppedJob = e.Droppable.DataContext as Job; - - OnDragAndDropJobs(draggedJob, droppedJob); - }); - - RemoveJobCommand = new RelayCommand(RemoveJob); - } - - private void RemoveJob(Job job) - { - NotificationProvider.ShowQuestion("Are you sure you want to remove " + job.Name); - } - - public override void OnApplicationStarted() - { - LoadJobs(); - } - - private void LoadJobs() - { - Task.Factory.StartNew(() => - { - Thread.Sleep(500); - - if (_jobsContext != null) - { - _jobsContext.Dispose(); - } - - _jobsContext = ObservablesContext.CreateDefault(); - - Jobs = _jobsContext.Jobs.Where(x => x.Machine.SerialNumber == Settings.MachineSerialNumber).ToObservableCollection(); - JobsCollectionView = CollectionViewSource.GetDefaultView(Jobs); - JobsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Job.LastUpdated), ListSortDirection.Descending)); - }); - } - } -} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs index cc64f82f5..168df019a 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs @@ -3,12 +3,33 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.Core.DI; +using Tango.PPC.Common; +using Tango.PPC.Common.Modules; +using Tango.PPC.UI.ViewsContracts; using Tango.SharedUI; namespace Tango.PPC.UI.ViewModels { - public class LayoutViewVM : ViewModel + public class LayoutViewVM : PPCViewModel { + [TangoInject] + public IPPCModuleLoader ModuleLoader { get; set; } + public override void OnApplicationStarted() + { + base.OnApplicationStarted(); + ModuleLoader.ModulesLoaded += ModuleLoader_ModulesLoaded; + } + + private void ModuleLoader_ModulesLoaded(object sender, EventArgs e) + { + View.ApplyModules(ModuleLoader.UserModules); + } + + public override void OnViewAttached() + { + + } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs index a33dc25d7..20752ac71 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs @@ -4,6 +4,7 @@ using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.BL; using Tango.Core; using Tango.Core.Helpers; using Tango.PPC.Common; @@ -19,9 +20,17 @@ namespace Tango.PPC.UI.ViewModels { public async override void OnApplicationStarted() { - await Task.Delay(500); - NavigationManager.NavigateTo(NavigationView.LayoutView); - NavigationManager.NavigateTo(NavigationView.JobsView); + await Task.Factory.StartNew(() => + { + ObservablesEntitiesAdapter.Instance.Initialize(); + }); + + ApplicationManager.ModulesInitialized += (_, __) => + { + NavigationManager.NavigateTo(NavigationView.LayoutView); + }; + + await AuthenticationProvider.Login("roy@twine-s.com", "1234"); } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs index d1fc4c015..deea33a0d 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs @@ -3,9 +3,11 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.Core.DI; using Tango.PPC.Common; using Tango.PPC.Common.Application; using Tango.PPC.Common.Authentication; +using Tango.PPC.Common.Modules; using Tango.PPC.Common.Navigation; using Tango.PPC.Common.Notifications; using Tango.SharedUI; diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/JobsView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/JobsView.xaml deleted file mode 100644 index 37c768a0f..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/JobsView.xaml +++ /dev/null @@ -1,155 +0,0 @@ - - - - - - - - - - - - - - - - - - - Jobs - - - - - - - - - - - - - - - - READY TO DYE - NOT READY - ALL - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/JobsView.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/JobsView.xaml.cs deleted file mode 100644 index 66f104511..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/JobsView.xaml.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -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.PPC.UI.Views -{ - /// - /// Interaction logic for JobsView.xaml - /// - public partial class JobsView : UserControl - { - public JobsView() - { - InitializeComponent(); - - //dataGridJobs.Sorting += DataGridJobs_Sorting; - } - - private void DataGridJobs_Sorting(object sender, DataGridSortingEventArgs e) - { - //if (e.Column != userSortColumn) - //{ - // userSortColumnBorder.Background = Application.Current.Resources["TangoMidAccentBrush"] as Brush; - //} - } - - private void OnJobIndexColumnClick(object sender, MouseButtonEventArgs e) - { - //SortDataGrid(dataGridJobs, dataGridJobs.Columns.Count - 1, ListSortDirection.Ascending); - //userSortColumnBorder.Background = Application.Current.Resources["TangoLowAccentBrush"] as Brush; - } - - private static void SortDataGrid(DataGrid dataGrid, int columnIndex = 0, ListSortDirection sortDirection = ListSortDirection.Ascending) - { - var column = dataGrid.Columns[columnIndex]; - - // Clear current sort descriptions - dataGrid.Items.SortDescriptions.Clear(); - - // Add the new sort description - dataGrid.Items.SortDescriptions.Add(new SortDescription(column.SortMemberPath, sortDirection)); - - // Apply sort - foreach (var col in dataGrid.Columns) - { - col.SortDirection = null; - } - column.SortDirection = sortDirection; - - // Refresh items to display sort - dataGrid.Items.Refresh(); - } - } -} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml index fb5cb4f8b..46e104627 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml @@ -98,7 +98,7 @@ - + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml.cs index e6c778a92..8ab602f2c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml.cs @@ -12,13 +12,16 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using Tango.Logging; +using Tango.PPC.Common; +using Tango.PPC.UI.ViewsContracts; namespace Tango.PPC.UI.Views { /// /// Interaction logic for LayoutView.xaml /// - public partial class LayoutView : UserControl + public partial class LayoutView : UserControl, ILayoutView { public static LayoutView Instance { get; private set; } @@ -27,5 +30,28 @@ namespace Tango.PPC.UI.Views InitializeComponent(); Instance = this; } + + public void ApplyModules(IEnumerable modules) + { + this.BeginInvoke(() => + { + foreach (var module in modules) + { + if (!NavigationControl.Elements.ToList().Exists(x => x.GetType() == module.MainViewType)) + { + LogManager.Default.Log("Loading module " + module.Name + "..."); + FrameworkElement view = Activator.CreateInstance(module.MainViewType) as FrameworkElement; + SharedUI.Controls.NavigationControl.SetNavigationName(view, module.Name); + NavigationControl.Elements.Add(view); + module.Initialize(); + } + } + + if (modules.Count() > 0) + { + NavigationControl.NavigateTo(modules.First().Name); + } + }); + } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewsContracts/ILayoutView.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewsContracts/ILayoutView.cs new file mode 100644 index 000000000..f79c790ff --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewsContracts/ILayoutView.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.PPC.Common; + +namespace Tango.PPC.UI.ViewsContracts +{ + public interface ILayoutView : IPPCView + { + void ApplyModules(IEnumerable modules); + } +} -- cgit v1.3.1