blob: 7737911e02a5bd48f61f87328c1b7461ed09393c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Core.Commands;
using Tango.Emulations.ExternalBridge;
using Tango.Integration.ExternalBridge;
using Tango.MachineStudio.Common;
using Tango.MachineStudio.Common.Notifications;
using Tango.Settings;
using Tango.SharedUI;
namespace Tango.MachineStudio.UI.ViewModels
{
/// <summary>
/// Represents the Machine Studio connection dialog, view model.
/// </summary>
/// <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>
public ExternalBridgeScanner Scanner
{
get { return _scanner; }
set { _scanner = value; RaisePropertyChangedAuto(); }
}
private IExternalBridgeClient _selectedMachine;
/// <summary>
/// Gets or sets the selected machine.
/// </summary>
public IExternalBridgeClient SelectedMachine
{
get { return _selectedMachine; }
set { _selectedMachine = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); }
}
/// <summary>
/// Gets or sets the connect command.
/// </summary>
public RelayCommand ConnectCommand { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="MachineConnectionViewVM"/> class.
/// </summary>
/// <param name="scanner">The scanner.</param>
public MachineConnectionViewVM(ExternalBridgeScanner scanner)
{
EnableDiagnostics = true;
UploadHardwareConfiguration = true;
Scanner = scanner;
ConnectCommand = new RelayCommand(Connect, (x) => SelectedMachine != null);
}
/// <summary>
/// Connect to the currently selected machine.
/// </summary>
private void Connect()
{
if (SelectedMachine != null)
{
Scanner.Stop();
Accept();
}
}
/// <summary>
/// Invokes the <see cref="E:Tango.SharedUI.DialogViewVM.Canceled" /> event.
/// </summary>
protected override void Cancel()
{
Scanner.Stop();
base.Cancel();
}
/// <summary>
/// Called when the dialog has been shown.
/// </summary>
public override void OnShow()
{
base.OnShow();
Scanner.AvailableMachines.Clear();
if (SettingsManager.Default.GetOrCreate<MachineStudioSettings>().UseExternalBridgeEmulator)
{
if (_emulator != null)
{
_emulator.Disconnect();
}
_emulator = new EmulatorExternalBridge();
}
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(); }
}
}
}
|