Skip to content

Commit 1bcd415

Browse files
committed
Include the vendor's OUI code in the manage page
1 parent cad6d59 commit 1bcd415

File tree

3 files changed

+53
-9
lines changed

3 files changed

+53
-9
lines changed

src/Core/Models/IdentityLookup.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public IdentityLookup(DeviceIdentification deviceIdentification)
8181

8282
VendorName = "Unknown Vendor";
8383
Model = "Unknown Model";
84+
VendorCode = BitConverter.ToString(deviceIdentification.VendorCode.ToArray());
8485

8586
var foundDevice = ((IEnumerable) _lookup).Cast<dynamic>().FirstOrDefault(device =>
8687
device.VendorCode.ToString() == BitConverter.ToString(deviceIdentification.VendorCode.ToArray()));
@@ -104,6 +105,8 @@ public IdentityLookup(DeviceIdentification deviceIdentification)
104105
$"{deviceIdentification.FirmwareMajor}.{deviceIdentification.FirmwareMinor}.{deviceIdentification.FirmwareBuild}";
105106
}
106107

108+
[ObservableProperty] private string _vendorCode = string.Empty;
109+
107110
[ObservableProperty] private string _vendorName = string.Empty;
108111

109112
[ObservableProperty] private string _model = string.Empty;

src/UI/Windows/Views/Pages/ManagePage.xaml

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,34 @@
4949
TextAlignment="Center"
5050
TextWrapping="Wrap"
5151
Text="Device Information"/>
52-
<TextBlock
53-
FontSize="24"
54-
Margin="20 10 20 0"
55-
HorizontalAlignment="Center"
56-
TextAlignment="Center"
57-
TextWrapping="Wrap"
58-
Text="{Binding Path=ViewModel.IdentityLookup.VendorName}"
59-
d:Text="ABC Corporation"/>
52+
<StackPanel Orientation="Horizontal"
53+
Margin="20 0 20 0"
54+
HorizontalAlignment="Center">
55+
<TextBlock
56+
FontSize="24"
57+
TextAlignment="Left"
58+
TextWrapping="Wrap"
59+
Text="{Binding Path=ViewModel.IdentityLookup.VendorName}"
60+
d:Text="ABC Corporation"/>
61+
<TextBlock
62+
FontSize="24"
63+
TextAlignment="Left"
64+
TextWrapping="Wrap"
65+
Text=" ("/>
66+
<TextBlock
67+
FontSize="24"
68+
TextAlignment="Left"
69+
TextWrapping="Wrap">
70+
<Hyperlink Click="Hyperlink_OnClick">
71+
<Run Text="{Binding Path=ViewModel.IdentityLookup.VendorCode}"/>
72+
</Hyperlink>
73+
</TextBlock>
74+
<TextBlock
75+
FontSize="24"
76+
TextAlignment="Left"
77+
TextWrapping="Wrap"
78+
Text=")"/>
79+
</StackPanel>
6080
<TextBlock
6181
FontSize="20"
6282
Margin="20 0 20 0"

src/UI/Windows/Views/Pages/ManagePage.xaml.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
using System.Windows;
1+
using System.Net.Http;
2+
using System.Windows;
23
using System.Windows.Controls;
34
using System.Windows.Data;
5+
using System.Windows.Documents;
46
using OSDPBench.Core.Actions;
57
using OSDPBench.Core.Models;
68
using OSDPBench.Core.ViewModels.Pages;
@@ -159,4 +161,23 @@ private void SetReaderLedActionControl()
159161

160162
DeviceActionControl.Children.Add(actionControl);
161163
}
164+
165+
private async void Hyperlink_OnClick(object sender, RoutedEventArgs eventArgs)
166+
{
167+
string vendorCode = ((Run)((Hyperlink)sender).Inlines.FirstInline).Text;
168+
string url = $"https://macvendors.com/query/{vendorCode}";
169+
170+
using var client = new HttpClient();
171+
172+
try
173+
{
174+
string result = await client.GetStringAsync(url);
175+
176+
MessageBox.Show(result, "Vendor Information");
177+
}
178+
catch (Exception exception)
179+
{
180+
MessageBox.Show($"Unable to open OUI lookup: {exception.Message}");
181+
}
182+
}
162183
}

0 commit comments

Comments
 (0)