mirror of
https://github.com/ckaczor/WorldClockStatusWindow.git
synced 2026-01-13 17:23:18 -05:00
Cleanup
- Refactoring - Resource strings
This commit is contained in:
36
Properties/Resources.Designer.cs
generated
36
Properties/Resources.Designer.cs
generated
@@ -79,6 +79,15 @@ namespace WorldClockStatusWindow.Properties {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Checking for update....
|
||||||
|
/// </summary>
|
||||||
|
public static string CheckingForUpdate {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("CheckingForUpdate", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to _Check for Update.
|
/// Looks up a localized string similar to _Check for Update.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -115,6 +124,33 @@ namespace WorldClockStatusWindow.Properties {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Downloading update....
|
||||||
|
/// </summary>
|
||||||
|
public static string DownloadingUpdate {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("DownloadingUpdate", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Installing update....
|
||||||
|
/// </summary>
|
||||||
|
public static string InstallingUpdate {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("InstallingUpdate", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Loading....
|
||||||
|
/// </summary>
|
||||||
|
public static string Loading {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("Loading", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to About.
|
/// Looks up a localized string similar to About.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -163,8 +163,20 @@
|
|||||||
No updates are available at this time.</value>
|
No updates are available at this time.</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="UpdateCheckNewVersion" xml:space="preserve">
|
<data name="UpdateCheckNewVersion" xml:space="preserve">
|
||||||
<value>Version {1} of {0} is now available.
|
<value>Version {0} is now available.
|
||||||
|
|
||||||
Would you like to download and install it now?</value>
|
Would you like to download and install it now?</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Loading" xml:space="preserve">
|
||||||
|
<value>Loading...</value>
|
||||||
|
</data>
|
||||||
|
<data name="CheckingForUpdate" xml:space="preserve">
|
||||||
|
<value>Checking for update...</value>
|
||||||
|
</data>
|
||||||
|
<data name="DownloadingUpdate" xml:space="preserve">
|
||||||
|
<value>Downloading update...</value>
|
||||||
|
</data>
|
||||||
|
<data name="InstallingUpdate" xml:space="preserve">
|
||||||
|
<value>Installing update...</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
@@ -5,8 +5,8 @@ using System.Windows;
|
|||||||
using Velopack;
|
using Velopack;
|
||||||
using Velopack.Sources;
|
using Velopack.Sources;
|
||||||
|
|
||||||
namespace WorldClockStatusWindow
|
namespace WorldClockStatusWindow;
|
||||||
{
|
|
||||||
internal static class UpdateCheck
|
internal static class UpdateCheck
|
||||||
{
|
{
|
||||||
private static UpdateManager _updateManager;
|
private static UpdateManager _updateManager;
|
||||||
@@ -19,22 +19,14 @@ namespace WorldClockStatusWindow
|
|||||||
|
|
||||||
public static async Task DisplayUpdateInformation(bool showIfCurrent)
|
public static async Task DisplayUpdateInformation(bool showIfCurrent)
|
||||||
{
|
{
|
||||||
UpdateInfo newVersion = null;
|
var newVersion = IsInstalled ? await UpdateManager.CheckForUpdatesAsync() : null;
|
||||||
|
|
||||||
if (IsInstalled)
|
|
||||||
{
|
|
||||||
newVersion = await UpdateManager.CheckForUpdatesAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newVersion != null)
|
if (newVersion != null)
|
||||||
{
|
{
|
||||||
// Format the check title
|
|
||||||
var updateCheckTitle = string.Format(Properties.Resources.UpdateCheckTitle, Properties.Resources.ApplicationName);
|
var updateCheckTitle = string.Format(Properties.Resources.UpdateCheckTitle, Properties.Resources.ApplicationName);
|
||||||
|
|
||||||
// Format the message
|
var updateCheckMessage = string.Format(Properties.Resources.UpdateCheckNewVersion, newVersion.TargetFullRelease.Version);
|
||||||
var updateCheckMessage = string.Format(Properties.Resources.UpdateCheckNewVersion, Properties.Resources.ApplicationName, newVersion.TargetFullRelease.Version);
|
|
||||||
|
|
||||||
// Ask the user to update
|
|
||||||
if (MessageBox.Show(updateCheckMessage, updateCheckTitle, MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
|
if (MessageBox.Show(updateCheckMessage, updateCheckTitle, MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -48,14 +40,11 @@ namespace WorldClockStatusWindow
|
|||||||
}
|
}
|
||||||
else if (showIfCurrent)
|
else if (showIfCurrent)
|
||||||
{
|
{
|
||||||
// Format the check title
|
|
||||||
var updateCheckTitle = string.Format(Properties.Resources.UpdateCheckTitle, Properties.Resources.ApplicationName);
|
var updateCheckTitle = string.Format(Properties.Resources.UpdateCheckTitle, Properties.Resources.ApplicationName);
|
||||||
|
|
||||||
// Format the message
|
|
||||||
var updateCheckMessage = string.Format(Properties.Resources.UpdateCheckCurrent, Properties.Resources.ApplicationName);
|
var updateCheckMessage = string.Format(Properties.Resources.UpdateCheckCurrent, Properties.Resources.ApplicationName);
|
||||||
|
|
||||||
MessageBox.Show(updateCheckMessage, updateCheckTitle, MessageBoxButton.OK, MessageBoxImage.Information);
|
MessageBox.Show(updateCheckMessage, updateCheckTitle, MessageBoxButton.OK, MessageBoxImage.Information);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ using Serilog;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Timers;
|
using System.Timers;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
|
using WorldClockStatusWindow.Properties;
|
||||||
using WorldClockStatusWindow.SettingsWindow;
|
using WorldClockStatusWindow.SettingsWindow;
|
||||||
|
|
||||||
namespace WorldClockStatusWindow;
|
namespace WorldClockStatusWindow;
|
||||||
@@ -25,7 +25,7 @@ internal class WindowSource : IWindowSource, IDisposable
|
|||||||
internal WindowSource()
|
internal WindowSource()
|
||||||
{
|
{
|
||||||
_floatingStatusWindow = new FloatingStatusWindow(this);
|
_floatingStatusWindow = new FloatingStatusWindow(this);
|
||||||
_floatingStatusWindow.SetText("Loading...");
|
_floatingStatusWindow.SetText(Resources.Loading);
|
||||||
|
|
||||||
_dispatcher = Dispatcher.CurrentDispatcher;
|
_dispatcher = Dispatcher.CurrentDispatcher;
|
||||||
|
|
||||||
@@ -41,12 +41,12 @@ internal class WindowSource : IWindowSource, IDisposable
|
|||||||
if (!UpdateCheck.IsInstalled)
|
if (!UpdateCheck.IsInstalled)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!Properties.Settings.Default.CheckVersionAtStartup)
|
if (!Settings.Default.CheckVersionAtStartup)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Log.Logger.Information("Checking for update");
|
Log.Logger.Information("Checking for update");
|
||||||
|
|
||||||
await _dispatcher.InvokeAsync(() => _floatingStatusWindow.SetText("Checking for update..."));
|
await _dispatcher.InvokeAsync(() => _floatingStatusWindow.SetText(Resources.CheckingForUpdate));
|
||||||
|
|
||||||
var newVersion = await UpdateCheck.UpdateManager.CheckForUpdatesAsync();
|
var newVersion = await UpdateCheck.UpdateManager.CheckForUpdatesAsync();
|
||||||
|
|
||||||
@@ -55,13 +55,13 @@ internal class WindowSource : IWindowSource, IDisposable
|
|||||||
|
|
||||||
Log.Logger.Information("Downloading update");
|
Log.Logger.Information("Downloading update");
|
||||||
|
|
||||||
await _dispatcher.InvokeAsync(() => _floatingStatusWindow.SetText("Downloading update..."));
|
await _dispatcher.InvokeAsync(() => _floatingStatusWindow.SetText(Resources.DownloadingUpdate));
|
||||||
|
|
||||||
await UpdateCheck.UpdateManager.DownloadUpdatesAsync(newVersion);
|
await UpdateCheck.UpdateManager.DownloadUpdatesAsync(newVersion);
|
||||||
|
|
||||||
Log.Logger.Information("Installing update");
|
Log.Logger.Information("Installing update");
|
||||||
|
|
||||||
await _dispatcher.InvokeAsync(() => _floatingStatusWindow.SetText("Installing update..."));
|
await _dispatcher.InvokeAsync(() => _floatingStatusWindow.SetText(Resources.InstallingUpdate));
|
||||||
|
|
||||||
UpdateCheck.UpdateManager.ApplyUpdatesAndRestart(newVersion);
|
UpdateCheck.UpdateManager.ApplyUpdatesAndRestart(newVersion);
|
||||||
}
|
}
|
||||||
@@ -92,7 +92,7 @@ internal class WindowSource : IWindowSource, IDisposable
|
|||||||
|
|
||||||
private void Load()
|
private void Load()
|
||||||
{
|
{
|
||||||
_timeZoneEntries = JsonSerializer.Deserialize<List<TimeZoneEntry>>(Properties.Settings.Default.TimeZones);
|
_timeZoneEntries = JsonSerializer.Deserialize<List<TimeZoneEntry>>(Settings.Default.TimeZones);
|
||||||
|
|
||||||
if (_timeZoneEntries.Any())
|
if (_timeZoneEntries.Any())
|
||||||
return;
|
return;
|
||||||
@@ -107,8 +107,8 @@ internal class WindowSource : IWindowSource, IDisposable
|
|||||||
|
|
||||||
private void Save()
|
private void Save()
|
||||||
{
|
{
|
||||||
Properties.Settings.Default.TimeZones = JsonSerializer.Serialize(_timeZoneEntries);
|
Settings.Default.TimeZones = JsonSerializer.Serialize(_timeZoneEntries);
|
||||||
Properties.Settings.Default.Save();
|
Settings.Default.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleTimerElapsed(object sender, ElapsedEventArgs e)
|
private void HandleTimerElapsed(object sender, ElapsedEventArgs e)
|
||||||
@@ -126,7 +126,7 @@ internal class WindowSource : IWindowSource, IDisposable
|
|||||||
if (text.Length > 0)
|
if (text.Length > 0)
|
||||||
text.AppendLine();
|
text.AppendLine();
|
||||||
|
|
||||||
text.Append($"{timeZoneEntry.Label.PadLeft(labelLength)}: {TimeZoneInfo.ConvertTime(now, timeZone).ToString(Properties.Settings.Default.TimeFormat)}");
|
text.Append($"{timeZoneEntry.Label.PadLeft(labelLength)}: {TimeZoneInfo.ConvertTime(now, timeZone).ToString(Settings.Default.TimeFormat)}");
|
||||||
}
|
}
|
||||||
|
|
||||||
_dispatcher.Invoke(() => _floatingStatusWindow.SetText(text.ToString()));
|
_dispatcher.Invoke(() => _floatingStatusWindow.SetText(text.ToString()));
|
||||||
@@ -143,9 +143,9 @@ internal class WindowSource : IWindowSource, IDisposable
|
|||||||
|
|
||||||
public Guid Id => Guid.Parse("29DF6CFD-6783-406F-AE12-4723EB7741EA");
|
public Guid Id => Guid.Parse("29DF6CFD-6783-406F-AE12-4723EB7741EA");
|
||||||
|
|
||||||
public string Name => "World Clock";
|
public string Name => Resources.ApplicationName;
|
||||||
|
|
||||||
public System.Drawing.Icon Icon => Properties.Resources.ApplicationIcon;
|
public System.Drawing.Icon Icon => Resources.ApplicationIcon;
|
||||||
|
|
||||||
public bool HasSettingsMenu => true;
|
public bool HasSettingsMenu => true;
|
||||||
|
|
||||||
@@ -153,7 +153,6 @@ internal class WindowSource : IWindowSource, IDisposable
|
|||||||
|
|
||||||
public void ShowAbout()
|
public void ShowAbout()
|
||||||
{
|
{
|
||||||
_floatingStatusWindow.SetText(Assembly.GetEntryAssembly()!.GetName().Version!.ToString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowSettings()
|
public void ShowSettings()
|
||||||
@@ -165,7 +164,7 @@ internal class WindowSource : IWindowSource, IDisposable
|
|||||||
new AboutSettingsPanel()
|
new AboutSettingsPanel()
|
||||||
};
|
};
|
||||||
|
|
||||||
var settingsWindow = new CategoryWindow(categoryPanels, Properties.Resources.SettingsTitle, Properties.Resources.CloseButtonText);
|
var settingsWindow = new CategoryWindow(categoryPanels, Resources.SettingsTitle, Resources.CloseButtonText);
|
||||||
|
|
||||||
var dialogResult = settingsWindow.ShowDialog();
|
var dialogResult = settingsWindow.ShowDialog();
|
||||||
|
|
||||||
@@ -183,11 +182,11 @@ internal class WindowSource : IWindowSource, IDisposable
|
|||||||
|
|
||||||
public string WindowSettings
|
public string WindowSettings
|
||||||
{
|
{
|
||||||
get => Properties.Settings.Default.WindowSettings;
|
get => Settings.Default.WindowSettings;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
Properties.Settings.Default.WindowSettings = value;
|
Settings.Default.WindowSettings = value;
|
||||||
Properties.Settings.Default.Save();
|
Settings.Default.Save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user