diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2017-12-24 12:59:22 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2017-12-24 12:59:22 +0200 |
| commit | 902f5d6d68ed52d92c089a65823ff49599cd3014 (patch) | |
| tree | 4dc34d4286eade21d7ae63bf118da8a37187b94f /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs | |
| parent | 6ceea3e717c6a365ef05c9f3bfd6ee62145a9a5e (diff) | |
| parent | 53db041e636bb3802dbe3cb911de6ef6ef41446c (diff) | |
| download | Tango-902f5d6d68ed52d92c089a65823ff49599cd3014.tar.gz Tango-902f5d6d68ed52d92c089a65823ff49599cd3014.zip | |
MERGE!
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs')
| -rw-r--r-- | Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs index b95a74a3e..b0315e633 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs @@ -11,10 +11,13 @@ using Tango.MachineStudio.Common.Navigation; using GalaSoft.MvvmLight.Ioc; using System.Reflection; using System.Collections; +using Tango.Integration.Services; +using Tango.Core; +using Tango.Logging; namespace Tango.MachineStudio.UI.StudioApplication { - public class DefaultStudioApplicationManager : IStudioApplicationManager + public class DefaultStudioApplicationManager : ExtendedObject, IStudioApplicationManager { private INavigationManager _navigationManager; @@ -23,12 +26,40 @@ namespace Tango.MachineStudio.UI.StudioApplication _navigationManager = navigationManager; } + public bool IsShuttingDown { get; private set; } + + private IExternalBridgeClient _connectedMachine; + + public IExternalBridgeClient ConnectedMachine + { + get { return _connectedMachine; } + set { _connectedMachine = value; RaisePropertyChangedAuto(); RaisePropertyChanged(nameof(IsMachineConnected)); } + } + + public bool IsMachineConnected + { + get { return ConnectedMachine != null; } + } + public async void ShutDown() { - _navigationManager.NavigateTo(NavigationView.ShutdownView); + if (IsShuttingDown) return; + + IsShuttingDown = true; await Task.Factory.StartNew(async () => { + try + { + if (ConnectedMachine != null) + { + ConnectedMachine.Disconnect().Wait(); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error disconnecting from machine."); + } //Do Shutdown Procedures... foreach (var vm in ServiceLocator.Current.GetAllInstancesByBase<IShutdownRequestBlocker>()) @@ -36,14 +67,12 @@ namespace Tango.MachineStudio.UI.StudioApplication var result = await vm.OnShutdownRequest(); if (!result) { - ThreadsHelper.InvokeUI(() => - { - _navigationManager.NavigateTo(NavigationView.MainView); - }); + IsShuttingDown = false; return; } } + _navigationManager.NavigateTo(NavigationView.ShutdownView); Thread.Sleep(3000); Environment.Exit(0); |
