From b393146e58b906fb7f7a11f83a22ab77e1b53d3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Holger=20B=C3=B6rchers?= Date: Fri, 17 Nov 2023 15:06:37 +0100 Subject: [PATCH] Initial commit --- App.axaml | 12 ++++++++ App.axaml.cs | 23 ++++++++++++++++ DiscoveredDeviceViewModel.cs | 53 ++++++++++++++++++++++++++++++++++++ MainWindow.axaml | 36 ++++++++++++++++++++++++ MainWindow.axaml.cs | 11 ++++++++ MainWindowViewModel.cs | 44 ++++++++++++++++++++++++++++++ Program.cs | 21 ++++++++++++++ SddpViewer.csproj | 22 +++++++++++++++ SddpViewer.sln | 22 +++++++++++++++ app.manifest | 18 ++++++++++++ 10 files changed, 262 insertions(+) create mode 100644 App.axaml create mode 100644 App.axaml.cs create mode 100644 DiscoveredDeviceViewModel.cs create mode 100644 MainWindow.axaml create mode 100644 MainWindow.axaml.cs create mode 100644 MainWindowViewModel.cs create mode 100644 Program.cs create mode 100644 SddpViewer.csproj create mode 100644 SddpViewer.sln create mode 100644 app.manifest diff --git a/App.axaml b/App.axaml new file mode 100644 index 0000000..89a7161 --- /dev/null +++ b/App.axaml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/App.axaml.cs b/App.axaml.cs new file mode 100644 index 0000000..8b7ca73 --- /dev/null +++ b/App.axaml.cs @@ -0,0 +1,23 @@ +using Avalonia; +using Avalonia.Controls.ApplicationLifetimes; +using Avalonia.Markup.Xaml; + +namespace SddpViewer; + +public partial class App : Application +{ + public override void Initialize() + { + AvaloniaXamlLoader.Load(this); + } + + public override void OnFrameworkInitializationCompleted() + { + if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) + { + desktop.MainWindow = new MainWindow(); + } + + base.OnFrameworkInitializationCompleted(); + } +} \ No newline at end of file diff --git a/DiscoveredDeviceViewModel.cs b/DiscoveredDeviceViewModel.cs new file mode 100644 index 0000000..897ebc8 --- /dev/null +++ b/DiscoveredDeviceViewModel.cs @@ -0,0 +1,53 @@ +namespace SddpViewer +{ + using System; + using System.Threading.Tasks; + + using CommunityToolkit.Mvvm.ComponentModel; + + using Rssdp; + + public partial class DiscoveredDeviceViewModel : ObservableObject + { + private readonly DiscoveredSsdpDevice device; + + public DiscoveredDeviceViewModel(DiscoveredSsdpDevice device) + { + this.device = device; + } + + /// + /// Sets or returns the type of notification, being either a uuid, device type, service type or upnp:rootdevice. + /// + public string NotificationType => this.device.NotificationType; + + /// + /// Sets or returns the universal service name (USN) of the device. + /// + public string Usn => this.device.Usn; + + /// + /// Sets or returns a URL pointing to the device description document for this device. + /// + public Uri DescriptionLocation => this.device.DescriptionLocation; + + /// + /// Sets or returns the length of time this information is valid for (from the time). + /// + public TimeSpan CacheLifetime => this.device.CacheLifetime; + + /// + /// Sets or returns the date and time this information was received. + /// + public DateTimeOffset AsAt => this.device.AsAt; + + [ObservableProperty] + private string _friendlyName = ""; + + public async Task GetFurtherInformationAsync() + { + var ssdpDevice = await this.device.GetDeviceInfo().ConfigureAwait(false); + FriendlyName = ssdpDevice.FriendlyName; + } + } +} \ No newline at end of file diff --git a/MainWindow.axaml b/MainWindow.axaml new file mode 100644 index 0000000..76c9f27 --- /dev/null +++ b/MainWindow.axaml @@ -0,0 +1,36 @@ + + + + + + + + + +