blob: 2d8857329b10e26b02a9794ac1b688be22bd4084 (
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
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Core.Commands;
using Tango.Integration.ExternalBridge;
using Tango.PPC.Common;
namespace Tango.PPC.Technician.ViewModels
{
public class RemoteConnectionsViewVM : PPCViewModel
{
public RelayCommand DisconnectCommand { get; set; }
private ExternalBridgeReceiver _selectedReceiver;
public ExternalBridgeReceiver SelectedReceiver
{
get { return _selectedReceiver; }
set
{
if (value != null)
{
_selectedReceiver = value;
InvalidateRelayCommands();
}
}
}
public RemoteConnectionsViewVM()
{
DisconnectCommand = new RelayCommand(DisconnectReceiver, () => SelectedReceiver != null);
}
private async void DisconnectReceiver()
{
if (SelectedReceiver != null)
{
try
{
await Task.Factory.StartNew(() =>
{
SelectedReceiver.Disconnect().Wait();
});
}
catch (Exception ex)
{
LogManager.Log(ex, "Error disconnecting the specified receiver.");
}
finally
{
_selectedReceiver = null;
RaisePropertyChanged(nameof(SelectedReceiver));
InvalidateRelayCommands();
}
}
}
public override void OnApplicationStarted()
{
}
}
}
|