From 733a3de573097bc8d80e65e10a42b73bbc86745d Mon Sep 17 00:00:00 2001 From: Chris Kaczor Date: Mon, 30 Sep 2024 17:41:54 -0400 Subject: [PATCH] Add update settings panel --- App.config | 3 ++ Program.cs | 8 --- Properties/Resources.Designer.cs | 58 +++++++++++++++++++++ Properties/Resources.resx | 22 ++++++++ Properties/Settings.Designer.cs | 12 +++++ Properties/Settings.settings | 3 ++ SettingsWindow/AboutSettingsPanel.xaml | 2 +- SettingsWindow/UpdateSettingsPanel.xaml | 22 ++++++++ SettingsWindow/UpdateSettingsPanel.xaml.cs | 31 +++++++++++ UpdateCheck.cs | 60 ++++++++++++++++++++++ WindowSource.cs | 16 +++--- WorldClockStatusWindow.sln.DotSettings | 2 + 12 files changed, 224 insertions(+), 15 deletions(-) create mode 100644 SettingsWindow/UpdateSettingsPanel.xaml create mode 100644 SettingsWindow/UpdateSettingsPanel.xaml.cs create mode 100644 UpdateCheck.cs create mode 100644 WorldClockStatusWindow.sln.DotSettings diff --git a/App.config b/App.config index 24584f9..e134e5c 100644 --- a/App.config +++ b/App.config @@ -22,6 +22,9 @@ [] + + True + \ No newline at end of file diff --git a/Program.cs b/Program.cs index 128db22..3abdce2 100644 --- a/Program.cs +++ b/Program.cs @@ -1,16 +1,12 @@ using Microsoft.Extensions.Logging; -using NuGet.Versioning; using Serilog; using System; using Velopack; -using Velopack.Sources; namespace WorldClockStatusWindow; internal class Program { - private static UpdateManager _updateManager; - [STAThread] public static void Main(string[] args) { @@ -28,8 +24,4 @@ internal class Program Log.Logger.Information("End"); } - - public static UpdateManager UpdateManager => _updateManager ??= new UpdateManager(new GithubSource("https://github.com/ckaczor/WorldClockStatusWindow", null, false)); - - public static string LocalVersion => (UpdateManager.CurrentVersion ?? new SemanticVersion(0, 0, 0)).ToString(); } \ No newline at end of file diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs index 3c5fbeb..606d2ab 100644 --- a/Properties/Resources.Designer.cs +++ b/Properties/Resources.Designer.cs @@ -88,6 +88,24 @@ namespace WorldClockStatusWindow.Properties { } } + /// + /// Looks up a localized string similar to Check _Now. + /// + public static string checkVersionNowButton { + get { + return ResourceManager.GetString("checkVersionNowButton", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to _Check for a new version on startup. + /// + public static string checkVersionOnStartupCheckBox { + get { + return ResourceManager.GetString("checkVersionOnStartupCheckBox", resourceCulture); + } + } + /// /// Looks up a localized string similar to Close. /// @@ -115,6 +133,15 @@ namespace WorldClockStatusWindow.Properties { } } + /// + /// Looks up a localized string similar to Update. + /// + public static string optionCategoryUpdate { + get { + return ResourceManager.GetString("optionCategoryUpdate", resourceCulture); + } + } + /// /// Looks up a localized string similar to Settings. /// @@ -133,6 +160,37 @@ namespace WorldClockStatusWindow.Properties { } } + /// + /// Looks up a localized string similar to You are already running the most recent version. + /// + ///No updates are available at this time.. + /// + public static string UpdateCheckCurrent { + get { + return ResourceManager.GetString("UpdateCheckCurrent", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Version {1} of {0} is now available. + /// + ///Would you like to download and install it now?. + /// + public static string UpdateCheckNewVersion { + get { + return ResourceManager.GetString("UpdateCheckNewVersion", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} Update. + /// + public static string UpdateCheckTitle { + get { + return ResourceManager.GetString("UpdateCheckTitle", resourceCulture); + } + } + /// /// Looks up a localized string similar to Version {0}. /// diff --git a/Properties/Resources.resx b/Properties/Resources.resx index be32e6e..0b023e5 100644 --- a/Properties/Resources.resx +++ b/Properties/Resources.resx @@ -145,4 +145,26 @@ Version {0} + + Update + + + _Check for a new version on startup + + + Check _Now + + + {0} Update + + + You are already running the most recent version. + +No updates are available at this time. + + + Version {1} of {0} is now available. + +Would you like to download and install it now? + \ No newline at end of file diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs index 8f5d4c5..bf9081a 100644 --- a/Properties/Settings.Designer.cs +++ b/Properties/Settings.Designer.cs @@ -70,5 +70,17 @@ namespace WorldClockStatusWindow.Properties { this["TimeZones"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool CheckVersionAtStartup { + get { + return ((bool)(this["CheckVersionAtStartup"])); + } + set { + this["CheckVersionAtStartup"] = value; + } + } } } diff --git a/Properties/Settings.settings b/Properties/Settings.settings index dd70d6c..ee3bfb2 100644 --- a/Properties/Settings.settings +++ b/Properties/Settings.settings @@ -14,5 +14,8 @@ [] + + True + \ No newline at end of file diff --git a/SettingsWindow/AboutSettingsPanel.xaml b/SettingsWindow/AboutSettingsPanel.xaml index e3fb541..70de048 100644 --- a/SettingsWindow/AboutSettingsPanel.xaml +++ b/SettingsWindow/AboutSettingsPanel.xaml @@ -13,7 +13,7 @@ - diff --git a/SettingsWindow/UpdateSettingsPanel.xaml b/SettingsWindow/UpdateSettingsPanel.xaml new file mode 100644 index 0000000..5a48289 --- /dev/null +++ b/SettingsWindow/UpdateSettingsPanel.xaml @@ -0,0 +1,22 @@ + + + +