blob: f0571475f1e464850283a003ef43ad48380a220d (
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
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Tango.FSE.UI.Panes
{
/// <summary>
/// Interaction logic for MachineConnectionPane.xaml
/// </summary>
public partial class MachineConnectionPane : UserControl
{
private List<ListBox> _lists;
private bool _blockSelection;
public MachineConnectionPane()
{
InitializeComponent();
_lists = new List<ListBox>();
_lists.Add(listEmulator);
_lists.Add(listUsb);
_lists.Add(listWifi);
_lists.Add(listSignalR);
_lists.ForEach(x => x.SelectionChanged += OnSelectionChanged);
}
private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (!_blockSelection && (sender as ListBox).SelectedItem != null)
{
_blockSelection = true;
foreach (var list in _lists.Where(x => x != sender))
{
list.SelectedIndex = -1;
}
ApplySelectedItem((sender as ListBox).SelectedItem);
_blockSelection = false;
}
}
private void ApplySelectedItem(object item)
{
var vm = DataContext as MachineConnectionPaneVM;
if (vm != null)
{
vm.SelectedMachine = item as Integration.ExternalBridge.IExternalBridgeClient;
}
}
private void ListBox_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e)
{
var vm = DataContext as MachineConnectionPaneVM;
if (vm != null)
{
vm.SelectedMachine = (sender as ListBox).SelectedItem as Integration.ExternalBridge.IExternalBridgeClient;
vm.ConnectToMachine();
}
}
}
}
|