From 5eb258e5bdb771882566d87e1185a6d45432ff7d Mon Sep 17 00:00:00 2001
From: XanatosX <10531466+XanatosX@users.noreply.github.com>
Date: Mon, 30 Jan 2023 19:15:43 +0100
Subject: [PATCH 01/10] Add license as embeeded resource
---
.../ModularToolManager.csproj | 4 ++++
src/ModularToolManager/Resources/LICENSE | 21 +++++++++++++++++++
2 files changed, 25 insertions(+)
create mode 100644 src/ModularToolManager/Resources/LICENSE
diff --git a/src/ModularToolManager/ModularToolManager.csproj b/src/ModularToolManager/ModularToolManager.csproj
index 1a41d839..c2320d05 100644
--- a/src/ModularToolManager/ModularToolManager.csproj
+++ b/src/ModularToolManager/ModularToolManager.csproj
@@ -7,6 +7,10 @@
+
+
+
+
diff --git a/src/ModularToolManager/Resources/LICENSE b/src/ModularToolManager/Resources/LICENSE
new file mode 100644
index 00000000..8e8c4142
--- /dev/null
+++ b/src/ModularToolManager/Resources/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2023 XanatosX
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
From e6748bcc4b078a5bc64746a428a90d8363a0c1e5 Mon Sep 17 00:00:00 2001
From: XanatosX <10531466+XanatosX@users.noreply.github.com>
Date: Mon, 30 Jan 2023 20:55:18 +0100
Subject: [PATCH 02/10] Add code to get version Add code to get license Add new
window for about Add license to about window Add version to about window
---
.../DependencyInjectionExtension.cs | 7 +-
src/ModularToolManager/Icons.axaml | 2 +
.../Properties/Properties.Designer.cs | 9 +++
.../Properties/Properties.resx | 3 +
.../Properties/Resources.Designer.cs | 9 +++
.../Properties/Resources.resx | 3 +
.../IO/GetApplicationInformationService.cs | 62 ++++++++++++++++
.../Services/IO/ResourceReaderService.cs | 71 +++++++++++++++++++
.../ViewModels/AboutViewModel.cs | 31 ++++++++
.../ViewModels/MainWindowViewModel.cs | 11 +++
src/ModularToolManager/Views/AboutView.axaml | 21 ++++++
.../Views/AboutView.axaml.cs | 15 ++++
src/ModularToolManager/Views/MainWindow.axaml | 5 --
13 files changed, 242 insertions(+), 7 deletions(-)
create mode 100644 src/ModularToolManager/Services/IO/GetApplicationInformationService.cs
create mode 100644 src/ModularToolManager/Services/IO/ResourceReaderService.cs
create mode 100644 src/ModularToolManager/ViewModels/AboutViewModel.cs
create mode 100644 src/ModularToolManager/Views/AboutView.axaml
create mode 100644 src/ModularToolManager/Views/AboutView.axaml.cs
diff --git a/src/ModularToolManager/DependencyInjection/DependencyInjectionExtension.cs b/src/ModularToolManager/DependencyInjection/DependencyInjectionExtension.cs
index 67e487bd..62d30776 100644
--- a/src/ModularToolManager/DependencyInjection/DependencyInjectionExtension.cs
+++ b/src/ModularToolManager/DependencyInjection/DependencyInjectionExtension.cs
@@ -57,7 +57,8 @@ public static IServiceCollection AddViewModels(this IServiceCollection collectio
.AddTransient()
.AddTransient()
.AddTransient()
- .AddTransient();
+ .AddTransient()
+ .AddTransient();
}
///
@@ -95,6 +96,8 @@ public static IServiceCollection AddServices(this IServiceCollection collection)
.AddSingleton()
.AddTransient()
.AddSingleton()
- .AddTransient();
+ .AddTransient()
+ .AddTransient()
+ .AddTransient();
}
}
diff --git a/src/ModularToolManager/Icons.axaml b/src/ModularToolManager/Icons.axaml
index 513a67e2..1f57e140 100644
--- a/src/ModularToolManager/Icons.axaml
+++ b/src/ModularToolManager/Icons.axaml
@@ -8,6 +8,7 @@
diff --git a/src/ModularToolManager/Properties/Properties.Designer.cs b/src/ModularToolManager/Properties/Properties.Designer.cs
index b983ae7d..9b4f4907 100644
--- a/src/ModularToolManager/Properties/Properties.Designer.cs
+++ b/src/ModularToolManager/Properties/Properties.Designer.cs
@@ -96,6 +96,15 @@ internal static string GithubUrl {
}
}
+ ///
+ /// Looks up a localized string similar to question_circle_regular.
+ ///
+ internal static string Icon_About {
+ get {
+ return ResourceManager.GetString("Icon_About", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to edit_regular.
///
diff --git a/src/ModularToolManager/Properties/Properties.resx b/src/ModularToolManager/Properties/Properties.resx
index 4df16c07..b7dc5ec8 100644
--- a/src/ModularToolManager/Properties/Properties.resx
+++ b/src/ModularToolManager/Properties/Properties.resx
@@ -129,6 +129,9 @@
https://github.com/XanatosX/ModularToolManager/issues
+
+ question_circle_regular
+
edit_regular
diff --git a/src/ModularToolManager/Properties/Resources.Designer.cs b/src/ModularToolManager/Properties/Resources.Designer.cs
index 9ac9aeb5..95d3affa 100644
--- a/src/ModularToolManager/Properties/Resources.Designer.cs
+++ b/src/ModularToolManager/Properties/Resources.Designer.cs
@@ -60,6 +60,15 @@ internal Resources() {
}
}
+ ///
+ /// Looks up a localized string similar to License.
+ ///
+ public static string About_License {
+ get {
+ return ResourceManager.GetString("About_License", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Path to function.
///
diff --git a/src/ModularToolManager/Properties/Resources.resx b/src/ModularToolManager/Properties/Resources.resx
index 3f1780ca..1180dc43 100644
--- a/src/ModularToolManager/Properties/Resources.resx
+++ b/src/ModularToolManager/Properties/Resources.resx
@@ -117,6 +117,9 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ License
+
Path to function
diff --git a/src/ModularToolManager/Services/IO/GetApplicationInformationService.cs b/src/ModularToolManager/Services/IO/GetApplicationInformationService.cs
new file mode 100644
index 00000000..22be84e1
--- /dev/null
+++ b/src/ModularToolManager/Services/IO/GetApplicationInformationService.cs
@@ -0,0 +1,62 @@
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ModularToolManager.Services.IO;
+
+
+internal class GetApplicationInformationService
+{
+ private readonly ResourceReaderService readerService;
+ private readonly ILogger logger;
+ private const string LICENSE_FILE_NAME = "LICENSE";
+
+ private string? license;
+
+ ///
+ /// Create a new instance of this class
+ ///
+ /// The reader service to use
+ public GetApplicationInformationService(ResourceReaderService readerService, ILogger logger)
+ {
+ this.readerService = readerService;
+ this.logger = logger;
+ }
+
+ ///
+ /// Get the license for the project
+ ///
+ /// The license information
+ public string? GetLicense()
+ {
+ license ??= readerService.GetResourceData(LICENSE_FILE_NAME);
+ return license;
+ }
+
+ ///
+ /// Get the version of the application
+ ///
+ /// The version of the project or null
+ public Version? GetVersion()
+ {
+ var assembly = Assembly.GetExecutingAssembly();
+ Version? returnVersion = null;
+ try
+ {
+
+ var versionString = FileVersionInfo.GetVersionInfo(assembly.Location).ProductVersion;
+ returnVersion = new Version(versionString ?? "0.0.0");
+ }
+ catch (Exception e)
+ {
+ logger.LogError(e, "Could not get version from assembly");
+ }
+
+ return returnVersion;
+ }
+}
diff --git a/src/ModularToolManager/Services/IO/ResourceReaderService.cs b/src/ModularToolManager/Services/IO/ResourceReaderService.cs
new file mode 100644
index 00000000..872321ae
--- /dev/null
+++ b/src/ModularToolManager/Services/IO/ResourceReaderService.cs
@@ -0,0 +1,71 @@
+using Microsoft.Extensions.Logging;
+using System.IO;
+using System.Reflection;
+
+namespace ModularToolManager.Services.IO;
+
+///
+/// Service to read resource files from the project
+///
+internal class ResourceReaderService
+{
+ ///
+ /// The base namespace for resource files
+ ///
+ private const string BASE_NAMESPACE = "ModularToolManager.Resources";
+
+ ///
+ /// The logger to use for writing errors
+ ///
+ private readonly ILogger logger;
+
+ ///
+ /// Create a new instance of this class
+ ///
+ /// The logger to use
+ public ResourceReaderService(ILogger logger)
+ {
+ this.logger = logger;
+ }
+
+ ///
+ /// Get the stream to the resource by its file name
+ ///
+ /// The file name to use
+ /// The stream to the file, Stream.Null if nothing was found or null
+ public Stream? GetResourceStream(string fileName)
+ {
+ return Assembly.GetExecutingAssembly().GetManifestResourceStream(GetResourcePath(fileName)) ?? Stream.Null;
+ }
+
+ ///
+ /// Get the content of the resource to load
+ ///
+ /// The file name to load
+ /// The string with the content or null if nothing was found
+ public string? GetResourceData(string fileName)
+ {
+ string? returnString = null;
+ var stream = GetResourceStream(fileName);
+ if (stream is null || stream == Stream.Null)
+ {
+ logger.LogError($"Could not get stream for resource with name {fileName}");
+ return returnString;
+ }
+ using (StreamReader reader = new StreamReader(stream))
+ {
+ returnString = reader.ReadToEnd();
+ }
+ return returnString;
+ }
+
+ ///
+ /// Get the path of the resource by the file name
+ ///
+ /// The file name to get the resource from
+ /// The path to the resource file
+ private string GetResourcePath(string fileName)
+ {
+ return $"{BASE_NAMESPACE}.{fileName}";
+ }
+}
diff --git a/src/ModularToolManager/ViewModels/AboutViewModel.cs b/src/ModularToolManager/ViewModels/AboutViewModel.cs
new file mode 100644
index 00000000..25905ec7
--- /dev/null
+++ b/src/ModularToolManager/ViewModels/AboutViewModel.cs
@@ -0,0 +1,31 @@
+using CommunityToolkit.Mvvm.ComponentModel;
+using ModularToolManager.Services.IO;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ModularToolManager.ViewModels;
+internal partial class AboutViewModel : ObservableObject
+{
+ [ObservableProperty]
+ private string license;
+
+ [ObservableProperty]
+ private string version;
+
+ //@TODO: Add new view for this!
+ [ObservableProperty]
+ private List dependencies;
+
+ private readonly GetApplicationInformationService getApplicationInformationService;
+
+ public AboutViewModel(GetApplicationInformationService getApplicationInformationService)
+ {
+ this.getApplicationInformationService = getApplicationInformationService;
+ License = getApplicationInformationService.GetLicense() ?? string.Empty;
+ Version = getApplicationInformationService.GetVersion()?.ToString() ?? string.Empty;
+ Dependencies = new();
+ }
+}
diff --git a/src/ModularToolManager/ViewModels/MainWindowViewModel.cs b/src/ModularToolManager/ViewModels/MainWindowViewModel.cs
index 266127b5..ea48feaa 100644
--- a/src/ModularToolManager/ViewModels/MainWindowViewModel.cs
+++ b/src/ModularToolManager/ViewModels/MainWindowViewModel.cs
@@ -165,6 +165,17 @@ private async Task OpenSettings()
await OpenModalWindow(Properties.Resources.SubMenu_Settings, Properties.Properties.Icon_settings, nameof(SettingsViewModel));
}
+
+ ///
+ /// Open the about window
+ ///
+ /// A awaitable task
+ [RelayCommand]
+ private async Task OpenAbout()
+ {
+ await OpenModalWindow(Properties.Resources.SubMenu_About, Properties.Properties.Icon_About, nameof(AboutViewModel));
+ }
+
///
/// Method to open a modal window
///
diff --git a/src/ModularToolManager/Views/AboutView.axaml b/src/ModularToolManager/Views/AboutView.axaml
new file mode 100644
index 00000000..ad26da5c
--- /dev/null
+++ b/src/ModularToolManager/Views/AboutView.axaml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/ModularToolManager/Views/AboutView.axaml.cs b/src/ModularToolManager/Views/AboutView.axaml.cs
new file mode 100644
index 00000000..0c583c69
--- /dev/null
+++ b/src/ModularToolManager/Views/AboutView.axaml.cs
@@ -0,0 +1,15 @@
+using Avalonia.Controls;
+using Avalonia.Markup.Xaml;
+
+namespace ModularToolManager.Views;
+public partial class AboutView : UserControl
+{
+ public AboutView()
+ {
+ InitializeComponent();
+ }
+ private void InitializeComponent()
+ {
+ AvaloniaXamlLoader.Load(this);
+ }
+}
diff --git a/src/ModularToolManager/Views/MainWindow.axaml b/src/ModularToolManager/Views/MainWindow.axaml
index 502e924a..b7d55313 100644
--- a/src/ModularToolManager/Views/MainWindow.axaml
+++ b/src/ModularToolManager/Views/MainWindow.axaml
@@ -17,11 +17,6 @@
HasSystemDecorations="False"
CanResize="False"
ShowInTaskbar="{Binding ShowInTaskbar}">
-
From 6071450deaa51fb12e0a333e4ec25851829fde01 Mon Sep 17 00:00:00 2001
From: XanatosX <10531466+XanatosX@users.noreply.github.com>
Date: Tue, 31 Jan 2023 08:18:16 +0100
Subject: [PATCH 03/10] Add depdencies to about view Add dependencies Add link
button style
---
src/ModularToolManager/App.axaml | 3 +-
.../Models/DependencyModel.cs | 17 +++++++
.../ModularToolManager.csproj | 2 +
.../Properties/Resources.Designer.cs | 45 +++++++++++++++++++
.../Properties/Resources.resx | 15 +++++++
.../{ => Resources}/Icons.axaml | 0
.../Resources/LinkButtonStyle.axaml | 29 ++++++++++++
.../Resources/dependencies.json | 20 +++++++++
.../MicrosoftDepdencyResolverService.cs | 12 ++++-
.../IO/GetApplicationInformationService.cs | 23 ++++++++++
.../ViewModels/AboutViewModel.cs | 18 ++++++--
.../ViewModels/DependencyViewModel.cs | 45 +++++++++++++++++++
src/ModularToolManager/Views/AboutView.axaml | 11 +++--
.../Views/DependencyView.axaml | 17 +++++++
.../Views/DependencyView.axaml.cs | 15 +++++++
src/ModularToolManager/Views/PluginView.axaml | 7 +--
.../Dependency/IDependencyResolverService.cs | 8 ++++
17 files changed, 275 insertions(+), 12 deletions(-)
create mode 100644 src/ModularToolManager/Models/DependencyModel.cs
rename src/ModularToolManager/{ => Resources}/Icons.axaml (100%)
create mode 100644 src/ModularToolManager/Resources/LinkButtonStyle.axaml
create mode 100644 src/ModularToolManager/Resources/dependencies.json
create mode 100644 src/ModularToolManager/ViewModels/DependencyViewModel.cs
create mode 100644 src/ModularToolManager/Views/DependencyView.axaml
create mode 100644 src/ModularToolManager/Views/DependencyView.axaml.cs
diff --git a/src/ModularToolManager/App.axaml b/src/ModularToolManager/App.axaml
index 3793ebb5..edcd6100 100644
--- a/src/ModularToolManager/App.axaml
+++ b/src/ModularToolManager/App.axaml
@@ -11,7 +11,8 @@
-
+
+
diff --git a/src/ModularToolManager/Models/DependencyModel.cs b/src/ModularToolManager/Models/DependencyModel.cs
new file mode 100644
index 00000000..46533172
--- /dev/null
+++ b/src/ModularToolManager/Models/DependencyModel.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ModularToolManager.Models;
+internal class DependencyModel
+{
+ public string? Name { get; init; }
+
+ public string? Version { get; init; }
+
+ public string? LicenseUrl { get; init; }
+
+ public string? ProjectUrl { get; init; }
+}
diff --git a/src/ModularToolManager/ModularToolManager.csproj b/src/ModularToolManager/ModularToolManager.csproj
index c2320d05..aa7a877b 100644
--- a/src/ModularToolManager/ModularToolManager.csproj
+++ b/src/ModularToolManager/ModularToolManager.csproj
@@ -7,9 +7,11 @@
+
+
diff --git a/src/ModularToolManager/Properties/Resources.Designer.cs b/src/ModularToolManager/Properties/Resources.Designer.cs
index 95d3affa..350ddb2d 100644
--- a/src/ModularToolManager/Properties/Resources.Designer.cs
+++ b/src/ModularToolManager/Properties/Resources.Designer.cs
@@ -60,6 +60,15 @@ internal Resources() {
}
}
+ ///
+ /// Looks up a localized string similar to Dependencies.
+ ///
+ public static string About_Dependency {
+ get {
+ return ResourceManager.GetString("About_Dependency", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to License.
///
@@ -69,6 +78,15 @@ public static string About_License {
}
}
+ ///
+ /// Looks up a localized string similar to Version:.
+ ///
+ public static string About_Version_Colon {
+ get {
+ return ResourceManager.GetString("About_Version_Colon", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Path to function.
///
@@ -168,6 +186,24 @@ public static string DefaultButton_Save {
}
}
+ ///
+ /// Looks up a localized string similar to License.
+ ///
+ public static string Dependency_License {
+ get {
+ return ResourceManager.GetString("Dependency_License", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Project.
+ ///
+ public static string Dependency_Project {
+ get {
+ return ResourceManager.GetString("Dependency_Project", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Search for function.
///
@@ -267,6 +303,15 @@ public static string Plugin_Url_Colon {
}
}
+ ///
+ /// Looks up a localized string similar to Running with Avalonia UI.
+ ///
+ public static string RunningWith {
+ get {
+ return ResourceManager.GetString("RunningWith", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Keep on Top.
///
diff --git a/src/ModularToolManager/Properties/Resources.resx b/src/ModularToolManager/Properties/Resources.resx
index 1180dc43..199dd245 100644
--- a/src/ModularToolManager/Properties/Resources.resx
+++ b/src/ModularToolManager/Properties/Resources.resx
@@ -117,9 +117,15 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ Dependencies
+
License
+
+ Version:
+
Path to function
@@ -153,6 +159,12 @@
Edit
+
+ License
+
+
+ Project
+
Search for function
@@ -186,6 +198,9 @@
Project url:
+
+ Running with Avalonia UI
+
Keep on Top
diff --git a/src/ModularToolManager/Icons.axaml b/src/ModularToolManager/Resources/Icons.axaml
similarity index 100%
rename from src/ModularToolManager/Icons.axaml
rename to src/ModularToolManager/Resources/Icons.axaml
diff --git a/src/ModularToolManager/Resources/LinkButtonStyle.axaml b/src/ModularToolManager/Resources/LinkButtonStyle.axaml
new file mode 100644
index 00000000..8fbeed8e
--- /dev/null
+++ b/src/ModularToolManager/Resources/LinkButtonStyle.axaml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/ModularToolManager/Resources/dependencies.json b/src/ModularToolManager/Resources/dependencies.json
new file mode 100644
index 00000000..325f33d7
--- /dev/null
+++ b/src/ModularToolManager/Resources/dependencies.json
@@ -0,0 +1,20 @@
+[
+ {
+ "Name": "Avalonia",
+ "Version": "0.10.18",
+ "ProjectUrl": "https://avaloniaui.net/",
+ "LicenseUrl": "https://licenses.nuget.org/MIT"
+ },
+ {
+ "Name": "Avalonia.Desktop",
+ "Version": "0.10.18",
+ "ProjectUrl": "https://avaloniaui.net/",
+ "LicenseUrl": "https://licenses.nuget.org/MIT"
+ },
+ {
+ "Name": "Avalonia.Diagnostics",
+ "Version": "0.10.18",
+ "ProjectUrl": "https://avaloniaui.net/",
+ "LicenseUrl": "https://licenses.nuget.org/MIT"
+ }
+]
\ No newline at end of file
diff --git a/src/ModularToolManager/Services/Dependencies/MicrosoftDepdencyResolverService.cs b/src/ModularToolManager/Services/Dependencies/MicrosoftDepdencyResolverService.cs
index 5f321793..7e4d8171 100644
--- a/src/ModularToolManager/Services/Dependencies/MicrosoftDepdencyResolverService.cs
+++ b/src/ModularToolManager/Services/Dependencies/MicrosoftDepdencyResolverService.cs
@@ -36,7 +36,7 @@ public MicrosoftDepdencyResolverService(IServiceProvider serviceProvider)
///
public T? GetDependency()
{
- return GetDependency(null);
+ return GetDependency(furtherInitilization: null);
}
///
@@ -50,6 +50,16 @@ public MicrosoftDepdencyResolverService(IServiceProvider serviceProvider)
return returnData;
}
+ ///
+ public T? GetDependency(Func objectFactory)
+ {
+ if (objectFactory is null)
+ {
+ return default;
+ }
+ return objectFactory.Invoke(serviceProvider);
+ }
+
///
public object? GetDependency(Type typeOf)
{
diff --git a/src/ModularToolManager/Services/IO/GetApplicationInformationService.cs b/src/ModularToolManager/Services/IO/GetApplicationInformationService.cs
index 22be84e1..6f10515e 100644
--- a/src/ModularToolManager/Services/IO/GetApplicationInformationService.cs
+++ b/src/ModularToolManager/Services/IO/GetApplicationInformationService.cs
@@ -1,10 +1,15 @@
using Microsoft.Extensions.Logging;
+using ModularToolManager.Models;
+using ModularToolManager.Services.Dependencies;
+using ModularToolManager.ViewModels;
using System;
using System.Collections.Generic;
using System.Diagnostics;
+using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
+using System.Text.Json;
using System.Threading.Tasks;
namespace ModularToolManager.Services.IO;
@@ -59,4 +64,22 @@ public GetApplicationInformationService(ResourceReaderService readerService, ILo
return returnVersion;
}
+
+ ///
+ /// Get the dependencies for this application
+ ///
+ /// A list with all the dependencies
+ public IEnumerable GetDependencies()
+ {
+ IEnumerable returnDependencies = Enumerable.Empty();
+ using (Stream? stream = readerService.GetResourceStream("dependencies.json"))
+ {
+ if (stream is not null && stream != Stream.Null)
+ {
+ returnDependencies = JsonSerializer.Deserialize>(stream) ?? returnDependencies;
+ }
+ }
+
+ return returnDependencies;
+ }
}
diff --git a/src/ModularToolManager/ViewModels/AboutViewModel.cs b/src/ModularToolManager/ViewModels/AboutViewModel.cs
index 25905ec7..d9e06af4 100644
--- a/src/ModularToolManager/ViewModels/AboutViewModel.cs
+++ b/src/ModularToolManager/ViewModels/AboutViewModel.cs
@@ -1,5 +1,8 @@
using CommunityToolkit.Mvvm.ComponentModel;
+using Microsoft.Extensions.DependencyInjection;
using ModularToolManager.Services.IO;
+using ModularToolManagerModel.Services.Dependency;
+using ModularToolManagerModel.Services.IO;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -12,20 +15,29 @@ internal partial class AboutViewModel : ObservableObject
[ObservableProperty]
private string license;
+ [ObservableProperty]
+ private string gitHubUrl;
+
[ObservableProperty]
private string version;
//@TODO: Add new view for this!
[ObservableProperty]
- private List dependencies;
+ private List dependencies;
private readonly GetApplicationInformationService getApplicationInformationService;
- public AboutViewModel(GetApplicationInformationService getApplicationInformationService)
+ public AboutViewModel(GetApplicationInformationService getApplicationInformationService, IDependencyResolverService dependencyResolverService)
{
this.getApplicationInformationService = getApplicationInformationService;
License = getApplicationInformationService.GetLicense() ?? string.Empty;
Version = getApplicationInformationService.GetVersion()?.ToString() ?? string.Empty;
- Dependencies = new();
+ Dependencies = getApplicationInformationService.GetDependencies()
+ .Select(dep => dependencyResolverService.GetDependency(provider =>
+ {
+ return new DependencyViewModel(dep, provider.GetRequiredService());
+ }))
+ .OfType()
+ .ToList();
}
}
diff --git a/src/ModularToolManager/ViewModels/DependencyViewModel.cs b/src/ModularToolManager/ViewModels/DependencyViewModel.cs
new file mode 100644
index 00000000..f4d0e55d
--- /dev/null
+++ b/src/ModularToolManager/ViewModels/DependencyViewModel.cs
@@ -0,0 +1,45 @@
+using CommunityToolkit.Mvvm.ComponentModel;
+using CommunityToolkit.Mvvm.Input;
+using ModularToolManager.Models;
+using ModularToolManagerModel.Services.IO;
+using System.Data;
+
+namespace ModularToolManager.ViewModels;
+internal partial class DependencyViewModel : ObservableObject
+{
+ [ObservableProperty]
+ [NotifyPropertyChangedFor(nameof(Name))]
+ [NotifyPropertyChangedFor(nameof(Version))]
+ [NotifyPropertyChangedFor(nameof(ProjectUrl))]
+ [NotifyPropertyChangedFor(nameof(LicenseUrl))]
+ [NotifyPropertyChangedFor(nameof(ProjectSet))]
+ [NotifyPropertyChangedFor(nameof(LicenseSet))]
+ private DependencyModel? dependency;
+ private readonly IUrlOpenerService urlOpenerService;
+
+ public string? Name => dependency.Name;
+
+ public string? Version => dependency.Version;
+
+ public string? ProjectUrl => dependency.ProjectUrl;
+
+ public bool ProjectSet => !string.IsNullOrEmpty(ProjectUrl);
+
+ public string? LicenseUrl => dependency.LicenseUrl;
+
+ public bool LicenseSet => !string.IsNullOrEmpty(LicenseUrl);
+
+
+
+ public DependencyViewModel(DependencyModel dependency, IUrlOpenerService urlOpenerService)
+ {
+ Dependency = dependency;
+ this.urlOpenerService = urlOpenerService;
+ }
+
+ [RelayCommand]
+ public void OpenUrl(string url)
+ {
+ urlOpenerService.OpenUrl(url);
+ }
+}
diff --git a/src/ModularToolManager/Views/AboutView.axaml b/src/ModularToolManager/Views/AboutView.axaml
index ad26da5c..993393b8 100644
--- a/src/ModularToolManager/Views/AboutView.axaml
+++ b/src/ModularToolManager/Views/AboutView.axaml
@@ -7,15 +7,18 @@
x:Class="ModularToolManager.Views.AboutView">
-
+
-
-
+
+
-
+
+
+
+
diff --git a/src/ModularToolManager/Views/DependencyView.axaml b/src/ModularToolManager/Views/DependencyView.axaml
new file mode 100644
index 00000000..a4dffdde
--- /dev/null
+++ b/src/ModularToolManager/Views/DependencyView.axaml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/ModularToolManager/Views/DependencyView.axaml.cs b/src/ModularToolManager/Views/DependencyView.axaml.cs
new file mode 100644
index 00000000..31993107
--- /dev/null
+++ b/src/ModularToolManager/Views/DependencyView.axaml.cs
@@ -0,0 +1,15 @@
+using Avalonia.Controls;
+using Avalonia.Markup.Xaml;
+
+namespace ModularToolManager.Views;
+public partial class DependencyView : UserControl
+{
+ public DependencyView()
+ {
+ InitializeComponent();
+ }
+ private void InitializeComponent()
+ {
+ AvaloniaXamlLoader.Load(this);
+ }
+}
diff --git a/src/ModularToolManager/Views/PluginView.axaml b/src/ModularToolManager/Views/PluginView.axaml
index 1b243622..38c8057e 100644
--- a/src/ModularToolManager/Views/PluginView.axaml
+++ b/src/ModularToolManager/Views/PluginView.axaml
@@ -6,7 +6,7 @@
mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="450"
x:Class="ModularToolManager.Views.PluginView"
MaxWidth="400">
-
+
@@ -16,7 +16,8 @@
-
-
+
diff --git a/src/ModularToolManagerModel/Services/Dependency/IDependencyResolverService.cs b/src/ModularToolManagerModel/Services/Dependency/IDependencyResolverService.cs
index 16bdef7c..dc7cd77b 100644
--- a/src/ModularToolManagerModel/Services/Dependency/IDependencyResolverService.cs
+++ b/src/ModularToolManagerModel/Services/Dependency/IDependencyResolverService.cs
@@ -21,6 +21,14 @@ public interface IDependencyResolverService
/// An instance of type T or null if nothing found
T? GetDependency(Action? furtherInitilization);
+ ///
+ /// Get a dependency of type T by object factory
+ ///
+ /// The type of the dependency to get
+ /// The factory to use for object initialization
+ /// >An instance of type T or null if nothing found
+ T? GetDependency(Func objectFactory);
+
///
/// Get all dependencies of type T
///
From ac86de2fc36836340b8ac5843930c25a09c2f5b6 Mon Sep 17 00:00:00 2001
From: XanatosX <10531466+XanatosX@users.noreply.github.com>
Date: Tue, 31 Jan 2023 20:30:21 +0100
Subject: [PATCH 04/10] Fix crash if settings for functions are null
---
src/ModularToolManager/ViewModels/AddFunctionViewModel.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/ModularToolManager/ViewModels/AddFunctionViewModel.cs b/src/ModularToolManager/ViewModels/AddFunctionViewModel.cs
index c01a87e4..6336b779 100644
--- a/src/ModularToolManager/ViewModels/AddFunctionViewModel.cs
+++ b/src/ModularToolManager/ViewModels/AddFunctionViewModel.cs
@@ -198,7 +198,7 @@ public bool LoadInFunction(string identifier)
SelectedFunctionPlugin = FunctionPlugins.FirstOrDefault(plugin => plugin.Plugin == function.Plugin);
foreach (var setting in PluginSettings ?? Enumerable.Empty())
{
- var settingToUpdate = function.Settings.FirstOrDefault(pSetting => pSetting.Key == setting.GetSettingsModel().Key);
+ var settingToUpdate = function.Settings?.FirstOrDefault(pSetting => pSetting.Key == setting.GetSettingsModel().Key);
if (settingToUpdate is not null)
{
setting.UpdateValue(settingToUpdate.Value);
From bd40f38e9d169db7508ac46260a913564e091ab0 Mon Sep 17 00:00:00 2001
From: XanatosX <10531466+XanatosX@users.noreply.github.com>
Date: Tue, 31 Jan 2023 20:32:17 +0100
Subject: [PATCH 05/10] Improve visuals for dependencies
---
.../Resources/dependencies.json | 30 +++++++++++++++++++
.../ViewModels/AboutViewModel.cs | 1 +
src/ModularToolManager/Views/AboutView.axaml | 3 +-
.../Views/DependencyView.axaml | 8 ++---
4 files changed, 36 insertions(+), 6 deletions(-)
diff --git a/src/ModularToolManager/Resources/dependencies.json b/src/ModularToolManager/Resources/dependencies.json
index 325f33d7..32c40ca0 100644
--- a/src/ModularToolManager/Resources/dependencies.json
+++ b/src/ModularToolManager/Resources/dependencies.json
@@ -16,5 +16,35 @@
"Version": "0.10.18",
"ProjectUrl": "https://avaloniaui.net/",
"LicenseUrl": "https://licenses.nuget.org/MIT"
+ },
+ {
+ "Name": "CommunityToolkit.Mvvm",
+ "Version": "8.0.0",
+ "ProjectUrl": "https://github.com/CommunityToolkit/dotnet",
+ "LicenseUrl": "https://licenses.nuget.org/MIT"
+ },
+ {
+ "Name": "Microsoft.Extensions.DependencyInjection",
+ "Version": "7.0.0",
+ "ProjectUrl": "https://dot.net",
+ "LicenseUrl": "https://licenses.nuget.org/MIT"
+ },
+ {
+ "Name": "Serilog",
+ "Version": "2.12.0",
+ "ProjectUrl": "https://serilog.net/",
+ "LicenseUrl": "https://licenses.nuget.org/Apache-2.0"
+ },
+ {
+ "Name": "Serilog.Extensions.Logging",
+ "Version": "3.1.0",
+ "ProjectUrl": "https://serilog.net/",
+ "LicenseUrl": "https://licenses.nuget.org/Apache-2.0"
+ },
+ {
+ "Name": "Serilog.Sinks.File",
+ "Version": "5.0.0",
+ "ProjectUrl": "https://serilog.net/",
+ "LicenseUrl": "https://licenses.nuget.org/Apache-2.0"
}
]
\ No newline at end of file
diff --git a/src/ModularToolManager/ViewModels/AboutViewModel.cs b/src/ModularToolManager/ViewModels/AboutViewModel.cs
index d9e06af4..9ee6b627 100644
--- a/src/ModularToolManager/ViewModels/AboutViewModel.cs
+++ b/src/ModularToolManager/ViewModels/AboutViewModel.cs
@@ -33,6 +33,7 @@ public AboutViewModel(GetApplicationInformationService getApplicationInformation
License = getApplicationInformationService.GetLicense() ?? string.Empty;
Version = getApplicationInformationService.GetVersion()?.ToString() ?? string.Empty;
Dependencies = getApplicationInformationService.GetDependencies()
+ .OrderBy(d => d.Name)
.Select(dep => dependencyResolverService.GetDependency(provider =>
{
return new DependencyViewModel(dep, provider.GetRequiredService());
diff --git a/src/ModularToolManager/Views/AboutView.axaml b/src/ModularToolManager/Views/AboutView.axaml
index 993393b8..60942193 100644
--- a/src/ModularToolManager/Views/AboutView.axaml
+++ b/src/ModularToolManager/Views/AboutView.axaml
@@ -4,6 +4,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:p="clr-namespace:ModularToolManager.Properties"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
+ MinWidth="900"
x:Class="ModularToolManager.Views.AboutView">
@@ -16,7 +17,7 @@
-
+
diff --git a/src/ModularToolManager/Views/DependencyView.axaml b/src/ModularToolManager/Views/DependencyView.axaml
index a4dffdde..e97e24b4 100644
--- a/src/ModularToolManager/Views/DependencyView.axaml
+++ b/src/ModularToolManager/Views/DependencyView.axaml
@@ -6,12 +6,10 @@
xmlns:p="clr-namespace:ModularToolManager.Properties"
x:Class="ModularToolManager.Views.DependencyView">
-
+
-
-
-
-
+
+
From 9189ab714a8edacb9840ed4174cf530fef354425 Mon Sep 17 00:00:00 2001
From: XanatosX <10531466+XanatosX@users.noreply.github.com>
Date: Tue, 31 Jan 2023 20:44:51 +0100
Subject: [PATCH 06/10] Finalize about view
---
.../Properties/Properties.Designer.cs | 13 +++++++++++--
.../Properties/Properties.resx | 5 ++++-
.../Properties/Resources.Designer.cs | 9 +++++++++
.../Properties/Resources.resx | 3 +++
.../ViewModels/AboutViewModel.cs | 19 ++++++++++++++-----
.../ViewModels/MainWindowViewModel.cs | 2 +-
src/ModularToolManager/Views/AboutView.axaml | 6 ++++--
7 files changed, 46 insertions(+), 11 deletions(-)
diff --git a/src/ModularToolManager/Properties/Properties.Designer.cs b/src/ModularToolManager/Properties/Properties.Designer.cs
index 9b4f4907..f265d203 100644
--- a/src/ModularToolManager/Properties/Properties.Designer.cs
+++ b/src/ModularToolManager/Properties/Properties.Designer.cs
@@ -90,9 +90,18 @@ internal static string FunctionsFile {
///
/// Looks up a localized string similar to https://github.com/XanatosX/ModularToolManager/issues.
///
- internal static string GithubUrl {
+ internal static string GithubIssueUrl {
get {
- return ResourceManager.GetString("GithubUrl", resourceCulture);
+ return ResourceManager.GetString("GithubIssueUrl", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to https://github.com/XanatosX/ModularToolManager/.
+ ///
+ internal static string GitHubUrl {
+ get {
+ return ResourceManager.GetString("GitHubUrl", resourceCulture);
}
}
diff --git a/src/ModularToolManager/Properties/Properties.resx b/src/ModularToolManager/Properties/Properties.resx
index b7dc5ec8..45ba0949 100644
--- a/src/ModularToolManager/Properties/Properties.resx
+++ b/src/ModularToolManager/Properties/Properties.resx
@@ -126,9 +126,12 @@
functions.dat
-
+
https://github.com/XanatosX/ModularToolManager/issues
+
+ https://github.com/XanatosX/ModularToolManager/
+
question_circle_regular
diff --git a/src/ModularToolManager/Properties/Resources.Designer.cs b/src/ModularToolManager/Properties/Resources.Designer.cs
index 350ddb2d..395b28be 100644
--- a/src/ModularToolManager/Properties/Resources.Designer.cs
+++ b/src/ModularToolManager/Properties/Resources.Designer.cs
@@ -78,6 +78,15 @@ public static string About_License {
}
}
+ ///
+ /// Looks up a localized string similar to Repository:.
+ ///
+ public static string About_Repository_Colon {
+ get {
+ return ResourceManager.GetString("About_Repository_Colon", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Version:.
///
diff --git a/src/ModularToolManager/Properties/Resources.resx b/src/ModularToolManager/Properties/Resources.resx
index 199dd245..4c5a1ec7 100644
--- a/src/ModularToolManager/Properties/Resources.resx
+++ b/src/ModularToolManager/Properties/Resources.resx
@@ -123,6 +123,9 @@
License
+
+ Repository:
+
Version:
diff --git a/src/ModularToolManager/ViewModels/AboutViewModel.cs b/src/ModularToolManager/ViewModels/AboutViewModel.cs
index 9ee6b627..8ca4dd2a 100644
--- a/src/ModularToolManager/ViewModels/AboutViewModel.cs
+++ b/src/ModularToolManager/ViewModels/AboutViewModel.cs
@@ -1,4 +1,5 @@
using CommunityToolkit.Mvvm.ComponentModel;
+using CommunityToolkit.Mvvm.Input;
using Microsoft.Extensions.DependencyInjection;
using ModularToolManager.Services.IO;
using ModularToolManagerModel.Services.Dependency;
@@ -15,21 +16,23 @@ internal partial class AboutViewModel : ObservableObject
[ObservableProperty]
private string license;
- [ObservableProperty]
- private string gitHubUrl;
-
[ObservableProperty]
private string version;
- //@TODO: Add new view for this!
[ObservableProperty]
private List dependencies;
+ public string GitHubUrl => Properties.Properties.GitHubUrl;
+
private readonly GetApplicationInformationService getApplicationInformationService;
+ private readonly IUrlOpenerService urlOpenerService;
- public AboutViewModel(GetApplicationInformationService getApplicationInformationService, IDependencyResolverService dependencyResolverService)
+ public AboutViewModel(GetApplicationInformationService getApplicationInformationService,
+ IDependencyResolverService dependencyResolverService,
+ IUrlOpenerService urlOpenerService)
{
this.getApplicationInformationService = getApplicationInformationService;
+ this.urlOpenerService = urlOpenerService;
License = getApplicationInformationService.GetLicense() ?? string.Empty;
Version = getApplicationInformationService.GetVersion()?.ToString() ?? string.Empty;
Dependencies = getApplicationInformationService.GetDependencies()
@@ -41,4 +44,10 @@ public AboutViewModel(GetApplicationInformationService getApplicationInformation
.OfType()
.ToList();
}
+
+ [RelayCommand]
+ private void OpenUrl(string url)
+ {
+ urlOpenerService.OpenUrl(url);
+ }
}
diff --git a/src/ModularToolManager/ViewModels/MainWindowViewModel.cs b/src/ModularToolManager/ViewModels/MainWindowViewModel.cs
index ea48feaa..1d7d95b5 100644
--- a/src/ModularToolManager/ViewModels/MainWindowViewModel.cs
+++ b/src/ModularToolManager/ViewModels/MainWindowViewModel.cs
@@ -102,7 +102,7 @@ public MainWindowViewModel(
UpdateShowInTaskbar();
- ReportBugCommand = new RelayCommand(() => urlOpenerService?.OpenUrl(Properties.Properties.GithubUrl));
+ ReportBugCommand = new RelayCommand(() => urlOpenerService?.OpenUrl(Properties.Properties.GithubIssueUrl));
ExitApplicationCommand = new RelayCommand(() => WeakReferenceMessenger.Default.Send(new CloseApplicationMessage()));
SelectLanguageCommand = new AsyncRelayCommand(async () => await OpenModalWindow(Properties.Resources.SubMenu_Language, Properties.Properties.Icon_language, nameof(ChangeLanguageViewModel)));
HideApplicationCommand = new RelayCommand(() => WeakReferenceMessenger.Default.Send(new ToggleApplicationVisibilityMessage(true)));
diff --git a/src/ModularToolManager/Views/AboutView.axaml b/src/ModularToolManager/Views/AboutView.axaml
index 60942193..7e5ee5ea 100644
--- a/src/ModularToolManager/Views/AboutView.axaml
+++ b/src/ModularToolManager/Views/AboutView.axaml
@@ -7,9 +7,11 @@
MinWidth="900"
x:Class="ModularToolManager.Views.AboutView">
-
+
-
+
+
+
From e8b3c20a4328367393f22239f2c088b2d079ee82 Mon Sep 17 00:00:00 2001
From: XanatosX <10531466+XanatosX@users.noreply.github.com>
Date: Tue, 31 Jan 2023 20:47:09 +0100
Subject: [PATCH 07/10] Add missing german translations
---
.../Properties/Resources.de.resx | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/src/ModularToolManager/Properties/Resources.de.resx b/src/ModularToolManager/Properties/Resources.de.resx
index 1a462edb..4ae1b649 100644
--- a/src/ModularToolManager/Properties/Resources.de.resx
+++ b/src/ModularToolManager/Properties/Resources.de.resx
@@ -117,6 +117,18 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ Abhängigkeiten
+
+
+ Lizenz
+
+
+ Repository:
+
+
+ Version:
+
Pfad zur Funktion
@@ -177,6 +189,9 @@
Projekt Link:
+
+ Läuft mit Avalonia UI
+
Immer über anderen Fenstern
From 7c9c5397b3c3d65b08391c3263b202662070859a Mon Sep 17 00:00:00 2001
From: XanatosX <10531466+XanatosX@users.noreply.github.com>
Date: Tue, 31 Jan 2023 20:52:03 +0100
Subject: [PATCH 08/10] Add missing summary blocks
Code refactoring
---
.../IO/GetApplicationInformationService.cs | 34 +++++++++----
.../ViewModels/AboutViewModel.cs | 48 ++++++++++++++-----
2 files changed, 63 insertions(+), 19 deletions(-)
diff --git a/src/ModularToolManager/Services/IO/GetApplicationInformationService.cs b/src/ModularToolManager/Services/IO/GetApplicationInformationService.cs
index 6f10515e..97720b61 100644
--- a/src/ModularToolManager/Services/IO/GetApplicationInformationService.cs
+++ b/src/ModularToolManager/Services/IO/GetApplicationInformationService.cs
@@ -1,27 +1,39 @@
using Microsoft.Extensions.Logging;
using ModularToolManager.Models;
-using ModularToolManager.Services.Dependencies;
-using ModularToolManager.ViewModels;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
-using System.Text;
using System.Text.Json;
-using System.Threading.Tasks;
namespace ModularToolManager.Services.IO;
-
+///
+/// Class to get all the information about the application
+///
internal class GetApplicationInformationService
{
+ ///
+ /// The service used to load data about the application
+ ///
private readonly ResourceReaderService readerService;
+
+ ///
+ /// Logger to use to log any problems
+ ///
private readonly ILogger logger;
+
+ ///
+ /// The file to load as a license
+ ///
private const string LICENSE_FILE_NAME = "LICENSE";
- private string? license;
+ ///
+ /// The cached license if already loaded
+ ///
+ private string? cachedLicense;
///
/// Create a new instance of this class
@@ -39,8 +51,8 @@ public GetApplicationInformationService(ResourceReaderService readerService, ILo
/// The license information
public string? GetLicense()
{
- license ??= readerService.GetResourceData(LICENSE_FILE_NAME);
- return license;
+ cachedLicense ??= readerService.GetResourceData(LICENSE_FILE_NAME);
+ return cachedLicense;
}
///
@@ -82,4 +94,10 @@ public IEnumerable GetDependencies()
return returnDependencies;
}
+
+ ///
+ /// Get the url to the github repository
+ ///
+ /// The link to the github repository
+ public string GetGithubUrl() => Properties.Properties.GitHubUrl;
}
diff --git a/src/ModularToolManager/ViewModels/AboutViewModel.cs b/src/ModularToolManager/ViewModels/AboutViewModel.cs
index 8ca4dd2a..1154b65f 100644
--- a/src/ModularToolManager/ViewModels/AboutViewModel.cs
+++ b/src/ModularToolManager/ViewModels/AboutViewModel.cs
@@ -4,37 +4,59 @@
using ModularToolManager.Services.IO;
using ModularToolManagerModel.Services.Dependency;
using ModularToolManagerModel.Services.IO;
-using System;
using System.Collections.Generic;
using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace ModularToolManager.ViewModels;
+
+///
+/// View model for the about view
+///
internal partial class AboutViewModel : ObservableObject
{
+ ///
+ /// The license string to show
+ ///
[ObservableProperty]
- private string license;
+ private string? license;
+ ///
+ /// The version string to show
+ ///
[ObservableProperty]
- private string version;
+ private string? version;
+ ///
+ /// The dependencies to show
+ ///
[ObservableProperty]
- private List dependencies;
+ private List? dependencies;
- public string GitHubUrl => Properties.Properties.GitHubUrl;
+ ///
+ /// The github project url
+ ///
+ [ObservableProperty]
+ private string? gitHubUrl;
- private readonly GetApplicationInformationService getApplicationInformationService;
+ ///
+ /// Service used to open url
+ ///
private readonly IUrlOpenerService urlOpenerService;
+ ///
+ /// Create a new instance of this view model
+ ///
+ /// The service used to get application information
+ /// The service used to resolve dependencies
+ /// The service used to open an url
public AboutViewModel(GetApplicationInformationService getApplicationInformationService,
IDependencyResolverService dependencyResolverService,
IUrlOpenerService urlOpenerService)
{
- this.getApplicationInformationService = getApplicationInformationService;
this.urlOpenerService = urlOpenerService;
- License = getApplicationInformationService.GetLicense() ?? string.Empty;
- Version = getApplicationInformationService.GetVersion()?.ToString() ?? string.Empty;
+ License = getApplicationInformationService.GetLicense();
+ Version = getApplicationInformationService.GetVersion()?.ToString();
+ GitHubUrl = getApplicationInformationService.GetGithubUrl();
Dependencies = getApplicationInformationService.GetDependencies()
.OrderBy(d => d.Name)
.Select(dep => dependencyResolverService.GetDependency(provider =>
@@ -45,6 +67,10 @@ public AboutViewModel(GetApplicationInformationService getApplicationInformation
.ToList();
}
+ ///
+ /// Command to open url in browser
+ ///
+ /// The url to open
[RelayCommand]
private void OpenUrl(string url)
{
From 09a1f394d1c472534a9db087fa94c20a0ebbddd3 Mon Sep 17 00:00:00 2001
From: XanatosX <10531466+XanatosX@users.noreply.github.com>
Date: Tue, 31 Jan 2023 20:54:41 +0100
Subject: [PATCH 09/10] Add missing summary blocks
Prevent null exceptions
---
.../ViewModels/DependencyViewModel.cs | 49 ++++++++++++++++---
1 file changed, 43 insertions(+), 6 deletions(-)
diff --git a/src/ModularToolManager/ViewModels/DependencyViewModel.cs b/src/ModularToolManager/ViewModels/DependencyViewModel.cs
index f4d0e55d..431b0603 100644
--- a/src/ModularToolManager/ViewModels/DependencyViewModel.cs
+++ b/src/ModularToolManager/ViewModels/DependencyViewModel.cs
@@ -2,11 +2,17 @@
using CommunityToolkit.Mvvm.Input;
using ModularToolManager.Models;
using ModularToolManagerModel.Services.IO;
-using System.Data;
namespace ModularToolManager.ViewModels;
+
+///
+/// View model to show a single dependency
+///
internal partial class DependencyViewModel : ObservableObject
{
+ ///
+ /// The dependency to show
+ ///
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(Name))]
[NotifyPropertyChangedFor(nameof(Version))]
@@ -15,28 +21,59 @@ internal partial class DependencyViewModel : ObservableObject
[NotifyPropertyChangedFor(nameof(ProjectSet))]
[NotifyPropertyChangedFor(nameof(LicenseSet))]
private DependencyModel? dependency;
+
+
+ ///
+ /// The service used to open an url
+ ///
private readonly IUrlOpenerService urlOpenerService;
- public string? Name => dependency.Name;
+ ///
+ /// The name of the dependency
+ ///
+ public string? Name => dependency?.Name;
- public string? Version => dependency.Version;
+ ///
+ /// The version of the dependency
+ ///
+ public string? Version => dependency?.Version;
- public string? ProjectUrl => dependency.ProjectUrl;
+ ///
+ /// The url to the project of the dependency
+ ///
+ public string? ProjectUrl => dependency?.ProjectUrl;
+ ///
+ /// Is the project url set
+ ///
public bool ProjectSet => !string.IsNullOrEmpty(ProjectUrl);
- public string? LicenseUrl => dependency.LicenseUrl;
+ ///
+ /// The url to the license of the dependency
+ ///
+ public string? LicenseUrl => dependency?.LicenseUrl;
+ ///
+ /// is the license for the dependency set
+ ///
public bool LicenseSet => !string.IsNullOrEmpty(LicenseUrl);
-
+ ///
+ /// Create a new instance of this class
+ ///
+ /// The depencency to show
+ /// The service used to open the url
public DependencyViewModel(DependencyModel dependency, IUrlOpenerService urlOpenerService)
{
Dependency = dependency;
this.urlOpenerService = urlOpenerService;
}
+ ///
+ /// Command to open a given url
+ ///
+ /// The url to open
[RelayCommand]
public void OpenUrl(string url)
{
From b730cbfb67837638270d4298775840e0a275a450 Mon Sep 17 00:00:00 2001
From: XanatosX <10531466+XanatosX@users.noreply.github.com>
Date: Tue, 31 Jan 2023 21:00:47 +0100
Subject: [PATCH 10/10] Add missing summary blocks
---
.../Models/DependencyModel.cs | 22 ++++++++++++++-----
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/src/ModularToolManager/Models/DependencyModel.cs b/src/ModularToolManager/Models/DependencyModel.cs
index 46533172..cc2f6051 100644
--- a/src/ModularToolManager/Models/DependencyModel.cs
+++ b/src/ModularToolManager/Models/DependencyModel.cs
@@ -1,17 +1,27 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+namespace ModularToolManager.Models;
-namespace ModularToolManager.Models;
+///
+/// Model for a single dependency
+///
internal class DependencyModel
{
+ ///
+ /// The name of the dependency
+ ///
public string? Name { get; init; }
+ ///
+ /// The version of the dependency
+ ///
public string? Version { get; init; }
+ ///
+ /// The path to the license of the dependency
+ ///
public string? LicenseUrl { get; init; }
+ ///
+ /// The path to the project url of the dependency
+ ///
public string? ProjectUrl { get; init; }
}