aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels')
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs19
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs25
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineConnectionViewVM.cs26
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineLoginViewVM.cs20
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs98
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ShutdownViewVM.cs3
6 files changed, 169 insertions, 22 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs
index f213af0d4..55a54e8aa 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs
@@ -4,8 +4,8 @@ using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
-using Tango.Core.Threading;
-using Tango.DAL.Observables;
+using Tango.Core.Helpers;
+using Tango.Integration.Observables;
using Tango.MachineStudio.Common.Modules;
using Tango.MachineStudio.Common.Navigation;
using Tango.MachineStudio.Common.Notifications;
@@ -13,12 +13,22 @@ using Tango.SharedUI;
namespace Tango.MachineStudio.UI.ViewModels
{
+ /// <summary>
+ /// Represents the Machine Studio loading view, view model.
+ /// </summary>
+ /// <seealso cref="Tango.SharedUI.ViewModel" />
public class LoadingViewVM : ViewModel
{
private INotificationProvider _notificationProvider;
private INavigationManager _navigationManager;
private IStudioModuleLoader _studioModuleLoader;
+ /// <summary>
+ /// Initializes a new instance of the <see cref="LoadingViewVM"/> class.
+ /// </summary>
+ /// <param name="navigationManager">The navigation manager.</param>
+ /// <param name="studioModuleLoader">The studio module loader.</param>
+ /// <param name="notificationProvider">The notification provider.</param>
public LoadingViewVM(INavigationManager navigationManager, IStudioModuleLoader studioModuleLoader, INotificationProvider notificationProvider)
{
_navigationManager = navigationManager;
@@ -27,9 +37,12 @@ namespace Tango.MachineStudio.UI.ViewModels
Load();
}
+ /// <summary>
+ /// Load application modules.
+ /// </summary>
private void Load()
{
- StaThreadHelper.StartStaThread(() =>
+ ThreadsHelper.StartStaThread(() =>
{
try
{
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs
index 6fe90fa99..c5936eea8 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs
@@ -16,6 +16,10 @@ using Tango.SharedUI;
namespace Tango.MachineStudio.UI.ViewModels
{
+ /// <summary>
+ /// Represents the Machine Studio login view, view model.
+ /// </summary>
+ /// <seealso cref="Tango.SharedUI.ViewModel" />
public class LoginViewVM : ViewModel
{
private IAuthenticationProvider _authenticationProvider;
@@ -24,6 +28,9 @@ namespace Tango.MachineStudio.UI.ViewModels
private Rfc2898Cryptographer cryptographer;
private String _email;
+ /// <summary>
+ /// Gets or sets the email.
+ /// </summary>
[Required(ErrorMessage = "Email is required")]
[EmailAddress(ErrorMessage = "Please enter a valid email")]
public String Email
@@ -33,16 +40,26 @@ namespace Tango.MachineStudio.UI.ViewModels
}
private bool _rememberMe;
-
+ /// <summary>
+ /// Gets or sets a value indicating whether to remember the last user email and password.
+ /// </summary>
public bool RememberMe
{
get { return _rememberMe; }
set { _rememberMe = value; RaisePropertyChangedAuto(); }
}
-
+ /// <summary>
+ /// Gets or sets the login command.
+ /// </summary>
public RelayCommand<String> LoginCommand { get; set; }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="LoginViewVM"/> class.
+ /// </summary>
+ /// <param name="authenticationProvider">The authentication provider.</param>
+ /// <param name="navigationManager">The navigation manager.</param>
+ /// <param name="notificationProvider">The notification provider.</param>
public LoginViewVM(IAuthenticationProvider authenticationProvider, INavigationManager navigationManager, INotificationProvider notificationProvider)
{
_notificationProvider = notificationProvider;
@@ -55,6 +72,10 @@ namespace Tango.MachineStudio.UI.ViewModels
RememberMe = SettingsManager.Default.MachineStudio.RememberMe;
}
+ /// <summary>
+ /// Logins the requested user.
+ /// </summary>
+ /// <param name="password">The password.</param>
private void Login(String password)
{
if (Validate())
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineConnectionViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineConnectionViewVM.cs
index b8b888e86..23be8d274 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineConnectionViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineConnectionViewVM.cs
@@ -10,10 +10,16 @@ using Tango.SharedUI;
namespace Tango.MachineStudio.UI.ViewModels
{
+ /// <summary>
+ /// Represents the Machine Studio connection dialog, view model.
+ /// </summary>
+ /// <seealso cref="Tango.MachineStudio.Common.Notifications.DialogViewVM" />
public class MachineConnectionViewVM : DialogViewVM
{
private ExternalBridgeScanner _scanner;
-
+ /// <summary>
+ /// Gets or sets the machine scanner.
+ /// </summary>
public ExternalBridgeScanner Scanner
{
get { return _scanner; }
@@ -21,15 +27,24 @@ namespace Tango.MachineStudio.UI.ViewModels
}
private IExternalBridgeClient _selectedMachine;
-
+ /// <summary>
+ /// Gets or sets the selected machine.
+ /// </summary>
public IExternalBridgeClient SelectedMachine
{
get { return _selectedMachine; }
set { _selectedMachine = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); }
}
+ /// <summary>
+ /// Gets or sets the connect command.
+ /// </summary>
public RelayCommand ConnectCommand { get; set; }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="MachineConnectionViewVM"/> class.
+ /// </summary>
+ /// <param name="scanner">The scanner.</param>
public MachineConnectionViewVM(ExternalBridgeScanner scanner)
{
Scanner = scanner;
@@ -37,6 +52,9 @@ namespace Tango.MachineStudio.UI.ViewModels
Scanner.Start();
}
+ /// <summary>
+ /// Connect to the currently selected machine.
+ /// </summary>
private void Connect()
{
if (SelectedMachine != null)
@@ -45,10 +63,12 @@ namespace Tango.MachineStudio.UI.ViewModels
}
}
+ /// <summary>
+ /// Called when the dialog has been shown.
+ /// </summary>
public override void OnShow()
{
base.OnShow();
-
Scanner.AvailableMachines.Clear();
}
}
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineLoginViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineLoginViewVM.cs
index a6ee9ee2a..20c2e3afb 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineLoginViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineLoginViewVM.cs
@@ -8,20 +8,40 @@ using Tango.MachineStudio.Common.Notifications;
namespace Tango.MachineStudio.UI.ViewModels
{
+ /// <summary>
+ /// Represents the machine login dialog, view model.
+ /// </summary>
+ /// <seealso cref="Tango.MachineStudio.Common.Notifications.DialogViewVM" />
public class MachineLoginViewVM : DialogViewVM
{
+ /// <summary>
+ /// Gets or sets the machine password.
+ /// </summary>
public String Password { get; set; }
+ /// <summary>
+ /// Gets or sets the login command.
+ /// </summary>
public RelayCommand<String> LoginCommand { get; set; }
+ /// <summary>
+ /// Gets or sets the cancel command.
+ /// </summary>
public RelayCommand CancelCommand { get; set; }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="MachineLoginViewVM"/> class.
+ /// </summary>
public MachineLoginViewVM()
{
LoginCommand = new RelayCommand<string>(Login);
CancelCommand = new RelayCommand(Cancel);
}
+ /// <summary>
+ /// Invoked when user presses the login button.
+ /// </summary>
+ /// <param name="password">The password.</param>
private void Login(string password)
{
Password = password;
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs
index b21b23935..679ba5ff3 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs
@@ -1,4 +1,5 @@
-using System;
+using GalaSoft.MvvmLight.Ioc;
+using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
@@ -7,6 +8,7 @@ using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Tango.Core.Commands;
+using Tango.Integration.Services;
using Tango.Logging;
using Tango.MachineStudio.Common;
using Tango.MachineStudio.Common.Authentication;
@@ -22,12 +24,19 @@ using Tango.Transport.Adapters;
namespace Tango.MachineStudio.UI.ViewModels
{
+ /// <summary>
+ /// Represents the Machine Studio main view, view model.
+ /// </summary>
+ /// <seealso cref="Tango.SharedUI.ViewModel{Tango.MachineStudio.UI.SupervisingController.IMainView}" />
public class MainViewVM : ViewModel<IMainView>
{
private IStudioModule _currentModule;
private INavigationManager _navigation;
private bool _isDisconnecting;
+ /// <summary>
+ /// Gets or sets the current loaded module.
+ /// </summary>
public IStudioModule CurrentModule
{
get { return _currentModule; }
@@ -35,33 +44,54 @@ namespace Tango.MachineStudio.UI.ViewModels
}
private bool _isModuleLoaded;
-
+ /// <summary>
+ /// Gets or sets a value indicating whether any module is loaded at the moment.
+ /// </summary>
public bool IsModuleLoaded
{
get { return _isModuleLoaded; }
set { _isModuleLoaded = value; RaisePropertyChangedAuto(); }
}
-
private bool _isMenuOpened;
-
+ /// <summary>
+ /// Gets or sets a value indicating whether the side menu is opened.
+ /// </summary>
public bool IsMenuOpened
{
get { return _isMenuOpened; }
set { _isMenuOpened = value; RaisePropertyChangedAuto(); }
}
+ /// <summary>
+ /// Gets or sets the start module command.
+ /// </summary>
public RelayCommand<IStudioModule> StartModuleCommand { get; set; }
+ /// <summary>
+ /// Gets or sets the home command.
+ /// </summary>
public RelayCommand HomeCommand { get; set; }
+ /// <summary>
+ /// Gets or sets the connect command.
+ /// </summary>
public RelayCommand ConnectCommand { get; set; }
+ /// <summary>
+ /// Gets or sets the disconnect command.
+ /// </summary>
public RelayCommand DisconnectCommand { get; set; }
+ /// <summary>
+ /// Gets or sets the sign-out command.
+ /// </summary>
public RelayCommand SignoutCommand { get; set; }
private IAuthenticationProvider _authenticationProvider;
+ /// <summary>
+ /// Gets or sets the authentication provider.
+ /// </summary>
public IAuthenticationProvider AuthenticationProvider
{
get { return _authenticationProvider; }
@@ -69,7 +99,9 @@ namespace Tango.MachineStudio.UI.ViewModels
}
private IStudioModuleLoader _studioModuleLoader;
-
+ /// <summary>
+ /// Gets or sets the studio module loader.
+ /// </summary>
public IStudioModuleLoader StudioModuleLoader
{
get { return _studioModuleLoader; }
@@ -77,7 +109,9 @@ namespace Tango.MachineStudio.UI.ViewModels
}
private INotificationProvider _notificationProvider;
-
+ /// <summary>
+ /// Gets or sets the notification provider.
+ /// </summary>
public INotificationProvider NotificationProvider
{
get { return _notificationProvider; }
@@ -85,15 +119,24 @@ namespace Tango.MachineStudio.UI.ViewModels
}
private IStudioApplicationManager _applicationManager;
-
+ /// <summary>
+ /// Gets or sets the application manager.
+ /// </summary>
public IStudioApplicationManager ApplicationManager
{
get { return _applicationManager; }
set { _applicationManager = value; RaisePropertyChangedAuto(); }
}
-
-
+ /// <summary>
+ /// Initializes a new instance of the <see cref="MainViewVM"/> class.
+ /// </summary>
+ /// <param name="view">The view.</param>
+ /// <param name="authenticationProvider">The authentication provider.</param>
+ /// <param name="studioModuleLoader">The studio module loader.</param>
+ /// <param name="notificationProvider">The notification provider.</param>
+ /// <param name="applicationManager">The application manager.</param>
+ /// <param name="navigationManager">The navigation manager.</param>
public MainViewVM(
IMainView view,
IAuthenticationProvider authenticationProvider,
@@ -116,6 +159,9 @@ namespace Tango.MachineStudio.UI.ViewModels
DisconnectCommand = new RelayCommand(DisconnectFromMachine, (x) => ApplicationManager.IsMachineConnected && !_isDisconnecting);
}
+ /// <summary>
+ /// Disconnected from the current connected machine.
+ /// </summary>
private async void DisconnectFromMachine()
{
using (_notificationProvider.PushTaskItem("Disconnecting from machine..."))
@@ -129,6 +175,9 @@ namespace Tango.MachineStudio.UI.ViewModels
}
}
+ /// <summary>
+ /// Signs-out the current logged-in user.
+ /// </summary>
private void SignOut()
{
_authenticationProvider.Logout();
@@ -137,6 +186,9 @@ namespace Tango.MachineStudio.UI.ViewModels
IsMenuOpened = false;
}
+ /// <summary>
+ /// Opens the machine connection dialog to allow the user to scan and connect to remote machines view USB/TCP.
+ /// </summary>
private void ConnectToMachine()
{
_notificationProvider.ShowModalDialog<MachineConnectionViewVM>(async (x) =>
@@ -152,17 +204,17 @@ namespace Tango.MachineStudio.UI.ViewModels
}
}
- if (x.SelectedMachine.Type != Integration.Services.ExternalBridgeClientType.USB)
+ if (x.SelectedMachine.RequiresAuthentication)
{
_notificationProvider.ShowModalDialog<MachineLoginViewVM>(async (login) =>
{
- using (NotificationProvider.PushTaskItem("Connecting to machine " + x.SelectedMachine.SerialNumber + "..."))
+ using (NotificationProvider.PushTaskItem("Connecting to machine " + x.SelectedMachine.ToString() + "..."))
{
try
{
await x.SelectedMachine.Connect();
- var authenticated = await x.SelectedMachine.Authenticate(login.Password);
+ var authenticated = await x.SelectedMachine.As<IExternalBridgeSecureClient>().Authenticate(login.Password);
if (!authenticated)
{
_notificationProvider.ShowError("It seems like you are not authorized to access the selected machine.");
@@ -184,7 +236,7 @@ namespace Tango.MachineStudio.UI.ViewModels
}
else
{
- using (NotificationProvider.PushTaskItem("Connecting to machine " + x.SelectedMachine.Device + "..."))
+ using (NotificationProvider.PushTaskItem("Connecting to " + x.SelectedMachine.ToString() + "..."))
{
try
{
@@ -208,26 +260,44 @@ namespace Tango.MachineStudio.UI.ViewModels
});
}
+ /// <summary>
+ /// Navigates to the home screen.
+ /// </summary>
private void Home()
{
StartModule(null);
}
- private void StartModule(IStudioModule module)
+ /// <summary>
+ /// Starts the specified module.
+ /// </summary>
+ /// <param name="module">The module.</param>
+ internal void StartModule(IStudioModule module)
{
IsMenuOpened = false;
+ foreach (var m in StudioModuleLoader.AllModules.Where(x => x != module))
+ {
+ m.IsLoaded = false;
+ }
+
if (module != null)
{
CurrentModule = module;
+ CurrentModule.IsLoaded = true;
IsModuleLoaded = true;
+ View.NavigateToModule(module);
}
else
{
IsModuleLoaded = false;
+ View.NavigateToModule(null);
}
}
+ /// <summary>
+ /// Called when the <see cref="T:Tango.SharedUI.IView" /> is loaded and attached.
+ /// </summary>
protected override void OnViewAttached()
{
base.OnViewAttached();
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ShutdownViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ShutdownViewVM.cs
index c7a919a82..ed771f00a 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ShutdownViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ShutdownViewVM.cs
@@ -6,6 +6,9 @@ using System.Threading.Tasks;
namespace Tango.MachineStudio.UI.ViewModels
{
+ /// <summary>
+ /// Represents the Machine Studio shutdown view, view model.
+ /// </summary>
public class ShutdownViewVM
{
}