show all adapter details in full-width dropdown
Display FriendlyName — Description — MAC for each device. Dropdown spans full form width; layout simplified to vertical stack.
This commit is contained in:
@@ -26,26 +26,37 @@ public partial class MainForm : Form
|
|||||||
_sessions.ManifestReceived += entries => this.Invoke(() => PopulateList(entries));
|
_sessions.ManifestReceived += entries => this.Invoke(() => PopulateList(entries));
|
||||||
|
|
||||||
foreach (var d in TunnelLink.ListDevices())
|
foreach (var d in TunnelLink.ListDevices())
|
||||||
_deviceBox.Items.Add($"{d.Name} — {d.Interface?.FriendlyName ?? d.Interface?.Description}");
|
{
|
||||||
|
var friendly = d.Interface?.FriendlyName ?? "";
|
||||||
|
var desc = d.Interface?.Description ?? "";
|
||||||
|
var mac = d.MacAddress?.GetAddressBytes();
|
||||||
|
var macStr = mac != null
|
||||||
|
? string.Join(":", mac.Select(b => b.ToString("X2")))
|
||||||
|
: "??-??-??-??-??-??";
|
||||||
|
_deviceBox.Items.Add($"{friendly} — {desc} — {macStr}");
|
||||||
|
}
|
||||||
if (_deviceBox.Items.Count > 0)
|
if (_deviceBox.Items.Count > 0)
|
||||||
_deviceBox.SelectedIndex = 0;
|
_deviceBox.SelectedIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitializeComponents()
|
void InitializeComponents()
|
||||||
{
|
{
|
||||||
Controls.Add(new Label { Text = "Adapter:", Left = 12, Top = 12, AutoSize = true });
|
const int pad = 12;
|
||||||
|
|
||||||
_deviceBox.Left = 70; _deviceBox.Top = 9;
|
_deviceBox.Left = pad; _deviceBox.Top = 12;
|
||||||
_deviceBox.Width = 330; _deviceBox.DropDownStyle = ComboBoxStyle.DropDownList;
|
_deviceBox.Width = ClientSize.Width - pad * 2;
|
||||||
|
_deviceBox.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
Controls.Add(_deviceBox);
|
Controls.Add(_deviceBox);
|
||||||
|
|
||||||
_discoverBtn.Text = "Discover";
|
_discoverBtn.Text = "Discover";
|
||||||
_discoverBtn.Left = 410; _discoverBtn.Top = 8; _discoverBtn.Width = 80;
|
_discoverBtn.Left = pad; _discoverBtn.Top = _deviceBox.Bottom + 8;
|
||||||
|
_discoverBtn.Width = 80;
|
||||||
_discoverBtn.Click += OnDiscover;
|
_discoverBtn.Click += OnDiscover;
|
||||||
Controls.Add(_discoverBtn);
|
Controls.Add(_discoverBtn);
|
||||||
|
|
||||||
_listView.Left = 12; _listView.Top = 40;
|
_listView.Left = pad; _listView.Top = _discoverBtn.Bottom + 8;
|
||||||
_listView.Width = 478; _listView.Height = 250;
|
_listView.Width = ClientSize.Width - pad * 2;
|
||||||
|
_listView.Height = 220;
|
||||||
_listView.View = View.Details;
|
_listView.View = View.Details;
|
||||||
_listView.FullRowSelect = true;
|
_listView.FullRowSelect = true;
|
||||||
_listView.CheckBoxes = true;
|
_listView.CheckBoxes = true;
|
||||||
@@ -57,8 +68,9 @@ public partial class MainForm : Form
|
|||||||
_listView.ItemChecked += OnItemChecked;
|
_listView.ItemChecked += OnItemChecked;
|
||||||
Controls.Add(_listView);
|
Controls.Add(_listView);
|
||||||
|
|
||||||
_statusLabel.Left = 12; _statusLabel.Top = 304;
|
_statusLabel.Left = pad; _statusLabel.Top = _listView.Bottom + 8;
|
||||||
_statusLabel.Width = 478; _statusLabel.AutoEllipsis = true;
|
_statusLabel.Width = ClientSize.Width - pad * 2;
|
||||||
|
_statusLabel.AutoEllipsis = true;
|
||||||
Controls.Add(_statusLabel);
|
Controls.Add(_statusLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user