diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2018-10-24 09:58:14 +0300 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2018-10-24 09:58:14 +0300 |
| commit | 63fec02910da55db999402121559e20d9bc2ab56 (patch) | |
| tree | decc3dacd47b42a6fdf3efaa9aceb544e388ed0e /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels | |
| parent | 8e9c53625339326ef5477c4a9222ffbbf01b5d50 (diff) | |
| parent | 0f2a4cf2802adc0dc177656dc1f27967bb436a9f (diff) | |
| download | Tango-63fec02910da55db999402121559e20d9bc2ab56.tar.gz Tango-63fec02910da55db999402121559e20d9bc2ab56.zip | |
merge
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels')
2 files changed, 102 insertions, 31 deletions
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 51b7168ed..7737911e0 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineConnectionViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineConnectionViewVM.cs @@ -52,6 +52,8 @@ namespace Tango.MachineStudio.UI.ViewModels /// <param name="scanner">The scanner.</param> public MachineConnectionViewVM(ExternalBridgeScanner scanner) { + EnableDiagnostics = true; + UploadHardwareConfiguration = true; Scanner = scanner; ConnectCommand = new RelayCommand(Connect, (x) => SelectedMachine != null); } @@ -97,5 +99,36 @@ namespace Tango.MachineStudio.UI.ViewModels Scanner.AvailableMachines.Add(_emulator); Scanner.Start(); } + + private bool _enableDiagnostics; + /// <summary> + /// Gets or sets a value indicating whether to enable diagnostics after connection. + /// </summary> + public bool EnableDiagnostics + { + get { return _enableDiagnostics; } + set { _enableDiagnostics = value; RaisePropertyChangedAuto(); } + } + + private bool _uploadHardwareConfiguration; + /// <summary> + /// Gets or sets a value indicating whether to upload hardware configuration after connection. + /// </summary> + public bool UploadHardwareConfiguration + { + get { return _uploadHardwareConfiguration; } + set { _uploadHardwareConfiguration = value; RaisePropertyChangedAuto(); } + } + + private bool _enableKeepAlive; + /// <summary> + /// Gets or sets a value indicating whether to use the keep alive mechanism. + /// </summary> + public bool EnableKeepAlive + { + get { return _enableKeepAlive; } + set { _enableKeepAlive = value; RaisePropertyChangedAuto(); } + } + } } 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 b3d896d53..9b625a6ee 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -66,6 +66,13 @@ namespace Tango.MachineStudio.UI.ViewModels set { _currentModule = value; RaisePropertyChangedAuto(); } } + private bool _isApplicationReady; + public bool IsApplicationReady + { + get { return _isApplicationReady; } + set { _isApplicationReady = value; RaisePropertyChangedAuto(); } + } + private bool _isModuleLoaded; /// <summary> /// Gets or sets a value indicating whether any module is loaded at the moment. @@ -438,6 +445,11 @@ namespace Tango.MachineStudio.UI.ViewModels } } + x.SelectedMachine.EnableDiagnostics = x.EnableDiagnostics; + x.SelectedMachine.EnableEmbeddedDebugging = x.EnableDiagnostics; + x.SelectedMachine.EnableEventsNotification = x.EnableDiagnostics; + x.SelectedMachine.UseKeepAlive = x.EnableKeepAlive; + if (x.SelectedMachine.RequiresAuthentication) { _notificationProvider.ShowModalDialog<MachineLoginViewVM>(async (login) => @@ -446,11 +458,6 @@ namespace Tango.MachineStudio.UI.ViewModels { try { - if (x.SelectedMachine.EnableDiagnostics) - { - x.SelectedMachine.EnableEmbeddedDebugging = true; - } - await x.SelectedMachine.As<IExternalBridgeSecureClient>().Connect(new PMR.Integration.ExternalBridgeLoginRequest() { AppID = "Machine Studio", @@ -472,6 +479,11 @@ namespace Tango.MachineStudio.UI.ViewModels PostMessage(new MachineConnectionChangedMessage() { Machine = x.SelectedMachine }); _eventLogger.Log(String.Format("Successfully connected to machine {0} via TCP", x.SelectedMachine.SerialNumber)); + if (x.UploadHardwareConfiguration) + { + UploadHardwareConfiguration(); + } + } catch (ResponseErrorException ex) { @@ -500,11 +512,6 @@ namespace Tango.MachineStudio.UI.ViewModels { try { - if (x.SelectedMachine.EnableDiagnostics) - { - x.SelectedMachine.EnableEmbeddedDebugging = true; - } - await x.SelectedMachine.Connect(); x.SelectedMachine.SerialNumber = vm.SelectedMachine.SerialNumber; ApplicationManager.SetConnectedMachine(x.SelectedMachine); @@ -513,6 +520,11 @@ namespace Tango.MachineStudio.UI.ViewModels _eventLogger.Log(String.Format("Successfully connected to machine {0} via USB", x.SelectedMachine.SerialNumber)); _settings.LastVirtualMachineSerialNumber = vm.SelectedMachine.SerialNumber; _settings.Save(); + + if (x.UploadHardwareConfiguration) + { + UploadHardwareConfiguration(); + } } catch (Exception ex) { @@ -553,22 +565,7 @@ namespace Tango.MachineStudio.UI.ViewModels { using (NotificationProvider.PushTaskItem("Uploading hardware configuration...")) { - try - { - using (ObservablesContext db = ObservablesContext.CreateDefault()) - { - var config = db.Adapter.GetConfiguration(s => s.Guid == ApplicationManager.Machine.ConfigurationGuid); - var hw = db.Adapter.GetHardwareVersionByMachine(ApplicationManager.Machine.Guid); - - await ApplicationManager.ConnectedMachine.UploadHardwareConfiguration(hw, config); - } - NotificationProvider.ShowInfo("Hardware configuration uploaded successfully."); - } - catch (Exception ex) - { - LogManager.Log(ex, "Error uploading hardware configuration."); - NotificationProvider.ShowError("Error uploading hardware configuration." + Environment.NewLine + ex.Message); - } + UploadHardwareConfiguration(); } } } @@ -616,6 +613,26 @@ namespace Tango.MachineStudio.UI.ViewModels InvalidateRelayCommands(); } + private async void UploadHardwareConfiguration() + { + try + { + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + var config = db.Adapter.GetConfiguration(s => s.Guid == ApplicationManager.Machine.ConfigurationGuid); + var hw = db.Adapter.GetHardwareVersionByMachine(ApplicationManager.Machine.Guid); + + await ApplicationManager.ConnectedMachine.UploadHardwareConfiguration(hw, config); + } + NotificationProvider.ShowInfo("Hardware configuration uploaded successfully."); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error uploading hardware configuration."); + NotificationProvider.ShowError("Error uploading hardware configuration." + Environment.NewLine + ex.Message); + } + } + /// <summary> /// Navigates to the home screen. /// </summary> @@ -651,9 +668,10 @@ namespace Tango.MachineStudio.UI.ViewModels m.IsLoaded = false; } + CurrentModule = module; + if (module != null) { - CurrentModule = module; CurrentModule.IsLoaded = true; IsModuleLoaded = true; @@ -796,6 +814,7 @@ namespace Tango.MachineStudio.UI.ViewModels } catch (Exception ex) { + LogManager.Log(ex, "Error while trying to upload bug report."); _notificationProvider.ShowError("An error occurred while trying to create the issue." + Environment.NewLine + ex.Message); } } @@ -819,6 +838,7 @@ namespace Tango.MachineStudio.UI.ViewModels } catch (Exception ex) { + LogManager.Log(ex, $"Error while trying to approve resolved bug '{item.ID}'."); _notificationProvider.ShowError("An error occurred while trying to update the issue." + Environment.NewLine + ex.Message); } vm.IsAvailable = true; @@ -840,6 +860,7 @@ namespace Tango.MachineStudio.UI.ViewModels } catch (Exception ex) { + LogManager.Log(ex, $"Error while trying to decline resolved bug '{item.ID}'."); _notificationProvider.ShowError("An error occurred while trying to update the issue." + Environment.NewLine + ex.Message); } @@ -865,14 +886,31 @@ namespace Tango.MachineStudio.UI.ViewModels public override void OnApplicationReady() { - foreach (var item in SettingsManager.Default.GetOrCreate<MachineStudioSettings>().StudioModulesBounds) + if (!IsApplicationReady) { - var module = StudioModuleLoader.AllModules.SingleOrDefault(x => x.Name == item.Name); + var settings = SettingsManager.Default.GetOrCreate<MachineStudioSettings>(); + + foreach (var item in settings.StudioModulesBounds) + { + var module = StudioModuleLoader.AllModules.SingleOrDefault(x => x.Name == item.Name); + + if (module != null && !module.InNewWindow) + { + OpenModuleInWindow(module, item.Bounds, item.State); + } + } - if (module != null && !module.InNewWindow) + if (settings.LastMainModuleName != null) { - OpenModuleInWindow(module, item.Bounds, item.State); + var m = StudioModuleLoader.UserModules.SingleOrDefault(x => x.Name == settings.LastMainModuleName); + + if (m != null) + { + StartModule(m); + } } + + IsApplicationReady = true; } } } |
