From ee697f7a3350d0a97bddee4de3a2ae4f9d285052 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Wed, 2 May 2018 17:36:54 +0300 Subject: merge --- .../Converters/PermissionToVisibilityConverter.cs | 38 +++++++++ .../Tango.MachineStudio.Common/IStudioViewModel.cs | 5 ++ .../StudioApplication/IStudioApplicationManager.cs | 8 ++ .../Tango.MachineStudio.Common/StudioViewModel.cs | 89 ++++++++++++++++++++++ .../Tango.MachineStudio.Common.csproj | 4 + 5 files changed, 144 insertions(+) create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Converters/PermissionToVisibilityConverter.cs (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common') diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Converters/PermissionToVisibilityConverter.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Converters/PermissionToVisibilityConverter.cs new file mode 100644 index 000000000..08e7d1c12 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Converters/PermissionToVisibilityConverter.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Data; +using Tango.BL.Entities; +using Tango.BL.Enumerations; +using Tango.Core.DI; +using Tango.MachineStudio.Common.Authentication; + +namespace Tango.MachineStudio.Common.Converters +{ + public class PermissionToVisibilityConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + User user = value as User; + + if (user != null) + { + if (user.HasPermission((Permissions)parameter)) + { + return Visibility.Visible; + } + } + + return Visibility.Collapsed; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/IStudioViewModel.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/IStudioViewModel.cs index 35ed50cd9..4203a1e8b 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/IStudioViewModel.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/IStudioViewModel.cs @@ -38,5 +38,10 @@ namespace Tango.MachineStudio.Common /// /// The arguments. void OnModuleRequest(params object[] args); + + /// + /// Called when the application has been started + /// + void OnApplicationStarted(); } } 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 be793ac81..1de18ac94 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IStudioApplicationManager.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IStudioApplicationManager.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows; using Tango.Integration.Services; namespace Tango.MachineStudio.Common.StudioApplication @@ -53,5 +54,12 @@ namespace Tango.MachineStudio.Common.StudioApplication /// Gets the machine studio application version. /// String Version { get; } + + /// + /// Notify the application manager about an external opened window. + /// When application exists. All registered windows will be closed. + /// + /// The window. + void RegisterOpenedWindow(Window window); } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs index 9c7e52d23..77fad1fc6 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioViewModel.cs @@ -7,6 +7,79 @@ using Tango.SharedUI; namespace Tango.MachineStudio.Common { + /// + /// Represents a Machine Studio view model + /// + /// The type of the module. + /// + /// + public abstract class StudioViewModelInternal : ViewModel, IStudioViewModel + { + /// + /// Gets or sets a value indicating whether this view model studio module is currently loaded. + /// + public bool IsModuleLoaded { get; private set; } + + /// + /// Initializes a new instance of the class. + /// + public StudioViewModelInternal() : 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() + { + IsModuleLoaded = false; + } + + /// + /// Called when the user has navigated in to the module. + /// + public virtual void OnNavigatedTo() + { + IsModuleLoaded = true; + } + + /// + /// 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() + { + + } + + /// + /// Called when the application has been started + /// + public virtual void OnApplicationStarted() + { + + } + } + /// /// Represents a Machine Studio view model /// @@ -70,6 +143,14 @@ namespace Tango.MachineStudio.Common { } + + /// + /// Called when the application has been started + /// + public virtual void OnApplicationStarted() + { + + } } /// @@ -90,6 +171,14 @@ namespace Tango.MachineStudio.Common } + /// + /// Called when the application has been started + /// + public virtual void OnApplicationStarted() + { + + } + /// /// Called when another module has wants to navigate to this module with some arguments. /// 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 e4a2720b9..ac6f84618 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 @@ -89,6 +89,7 @@ RealTimeGraphControl.xaml + @@ -287,5 +288,8 @@ True + + + \ No newline at end of file -- cgit v1.3.1