diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-06-14 15:57:24 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-06-14 15:57:24 +0300 |
| commit | a775178c063082eb6a401b4254a046133840af03 (patch) | |
| tree | 4ba9572da806e6e5ec031853188f6f335546fb57 /Software/Visual_Studio/PPC/Tango.PPC.UI | |
| parent | 099cb04861e293cf675d8b5216448a766eef7954 (diff) | |
| download | Tango-a775178c063082eb6a401b4254a046133840af03.tar.gz Tango-a775178c063082eb6a401b4254a046133840af03.zip | |
Working on PPC...
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI')
8 files changed, 194 insertions, 23 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Authentication/DefaultAuthenticationProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Authentication/DefaultAuthenticationProvider.cs index 8a60caf6d..53a37c7f5 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Authentication/DefaultAuthenticationProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Authentication/DefaultAuthenticationProvider.cs @@ -10,10 +10,22 @@ using Tango.PPC.Common.Authentication; namespace Tango.PPC.UI.Authentication { + /// <summary> + /// Represents the default PPC authentication provider. + /// </summary> + /// <seealso cref="Tango.Core.ExtendedObject" /> + /// <seealso cref="Tango.PPC.Common.Authentication.IAuthenticationProvider" /> public class DefaultAuthenticationProvider : ExtendedObject, IAuthenticationProvider { - private User _currentUser; + /// <summary> + /// Occurs when the current logged-in user has changed. + /// </summary> + public event EventHandler<User> CurrentUserChanged; + private User _currentUser; + /// <summary> + /// Gets the current logged-in user. + /// </summary> public User CurrentUser { get { return _currentUser; } @@ -24,8 +36,12 @@ namespace Tango.PPC.UI.Authentication } } - public event EventHandler<User> CurrentUserChanged; - + /// <summary> + /// Performs a user login by the specified email and password. + /// </summary> + /// <param name="email">The email.</param> + /// <param name="password">The password.</param> + /// <returns></returns> public Task<User> Login(string email, string password) { return Task.Factory.StartNew(() => @@ -36,6 +52,9 @@ namespace Tango.PPC.UI.Authentication }); } + /// <summary> + /// Logs-out the current logged-in user. + /// </summary> public void Logout() { CurrentUser = null; 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 8c42a3a44..82640f899 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs @@ -13,15 +13,27 @@ using Tango.SharedUI.Controls; namespace Tango.PPC.UI.Navigation { + /// <summary> + /// Represents the default PPC navigation manager. + /// </summary> + /// <seealso cref="Tango.PPC.Common.Navigation.INavigationManager" /> public class DefaultNavigationManager : INavigationManager { private IPPCModuleLoader _moduleLoader; + /// <summary> + /// Initializes a new instance of the <see cref="DefaultNavigationManager"/> class. + /// </summary> + /// <param name="moduleLoader">The module loader.</param> public DefaultNavigationManager(IPPCModuleLoader moduleLoader) { _moduleLoader = moduleLoader; } + /// <summary> + /// Navigates to the specified PPC view. + /// </summary> + /// <param name="view">The view.</param> public void NavigateTo(NavigationView view) { if (view == NavigationView.HomeModule) @@ -36,6 +48,10 @@ namespace Tango.PPC.UI.Navigation } } + /// <summary> + /// Navigates to the specified module. + /// </summary> + /// <typeparam name="T"></typeparam> public void NavigateTo<T>() where T : IPPCModule { MainView.Instance.NavigationControl.NavigateTo(NavigationView.LayoutView.ToString()); @@ -44,11 +60,32 @@ namespace Tango.PPC.UI.Navigation navigationControl.NavigateTo(module.Name); } + /// <summary> + /// Navigates to the specified module name. + /// </summary> + /// <param name="moduleName">Name of the module.</param> + public void NavigateTo(string moduleName) + { + var navigationControl = LayoutView.Instance.NavigationControl; + navigationControl.NavigateTo(moduleName); + } + + /// <summary> + /// Navigates to the specified module using the view path (e.g MainView.JobsView). + /// </summary> + /// <typeparam name="T"></typeparam> + /// <param name="viewPath">The view path.</param> public void NavigateTo<T>(string viewPath) where T : IPPCModule { NavigateTo<T>(viewPath.Split(',')); } + /// <summary> + /// Navigates to the specified module using the view path (e.g MainView,JobsView). + /// This method makes it easy to do stuff like NavigateTo(nameof(MainView),nameof(JobsView)); + /// </summary> + /// <typeparam name="T"></typeparam> + /// <param name="viewPath">The view path.</param> public void NavigateTo<T>(params String[] viewPath) where T : IPPCModule { MainView.Instance.NavigationControl.NavigateTo(NavigationView.LayoutView.ToString()); @@ -72,11 +109,5 @@ namespace Tango.PPC.UI.Navigation }); } } - - public void NavigateTo(string moduleName) - { - var navigationControl = LayoutView.Instance.NavigationControl; - navigationControl.NavigateTo(moduleName); - } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs index 02e41e087..5e4bd7c30 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs @@ -14,22 +14,43 @@ using Tango.SharedUI.Helpers; namespace Tango.PPC.UI.Notifications { + /// <summary> + /// Represents the default PPC notification provider. + /// </summary> + /// <seealso cref="Tango.Core.ExtendedObject" /> + /// <seealso cref="Tango.PPC.Common.Notifications.INotificationProvider" /> public class DefaultNotificationProvider : ExtendedObject, INotificationProvider { + /// <summary> + /// Represents a pending message box. + /// </summary> private class PendingMessageBox { + /// <summary> + /// Gets or sets the message view model. + /// </summary> public MessageBoxVM VM { get; set; } + + /// <summary> + /// Gets or sets the message task completion source. + /// </summary> public TaskCompletionSource<bool> CompletionSource { get; set; } } private ConcurrentQueue<PendingMessageBox> _pendingMessageBoxes; + /// <summary> + /// Initializes a new instance of the <see cref="DefaultNotificationProvider"/> class. + /// </summary> public DefaultNotificationProvider() { _pendingMessageBoxes = new ConcurrentQueue<PendingMessageBox>(); } private MessageBoxVM _currentMessageBox; + /// <summary> + /// Gets the current message box if any. + /// </summary> public MessageBoxVM CurrentMessageBox { get { return _currentMessageBox; } @@ -41,6 +62,9 @@ namespace Tango.PPC.UI.Notifications } } + /// <summary> + /// Gets a value indicating whether a message box is available. + /// </summary> public bool HasMessageBox { get @@ -49,6 +73,11 @@ namespace Tango.PPC.UI.Notifications } } + /// <summary> + /// Shows an error message box. + /// </summary> + /// <param name="message">The message.</param> + /// <returns></returns> public Task ShowError(string message) { return ShowMessageBox(new MessageBoxVM() @@ -60,6 +89,11 @@ namespace Tango.PPC.UI.Notifications }); } + /// <summary> + /// Shows an information message box. + /// </summary> + /// <param name="message">The message.</param> + /// <returns></returns> public Task ShowInfo(string message) { return ShowMessageBox(new MessageBoxVM() @@ -71,6 +105,11 @@ namespace Tango.PPC.UI.Notifications }); } + /// <summary> + /// Shows warning message box. + /// </summary> + /// <param name="message">The message.</param> + /// <returns></returns> public Task ShowWarning(string message) { return ShowMessageBox(new MessageBoxVM() @@ -82,6 +121,11 @@ namespace Tango.PPC.UI.Notifications }); } + /// <summary> + /// Shows a question message box. + /// </summary> + /// <param name="message">The message.</param> + /// <returns></returns> public Task<bool> ShowQuestion(string message) { return ShowMessageBox(new MessageBoxVM() @@ -94,6 +138,11 @@ namespace Tango.PPC.UI.Notifications }); } + /// <summary> + /// Shows the message box. + /// </summary> + /// <param name="vm">The view model.</param> + /// <returns></returns> private Task<bool> ShowMessageBox(MessageBoxVM vm) { TaskCompletionSource<bool> source = new TaskCompletionSource<bool>(); @@ -117,6 +166,9 @@ namespace Tango.PPC.UI.Notifications return source.Task; } + /// <summary> + /// Called when the message box has been closed. + /// </summary> private void OnMessageBoxClosed() { CurrentMessageBox = null; 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 2fbc6c34e..233751ddb 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs @@ -19,25 +19,60 @@ using System.Windows.Threading; namespace Tango.PPC.UI.PPCApplication { + /// <summary> + /// Represents the default PPC application manager. + /// </summary> + /// <seealso cref="Tango.Core.ExtendedObject" /> + /// <seealso cref="Tango.PPC.Common.Application.IPPCApplicationManager" /> public class DefaultPPCApplicationManager : ExtendedObject, IPPCApplicationManager { private List<PPCViewModel> _notifiedViewModels; + /// <summary> + /// Occurs when the connected machine property has changed. + /// </summary> + public event EventHandler<IMachineOperator> ConnectedMachineChanged; + + /// <summary> + /// Occurs when the application has started. + /// </summary> + public event EventHandler ApplicationStarted; + + /// <summary> + /// Occurs when all PPC modules are ready and initialized. + /// </summary> + public event EventHandler ModulesInitialized; + + /// <summary> + /// Gets a value indicating whether the application is shutting down. + /// </summary> public bool IsShuttingDown { get; private set; } + + private IMachineOperator _connectedMachine; + /// <summary> + /// Gets or sets the currently connected machine if any. + /// </summary> + /// <exception cref="NotImplementedException"> + /// </exception> public IMachineOperator ConnectedMachine { get { - throw new NotImplementedException(); + return _connectedMachine; } - set { - throw new NotImplementedException(); + _connectedMachine = value; + RaisePropertyChangedAuto(); + ConnectedMachineChanged?.Invoke(this, ConnectedMachine); } } + /// <summary> + /// Gets the application version. + /// </summary> + /// <exception cref="NotImplementedException"></exception> public string Version { get @@ -47,6 +82,9 @@ namespace Tango.PPC.UI.PPCApplication } private Machine _machine; + /// <summary> + /// Gets the associated observable entity machine. + /// </summary> public Machine Machine { private set @@ -59,8 +97,9 @@ namespace Tango.PPC.UI.PPCApplication } } - public event EventHandler<IMachineOperator> ConnectedMachineChanged; - + /// <summary> + /// Initializes a new instance of the <see cref="DefaultPPCApplicationManager"/> class. + /// </summary> public DefaultPPCApplicationManager() { if (!DesignMode) @@ -132,6 +171,9 @@ namespace Tango.PPC.UI.PPCApplication } } + /// <summary> + /// Shutdown the application. + /// </summary> public void ShutDown() { IsShuttingDown = true; @@ -141,11 +183,5 @@ namespace Tango.PPC.UI.PPCApplication vm.OnApplicationShuttingDown(); } } - - /// <summary> - /// Occurs when the application has started. - /// </summary> - 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 fb0e35618..fdeff4fc4 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 @@ -262,9 +262,7 @@ <ItemGroup> <Resource Include="Images\MessageBox Icons\information.png" /> </ItemGroup> - <ItemGroup> - <Folder Include="Messages\" /> - </ItemGroup> + <ItemGroup /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="..\..\packages\System.Data.SQLite.Core.1.0.108.0\build\net46\System.Data.SQLite.Core.targets" Condition="Exists('..\..\packages\System.Data.SQLite.Core.1.0.108.0\build\net46\System.Data.SQLite.Core.targets')" /> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> 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 168df019a..4e200ada6 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs @@ -11,22 +11,40 @@ using Tango.SharedUI; namespace Tango.PPC.UI.ViewModels { + /// <summary> + /// Represents the layout view containing the main menu and all modules. + /// </summary> + /// <seealso cref="Tango.PPC.Common.PPCViewModel{Tango.PPC.UI.ViewsContracts.ILayoutView}" /> public class LayoutViewVM : PPCViewModel<ILayoutView> { + /// <summary> + /// Gets or sets the module loader. + /// </summary> [TangoInject] public IPPCModuleLoader ModuleLoader { get; set; } + /// <summary> + /// Called when the application has been started. + /// </summary> public override void OnApplicationStarted() { base.OnApplicationStarted(); ModuleLoader.ModulesLoaded += ModuleLoader_ModulesLoaded; } + /// <summary> + /// Handles the ModulesLoaded event of the ModuleLoader. + /// </summary> + /// <param name="sender">The source of the event.</param> + /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void ModuleLoader_ModulesLoaded(object sender, EventArgs e) { View.ApplyModules(ModuleLoader.UserModules); } + /// <summary> + /// Called when the instance of IPPCView is available. + /// </summary> 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 588cc8b64..f6b06ca61 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs @@ -19,11 +19,21 @@ using Tango.SharedUI; namespace Tango.PPC.UI.ViewModels { + /// <summary> + /// Represents the PPC loading splash screen view model. + /// </summary> + /// <seealso cref="Tango.PPC.Common.PPCViewModel" /> public class LoadingViewVM : PPCViewModel { + /// <summary> + /// Gets or sets the module loader. + /// </summary> [TangoInject] public IPPCModuleLoader ModuleLoader { get; set; } + /// <summary> + /// Called when the application has been started. + /// </summary> public async override void OnApplicationStarted() { await Task.Factory.StartNew(() => 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 deea33a0d..faac9ad16 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs @@ -14,8 +14,15 @@ using Tango.SharedUI; namespace Tango.PPC.UI.ViewModels { + /// <summary> + /// Represents the PPC main view model. + /// </summary> + /// <seealso cref="Tango.PPC.Common.PPCViewModel" /> public class MainViewVM : PPCViewModel { + /// <summary> + /// Called when the application has been started. + /// </summary> public override void OnApplicationStarted() { |
