From ee88fc31d9b1b8f4782c7103d91de2d1b11c211b Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 13 Feb 2018 19:41:19 +0200 Subject: Implemented StudioModuleBase. --- .../Tango.MachineStudio.Common/StudioModuleBase.cs | 92 ++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioModuleBase.cs (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioModuleBase.cs') diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioModuleBase.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioModuleBase.cs new file mode 100644 index 000000000..a773adf8b --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioModuleBase.cs @@ -0,0 +1,92 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Media.Imaging; +using Tango.Integration.Observables; + +namespace Tango.MachineStudio.Common +{ + /// + /// Represents a base class for studio modules. + /// + /// + public abstract class StudioModuleBase : IStudioModule + { + private bool _isInitialized; + private bool _isLoaded; + + /// + /// Occurs when the user has navigated into or out of this module. + /// + public event EventHandler IsLoadedChanged; + + /// + /// Gets the module name. + /// + public abstract string Name { get; } + + /// + /// Gets the module description. + /// + public abstract string Description { get; } + + /// + /// Gets the module cover image. + /// + public abstract BitmapSource Image { get; } + + /// + /// Gets the module entry point view. + /// + public abstract FrameworkElement MainView { get; } + + /// + /// Gets the permission required to see and load this module. + /// + public abstract Permissions Permission { get; } + + /// + /// Gets a value indicating whether this module has been initialized. + /// + public bool IsInitialized + { + get + { + return _isInitialized; + } + protected set + { + _isInitialized = value; + } + } + + /// + /// Sets a value indicating whether this module is loaded. + /// + public bool IsLoaded + { + get + { + return _isLoaded; + } + set + { + _isLoaded = value; + IsLoadedChanged?.Invoke(this, value); + } + } + + /// + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + /// + public abstract void Dispose(); + + /// + /// Perform any operations required to initialize this module. + /// + public abstract void Initialize(); + } +} -- cgit v1.3.1 From 94ac70f0eaf29fcca4ae3ff5552c52cad22df492 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 14 Feb 2018 10:55:19 +0200 Subject: Refactored all studio modules to use StudioModuleBase. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 8388608 -> 8388608 bytes .../Modules/Tango.MachineStudio.DB/DBModule.cs | 43 +++------------- .../DeveloperModule.cs | 54 +++++++++++---------- .../MachineDesignerModule.cs | 34 +++---------- .../Tango.MachineStudio.Stubs/StubsModule.cs | 36 +++----------- .../SynchronizationModule.cs | 42 +++------------- .../TechnicianModule.cs | 8 --- .../Properties/AssemblyInfo.cs | 3 ++ .../Tango.MachineStudio.Common/StudioModuleBase.cs | 25 +++++++++- 10 files changed, 85 insertions(+), 160 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioModuleBase.cs') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 4354c3d3f..b3ae0ea82 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 54a54624a..f105194a9 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/DBModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/DBModule.cs index 82cd716b3..0ad6aa541 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/DBModule.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/DBModule.cs @@ -15,66 +15,39 @@ namespace Tango.MachineStudio.DB /// Represents a Machine Studio database module. /// /// - public class DBModule : IStudioModule + public class DBModule : StudioModuleBase { - private bool _isInitialized; - private bool _isLoaded; - /// /// Gets the module name. /// - public string Name => "Data Base"; + public override string Name => "Data Base"; /// /// Gets the module description. /// - public string Description => "Provides access to raw database tables."; + public override string Description => "Provides access to raw database tables."; /// /// Gets the module cover image. /// - public BitmapSource Image => SharedUI.Helpers.ResourceHelper.GetImageFromResources("Images/db.png"); + public override BitmapSource Image => SharedUI.Helpers.ResourceHelper.GetImageFromResources("Images/db.png"); /// /// Gets the module entry point view. /// - public FrameworkElement MainView => new MainDBView(); - - /// - /// Gets a value indicating whether this module has been initialized. - /// - public bool IsInitialized => _isInitialized; + public override FrameworkElement MainView => new MainDBView(); /// /// Gets the permission required to see and load this module. /// - public Permissions Permission => Permissions.RunDataBaseModule; - - /// - /// Sets a value indicating whether this module is loaded. - /// - public bool IsLoaded { get => _isLoaded; set => _isLoaded = value; } + public override Permissions Permission => Permissions.RunDataBaseModule; /// /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// - /// - public void Dispose() + public override void Dispose() { - throw new NotImplementedException(); - } - - /// - /// Perform any operations required to initialize this module. - /// - public void Initialize() - { - if (!_isInitialized) - { - //Initialize - - _isInitialized = true; - } + } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/DeveloperModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/DeveloperModule.cs index 1a405f861..6cdda4bc8 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/DeveloperModule.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/DeveloperModule.cs @@ -12,41 +12,43 @@ using Tango.SharedUI.Helpers; namespace Tango.MachineStudio.Developer { - public class DeveloperModule : IStudioModule + /// + /// Represents the Machine Studio developer module. + /// + /// + public class DeveloperModule : StudioModuleBase { - private bool _isInitialized; - private bool _isLoaded; - - public string Name => "Developer"; - - public string Description => "Research and development, manage RML, STRIP and Process."; - - public BitmapSource Image => ResourceHelper.GetImageFromResources("Images/developer.jpg"); - - public FrameworkElement MainView => new MainView(); + /// + /// Gets the module name. + /// + public override string Name => "Developer"; - public bool IsInitialized => _isInitialized; + /// + /// Gets the module description. + /// + public override string Description => "Research and development, manage RML, STRIP and Process."; /// - /// Sets a value indicating whether this module is loaded. + /// Gets the module cover image. /// - public bool IsLoaded { get => _isLoaded; set => _isLoaded = value; } + public override BitmapSource Image => ResourceHelper.GetImageFromResources("Images/developer.jpg"); - public Permissions Permission => Permissions.RunDeveloperModule; + /// + /// Gets the module entry point view. + /// + public override FrameworkElement MainView => new MainView(); - public void Dispose() - { - throw new NotImplementedException(); - } + /// + /// Gets the permission required to see and load this module. + /// + public override Permissions Permission => Permissions.RunDeveloperModule; - public void Initialize() + /// + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + /// + public override void Dispose() { - if (!_isInitialized) - { - //Initialize.. - - _isInitialized = true; - } + } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/MachineDesignerModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/MachineDesignerModule.cs index f5b0cba98..a6fa13f08 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/MachineDesignerModule.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/MachineDesignerModule.cs @@ -16,57 +16,37 @@ namespace Tango.MachineStudio.MachineDesigner /// Represents a machine designer Machine Studio module providing an interactive GUI for managing machine configurations. /// /// - public class MachineDesignerModule : IStudioModule + public class MachineDesignerModule : StudioModuleBase { - private bool _isLoaded; - /// /// Gets the module name. /// - public string Name => "Machine Designer"; + public override string Name => "Machine Designer"; /// /// Gets the module description. /// - public string Description => "Provides a graphical control over machine configurations. Create, manage and deploy machine configurations using simple drag and drop interface."; + public override string Description => "Provides a graphical control over machine configurations. Create, manage and deploy machine configurations using simple drag and drop interface."; /// /// Gets the module cover image. /// - public BitmapSource Image => ResourceHelper.GetImageFromResources("Images/machine-designer-module.jpg"); - - /// - /// Sets a value indicating whether this module is loaded. - /// - public bool IsLoaded { get => _isLoaded; set => _isLoaded = value; } + public override BitmapSource Image => ResourceHelper.GetImageFromResources("Images/machine-designer-module.jpg"); /// /// Gets the module entry point view. /// - public FrameworkElement MainView => new MainView(); + public override FrameworkElement MainView => new MainView(); /// /// Gets the permission required to see and load this module. /// - public Permissions Permission => Permissions.RunMachineDesignerModule; - - /// - /// Gets a value indicating whether this module has been initialized. - /// - public bool IsInitialized => true; + public override Permissions Permission => Permissions.RunMachineDesignerModule; /// /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// - public void Dispose() - { - - } - - /// - /// Perform any operations required to initialize this module. - /// - public void Initialize() + public override void Dispose() { } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubsModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubsModule.cs index 359ac2977..817c68b49 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubsModule.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/StubsModule.cs @@ -16,59 +16,39 @@ namespace Tango.MachineStudio.Stubs /// Represents a stubs execution Machine Studio module capable of executing stubs against the current connected machine using a C# script engine. /// /// - public class StubsModule : IStudioModule + public class StubsModule : StudioModuleBase { - private bool _isLoaded; - /// /// Gets the module name. /// - public string Name => "Stubs"; + public override string Name => "Stubs"; /// /// Gets the module description. /// - public string Description => "Execute machine tests using an interactive C# scripting editor"; + public override string Description => "Execute machine tests using an interactive C# scripting editor"; /// /// Gets the module cover image. /// - public BitmapSource Image => ResourceHelper.GetImageFromResources("Images/stubs.jpg"); + public override BitmapSource Image => ResourceHelper.GetImageFromResources("Images/stubs.jpg"); /// /// Gets the module entry point view. /// - public FrameworkElement MainView => new MainView(); - - /// - /// Sets a value indicating whether this module is loaded. - /// - public bool IsLoaded { get => _isLoaded; set => _isLoaded = value; } + public override FrameworkElement MainView => new MainView(); /// /// Gets the permission required to see and load this module. /// - public Permissions Permission => Permissions.RunSynchronizationModule; - - /// - /// Gets a value indicating whether this module has been initialized. - /// - public bool IsInitialized => true; + public override Permissions Permission => Permissions.RunSynchronizationModule; /// /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// - public void Dispose() - { - //throw new NotImplementedException(); - } - - /// - /// Perform any operations required to initialize this module. - /// - public void Initialize() + public override void Dispose() { - //throw new NotImplementedException(); + } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/SynchronizationModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/SynchronizationModule.cs index bbf0f8ca1..5292c6048 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/SynchronizationModule.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/SynchronizationModule.cs @@ -16,65 +16,39 @@ namespace Tango.MachineStudio.Synchronization /// Represents a Machine Studio module capable of comparing and synchronizing machines data against Twine remote database. /// /// - public class SynchronizationModule : IStudioModule + public class SynchronizationModule : StudioModuleBase { - private bool _isLoaded; - private bool _isInitialized; - /// /// Gets the module name. /// - public string Name => "Synchronization"; + public override string Name => "Synchronization"; /// /// Gets the module description. /// - public string Description => "Perform local to local or remote to local database synchronization."; + public override string Description => "Perform local to local or remote to local database synchronization."; /// /// Gets the module cover image. /// - public BitmapSource Image => ResourceHelper.GetImageFromResources("Images/synchronization.jpg"); + public override BitmapSource Image => ResourceHelper.GetImageFromResources("Images/synchronization.jpg"); /// /// Gets the module entry point view. /// - public FrameworkElement MainView => new MainView(); - - /// - /// Sets a value indicating whether this module is loaded. - /// - public bool IsLoaded { get => _isLoaded; set => _isLoaded = value; } - - /// - /// Gets a value indicating whether this module has been initialized. - /// - public bool IsInitialized => _isInitialized; + public override FrameworkElement MainView => new MainView(); /// /// Gets the permission required to see and load this module. /// - public Permissions Permission => Permissions.RunSynchronizationModule; + public override Permissions Permission => Permissions.RunSynchronizationModule; /// /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// - public void Dispose() + public override void Dispose() { - //Dispose... - } - - /// - /// Perform any operations required to initialize this module. - /// - public void Initialize() - { - if (!_isInitialized) - { - //Initialize.. - - _isInitialized = true; - } + } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechnicianModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechnicianModule.cs index 7e0fdd3a4..e55fde0e5 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechnicianModule.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechnicianModule.cs @@ -50,13 +50,5 @@ namespace Tango.MachineStudio.Technician { } - - /// - /// Perform any operations required to initialize this module. - /// - public override void Initialize() - { - IsInitialized = true; - } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Properties/AssemblyInfo.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Properties/AssemblyInfo.cs index 33d6edb60..f03b250be 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Properties/AssemblyInfo.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Properties/AssemblyInfo.cs @@ -15,3 +15,6 @@ using System.Windows; //(used if a resource is not found in the page, // app, or any theme specific resource dictionaries) )] + +//Friends With +[assembly: InternalsVisibleTo("Tango.MachineStudio.UI")] diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioModuleBase.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioModuleBase.cs index a773adf8b..5c594ab70 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioModuleBase.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioModuleBase.cs @@ -57,7 +57,7 @@ namespace Tango.MachineStudio.Common { return _isInitialized; } - protected set + private set { _isInitialized = value; } @@ -87,6 +87,27 @@ namespace Tango.MachineStudio.Common /// /// Perform any operations required to initialize this module. /// - public abstract void Initialize(); + public void Initialize() + { + OnInitialized(); + IsInitialized = true; + } + + /// + /// Called when machine studio initializes this module. + /// + protected virtual void OnInitialized() + { + + } + + /// + /// Raises the event. + /// + /// if set to true the module is loaded. + protected virtual void OnLoadedChanged(bool loaded) + { + + } } } -- cgit v1.3.1