migration due nuget updates

This commit is contained in:
2024-09-05 14:53:39 +02:00
parent 7c4dae8c8d
commit 46179463e1
3 changed files with 24 additions and 22 deletions

View File

@@ -1,18 +1,19 @@
using Pilz.UI.Telerik; using Pilz.UI.Telerik;
using Pilz.UI.Telerik.Symbols;
using System.Reflection; using System.Reflection;
namespace ModpackUpdater; namespace ModpackUpdater;
public class AppSymbolFactory : SymbolFactory<AppSymbols> public class AppSymbolFactory : RadSymbolFactory<AppSymbols>
{ {
public static AppSymbolFactory Instance { get; } = new(); public static IRadSymbolFactory<AppSymbols> Instance { get; } = new AppSymbolFactory();
public override Assembly GetSvgImageResourceAssembly() public override Assembly GetImageResourceAssembly()
{ {
return Assembly.GetExecutingAssembly(); return Assembly.GetExecutingAssembly();
} }
public override string GetSvgImageRessourcePath(AppSymbols svgImage) public override string GetImageRessourcePath(AppSymbols svgImage)
{ {
return $"{GetType().Namespace}.Symbols.{svgImage}.svg"; return $"{GetType().Namespace}.Symbols.{svgImage}.svg";
} }

View File

@@ -41,7 +41,7 @@ public class AppUpdater
{ {
var client = new HttpClient(); var client = new HttpClient();
var tempFileName = Path.GetTempFileName(); var tempFileName = Path.GetTempFileName();
var appFileName = Pilz.IO.Extensions.GetExecutablePath(); var appFileName = Pilz.Win32.NativeTools.GetExecutablePath();
var oldFileName = appFileName + ".old"; var oldFileName = appFileName + ".old";
// Delete old file // Delete old file

View File

@@ -1,6 +1,7 @@
using ModpackUpdater.Manager; using ModpackUpdater.Manager;
using ModpackUpdater.Model; using ModpackUpdater.Model;
using ModpackUpdater.My.Resources; using ModpackUpdater.My.Resources;
using Pilz.UI.Symbols;
using Pilz.UI.Telerik; using Pilz.UI.Telerik;
using System.Diagnostics; using System.Diagnostics;
using System.Reflection; using System.Reflection;
@@ -34,12 +35,12 @@ public partial class Form1
Text = $"{Text} (v{Assembly.GetExecutingAssembly().GetName().Version})"; Text = $"{Text} (v{Assembly.GetExecutingAssembly().GetName().Version})";
RadButton_Install.SvgImage = AppSymbolFactory.Instance.GetSvgImage(AppSymbols.software_installer, SvgImageSize.Small); RadButton_Install.SvgImage = AppSymbolFactory.Instance.GetSvgImage(AppSymbols.software_installer, SymbolSize.Small);
RadButton_CheckForUpdates.SvgImage = AppSymbolFactory.Instance.GetSvgImage(AppSymbols.update_done, SvgImageSize.Small); RadButton_CheckForUpdates.SvgImage = AppSymbolFactory.Instance.GetSvgImage(AppSymbols.update_done, SymbolSize.Small);
radButton_RefreshConfig.SvgImage = AppSymbolFactory.Instance.GetSvgImage(AppSymbols.refresh, SvgImageSize.Small); radButton_RefreshConfig.SvgImage = AppSymbolFactory.Instance.GetSvgImage(AppSymbols.refresh, SymbolSize.Small);
RadButton_SearchMinecraftProfileFolder.SvgImage = AppSymbolFactory.Instance.GetSvgImage(AppSymbols.opened_folder, SvgImageSize.Small); RadButton_SearchMinecraftProfileFolder.SvgImage = AppSymbolFactory.Instance.GetSvgImage(AppSymbols.opened_folder, SymbolSize.Small);
radButton_PasteInstallKey.SvgImage = AppSymbolFactory.Instance.GetSvgImage(AppSymbols.paste, SvgImageSize.Small); radButton_PasteInstallKey.SvgImage = AppSymbolFactory.Instance.GetSvgImage(AppSymbols.paste, SymbolSize.Small);
RadButton_PasteModpackConfig.SvgImage = AppSymbolFactory.Instance.GetSvgImage(AppSymbols.paste, SvgImageSize.Small); RadButton_PasteModpackConfig.SvgImage = AppSymbolFactory.Instance.GetSvgImage(AppSymbols.paste, SymbolSize.Small);
} }
private void LoadMinecraftProfile(string folderPath) private void LoadMinecraftProfile(string folderPath)
@@ -107,7 +108,7 @@ public partial class Form1
if (modpackInfo == null || string.IsNullOrWhiteSpace(RadTextBoxControl_MinecraftProfileFolder.Text) /*|| modpackInfo.Valid*/) if (modpackInfo == null || string.IsNullOrWhiteSpace(RadTextBoxControl_MinecraftProfileFolder.Text) /*|| modpackInfo.Valid*/)
{ {
SetStatus(LangRes.StatusText_MinecraftProfileWarning, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.general_warning_sign, SvgImageSize.Small)); SetStatus(LangRes.StatusText_MinecraftProfileWarning, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.general_warning_sign, SymbolSize.Small));
RadButton_PasteModpackConfig.Enabled = false; RadButton_PasteModpackConfig.Enabled = false;
radButton_PasteInstallKey.Enabled = false; radButton_PasteInstallKey.Enabled = false;
RadButton_CheckForUpdates.Enabled = false; RadButton_CheckForUpdates.Enabled = false;
@@ -116,7 +117,7 @@ public partial class Form1
} }
else if (updateConfig == null || string.IsNullOrWhiteSpace(RadTextBoxControl_ModpackConfig.Text)) else if (updateConfig == null || string.IsNullOrWhiteSpace(RadTextBoxControl_ModpackConfig.Text))
{ {
SetStatus(LangRes.StatusText_ConfigIncompleteOrNotLoaded, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.general_warning_sign, SvgImageSize.Small)); SetStatus(LangRes.StatusText_ConfigIncompleteOrNotLoaded, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.general_warning_sign, SymbolSize.Small));
RadButton_PasteModpackConfig.Enabled = true; RadButton_PasteModpackConfig.Enabled = true;
radButton_PasteInstallKey.Enabled = false; radButton_PasteInstallKey.Enabled = false;
RadButton_CheckForUpdates.Enabled = false; RadButton_CheckForUpdates.Enabled = false;
@@ -125,7 +126,7 @@ public partial class Form1
} }
else if (updateConfig.Maintenance && !updateOptions.IgnoreMaintenance) else if (updateConfig.Maintenance && !updateOptions.IgnoreMaintenance)
{ {
SetStatus(LangRes.StatusText_Maintenance, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.services, SvgImageSize.Small)); SetStatus(LangRes.StatusText_Maintenance, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.services, SymbolSize.Small));
RadButton_PasteModpackConfig.Enabled = true; RadButton_PasteModpackConfig.Enabled = true;
radButton_PasteInstallKey.Enabled = true; radButton_PasteInstallKey.Enabled = true;
RadButton_CheckForUpdates.Enabled = false; RadButton_CheckForUpdates.Enabled = false;
@@ -148,28 +149,28 @@ public partial class Form1
void error() void error()
{ {
SetStatus(LangRes.StatusText_ErrorWhileUpdateCheckOrUpdate, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.close, SvgImageSize.Small)); SetStatus(LangRes.StatusText_ErrorWhileUpdateCheckOrUpdate, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.close, SymbolSize.Small));
currentUpdating = false; currentUpdating = false;
} }
void installing() void installing()
{ {
SetStatus(LangRes.StatusText_Installing, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.software_installer, SvgImageSize.Small)); SetStatus(LangRes.StatusText_Installing, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.software_installer, SymbolSize.Small));
currentUpdating = true; currentUpdating = true;
} }
void updatesAvailable() void updatesAvailable()
{ {
SetStatus(LangRes.StatusText_UpdateAvailable, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.software_installer, SvgImageSize.Small)); SetStatus(LangRes.StatusText_UpdateAvailable, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.software_installer, SymbolSize.Small));
} }
void everythingOk() void everythingOk()
{ {
SetStatus(LangRes.StatusTest_EverythingOk, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.done, SvgImageSize.Small)); SetStatus(LangRes.StatusTest_EverythingOk, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.done, SymbolSize.Small));
currentUpdating = false; currentUpdating = false;
} }
// Check only if not pressed "install", not really needed otherwise. // Check only if not pressed "install", not really needed otherwise.
if (lastUpdateCheckResult is null || !doInstall) if (lastUpdateCheckResult is null || !doInstall)
{ {
SetStatus(LangRes.StatusText_CheckingForUpdates, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.update_done, SvgImageSize.Small)); SetStatus(LangRes.StatusText_CheckingForUpdates, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.update_done, SymbolSize.Small));
// Check for extras once again // Check for extras once again
updateOptions.IncludeExtras = features.IsEnabled(ModpackFeatures.FeatureAllowExtas, new AllowExtrasFeatureContext(modpackInfo)); updateOptions.IncludeExtras = features.IsEnabled(ModpackFeatures.FeatureAllowExtas, new AllowExtrasFeatureContext(modpackInfo));
@@ -238,12 +239,12 @@ public partial class Form1
private void Update_InstallProgessUpdated(UpdateCheckResult result, int processedSyncs) private void Update_InstallProgessUpdated(UpdateCheckResult result, int processedSyncs)
{ {
int actionCount = result.Actions.Count; int actionCount = result.Actions.Count;
SetStatus(Math.Round(processedSyncs / (double)actionCount * 100d, 1) + "%", AppSymbolFactory.Instance.GetSvgImage(AppSymbols.software_installer, SvgImageSize.Small)); SetStatus(Math.Round(processedSyncs / (double)actionCount * 100d, 1) + "%", AppSymbolFactory.Instance.GetSvgImage(AppSymbols.software_installer, SymbolSize.Small));
} }
private void Updated_CheckingProgresssUpdated(int toCheck, int processed) private void Updated_CheckingProgresssUpdated(int toCheck, int processed)
{ {
SetStatus(Math.Round(processed / (double)toCheck * 100d, 1) + "%", AppSymbolFactory.Instance.GetSvgImage(AppSymbols.update_done, SvgImageSize.Small)); SetStatus(Math.Round(processed / (double)toCheck * 100d, 1) + "%", AppSymbolFactory.Instance.GetSvgImage(AppSymbols.update_done, SymbolSize.Small));
} }
private void ButtonX_SearchMinecraftProfile_Click(object sender, EventArgs e) private void ButtonX_SearchMinecraftProfile_Click(object sender, EventArgs e)
@@ -299,7 +300,7 @@ public partial class Form1
var updater = new AppUpdater(); var updater = new AppUpdater();
if (!updateOptions.NoUpdate && await updater.Check() && RadMessageBox.Show(LangRes.MsgBox_UpdateAvailable, LangRes.MsgBox_UpdateAvailable_Title, MessageBoxButtons.YesNo, RadMessageIcon.Info) == DialogResult.Yes) if (!updateOptions.NoUpdate && await updater.Check() && RadMessageBox.Show(LangRes.MsgBox_UpdateAvailable, LangRes.MsgBox_UpdateAvailable_Title, MessageBoxButtons.YesNo, RadMessageIcon.Info) == DialogResult.Yes)
{ {
SetStatus(LangRes.StatusText_InstallingAppUpdate, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.software_installer, SvgImageSize.Small)); SetStatus(LangRes.StatusText_InstallingAppUpdate, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.software_installer, SymbolSize.Small));
Enabled = false; Enabled = false;
await updater.Install(); await updater.Install();
Application.Restart(); Application.Restart();