migrate to svg symbols & add maintenance info

This commit is contained in:
2024-06-20 07:24:23 +02:00
parent fc27fc1c34
commit 3dc69a4f26
34 changed files with 288 additions and 503 deletions

View File

@@ -1,6 +1,7 @@
using ModpackUpdater.Manager;
using ModpackUpdater.Model;
using ModpackUpdater.My.Resources;
using Pilz.UI.Telerik;
using System.Diagnostics;
using Telerik.WinControls;
using Telerik.WinControls.UI;
@@ -28,7 +29,16 @@ public partial class Form1
public Form1()
{
InitializeComponent();
Text = $"{Text} (v{Application.ProductVersion})";
RadButton_Install.SvgImage = AppSymbolFactory.Instance.GetSvgImage(AppSymbols.software_installer, SvgImageSize.Small);
RadButton_CheckForUpdates.SvgImage = AppSymbolFactory.Instance.GetSvgImage(AppSymbols.update_done, SvgImageSize.Small);
RadButton_EditModpackConfig.SvgImage = AppSymbolFactory.Instance.GetSvgImage(AppSymbols.wrench, SvgImageSize.Small);
radButton_RefreshConfig.SvgImage = AppSymbolFactory.Instance.GetSvgImage(AppSymbols.refresh, SvgImageSize.Small);
RadButton_SearchMinecraftProfileFolder.SvgImage = AppSymbolFactory.Instance.GetSvgImage(AppSymbols.opened_folder, SvgImageSize.Small);
RadButton_SearchModpackConfig.SvgImage = AppSymbolFactory.Instance.GetSvgImage(AppSymbols.opened_folder, SvgImageSize.Small);
RadButton_PasteModpackConfig.SvgImage = AppSymbolFactory.Instance.GetSvgImage(AppSymbols.paste, SvgImageSize.Small);
}
private bool IsMinecaftProfileLoaded()
@@ -57,12 +67,12 @@ public partial class Form1
if (!IsMinecaftProfileLoaded() || !MinecraftProfileChecker.CheckProfile(GetMinecraftProfilePath()))
{
SetStatus(LangRes.StatusText_MinecraftProfileWarning, MySymbols.icons8_general_warning_sign_16px);
SetStatus(LangRes.StatusText_MinecraftProfileWarning, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.general_warning_sign, SvgImageSize.Small));
CheckStatusRet = false;
}
else if (!IsUpdateConfigLoaded())
{
SetStatus(LangRes.StatusText_MinecraftProfileWarning, MySymbols.icons8_general_warning_sign_16px);
SetStatus(LangRes.StatusText_MinecraftProfileWarning, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.general_warning_sign, SvgImageSize.Small));
CheckStatusRet = false;
}
else
@@ -71,16 +81,16 @@ public partial class Form1
return CheckStatusRet;
}
private void SetStatus(string statusText, Image image)
private void SetStatus(string statusText, RadSvgImage image)
{
RadLabel_Status.Text = statusText;
RadLabel_Status.Image = image;
RadLabel_Status.SvgImage = image;
}
private void ClearStatus()
{
RadLabel_Status.Text = "-";
RadLabel_Status.Image = null;
RadLabel_Status.SvgImage = null;
}
private void LoadMinecraftProfile(string folderPath)
@@ -107,7 +117,9 @@ public partial class Form1
RadTextBoxControl_ModpackConfig.Text = string.Empty;
}
if (IsMinecaftProfileLoaded())
if (updateConfig != null && updateConfig.Maintenance && !updateOptions.IgnoreMaintenance)
SetStatus(LangRes.StatusText_Maintenance, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.services, SvgImageSize.Small));
else if (IsMinecaftProfileLoaded())
RadButton_CheckForUpdates.PerformClick();
else
ClearStatus();
@@ -122,7 +134,7 @@ public partial class Form1
// Check only if not pressed "install", not really needed otherwise.
if (lastUpdateCheckResult is null || !doInstall)
{
SetStatus(LangRes.StatusText_CheckingForUpdates, MySymbols.icons8_update_16px);
SetStatus(LangRes.StatusText_CheckingForUpdates, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.update_done, SvgImageSize.Small));
try
{
@@ -130,7 +142,7 @@ public partial class Form1
}
catch
{
SetStatus(LangRes.StatusText_ErrorWhileUpdateCheckOrUpdate, MySymbols.icons8_delete_16px);
SetStatus(LangRes.StatusText_ErrorWhileUpdateCheckOrUpdate, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.close, SvgImageSize.Small));
}
finally
{
@@ -138,12 +150,12 @@ public partial class Form1
}
if (lastUpdateCheckResult is null || lastUpdateCheckResult.HasError)
SetStatus(LangRes.StatusText_ErrorWhileUpdateCheckOrUpdate, MySymbols.icons8_delete_16px);
SetStatus(LangRes.StatusText_ErrorWhileUpdateCheckOrUpdate, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.close, SvgImageSize.Small));
else if (lastUpdateCheckResult.HasUpdates)
{
if (doInstall)
{
SetStatus(LangRes.StatusText_Installing, MySymbols.icons8_software_installer_16px);
SetStatus(LangRes.StatusText_Installing, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.software_installer, SvgImageSize.Small));
currentUpdating = true;
try
@@ -151,14 +163,14 @@ public partial class Form1
if (await updater.Install(lastUpdateCheckResult) == true)
{
lastUpdateCheckResult = null; // Reset last update check, a new one would be needed now.
SetStatus(LangRes.StatusTest_EverythingOk, MySymbols.icons8_checkmark_16px);
SetStatus(LangRes.StatusTest_EverythingOk, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.done, SvgImageSize.Small));
}
else
SetStatus(LangRes.StatusText_ErrorWhileUpdateCheckOrUpdate, MySymbols.icons8_delete_16px);
SetStatus(LangRes.StatusText_ErrorWhileUpdateCheckOrUpdate, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.close, SvgImageSize.Small));
}
catch(Exception)
catch (Exception)
{
SetStatus(LangRes.StatusText_ErrorWhileUpdateCheckOrUpdate, MySymbols.icons8_delete_16px);
SetStatus(LangRes.StatusText_ErrorWhileUpdateCheckOrUpdate, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.close, SvgImageSize.Small));
if (Debugger.IsAttached)
throw;
}
@@ -168,21 +180,21 @@ public partial class Form1
}
}
else
SetStatus(LangRes.StatusText_UpdateAvailable, MySymbols.icons8_software_installer_16px);
SetStatus(LangRes.StatusText_UpdateAvailable, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.software_installer, SvgImageSize.Small));
}
else
SetStatus(LangRes.StatusTest_EverythingOk, MySymbols.icons8_checkmark_16px);
SetStatus(LangRes.StatusTest_EverythingOk, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.done, SvgImageSize.Small));
}
private void Update_InstallProgessUpdated(UpdateCheckResult result, int processedSyncs)
{
int actionCount = result.Actions.Count;
SetStatus(Math.Round(processedSyncs / (double)actionCount * 100d, 1) + "%", MySymbols.icons8_software_installer_16px);
SetStatus(Math.Round(processedSyncs / (double)actionCount * 100d, 1) + "%", AppSymbolFactory.Instance.GetSvgImage(AppSymbols.software_installer, SvgImageSize.Small));
}
private void Updated_CheckingProgresssUpdated(int toCheck, int processed)
{
SetStatus(Math.Round(processed / (double)toCheck * 100d, 1) + "%", MySymbols.icons8_update_16px);
SetStatus(Math.Round(processed / (double)toCheck * 100d, 1) + "%", AppSymbolFactory.Instance.GetSvgImage(AppSymbols.update_done, SvgImageSize.Small));
}
private void ButtonX_SearchMinecraftProfile_Click(object sender, EventArgs e)
@@ -208,6 +220,11 @@ public partial class Form1
LoadUpdateConfigFile(text);
}
private void RadButton_RefreshConfig_Click(object sender, EventArgs e)
{
LoadUpdateConfigFile(RadTextBoxControl_ModpackConfig.Text);
}
private async void ButtonX_CheckForUpdates_Click(object sender, EventArgs e)
{
ClearStatus();
@@ -244,7 +261,7 @@ public partial class Form1
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)
{
SetStatus(LangRes.StatusText_InstallingAppUpdate, MySymbols.icons8_software_installer_16px);
SetStatus(LangRes.StatusText_InstallingAppUpdate, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.software_installer, SvgImageSize.Small));
Enabled = false;
await updater.Install();
Application.Restart();