Minor changes
This commit is contained in:
parent
af503dc1bb
commit
56fa20b86f
@ -109,14 +109,11 @@ public partial class DiscoveredDeviceViewModel : ObservableObject, IDisposable
|
||||
public async Task GetFurtherInformationAsync()
|
||||
{
|
||||
_ssdpDevice = await _device.GetDeviceInfo().ConfigureAwait(false);
|
||||
FriendlyName = _ssdpDevice.ModelDescription;
|
||||
FriendlyName = _ssdpDevice.FriendlyName;
|
||||
Icon = _ssdpDevice.Icons.MinBy(x => x.Height);
|
||||
PresentationUrl = _ssdpDevice.PresentationUrl;
|
||||
ModelNumber = _ssdpDevice.ModelNumber;
|
||||
Version = _ssdpDevice.SerialNumber?.Split(',').Last() ?? new Version().ToString();
|
||||
using var client = new HttpClient();
|
||||
var response = await client.GetAsync(_ssdpDevice.ModelUrl).ConfigureAwait(false);
|
||||
ResponseHeader = await response.Content.ReadAsStringAsync();
|
||||
}
|
||||
|
||||
private string EvaluateHostName() => Dns.GetHostEntry(IpAddress).HostName;
|
||||
@ -129,6 +126,8 @@ public partial class DiscoveredDeviceViewModel : ObservableObject, IDisposable
|
||||
|
||||
private string EvaluateMacAddress()
|
||||
{
|
||||
if (!ArpLookup.Arp.IsSupported)
|
||||
return "not supported";
|
||||
var lookupResult = ArpLookup.Arp.Lookup(IpAddress);
|
||||
return lookupResult is null ? "Unknown" : string.Join(":", lookupResult.GetAddressBytes().Select(b => $"{b:x2}"));
|
||||
}
|
||||
|
@ -1,16 +1,16 @@
|
||||
<Window
|
||||
x:Class="SddpViewer.MainWindow"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:sddpViewer="clr-namespace:SddpViewer"
|
||||
Title="SDDP viewer"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
mc:Ignorable="d"
|
||||
x:Class="SddpViewer.MainWindow"
|
||||
x:CompileBindings="True"
|
||||
x:DataType="sddpViewer:MainWindowViewModel"
|
||||
mc:Ignorable="d">
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:sddpViewer="clr-namespace:SddpViewer"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Window.DataContext>
|
||||
<sddpViewer:MainWindowViewModel />
|
||||
</Window.DataContext>
|
||||
@ -18,8 +18,8 @@
|
||||
<StackPanel Margin="10" Spacing="5">
|
||||
<TextBlock Text="Device IP Address" />
|
||||
<ComboBox
|
||||
HorizontalAlignment="Stretch"
|
||||
DisplayMemberBinding="{Binding DisplayName}"
|
||||
HorizontalAlignment="Stretch"
|
||||
ItemsSource="{Binding NetworkAdapters}"
|
||||
SelectedItem="{Binding SelectedNetworkAdapter}" />
|
||||
<TextBlock Text="Notification filter" />
|
||||
@ -30,7 +30,7 @@
|
||||
<Button Command="{Binding ResearchCommand}" Content="Search more" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<Grid Grid.Row="0" Grid.Column="1">
|
||||
<Grid Grid.Column="1" Grid.Row="0">
|
||||
<TextBox
|
||||
IsReadOnly="True"
|
||||
Text="{ReflectionBinding SelectedItem.ResponseHeader,
|
||||
@ -38,23 +38,25 @@
|
||||
TextWrapping="Wrap" />
|
||||
</Grid>
|
||||
<DataGrid
|
||||
x:Name="DevicesDataGrid"
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
AutoGenerateColumns="False"
|
||||
FrozenColumnCount="2"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
Grid.Row="1"
|
||||
IsReadOnly="True"
|
||||
ItemsSource="{Binding SddpDevices}">
|
||||
ItemsSource="{Binding SddpDevices}"
|
||||
x:Name="DevicesDataGrid">
|
||||
<DataGrid.Columns>
|
||||
<DataGridCheckBoxColumn
|
||||
Width="50"
|
||||
Binding="{Binding Online}"
|
||||
IsReadOnly="True" />
|
||||
IsReadOnly="True"
|
||||
Width="50" />
|
||||
<DataGridTextColumn Binding="{Binding FriendlyName}" Header="Name" />
|
||||
<DataGridTextColumn Binding="{Binding Usn}" Header="Usn" />
|
||||
<DataGridTextColumn Binding="{Binding DescriptionLocation}" Header="Location" />
|
||||
<!-- <DataGridTextColumn Binding="{Binding Usn}" Header="Usn" /> -->
|
||||
<DataGridTextColumn
|
||||
Binding="{Binding IpAddress}" CanUserSort="True"
|
||||
Binding="{Binding IpAddress}"
|
||||
CanUserSort="True"
|
||||
CustomSortComparer="{StaticResource IpAddressComparer}"
|
||||
Header="Ip address" />
|
||||
<DataGridTextColumn Binding="{Binding HostName}" Header="Hostname" />
|
||||
|
@ -21,35 +21,26 @@ public sealed partial class MainWindowViewModel : ObservableObject, IDisposable
|
||||
|
||||
private static async void SddpDevices_OnCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
switch (e.Action)
|
||||
{
|
||||
switch (e.Action)
|
||||
{
|
||||
case NotifyCollectionChangedAction.Add:
|
||||
await AddAction(e.NewItems);
|
||||
break;
|
||||
case NotifyCollectionChangedAction.Remove:
|
||||
RemoveAction(e.OldItems);
|
||||
break;
|
||||
case NotifyCollectionChangedAction.Replace:
|
||||
RemoveAction(e.OldItems);
|
||||
await AddAction(e.NewItems);
|
||||
break;
|
||||
case NotifyCollectionChangedAction.Reset:
|
||||
RemoveAction(sender as ObservableCollection<DiscoveredDeviceViewModel>);
|
||||
break;
|
||||
case NotifyCollectionChangedAction.Move:
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
case NotifyCollectionChangedAction.Add:
|
||||
await AddAction(e.NewItems);
|
||||
break;
|
||||
case NotifyCollectionChangedAction.Remove:
|
||||
RemoveAction(e.OldItems);
|
||||
break;
|
||||
case NotifyCollectionChangedAction.Replace:
|
||||
RemoveAction(e.OldItems);
|
||||
await AddAction(e.NewItems);
|
||||
break;
|
||||
case NotifyCollectionChangedAction.Reset:
|
||||
RemoveAction(sender as ObservableCollection<DiscoveredDeviceViewModel>);
|
||||
break;
|
||||
case NotifyCollectionChangedAction.Move:
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw; // TODO handle exception
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
private static void RemoveAction(IList? list)
|
||||
@ -119,6 +110,7 @@ public sealed partial class MainWindowViewModel : ObservableObject, IDisposable
|
||||
_locator.StopListeningForNotifications();
|
||||
_locator.DeviceAvailable -= LocatorOnDeviceAvailable;
|
||||
_locator.DeviceUnavailable -= LocatorOnDeviceUnavailable;
|
||||
_locator.Dispose();
|
||||
}
|
||||
|
||||
await StartListening(async locator =>
|
||||
|
Loading…
x
Reference in New Issue
Block a user