From de099bd3b50b8ea52b212b8d322626582c2648be Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Sun, 22 Apr 2018 13:35:22 +0300 Subject: Implemented new TangoIOC container & TangoMessenger. Got rid of MVVMLite libs ! Got rid of IShutdownRequestBlocker, IShutdownListener, IModuleRequestListener. Implemented IStudioViewModel & StudioViewModel. --- .../ExtensionMethods/IStudioMessageExtensions.cs | 22 ---- .../ExtensionMethods/TangoIOCExtensions.cs | 22 ++++ .../IStudioModuleViewVM.cs | 29 ----- .../Tango.MachineStudio.Common/IStudioViewModel.cs | 42 ++++++++ .../StudioApplication/IModuleRequestListener.cs | 21 ---- .../StudioApplication/IShutdownListener.cs | 19 ---- .../StudioApplication/IShutdownRequestBlocker.cs | 21 ---- .../StudioApplication/IStudioApplicationManager.cs | 2 +- .../Tango.MachineStudio.Common/StudioViewModel.cs | 117 ++++++++++++++++++++- .../Tango.MachineStudio.Common.csproj | 22 +--- .../Tango.MachineStudio.Common/app.config | 40 +++++++ .../Tango.MachineStudio.Common/packages.config | 2 +- 12 files changed, 222 insertions(+), 137 deletions(-) delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/ExtensionMethods/IStudioMessageExtensions.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/ExtensionMethods/TangoIOCExtensions.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/IStudioModuleViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/IStudioViewModel.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IModuleRequestListener.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IShutdownListener.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IShutdownRequestBlocker.cs (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common') diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/ExtensionMethods/IStudioMessageExtensions.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/ExtensionMethods/IStudioMessageExtensions.cs deleted file mode 100644 index 7ae259e04..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/ExtensionMethods/IStudioMessageExtensions.cs +++ /dev/null @@ -1,22 +0,0 @@ -using GalaSoft.MvvmLight.Messaging; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.MachineStudio.Common.Messages; - -/// -/// Contains extension methods. -/// -public static class IStudioMessageExtensions -{ - /// - /// Sends the message. - /// - /// The message. - public static void Send(this IStudioMessage message) - { - Messenger.Default.Send(message); - } -} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/ExtensionMethods/TangoIOCExtensions.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/ExtensionMethods/TangoIOCExtensions.cs new file mode 100644 index 000000000..827650f59 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/ExtensionMethods/TangoIOCExtensions.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.DI; +using Tango.MachineStudio.Common; + +public static class TangoIOCExtensions +{ + /// + /// Gets the specified module view models. + /// + /// The Tango IOC. + /// The module. + /// + public static IEnumerable GetModuleViewModels(this TangoIOC tangoIOC, IStudioModule module) + { + var viewModels = tangoIOC.GetAllInstancesByBase().Where(x => x != null && x.GetType().BaseType.GetGenericArguments().Length > 0 && x.GetType().BaseType.GetGenericArguments()[0] == module.GetType()); + return viewModels; + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/IStudioModuleViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/IStudioModuleViewVM.cs deleted file mode 100644 index 1fd562590..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/IStudioModuleViewVM.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.MachineStudio.Common -{ - public interface IStudioModuleViewVM - { - /// - /// Called when the module . - /// - void OnNavigatedTo(); - /// - /// Called when [navigated from]. - /// - void OnNavigatedFrom(); - /// - /// Called when [shutting down]. - /// - void OnShuttingDown(); - /// - /// Called when the application is shutting down. - /// - /// - Task OnShutdownRequest(); - } -} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/IStudioViewModel.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/IStudioViewModel.cs new file mode 100644 index 000000000..35ed50cd9 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/IStudioViewModel.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.Common +{ + /// + /// Represents a Machine Studio view model. + /// + public interface IStudioViewModel + { + /// + /// Called when the user has navigated in to the module. + /// + void OnNavigatedTo(); + + /// + /// Called when the user has navigated out of the module. + /// + void OnNavigatedFrom(); + + /// + /// Called when application is shutting down. + /// + void OnShuttingDown(); + + /// + /// Called before the application is shutting down. + /// Return false to cancel the shutdown in case an important process is in progress. + /// + /// + Task OnShutdownRequest(); + + /// + /// Called when another module has wants to navigate to this module with some arguments. + /// + /// The arguments. + void OnModuleRequest(params object[] args); + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IModuleRequestListener.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IModuleRequestListener.cs deleted file mode 100644 index b950d7bcd..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IModuleRequestListener.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.MachineStudio.Common.StudioApplication -{ - /// - /// Represents a type which will be notified when a new module request was made by - /// - public interface IModuleRequestListener - { - /// - /// Called when the request has been made. - /// - /// The module instance. - /// The arguments. - void OnRequestModule(IStudioModule module, Object args); - } -} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IShutdownListener.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IShutdownListener.cs deleted file mode 100644 index 1ca5a7df2..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IShutdownListener.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.MachineStudio.Common.StudioApplication -{ - /// - /// Used to notify view models about application terminating. - /// - public interface IShutdownListener - { - /// - /// Called when the application is about to terminate. - /// - void OnShuttingDown(); - } -} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IShutdownRequestBlocker.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IShutdownRequestBlocker.cs deleted file mode 100644 index 4d5f968a4..000000000 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IShutdownRequestBlocker.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.MachineStudio.Common.StudioApplication -{ - /// - /// Represents a component capable of receiving notification for when the Machine Studio shuts down. - /// The component can perform it's own shutdown operations, or cancel the current shutdown operation. - /// - public interface IShutdownRequestBlocker - { - /// - /// Called when the application is shutting down. - /// - /// - Task OnShutdownRequest(); - } -} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IStudioApplicationManager.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IStudioApplicationManager.cs index 9a5f39a96..be793ac81 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IStudioApplicationManager.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IStudioApplicationManager.cs @@ -47,7 +47,7 @@ namespace Tango.MachineStudio.Common.StudioApplication /// /// Name of the module. /// The arguments. - void RequestModule(String moduleName, Object args); + void RequestModule(String moduleName, params object[] args); /// /// Gets the machine studio application version. diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs index 6b7984faf..30e96bd0a 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs @@ -7,19 +7,126 @@ using Tango.SharedUI; namespace Tango.MachineStudio.Common { - public abstract class StudioViewModel : ViewModel + /// + /// Represents a Machine Studio view model + /// + /// The type of the module. + /// + /// + public abstract class StudioViewModel : ViewModel, IStudioViewModel where Module : IStudioModule { - public abstract Task RequestShutdown(); + /// + /// Initializes a new instance of the class. + /// + public StudioViewModel() : base() + { + + } + + /// + /// Called when another module has wants to navigate to this module with some arguments. + /// + /// The arguments. + public virtual void OnModuleRequest(params object[] args) + { + + } + + /// + /// Called when the user has navigated out of the module. + /// + public virtual void OnNavigatedFrom() + { + + } + + /// + /// Called when the user has navigated in to the module. + /// + public virtual void OnNavigatedTo() + { + + } + + /// + /// Called before the application is shutting down. + /// Return false to cancel the shutdown in case an important process is in progress. + /// + /// + public virtual Task OnShutdownRequest() + { + return Task.FromResult(true); + } + + /// + /// Called when application is shutting down. + /// + public virtual void OnShuttingDown() + { + + } } - public abstract class StudioViewModel : ViewModel where T : IView + /// + /// Represents a Machine Studio view model. + /// + /// The type of the module. + /// + /// + /// + public abstract class StudioViewModel : ViewModel, IStudioViewModel where Module : IStudioModule where T : IView { - public abstract Task OnShutdownRequest(); - + /// + /// Initializes a new instance of the class. + /// + /// The view. public StudioViewModel(T view) : base(view) { } + + /// + /// Called when another module has wants to navigate to this module with some arguments. + /// + /// The arguments. + public virtual void OnModuleRequest(params object[] args) + { + + } + + /// + /// Called when the user has navigated out of the module. + /// + public virtual void OnNavigatedFrom() + { + + } + + /// + /// Called when the user has navigated in to the module. + /// + public virtual void OnNavigatedTo() + { + + } + + /// + /// Called before the application is shutting down. + /// Return false to cancel the shutdown in case an important process is in progress. + /// + /// + public virtual Task OnShutdownRequest() + { + return Task.FromResult(true); + } + + /// + /// Called when application is shutting down. + /// + public virtual void OnShuttingDown() + { + + } } } 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 index ab99a3ad7..f722d13ae 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj @@ -37,15 +37,6 @@ ..\..\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\Google.Protobuf.3.4.1\lib\net45\Google.Protobuf.dll @@ -58,9 +49,6 @@ ..\..\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 - @@ -68,7 +56,7 @@ - ..\..\packages\MahApps.Metro.1.5.0\lib\net45\System.Windows.Interactivity.dll + ..\..\packages\Expression.Blend.Sdk.1.0.2\lib\net45\System.Windows.Interactivity.dll @@ -105,22 +93,20 @@ + - + - - - - + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/app.config b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/app.config index 4a6cb0526..77b7003e2 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/app.config +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/app.config @@ -10,6 +10,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/packages.config b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/packages.config index 8cd12859b..c9f4c28c9 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/packages.config +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/packages.config @@ -2,9 +2,9 @@ + - \ No newline at end of file -- cgit v1.3.1