diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-04-22 13:35:22 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-04-22 13:35:22 +0300 |
| commit | de099bd3b50b8ea52b212b8d322626582c2648be (patch) | |
| tree | eea98a7f7b073d6cf8ded47bddc3b3f3f5e7c430 /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common | |
| parent | 8edd1a95962a5c1c2e73d15f209a9fb362ff884a (diff) | |
| download | Tango-de099bd3b50b8ea52b212b8d322626582c2648be.tar.gz Tango-de099bd3b50b8ea52b212b8d322626582c2648be.zip | |
Implemented new TangoIOC container & TangoMessenger.
Got rid of MVVMLite libs !
Got rid of IShutdownRequestBlocker, IShutdownListener, IModuleRequestListener.
Implemented IStudioViewModel & StudioViewModel.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common')
12 files changed, 222 insertions, 137 deletions
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; - -/// <summary> -/// Contains <see cref="IStudioMessage"/> extension methods. -/// </summary> -public static class IStudioMessageExtensions -{ - /// <summary> - /// Sends the message. - /// </summary> - /// <param name="message">The message.</param> - 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 +{ + /// <summary> + /// Gets the specified module <see cref="IStudioViewModel"/> view models. + /// </summary> + /// <param name="tangoIOC">The Tango IOC.</param> + /// <param name="module">The module.</param> + /// <returns></returns> + public static IEnumerable<IStudioViewModel> GetModuleViewModels(this TangoIOC tangoIOC, IStudioModule module) + { + var viewModels = tangoIOC.GetAllInstancesByBase<IStudioViewModel>().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 - { - /// <summary> - /// Called when the module . - /// </summary> - void OnNavigatedTo(); - /// <summary> - /// Called when [navigated from]. - /// </summary> - void OnNavigatedFrom(); - /// <summary> - /// Called when [shutting down]. - /// </summary> - void OnShuttingDown(); - /// <summary> - /// Called when the application is shutting down. - /// </summary> - /// <returns></returns> - Task<bool> 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 +{ + /// <summary> + /// Represents a Machine Studio view model. + /// </summary> + public interface IStudioViewModel + { + /// <summary> + /// Called when the user has navigated in to the module. + /// </summary> + void OnNavigatedTo(); + + /// <summary> + /// Called when the user has navigated out of the module. + /// </summary> + void OnNavigatedFrom(); + + /// <summary> + /// Called when application is shutting down. + /// </summary> + void OnShuttingDown(); + + /// <summary> + /// Called before the application is shutting down. + /// Return false to cancel the shutdown in case an important process is in progress. + /// </summary> + /// <returns></returns> + Task<bool> OnShutdownRequest(); + + /// <summary> + /// Called when another module has wants to navigate to this module with some arguments. + /// </summary> + /// <param name="args">The arguments.</param> + 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 -{ - /// <summary> - /// Represents a type which will be notified when a new module request was made by <see cref="IStudioApplicationManager.RequestModule(string, object)"/> - /// </summary> - public interface IModuleRequestListener - { - /// <summary> - /// Called when the request has been made. - /// </summary> - /// <param name="module">The module instance.</param> - /// <param name="args">The arguments.</param> - 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 -{ - /// <summary> - /// Used to notify view models about application terminating. - /// </summary> - public interface IShutdownListener - { - /// <summary> - /// Called when the application is about to terminate. - /// </summary> - 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 -{ - /// <summary> - /// 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. - /// </summary> - public interface IShutdownRequestBlocker - { - /// <summary> - /// Called when the application is shutting down. - /// </summary> - /// <returns></returns> - Task<bool> 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 /// </summary> /// <param name="moduleName">Name of the module.</param> /// <param name="args">The arguments.</param> - void RequestModule(String moduleName, Object args); + void RequestModule(String moduleName, params object[] args); /// <summary> /// 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 + /// <summary> + /// Represents a Machine Studio view model + /// </summary> + /// <typeparam name="Module">The type of the module.</typeparam> + /// <seealso cref="Tango.SharedUI.ViewModel" /> + /// <seealso cref="Tango.MachineStudio.Common.IStudioViewModel" /> + public abstract class StudioViewModel<Module> : ViewModel, IStudioViewModel where Module : IStudioModule { - public abstract Task<bool> RequestShutdown(); + /// <summary> + /// Initializes a new instance of the <see cref="StudioViewModel{Module}"/> class. + /// </summary> + public StudioViewModel() : base() + { + + } + + /// <summary> + /// Called when another module has wants to navigate to this module with some arguments. + /// </summary> + /// <param name="args">The arguments.</param> + public virtual void OnModuleRequest(params object[] args) + { + + } + + /// <summary> + /// Called when the user has navigated out of the module. + /// </summary> + public virtual void OnNavigatedFrom() + { + + } + + /// <summary> + /// Called when the user has navigated in to the module. + /// </summary> + public virtual void OnNavigatedTo() + { + + } + + /// <summary> + /// Called before the application is shutting down. + /// Return false to cancel the shutdown in case an important process is in progress. + /// </summary> + /// <returns></returns> + public virtual Task<bool> OnShutdownRequest() + { + return Task.FromResult(true); + } + + /// <summary> + /// Called when application is shutting down. + /// </summary> + public virtual void OnShuttingDown() + { + + } } - public abstract class StudioViewModel<T> : ViewModel<T> where T : IView + /// <summary> + /// Represents a Machine Studio view model. + /// </summary> + /// <typeparam name="Module">The type of the module.</typeparam> + /// <typeparam name="T"></typeparam> + /// <seealso cref="Tango.SharedUI.ViewModel" /> + /// <seealso cref="Tango.MachineStudio.Common.IStudioViewModel" /> + public abstract class StudioViewModel<Module, T> : ViewModel<T>, IStudioViewModel where Module : IStudioModule where T : IView { - public abstract Task<bool> OnShutdownRequest(); - + /// <summary> + /// Initializes a new instance of the <see cref="StudioViewModel{Module, T}"/> class. + /// </summary> + /// <param name="view">The view.</param> public StudioViewModel(T view) : base(view) { } + + /// <summary> + /// Called when another module has wants to navigate to this module with some arguments. + /// </summary> + /// <param name="args">The arguments.</param> + public virtual void OnModuleRequest(params object[] args) + { + + } + + /// <summary> + /// Called when the user has navigated out of the module. + /// </summary> + public virtual void OnNavigatedFrom() + { + + } + + /// <summary> + /// Called when the user has navigated in to the module. + /// </summary> + public virtual void OnNavigatedTo() + { + + } + + /// <summary> + /// Called before the application is shutting down. + /// Return false to cancel the shutdown in case an important process is in progress. + /// </summary> + /// <returns></returns> + public virtual Task<bool> OnShutdownRequest() + { + return Task.FromResult(true); + } + + /// <summary> + /// Called when application is shutting down. + /// </summary> + 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 @@ <Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"> <HintPath>..\..\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.SqlServer.dll</HintPath> </Reference> - <Reference Include="GalaSoft.MvvmLight, Version=5.3.0.19026, Culture=neutral, PublicKeyToken=e7570ab207bcb616, processorArchitecture=MSIL"> - <HintPath>..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.dll</HintPath> - </Reference> - <Reference Include="GalaSoft.MvvmLight.Extras, Version=5.3.0.19032, Culture=neutral, PublicKeyToken=669f0b5e8f868abf, processorArchitecture=MSIL"> - <HintPath>..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.Extras.dll</HintPath> - </Reference> - <Reference Include="GalaSoft.MvvmLight.Platform, Version=5.3.0.19032, Culture=neutral, PublicKeyToken=5f873c45e98af8a1, processorArchitecture=MSIL"> - <HintPath>..\..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.Platform.dll</HintPath> - </Reference> <Reference Include="Google.Protobuf, Version=3.4.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL"> <HintPath>..\..\packages\Google.Protobuf.3.4.1\lib\net45\Google.Protobuf.dll</HintPath> </Reference> @@ -58,9 +49,6 @@ <Reference Include="MaterialDesignThemes.Wpf, Version=2.3.1.953, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\..\packages\MaterialDesignThemes.2.3.1.953\lib\net45\MaterialDesignThemes.Wpf.dll</HintPath> </Reference> - <Reference Include="Microsoft.Practices.ServiceLocation, Version=1.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> - <HintPath>..\..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll</HintPath> - </Reference> <Reference Include="System" /> <Reference Include="System.ComponentModel.DataAnnotations" /> <Reference Include="System.Data" /> @@ -68,7 +56,7 @@ <Reference Include="System.ServiceModel" /> <Reference Include="System.Speech" /> <Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> - <HintPath>..\..\packages\MahApps.Metro.1.5.0\lib\net45\System.Windows.Interactivity.dll</HintPath> + <HintPath>..\..\packages\Expression.Blend.Sdk.1.0.2\lib\net45\System.Windows.Interactivity.dll</HintPath> </Reference> <Reference Include="System.Xml" /> <Reference Include="Microsoft.CSharp" /> @@ -105,22 +93,20 @@ <Compile Include="EventLogging\DefaultEventLogger.cs" /> <Compile Include="EventLogging\IEventLogger.cs" /> <Compile Include="ExtensionMethods\CommonDialogExtensions.cs" /> + <Compile Include="ExtensionMethods\TangoIOCExtensions.cs" /> <Compile Include="Html\IHtmlPresenter.cs" /> <Compile Include="Helpers\GraphsHelper.cs" /> - <Compile Include="IStudioModuleViewVM.cs" /> + <Compile Include="IStudioViewModel.cs" /> <Compile Include="Messages\MachineConnectionChangedMessage.cs" /> <Compile Include="Notifications\BarItem.cs" /> <Compile Include="Notifications\DialogViewVM.cs" /> <Compile Include="Speech\DefaultSpeechProvider.cs" /> <Compile Include="Speech\ISpeechProvider.cs" /> - <Compile Include="StudioApplication\IModuleRequestListener.cs" /> - <Compile Include="StudioApplication\IShutdownListener.cs" /> <Compile Include="StudioApplication\IStudioApplicationManager.cs" /> - <Compile Include="StudioApplication\IShutdownRequestBlocker.cs" /> - <Compile Include="ExtensionMethods\IStudioMessageExtensions.cs" /> <Compile Include="Messages\IStudioMessage.cs" /> <Compile Include="Notifications\TaskItem.cs" /> <Compile Include="StudioModuleBase.cs" /> + <Compile Include="StudioViewModel.cs" /> <Compile Include="Update\CheckForUpdatesResponse.cs" /> <Compile Include="Update\CheckForUpdatesRequest.cs" /> <Compile Include="Update\FileStreamWrapper.cs" /> 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 @@ <assemblyIdentity name="System.Reactive.Core" publicKeyToken="94bc3704cddfc263" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-3.0.3000.0" newVersion="3.0.3000.0" /> </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-1.2.2.0" newVersion="1.2.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Reflection.Metadata" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-1.4.2.0" newVersion="1.4.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO.FileSystem" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO.Compression" publicKeyToken="b77a5c561934e089" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO.FileSystem.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Security.Cryptography.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Xml.XPath.XDocument" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Console" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Diagnostics.StackTrace" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" /> + </dependentAssembly> </assemblyBinding> </runtime> <entityFramework> 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 @@ <packages> <package id="CommonServiceLocator" version="1.3" targetFramework="net46" /> <package id="EntityFramework" version="6.0.0" targetFramework="net46" /> + <package id="Expression.Blend.Sdk" version="1.0.2" targetFramework="net46" /> <package id="Google.Protobuf" version="3.4.1" targetFramework="net46" /> <package id="MahApps.Metro" version="1.5.0" targetFramework="net46" /> <package id="MaterialDesignColors" version="1.1.2" targetFramework="net46" /> <package id="MaterialDesignThemes" version="2.3.1.953" targetFramework="net46" /> - <package id="MvvmLightLibs" version="5.3.0.0" targetFramework="net46" /> </packages>
\ No newline at end of file |
