diff options
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels')
4 files changed, 108 insertions, 31 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 new file mode 100644 index 000000000..72ab5aca9 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Tango.MachineStudio.Common.Modules; +using Tango.MachineStudio.Common.Navigation; +using Tango.SharedUI; + +namespace Tango.MachineStudio.UI.ViewModels +{ + public class LoadingViewVM : ViewModel + { + public LoadingViewVM(INavigationManager navigationManager, IStudioModuleLoader studioModuleLoader) + { + Task.Factory.StartNew(() => + { + Thread.Sleep(3000); + }).ContinueWith((x) => + { + + studioModuleLoader.LoadModules(); + navigationManager.NavigateTo(NavigationView.LoginView); + + }, TaskScheduler.FromCurrentSynchronizationContext()); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs new file mode 100644 index 000000000..67c116790 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using Tango.Core.Commands; +using Tango.MachineStudio.Common.Authentication; +using Tango.MachineStudio.Common.Navigation; +using Tango.SharedUI; + +namespace Tango.MachineStudio.UI.ViewModels +{ + public class LoginViewVM : ViewModel + { + private IAuthenticationProvider _authenticationProvider; + private INavigationManager _navigationManager; + + private String _email; + public String Email + { + get { return _email; } + set { _email = value; RaisePropertyChangedAuto(); } + } + + public RelayCommand<PasswordBox> LoginCommand { get; set; } + + public LoginViewVM(IAuthenticationProvider authenticationProvider, INavigationManager navigationManager) + { + _navigationManager = navigationManager; + _authenticationProvider = authenticationProvider; + LoginCommand = new RelayCommand<PasswordBox>(Login); + } + + private void Login(PasswordBox passwordBox) + { + String password = passwordBox.Password; + try + { + _authenticationProvider.Login(Email, password); + _navigationManager.NavigateTo(NavigationView.MainView); + } + catch (Exception ex) + { + MessageBox.Show("Failed"); + } + } + } +} 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 e0aff5be3..213d1a83d 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -8,6 +8,8 @@ using System.Text; using System.Threading.Tasks; using Tango.Core.Commands; using Tango.MachineStudio.Common; +using Tango.MachineStudio.Common.Authentication; +using Tango.MachineStudio.Common.Modules; using Tango.MachineStudio.UI.SupervisingController; using Tango.SharedUI; @@ -15,8 +17,6 @@ namespace Tango.MachineStudio.UI.ViewModels { public class MainViewVM : ViewModel<IMainView> { - public ObservableCollection<IStudioModule> Modules { get; set; } - private IStudioModule _currentModule; public IStudioModule CurrentModule @@ -37,43 +37,29 @@ namespace Tango.MachineStudio.UI.ViewModels public RelayCommand HomeCommand { get; set; } - public String Text { get; set; } - - public MainViewVM(IMainView view) : base(view) + private IAuthenticationProvider _authenticationProvider; + public IAuthenticationProvider AuthenticationProvider { - Modules = new ObservableCollection<IStudioModule>(); - - LoadModules(); - - Text = "Hi ROy"; + get { return _authenticationProvider; } + set { _authenticationProvider = value; RaisePropertyChangedAuto(); } + } - StartModuleCommand = new RelayCommand<IStudioModule>(StartModule); + private IStudioModuleLoader _studioModuleLoader; - HomeCommand = new RelayCommand(Home); + public IStudioModuleLoader StudioModuleLoader + { + get { return _studioModuleLoader; } + set { _studioModuleLoader = value; RaisePropertyChangedAuto(); } } - private void LoadModules() + public MainViewVM(IMainView view, IAuthenticationProvider authenticationProvider, IStudioModuleLoader studioModuleLoader) : base(view) { - string assemblyFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + AuthenticationProvider = authenticationProvider; + StudioModuleLoader = studioModuleLoader; - foreach (var file in Directory.GetFiles(assemblyFolder, "*.dll").Where(x => x.Contains("MachineStudio"))) - { - try - { - Assembly moduleAssembly = null; - moduleAssembly = Assembly.LoadFrom(file); + StartModuleCommand = new RelayCommand<IStudioModule>(StartModule); - if (moduleAssembly != null) - { - foreach (var moduleType in moduleAssembly.GetTypes().Where(x => !x.IsInterface && typeof(IStudioModule).IsAssignableFrom(x))) - { - var module = Activator.CreateInstance(moduleType) as IStudioModule; - Modules.Add(module); - } - } - } - catch { } - } + HomeCommand = new RelayCommand(Home); } private void Home() diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ShutdownViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ShutdownViewVM.cs new file mode 100644 index 000000000..c7a919a82 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ShutdownViewVM.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.UI.ViewModels +{ + public class ShutdownViewVM + { + } +} |
