ui(client): formatting & code improvements
This commit is contained in:
@@ -54,7 +54,7 @@ public class AppUpdater(string updateUrl)
|
||||
}
|
||||
|
||||
// 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;
|
||||
try
|
||||
@@ -68,7 +68,8 @@ public class AppUpdater(string updateUrl)
|
||||
}
|
||||
finally
|
||||
{
|
||||
downloadStream?.Dispose();
|
||||
if (downloadStream != null)
|
||||
await downloadStream.DisposeAsync();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,9 +62,9 @@ public partial class MainForm : Window
|
||||
{
|
||||
loadingData = true;
|
||||
|
||||
TextBoxMinecraftProfileFolder.Text = modpackInfo?.LocaLPath ?? AppConfig.Instance.LastMinecraftProfilePath ?? TextBoxMinecraftProfileFolder.Text;
|
||||
TextBoxModpackConfig.Text = modpackInfo?.ConfigUrl ?? TextBoxModpackConfig.Text;
|
||||
TextBoxInstallKey.Text = modpackInfo?.ExtrasKey ?? TextBoxInstallKey.Text;
|
||||
TextBoxMinecraftProfileFolder.Text = modpackInfo.LocaLPath ?? AppConfig.Instance.LastMinecraftProfilePath ?? TextBoxMinecraftProfileFolder.Text;
|
||||
TextBoxModpackConfig.Text = modpackInfo.ConfigUrl ?? TextBoxModpackConfig.Text;
|
||||
TextBoxInstallKey.Text = modpackInfo.ExtrasKey ?? TextBoxInstallKey.Text;
|
||||
|
||||
loadingData = false;
|
||||
}
|
||||
@@ -186,9 +186,6 @@ public partial class MainForm : Window
|
||||
if (Debugger.IsAttached)
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Error while update check
|
||||
@@ -263,7 +260,7 @@ public partial class MainForm : Window
|
||||
|
||||
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)
|
||||
{
|
||||
SetStatus(GeneralLangRes.DownloadProgramUpdate, Symbols.Fluent.GetImageSource(SymbolsFluent.software_installer));
|
||||
|
||||
@@ -7,13 +7,12 @@ namespace ModpackUpdater.Apps.Client.Gui;
|
||||
|
||||
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 ILogger log = new ConsoleLogger();
|
||||
|
||||
public static ISettings Settings => settingsManager.Instance;
|
||||
public static ILogger Log => log;
|
||||
public static ILogger Log { get; } = new ConsoleLogger();
|
||||
|
||||
static Program()
|
||||
{
|
||||
@@ -37,13 +36,13 @@ public static class Program
|
||||
|
||||
private static string GetSettingsPath(int? settingsVersion = 3)
|
||||
{
|
||||
const string AppDataDirectoryName = "MinecraftModpackUpdater";
|
||||
const string appDataDirectoryName = "MinecraftModpackUpdater";
|
||||
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);
|
||||
settingsPath = Path.Combine(settingsPath, SettingsFileName);
|
||||
settingsPath = Path.Combine(settingsPath, settingsFileName);
|
||||
|
||||
return settingsPath;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user