diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2019-03-12 18:36:19 +0200 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2019-03-12 18:36:19 +0200 |
| commit | ae18d2f719a92d55d0427273128975d34a4939e7 (patch) | |
| tree | 96aea7bfbf8ada0417b601b4507f2a2c4fd9563b /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineConnectionViewVM.cs | |
| parent | dfc268012d5c72e9a545b0d9f4ecfaf21758eb1c (diff) | |
| parent | 81d88a18ac614604befb041a81781ab33eb08067 (diff) | |
| download | Tango-ae18d2f719a92d55d0427273128975d34a4939e7.tar.gz Tango-ae18d2f719a92d55d0427273128975d34a4939e7.zip | |
merge
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineConnectionViewVM.cs')
| -rw-r--r-- | Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineConnectionViewVM.cs | 46 |
1 files changed, 28 insertions, 18 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 7737911e0..ce49d805e 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineConnectionViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineConnectionViewVM.cs @@ -19,18 +19,16 @@ namespace Tango.MachineStudio.UI.ViewModels /// <seealso cref="Tango.MachineStudio.Common.Notifications.DialogViewVM" /> public class MachineConnectionViewVM : DialogViewVM { - private EmulatorExternalBridge _emulator; - - private ExternalBridgeScanner _scanner; - /// <summary> - /// Gets or sets the machine scanner. - /// </summary> + private static ExternalBridgeScanner _scanner; public ExternalBridgeScanner Scanner { get { return _scanner; } set { _scanner = value; RaisePropertyChangedAuto(); } } + + private EmulatorExternalBridge _emulator; + private IExternalBridgeClient _selectedMachine; /// <summary> /// Gets or sets the selected machine. @@ -50,11 +48,15 @@ namespace Tango.MachineStudio.UI.ViewModels /// Initializes a new instance of the <see cref="MachineConnectionViewVM"/> class. /// </summary> /// <param name="scanner">The scanner.</param> - public MachineConnectionViewVM(ExternalBridgeScanner scanner) + public MachineConnectionViewVM() { + if (_scanner == null) + { + _scanner = new ExternalBridgeScanner(); + } + EnableDiagnostics = true; UploadHardwareConfiguration = true; - Scanner = scanner; ConnectCommand = new RelayCommand(Connect, (x) => SelectedMachine != null); } @@ -65,7 +67,7 @@ namespace Tango.MachineStudio.UI.ViewModels { if (SelectedMachine != null) { - Scanner.Stop(); + _scanner.Stop(); Accept(); } } @@ -75,7 +77,7 @@ namespace Tango.MachineStudio.UI.ViewModels /// </summary> protected override void Cancel() { - Scanner.Stop(); + _scanner.Stop(); base.Cancel(); } @@ -85,19 +87,27 @@ namespace Tango.MachineStudio.UI.ViewModels public override void OnShow() { base.OnShow(); - Scanner.AvailableMachines.Clear(); - if (SettingsManager.Default.GetOrCreate<MachineStudioSettings>().UseExternalBridgeEmulator) + try { - if (_emulator != null) + _scanner.AvailableMachines.Clear(); + + if (SettingsManager.Default.GetOrCreate<MachineStudioSettings>().UseExternalBridgeEmulator) { - _emulator.Disconnect(); + if (_emulator != null) + { + _emulator.Disconnect(); + } + _emulator = new EmulatorExternalBridge(); } - _emulator = new EmulatorExternalBridge(); - } - Scanner.AvailableMachines.Add(_emulator); - Scanner.Start(); + _scanner.AvailableMachines.Add(_emulator); + _scanner.Start(); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error starting external bridge scanner."); + } } private bool _enableDiagnostics; |
