ui(client): formatting & code improvements

This commit is contained in:
2025-11-07 15:22:28 +01:00
parent 4baf571713
commit 1c070891f1
3 changed files with 13 additions and 16 deletions

View File

@@ -54,7 +54,7 @@ public class AppUpdater(string updateUrl)
} }
// Download the new file // Download the new file
using (var tempFileStream = new FileStream(tempFileName, FileMode.Create, FileAccess.ReadWrite)) await using (var tempFileStream = new FileStream(tempFileName, FileMode.Create, FileAccess.ReadWrite))
{ {
Stream? downloadStream = null; Stream? downloadStream = null;
try try
@@ -68,7 +68,8 @@ public class AppUpdater(string updateUrl)
} }
finally finally
{ {
downloadStream?.Dispose(); if (downloadStream != null)
await downloadStream.DisposeAsync();
} }
} }

View File

@@ -62,9 +62,9 @@ public partial class MainForm : Window
{ {
loadingData = true; loadingData = true;
TextBoxMinecraftProfileFolder.Text = modpackInfo?.LocaLPath ?? AppConfig.Instance.LastMinecraftProfilePath ?? TextBoxMinecraftProfileFolder.Text; TextBoxMinecraftProfileFolder.Text = modpackInfo.LocaLPath ?? AppConfig.Instance.LastMinecraftProfilePath ?? TextBoxMinecraftProfileFolder.Text;
TextBoxModpackConfig.Text = modpackInfo?.ConfigUrl ?? TextBoxModpackConfig.Text; TextBoxModpackConfig.Text = modpackInfo.ConfigUrl ?? TextBoxModpackConfig.Text;
TextBoxInstallKey.Text = modpackInfo?.ExtrasKey ?? TextBoxInstallKey.Text; TextBoxInstallKey.Text = modpackInfo.ExtrasKey ?? TextBoxInstallKey.Text;
loadingData = false; loadingData = false;
} }
@@ -186,9 +186,6 @@ public partial class MainForm : Window
if (Debugger.IsAttached) if (Debugger.IsAttached)
throw; throw;
} }
finally
{
}
} }
// Error while update check // Error while update check
@@ -263,7 +260,7 @@ public partial class MainForm : Window
private async void MainForm_Loaded(object? sender, RoutedEventArgs e) private async void MainForm_Loaded(object? sender, RoutedEventArgs e)
{ {
var updater = new AppUpdater(Program.UPDATE_URL); var updater = new AppUpdater(Program.UpdateUrl);
if (await updater.Check() && await MessageBoxManager.GetMessageBoxStandard(MsgBoxLangRes.UpdateAvailable_Title, MsgBoxLangRes.UpdateAvailable, ButtonEnum.YesNo).ShowWindowDialogAsync(this) == ButtonResult.Ok) if (await updater.Check() && await MessageBoxManager.GetMessageBoxStandard(MsgBoxLangRes.UpdateAvailable_Title, MsgBoxLangRes.UpdateAvailable, ButtonEnum.YesNo).ShowWindowDialogAsync(this) == ButtonResult.Ok)
{ {
SetStatus(GeneralLangRes.DownloadProgramUpdate, Symbols.Fluent.GetImageSource(SymbolsFluent.software_installer)); SetStatus(GeneralLangRes.DownloadProgramUpdate, Symbols.Fluent.GetImageSource(SymbolsFluent.software_installer));

View File

@@ -7,13 +7,12 @@ namespace ModpackUpdater.Apps.Client.Gui;
public static class Program public static class Program
{ {
public const string UPDATE_URL = "https://git.pilzinsel64.de/litw-refined/minecraft-modpack-updater/-/snippets/3/raw/main/updates.json"; public const string UpdateUrl = "https://git.pilzinsel64.de/litw-refined/minecraft-modpack-updater/-/snippets/3/raw/main/updates.json";
private static readonly SettingsManager settingsManager; private static readonly SettingsManager settingsManager;
private static readonly ILogger log = new ConsoleLogger();
public static ISettings Settings => settingsManager.Instance; public static ISettings Settings => settingsManager.Instance;
public static ILogger Log => log; public static ILogger Log { get; } = new ConsoleLogger();
static Program() static Program()
{ {
@@ -37,13 +36,13 @@ public static class Program
private static string GetSettingsPath(int? settingsVersion = 3) private static string GetSettingsPath(int? settingsVersion = 3)
{ {
const string AppDataDirectoryName = "MinecraftModpackUpdater"; const string appDataDirectoryName = "MinecraftModpackUpdater";
var fileNamePostfix = settingsVersion == null ? string.Empty : $"V{settingsVersion}"; var fileNamePostfix = settingsVersion == null ? string.Empty : $"V{settingsVersion}";
var SettingsFileName = $"Settings{fileNamePostfix}.json"; var settingsFileName = $"Settings{fileNamePostfix}.json";
var settingsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), AppDataDirectoryName); var settingsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), appDataDirectoryName);
Directory.CreateDirectory(settingsPath); Directory.CreateDirectory(settingsPath);
settingsPath = Path.Combine(settingsPath, SettingsFileName); settingsPath = Path.Combine(settingsPath, settingsFileName);
return settingsPath; return settingsPath;
} }