aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication
diff options
context:
space:
mode:
authorAvi Levkovich <avi@twine-s.com>2017-12-28 15:16:27 +0200
committerAvi Levkovich <avi@twine-s.com>2017-12-28 15:16:27 +0200
commitc056f991c0168f6449fac16c3b0cb165518c5e01 (patch)
treee5c69bb1f3e03029991efe15e930af80ff6712db /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication
parent15799210aab388996f86808e000940093306ca41 (diff)
parent2d3f4bfd4b265888933ad8a7e21e4dd80aa1eda2 (diff)
downloadTango-c056f991c0168f6449fac16c3b0cb165518c5e01.tar.gz
Tango-c056f991c0168f6449fac16c3b0cb165518c5e01.zip
MERGE.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication')
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs61
1 files changed, 55 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..336681801 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,60 @@ 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));
+
+ if (_connectedMachine != null)
+ {
+ _connectedMachine.StateChanged -= ConnectedMachine_StateChanged;
+ _connectedMachine.StateChanged += ConnectedMachine_StateChanged;
+ }
+ }
+ }
+
+ private void ConnectedMachine_StateChanged(object sender, Transport.TransportComponentState e)
+ {
+ if (e == Transport.TransportComponentState.Disconnected || e == Transport.TransportComponentState.Failed)
+ {
+ ConnectedMachine = null;
+ }
+
+ }
+
+ 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 +87,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);