aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2018-08-23 14:52:22 +0300
committerShlomo Hecht <shlomo@twine-s.com>2018-08-23 14:52:22 +0300
commit4e81425d99f39b8edc10660d72566c6c1408810d (patch)
tree16e93ce35705611e02684c8e8d45b9ce40fbee3e /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels
parent09c780fd78c43291f7298f854770fbb47d014f02 (diff)
downloadTango-4e81425d99f39b8edc10660d72566c6c1408810d.tar.gz
Tango-4e81425d99f39b8edc10660d72566c6c1408810d.zip
changes on other computers
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels')
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs9
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs41
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineSerialViewVM.cs2
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs30
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs3
5 files changed, 57 insertions, 28 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 a468dc2e7..215f7afb5 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs
@@ -28,7 +28,7 @@ namespace Tango.MachineStudio.UI.ViewModels
/// Represents the Machine Studio loading view, view model.
/// </summary>
/// <seealso cref="Tango.SharedUI.ViewModel" />
- public class LoadingViewVM : StudioViewModelInternal
+ public class LoadingViewVM : StudioViewModel
{
private INotificationProvider _notificationProvider;
private TeamFoundationServiceExtendedClient _tfs;
@@ -141,7 +141,7 @@ namespace Tango.MachineStudio.UI.ViewModels
Status = "Loading, please wait...";
- ObservablesEntitiesAdapter.Instance.Initialize();
+ ObservablesStaticCollections.Instance.Initialize();
_eventLogger.Log(EventTypes.ApplicationStarted, "Application Started!");
@@ -172,5 +172,10 @@ namespace Tango.MachineStudio.UI.ViewModels
}
});
}
+
+ public override void OnApplicationReady()
+ {
+
+ }
}
}
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 f2a4f1143..a37879a5e 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs
@@ -51,6 +51,15 @@ namespace Tango.MachineStudio.UI.ViewModels
set { _password = value; RaisePropertyChangedAuto(); }
}
+ private bool _isLogging;
+ /// <summary>
+ /// Gets or sets a value indicating whether this instance is logging.
+ /// </summary>
+ public bool IsLogging
+ {
+ get { return _isLogging; }
+ set { _isLogging = value; RaisePropertyChangedAuto(); }
+ }
private bool _rememberMe;
/// <summary>
@@ -81,7 +90,7 @@ namespace Tango.MachineStudio.UI.ViewModels
_navigationManager = navigationManager;
_authenticationProvider = authenticationProvider;
_eventLogger = eventLogger;
- LoginCommand = new RelayCommand(Login);
+ LoginCommand = new RelayCommand(Login,() => !IsLogging);
cryptographer = new Rfc2898Cryptographer();
Email = _settings.LastLoginEmail;
@@ -100,26 +109,38 @@ namespace Tango.MachineStudio.UI.ViewModels
/// <summary>
/// Logins the requested user.
/// </summary>
- private void Login()
+ private async void Login()
{
if (Validate())
{
try
{
- _authenticationProvider.Login(Email, Password);
- _navigationManager.NavigateTo(NavigationView.MainView);
- _settings.LastLoginEmail = Email;
- _settings.RememberMe = RememberMe;
+ IsLogging = true;
+ InvalidateRelayCommands();
- _settings.LastLoginPassword = RememberMe ? cryptographer.Encrypt(Password) : null;
- _settings.Save();
+ await Task.Factory.StartNew(() =>
+ {
+ _authenticationProvider.Login(Email, Password);
+ _navigationManager.NavigateTo(NavigationView.MainView);
+ _settings.LastLoginEmail = Email;
+ _settings.RememberMe = RememberMe;
- _eventLogger.Log("User logged in");
+ _settings.LastLoginPassword = RememberMe ? cryptographer.Encrypt(Password) : null;
+ _settings.Save();
+
+ _eventLogger.Log("User logged in");
+ });
}
- catch
+ catch (Exception)
{
+
_notificationProvider.ShowError("Invalid credentials. Please try again.");
}
+ finally
+ {
+ IsLogging = false;
+ InvalidateRelayCommands();
+ }
}
}
}
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineSerialViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineSerialViewVM.cs
index 44cfc6788..db32fe623 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineSerialViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineSerialViewVM.cs
@@ -29,7 +29,7 @@ namespace Tango.MachineStudio.UI.ViewModels
var settings = SettingsManager.Default.GetOrCreate<MachineStudioSettings>();
- SelectedMachine = ObservablesEntitiesAdapter.Instance.Machines.SingleOrDefault(x => x.SerialNumber == settings.LastVirtualMachineSerialNumber);
+ SelectedMachine = ObservablesStaticCollections.Instance.Machines.SingleOrDefault(x => x.SerialNumber == settings.LastVirtualMachineSerialNumber);
}
}
}
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 f8320e1f2..f164d7f14 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs
@@ -10,6 +10,7 @@ using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
+using Tango.BL;
using Tango.BL.Entities;
using Tango.Core.Commands;
using Tango.Core.DI;
@@ -547,8 +548,13 @@ namespace Tango.MachineStudio.UI.ViewModels
{
try
{
- var configuration = ApplicationManager.ConnectedMachine.Machine.Configuration;
- await ApplicationManager.ConnectedMachine.UploadHardwareConfiguration(configuration.HardwareVersion, configuration);
+ using (ObservablesContext db = ObservablesContext.CreateDefault())
+ {
+ var config = db.Adapter.GetConfiguration(s => s.Guid == ApplicationManager.ConnectedMachine.Machine.ConfigurationGuid);
+ var hw = db.Adapter.GetHardwareVersionByMachine(ApplicationManager.ConnectedMachine.Machine.Guid);
+
+ await ApplicationManager.ConnectedMachine.UploadHardwareConfiguration(hw, config);
+ }
NotificationProvider.ShowInfo("Hardware configuration uploaded successfully.");
}
catch (Exception ex)
@@ -623,20 +629,19 @@ namespace Tango.MachineStudio.UI.ViewModels
{
LogManager.Log(String.Format("Starting module '{0}'...", module.Name));
- if (!(MainView.Self as MainView).TransitionControl.Elements.ToList().Exists(x => x.GetType() == module.MainViewType))
+ if (!(MainView.Self as MainView).NavigationControl.Elements.ToList().Exists(x => x.GetType() == module.MainViewType))
{
LogManager.Log("Module was not initialized. Initializing...");
FrameworkElement view = Activator.CreateInstance(module.MainViewType) as FrameworkElement;
NavigationControl.SetNavigationName(view, module.Name);
- (MainView.Self as MainView).TransitionControl.Elements.Add(view);
+ (MainView.Self as MainView).NavigationControl.Elements.Add(view);
}
}
foreach (var m in StudioModuleLoader.AllModules.Where(x => x != module && !x.InNewWindow))
{
m.IsLoaded = false;
- TangoIOC.Default.GetModuleViewModels(m).ToList().ForEach(x => x.OnNavigatedFrom());
}
if (module != null)
@@ -646,15 +651,13 @@ namespace Tango.MachineStudio.UI.ViewModels
IsModuleLoaded = true;
LogManager.Log(String.Format("Navigating to module '{0}'...", module.Name));
- (MainView.Self as MainView).TransitionControl.NavigateTo(module.Name);
-
- TangoIOC.Default.GetModuleViewModels(module).ToList().ForEach(x => x.OnNavigatedTo());
+ (MainView.Self as MainView).NavigationControl.NavigateTo(module.Name);
}
else
{
IsModuleLoaded = false;
LogManager.Log(String.Format("Navigating to Home..."));
- (MainView.Self as MainView).TransitionControl.NavigateTo("Home");
+ (MainView.Self as MainView).NavigationControl.NavigateTo("Home");
}
}
@@ -674,16 +677,16 @@ namespace Tango.MachineStudio.UI.ViewModels
LogManager.Log(String.Format("Starting module '{0}' in new window...", module.Name));
- if (!(MainView.Self as MainView).TransitionControl.Elements.ToList().Exists(x => x.GetType() == module.MainViewType))
+ if (!(MainView.Self as MainView).NavigationControl.Elements.ToList().Exists(x => x.GetType() == module.MainViewType))
{
LogManager.Log("Module was not initialized. Initializing...");
FrameworkElement v = Activator.CreateInstance(module.MainViewType) as FrameworkElement;
NavigationControl.SetNavigationName(v, module.Name);
- (MainView.Self as MainView).TransitionControl.Elements.Add(v);
+ (MainView.Self as MainView).NavigationControl.Elements.Add(v);
}
LogManager.Log("Detaching module view...");
- var view = (MainView.Self as MainView).TransitionControl.GetAndDetach(module.Name);
+ var view = (MainView.Self as MainView).NavigationControl.GetAndDetach(module.Name);
ModuleWindowVM vm = new ModuleWindowVM(module);
ModuleWindow window = new ModuleWindow(this, vm, view);
@@ -694,7 +697,6 @@ namespace Tango.MachineStudio.UI.ViewModels
window.grid.Children.Remove(view);
module.InNewWindow = false;
- TangoIOC.Default.GetModuleViewModels(module).ToList().ForEach(v => v.OnNavigatedFrom());
};
window.Owner = MainWindow.Instance;
@@ -702,8 +704,6 @@ namespace Tango.MachineStudio.UI.ViewModels
LogManager.Log("Opening new window...");
window.Show();
- TangoIOC.Default.GetModuleViewModels(module).ToList().ForEach(x => x.OnNavigatedTo());
-
(_applicationManager as DefaultStudioApplicationManager).RegisterOpenedWindow(window);
}
catch (Exception ex)
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs
index f2550c598..6dbc99591 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs
@@ -294,6 +294,9 @@ namespace Tango.MachineStudio.UI.ViewModels
}
}
+ //Copy new updater utility to app path.
+ File.Copy(Path.Combine(_newPackageTempFolder, "Tango.MachineStudio.Updater.exe"), Path.Combine(_appPath, "Tango.MachineStudio.Updater.exe"), true);
+
TangoIOC.Default.GetInstance<MainViewVM>().DisableCheckForUpdates = true;
Status = UpdateStatus.UpdateCompleted;
}