diff options
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 | 22 |
1 files changed, 21 insertions, 1 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 b0315e633..336681801 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs @@ -33,7 +33,27 @@ namespace Tango.MachineStudio.UI.StudioApplication public IExternalBridgeClient ConnectedMachine { get { return _connectedMachine; } - set { _connectedMachine = value; RaisePropertyChangedAuto(); RaisePropertyChanged(nameof(IsMachineConnected)); } + 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 |
