diff --git a/src/App.axaml.cs b/src/App.axaml.cs
index ec292cc..707af5c 100644
--- a/src/App.axaml.cs
+++ b/src/App.axaml.cs
@@ -1,4 +1,3 @@
-using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
diff --git a/src/DiscoveredDeviceViewModel.cs b/src/DiscoveredDeviceViewModel.cs
index 2d33d62..2d694fe 100644
--- a/src/DiscoveredDeviceViewModel.cs
+++ b/src/DiscoveredDeviceViewModel.cs
@@ -1,69 +1,75 @@
-using System.Drawing;
-using System.Linq;
+namespace SddpViewer;
-namespace SddpViewer
+using System;
+using System.Threading.Tasks;
+
+using CommunityToolkit.Mvvm.ComponentModel;
+
+using Rssdp;
+
+public partial class DiscoveredDeviceViewModel : ObservableObject
{
- using System;
- using System.Threading.Tasks;
+ private readonly DiscoveredSsdpDevice _device;
- using CommunityToolkit.Mvvm.ComponentModel;
-
- using Rssdp;
-
- public partial class DiscoveredDeviceViewModel : ObservableObject
+ public DiscoveredDeviceViewModel(DiscoveredSsdpDevice device)
{
- private readonly DiscoveredSsdpDevice device;
+ _device = device;
+ ResponseHeader = GetResponseHeader();
+ }
- public DiscoveredDeviceViewModel(DiscoveredSsdpDevice device)
- {
- this.device = device;
- }
+ private string GetResponseHeader()
+ {
+ return string.Join(
+ "," + Environment.NewLine,
+ _device.ResponseHeaders.Select(x => $"{{{x.Key} : {string.Join(";", x.Value)}}}")
+ );
+ }
- ///
- /// Sets or returns the type of notification, being either a uuid, device type, service type or upnp:rootdevice.
- ///
- public string NotificationType => this.device.NotificationType;
+ public string ResponseHeader { get; }
- ///
- /// Sets or returns the universal service name (USN) of the device.
- ///
- public string Usn => this.device.Usn;
+ ///
+ /// Sets or returns the type of notification, being either a uuid, device type, service type or upnp:rootdevice.
+ ///
+ public string NotificationType => _device.NotificationType;
- ///
- /// Sets or returns a URL pointing to the device description document for this device.
- ///
- public Uri DescriptionLocation => this.device.DescriptionLocation;
+ ///
+ /// Sets or returns the universal service name (USN) of the device.
+ ///
+ public string Usn => _device.Usn;
- ///
- /// Sets or returns the length of time this information is valid for (from the time).
- ///
- public TimeSpan CacheLifetime => this.device.CacheLifetime;
+ ///
+ /// Sets or returns a URL pointing to the device description document for this device.
+ ///
+ public Uri DescriptionLocation => _device.DescriptionLocation;
- ///
- /// Sets or returns the date and time this information was received.
- ///
- public DateTimeOffset AsAt => this.device.AsAt;
+ ///
+ /// Sets or returns the length of time this information is valid for (from the time).
+ ///
+ public TimeSpan CacheLifetime => _device.CacheLifetime;
- [ObservableProperty]
- private string _friendlyName = "";
+ ///
+ /// Sets or returns the date and time this information was received.
+ ///
+ public DateTimeOffset AsAt => _device.AsAt;
- [ObservableProperty]
- private SsdpDeviceIcon? _icon;
+ [ObservableProperty]
+ private string _friendlyName = "";
- [ObservableProperty]
- private Uri? _presentationUrl;
+ [ObservableProperty]
+ private SsdpDeviceIcon? _icon;
- [ObservableProperty]
- private string _modelNumber;
+ [ObservableProperty]
+ private Uri? _presentationUrl;
- public async Task GetFurtherInformationAsync()
- {
- var ssdpDevice = await this.device.GetDeviceInfo().ConfigureAwait(false);
- FriendlyName = ssdpDevice.FriendlyName;
- Icon = ssdpDevice.Icons.MinBy(x=> x.Height);
- PresentationUrl = ssdpDevice.PresentationUrl;
- ModelNumber = ssdpDevice.ModelNumber;
+ [ObservableProperty]
+ private string _modelNumber = "";
- }
+ public async Task GetFurtherInformationAsync()
+ {
+ var ssdpDevice = await _device.GetDeviceInfo().ConfigureAwait(false);
+ FriendlyName = ssdpDevice.FriendlyName;
+ Icon = ssdpDevice.Icons.MinBy(x => x.Height);
+ PresentationUrl = ssdpDevice.PresentationUrl;
+ ModelNumber = ssdpDevice.ModelNumber;
}
}
diff --git a/src/GlobalUsings.cs b/src/GlobalUsings.cs
new file mode 100644
index 0000000..302ce28
--- /dev/null
+++ b/src/GlobalUsings.cs
@@ -0,0 +1,3 @@
+// Global using directives
+
+global using Avalonia;
diff --git a/src/MainWindow.axaml b/src/MainWindow.axaml
index 7a6073b..c9ad6bf 100644
--- a/src/MainWindow.axaml
+++ b/src/MainWindow.axaml
@@ -1,25 +1,25 @@
+ Title="SDDP viewer"
+ d:DesignHeight="450"
+ d:DesignWidth="800"
+ x:CompileBindings="True"
+ x:DataType="sddpViewer:MainWindowViewModel"
+ mc:Ignorable="d">
-
+
@@ -27,10 +27,22 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/MainWindowViewModel.cs b/src/MainWindowViewModel.cs
index 6cdbeec..cad0bd2 100644
--- a/src/MainWindowViewModel.cs
+++ b/src/MainWindowViewModel.cs
@@ -1,11 +1,7 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
+namespace SddpViewer;
using Avalonia.Threading;
-namespace SddpViewer;
-
using System.Collections.ObjectModel;
using System.Threading.Tasks;
@@ -14,7 +10,7 @@ using CommunityToolkit.Mvvm.Input;
using Rssdp;
-public partial class MainWindowViewModel : ObservableObject
+public sealed partial class MainWindowViewModel : ObservableObject, IDisposable
{
public MainWindowViewModel()
{
@@ -24,9 +20,11 @@ public partial class MainWindowViewModel : ObservableObject
private void LocatorOnDeviceUnavailable(object? sender, DeviceUnavailableEventArgs e)
{
- var existingDevice = SddpDevices.FirstOrDefault(x =>
- string.Equals(x.Usn, e.DiscoveredDevice.Usn, StringComparison.Ordinal));
- if(existingDevice is null) return;
+ var existingDevice = SddpDevices.FirstOrDefault(
+ x => string.Equals(x.Usn, e.DiscoveredDevice.Usn, StringComparison.Ordinal)
+ );
+ if (existingDevice is null)
+ return;
Dispatcher.UIThread.Invoke(() => SddpDevices.Remove(existingDevice));
}
@@ -79,4 +77,9 @@ public partial class MainWindowViewModel : ObservableObject
_locator.StartListeningForNotifications();
await _locator.SearchAsync();
}
+
+ public void Dispose()
+ {
+ _locator?.Dispose();
+ }
}
diff --git a/src/NetworkAdapter.cs b/src/NetworkAdapter.cs
index b4ccbf7..7f86913 100644
--- a/src/NetworkAdapter.cs
+++ b/src/NetworkAdapter.cs
@@ -1,5 +1,3 @@
-using System.Collections.Generic;
-using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;
diff --git a/src/Program.cs b/src/Program.cs
index b52fa6d..dcfad55 100644
--- a/src/Program.cs
+++ b/src/Program.cs
@@ -1,9 +1,6 @@
-using Avalonia;
-using System;
+namespace SddpViewer;
-namespace SddpViewer;
-
-class Program
+internal static class Program
{
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
diff --git a/src/SddpViewer.csproj b/src/SddpViewer.csproj
index 12e727d..c113098 100644
--- a/src/SddpViewer.csproj
+++ b/src/SddpViewer.csproj
@@ -3,6 +3,7 @@
WinExe
net8.0
enable
+ enable
true
app.manifest
true