/
SelectInterfaceDialog.xaml.cs
58 lines (48 loc) · 1.94 KB
/
SelectInterfaceDialog.xaml.cs
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
using System.Collections.Generic;
using System.Windows;
using PcapDotNet.Core;
using PcapDotNet.Core.Extensions;
namespace TrafficAnalyzer
{
/// <summary>
/// Interaction logic for SelectInterfaceDialog.xaml
/// </summary>
public partial class SelectInterfaceDialog
{
private IList<LivePacketDevice> _devices;
public IPacketDevice SelectedDevice;
public SelectInterfaceDialog()
{
InitializeComponent();
}
private void WindowLoaded(object sender, RoutedEventArgs e)
{
_devices = LivePacketDevice.AllLocalMachine;
interfacesComboBox.DataContext = _devices;
if (_devices.Count == 0)
{
MessageBox.Show("No capture interface available", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
private void SelectButtonClick(object sender, RoutedEventArgs e)
{
SelectedDevice = (IPacketDevice) interfacesComboBox.SelectedItem;
DialogResult = true;
Close();
}
private void CancelButtonClick(object sender, RoutedEventArgs e)
{
Close();
}
private void InterfacesComboBoxSelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
MACAddressLabel.Content =
string.Format("Mac Address : {0}",((LivePacketDevice) interfacesComboBox.SelectedItem).GetMacAddress());
OperationStatusLabel.Content =
string.Format("Operational Status : {0}",
((LivePacketDevice) interfacesComboBox.SelectedItem).GetNetworkInterface().OperationalStatus);
InterfaceTypeLabel.Content = string.Format("Interface Type : {0}",
((LivePacketDevice) interfacesComboBox.SelectedItem).GetNetworkInterface().NetworkInterfaceType );
}
}
}