From 5e641b0e8c83567eaf59f1e867f85f0884b092c0 Mon Sep 17 00:00:00 2001 From: Cherry <13651622+MolotovCherry@users.noreply.github.com> Date: Mon, 13 Nov 2023 20:09:09 -0800 Subject: [PATCH] Allow version in unpackaged app --- Virtual Display Driver Control/App.xaml.cs | 2 ++ .../Common/Version.cs | 20 +++++++++++++++++++ .../Views/SettingsView.xaml.cs | 9 +-------- 3 files changed, 23 insertions(+), 8 deletions(-) create mode 100644 Virtual Display Driver Control/Common/Version.cs diff --git a/Virtual Display Driver Control/App.xaml.cs b/Virtual Display Driver Control/App.xaml.cs index 418ed6b6..60ea98ae 100644 --- a/Virtual Display Driver Control/App.xaml.cs +++ b/Virtual Display Driver Control/App.xaml.cs @@ -4,6 +4,8 @@ namespace Virtual_Display_Driver_Control { public partial class App : Application { + public static Version Version = new Version(1, 0, 0); + #pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. public static Window Window { get; private set; } public static IAppSettings Settings { get; private set; } diff --git a/Virtual Display Driver Control/Common/Version.cs b/Virtual Display Driver Control/Common/Version.cs new file mode 100644 index 00000000..e58025d1 --- /dev/null +++ b/Virtual Display Driver Control/Common/Version.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Windows.Devices.Bluetooth; + +namespace Virtual_Display_Driver_Control.Common; + +public class Version { + public uint Major; + public uint Minor; + public uint Patch; + + public Version(uint major, uint minor, uint patch) { + Major = major; + Minor = minor; + Patch = patch; + } +} diff --git a/Virtual Display Driver Control/Views/SettingsView.xaml.cs b/Virtual Display Driver Control/Views/SettingsView.xaml.cs index 76c57ccd..1b307a0e 100644 --- a/Virtual Display Driver Control/Views/SettingsView.xaml.cs +++ b/Virtual Display Driver Control/Views/SettingsView.xaml.cs @@ -3,8 +3,6 @@ using Microsoft.UI.Xaml.Controls; using System; using Virtual_Display_Driver_Control.Helpers; -using Windows.ApplicationModel; -using Windows.Storage; using Windows.System; namespace Virtual_Display_Driver_Control.Views; @@ -12,9 +10,8 @@ namespace Virtual_Display_Driver_Control.Views; public sealed partial class SettingsView : Page { public string AppInfo { get { - var version = Package.Current.Id.Version; var appTitle = Application.Current.Resources["AppTitleName"] as string; - var versionString = $"{version.Major}.{version.Minor}.{version.Build}.{version.Revision}"; + var versionString = $"{App.Version.Major}.{App.Version.Minor}.{App.Version.Patch}"; return $"{appTitle} - v{versionString}"; } } @@ -49,8 +46,6 @@ private void themeMode_SelectionChanged(object sender, RoutedEventArgs e) { } private void themeMode_load() { - ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings; - // do not fire callback when we change the index here themeMode.SelectionChanged -= themeMode_SelectionChanged; @@ -75,8 +70,6 @@ private void themeMaterial_load() { ((ComboBoxItem)themeMaterial.Items[1]).IsEnabled = false; } - ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings; - // do not fire callback when we change the index here themeMaterial.SelectionChanged -= themeMaterial_SelectionChanged;