more refactoring

This commit is contained in:
2024-09-06 09:14:25 +02:00
parent 3625962a27
commit 5bccd070f4
31 changed files with 216 additions and 71 deletions

View File

@@ -3,7 +3,7 @@ using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
namespace ModpackUpdater
namespace ModpackUpdater.Apps.Client
{
[Microsoft.VisualBasic.CompilerServices.DesignerGenerated()]

View File

@@ -1,14 +1,12 @@
using ModpackUpdater.Apps.Client;
using ModpackUpdater.Manager;
using ModpackUpdater.Manager;
using ModpackUpdater.My.Resources;
using Pilz.UI.Symbols;
using Pilz.UI.Telerik;
using System.Diagnostics;
using System.Reflection;
using Telerik.WinControls;
using Telerik.WinControls.UI;
namespace ModpackUpdater;
namespace ModpackUpdater.Apps.Client;
public partial class Form1
{
@@ -35,12 +33,12 @@ public partial class Form1
Text = $"{Text} (v{Assembly.GetExecutingAssembly().GetName().Version})";
RadButton_Install.SvgImage = AppSymbolFactory.Instance.GetSvgImage(AppSymbols.software_installer, SymbolSize.Small);
RadButton_CheckForUpdates.SvgImage = AppSymbolFactory.Instance.GetSvgImage(AppSymbols.update_done, SymbolSize.Small);
radButton_RefreshConfig.SvgImage = AppSymbolFactory.Instance.GetSvgImage(AppSymbols.refresh, SymbolSize.Small);
RadButton_SearchMinecraftProfileFolder.SvgImage = AppSymbolFactory.Instance.GetSvgImage(AppSymbols.opened_folder, SymbolSize.Small);
radButton_PasteInstallKey.SvgImage = AppSymbolFactory.Instance.GetSvgImage(AppSymbols.paste, SymbolSize.Small);
RadButton_PasteModpackConfig.SvgImage = AppSymbolFactory.Instance.GetSvgImage(AppSymbols.paste, SymbolSize.Small);
RadButton_Install.SvgImage = AppGlobals.Symbols.GetSvgImage(AppSymbols.software_installer, SymbolSize.Small);
RadButton_CheckForUpdates.SvgImage = AppGlobals.Symbols.GetSvgImage(AppSymbols.update_done, SymbolSize.Small);
radButton_RefreshConfig.SvgImage = AppGlobals.Symbols.GetSvgImage(AppSymbols.refresh, SymbolSize.Small);
RadButton_SearchMinecraftProfileFolder.SvgImage = AppGlobals.Symbols.GetSvgImage(AppSymbols.opened_folder, SymbolSize.Small);
radButton_PasteInstallKey.SvgImage = AppGlobals.Symbols.GetSvgImage(AppSymbols.paste, SymbolSize.Small);
RadButton_PasteModpackConfig.SvgImage = AppGlobals.Symbols.GetSvgImage(AppSymbols.paste, SymbolSize.Small);
}
private void LoadMinecraftProfile(string folderPath)
@@ -108,7 +106,7 @@ public partial class Form1
if (modpackInfo == null || string.IsNullOrWhiteSpace(RadTextBoxControl_MinecraftProfileFolder.Text) /*|| modpackInfo.Valid*/)
{
SetStatus(LangRes.StatusText_MinecraftProfileWarning, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.general_warning_sign, SymbolSize.Small));
SetStatus(LangRes.StatusText_MinecraftProfileWarning, AppGlobals.Symbols.GetSvgImage(AppSymbols.general_warning_sign, SymbolSize.Small));
RadButton_PasteModpackConfig.Enabled = false;
radButton_PasteInstallKey.Enabled = false;
RadButton_CheckForUpdates.Enabled = false;
@@ -117,7 +115,7 @@ public partial class Form1
}
else if (updateConfig == null || string.IsNullOrWhiteSpace(RadTextBoxControl_ModpackConfig.Text))
{
SetStatus(LangRes.StatusText_ConfigIncompleteOrNotLoaded, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.general_warning_sign, SymbolSize.Small));
SetStatus(LangRes.StatusText_ConfigIncompleteOrNotLoaded, AppGlobals.Symbols.GetSvgImage(AppSymbols.general_warning_sign, SymbolSize.Small));
RadButton_PasteModpackConfig.Enabled = true;
radButton_PasteInstallKey.Enabled = false;
RadButton_CheckForUpdates.Enabled = false;
@@ -126,7 +124,7 @@ public partial class Form1
}
else if (updateConfig.Maintenance && !updateOptions.IgnoreMaintenance)
{
SetStatus(LangRes.StatusText_Maintenance, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.services, SymbolSize.Small));
SetStatus(LangRes.StatusText_Maintenance, AppGlobals.Symbols.GetSvgImage(AppSymbols.services, SymbolSize.Small));
RadButton_PasteModpackConfig.Enabled = true;
radButton_PasteInstallKey.Enabled = true;
RadButton_CheckForUpdates.Enabled = false;
@@ -149,28 +147,28 @@ public partial class Form1
void error()
{
SetStatus(LangRes.StatusText_ErrorWhileUpdateCheckOrUpdate, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.close, SymbolSize.Small));
SetStatus(LangRes.StatusText_ErrorWhileUpdateCheckOrUpdate, AppGlobals.Symbols.GetSvgImage(AppSymbols.close, SymbolSize.Small));
currentUpdating = false;
}
void installing()
{
SetStatus(LangRes.StatusText_Installing, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.software_installer, SymbolSize.Small));
SetStatus(LangRes.StatusText_Installing, AppGlobals.Symbols.GetSvgImage(AppSymbols.software_installer, SymbolSize.Small));
currentUpdating = true;
}
void updatesAvailable()
{
SetStatus(LangRes.StatusText_UpdateAvailable, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.software_installer, SymbolSize.Small));
SetStatus(LangRes.StatusText_UpdateAvailable, AppGlobals.Symbols.GetSvgImage(AppSymbols.software_installer, SymbolSize.Small));
}
void everythingOk()
{
SetStatus(LangRes.StatusTest_EverythingOk, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.done, SymbolSize.Small));
SetStatus(LangRes.StatusTest_EverythingOk, AppGlobals.Symbols.GetSvgImage(AppSymbols.done, SymbolSize.Small));
currentUpdating = false;
}
// Check only if not pressed "install", not really needed otherwise.
if (lastUpdateCheckResult is null || !doInstall)
{
SetStatus(LangRes.StatusText_CheckingForUpdates, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.update_done, SymbolSize.Small));
SetStatus(LangRes.StatusText_CheckingForUpdates, AppGlobals.Symbols.GetSvgImage(AppSymbols.update_done, SymbolSize.Small));
// Check for extras once again
updateOptions.IncludeExtras = features.IsEnabled(ModpackFeatures.FeatureAllowExtas, new AllowExtrasFeatureContext(modpackInfo));
@@ -239,12 +237,12 @@ public partial class Form1
private void Update_InstallProgessUpdated(UpdateCheckResult result, int processedSyncs)
{
int actionCount = result.Actions.Count;
SetStatus(Math.Round(processedSyncs / (double)actionCount * 100d, 1) + "%", AppSymbolFactory.Instance.GetSvgImage(AppSymbols.software_installer, SymbolSize.Small));
SetStatus(Math.Round(processedSyncs / (double)actionCount * 100d, 1) + "%", AppGlobals.Symbols.GetSvgImage(AppSymbols.software_installer, SymbolSize.Small));
}
private void Updated_CheckingProgresssUpdated(int toCheck, int processed)
{
SetStatus(Math.Round(processed / (double)toCheck * 100d, 1) + "%", AppSymbolFactory.Instance.GetSvgImage(AppSymbols.update_done, SymbolSize.Small));
SetStatus(Math.Round(processed / (double)toCheck * 100d, 1) + "%", AppGlobals.Symbols.GetSvgImage(AppSymbols.update_done, SymbolSize.Small));
}
private void ButtonX_SearchMinecraftProfile_Click(object sender, EventArgs e)
@@ -300,7 +298,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, AppSymbolFactory.Instance.GetSvgImage(AppSymbols.software_installer, SymbolSize.Small));
SetStatus(LangRes.StatusText_InstallingAppUpdate, AppGlobals.Symbols.GetSvgImage(AppSymbols.software_installer, SymbolSize.Small));
Enabled = false;
await updater.Install();
Application.Restart();

View File

@@ -11,14 +11,6 @@
<Version>1.5.2.2</Version>
</PropertyGroup>
<ItemGroup>
<None Remove="CustomThemes\Office2019DarkBluePurple.tssp" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="CustomThemes\Office2019DarkBluePurple.tssp" />
</ItemGroup>
<ItemGroup>
<Compile Update="FiledialogFilters.Designer.cs">
<DesignTime>True</DesignTime>
@@ -57,12 +49,9 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ModpackUpdater.Apps\ModpackUpdater.Apps.csproj" />
<ProjectReference Include="..\ModpackUpdater.Manager\ModpackUpdater.Manager.csproj" />
<ProjectReference Include="..\ModpackUpdater\ModpackUpdater.csproj" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Symbols\*.svg" />
</ItemGroup>
</Project>

View File

@@ -44,8 +44,10 @@ public static class Program
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.SetHighDpiMode(HighDpiMode.PerMonitorV2);
AppGlobals.Initialize();
if (ThemeResolutionService.LoadPackageResource("ModpackUpdater.CustomThemes.Office2019DarkBluePurple.tssp"))
// Keep old theme for now, it looks a bit better
if (ThemeResolutionService.LoadPackageResource($"{typeof(AppGlobals).Namespace}.CustomThemes.Office2019DarkBluePurple.tssp"))
ThemeResolutionService.ApplicationThemeName = "Office2019DarkBluePurple";
Application.Run(new Form1(updateOptions));

View File

@@ -28,11 +28,77 @@ partial class Form1
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "Form1";
radSplitContainer1 = new Telerik.WinControls.UI.RadSplitContainer();
splitPanel1 = new Telerik.WinControls.UI.SplitPanel();
splitPanel2 = new Telerik.WinControls.UI.SplitPanel();
((System.ComponentModel.ISupportInitialize)radSplitContainer1).BeginInit();
radSplitContainer1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)splitPanel1).BeginInit();
((System.ComponentModel.ISupportInitialize)splitPanel2).BeginInit();
((System.ComponentModel.ISupportInitialize)this).BeginInit();
SuspendLayout();
//
// radSplitContainer1
//
radSplitContainer1.Controls.Add(splitPanel1);
radSplitContainer1.Controls.Add(splitPanel2);
radSplitContainer1.Dock = DockStyle.Fill;
radSplitContainer1.Location = new Point(0, 0);
radSplitContainer1.Name = "radSplitContainer1";
//
//
//
radSplitContainer1.RootElement.MinSize = new Size(25, 25);
radSplitContainer1.Size = new Size(800, 450);
radSplitContainer1.TabIndex = 0;
radSplitContainer1.TabStop = false;
//
// splitPanel1
//
splitPanel1.Location = new Point(0, 0);
splitPanel1.Name = "splitPanel1";
//
//
//
splitPanel1.RootElement.MinSize = new Size(25, 25);
splitPanel1.Size = new Size(398, 450);
splitPanel1.TabIndex = 0;
splitPanel1.TabStop = false;
splitPanel1.Text = "splitPanel1";
//
// splitPanel2
//
splitPanel2.Location = new Point(402, 0);
splitPanel2.Name = "splitPanel2";
//
//
//
splitPanel2.RootElement.MinSize = new Size(25, 25);
splitPanel2.Size = new Size(398, 450);
splitPanel2.TabIndex = 1;
splitPanel2.TabStop = false;
splitPanel2.Text = "splitPanel2";
//
// Form1
//
AutoScaleBaseSize = new Size(7, 15);
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(radSplitContainer1);
Name = "Form1";
Text = "Form1";
((System.ComponentModel.ISupportInitialize)radSplitContainer1).EndInit();
radSplitContainer1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)splitPanel1).EndInit();
((System.ComponentModel.ISupportInitialize)splitPanel2).EndInit();
((System.ComponentModel.ISupportInitialize)this).EndInit();
ResumeLayout(false);
}
#endregion
private Telerik.WinControls.UI.RadSplitContainer radSplitContainer1;
private Telerik.WinControls.UI.SplitPanel splitPanel1;
private Telerik.WinControls.UI.SplitPanel splitPanel2;
}

View File

@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
@@ -26,36 +26,36 @@
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->

View File

@@ -9,7 +9,14 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Pilz.UI.Telerik" Version="2.7.2" />
<PackageReference Include="UI.for.WinForms.Common" Version="2024.3.806" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ModpackUpdater.Apps\ModpackUpdater.Apps.csproj" />
<ProjectReference Include="..\ModpackUpdater.Manager\ModpackUpdater.Manager.csproj" />
<ProjectReference Include="..\ModpackUpdater\ModpackUpdater.csproj" />
</ItemGroup>
</Project>

View File

@@ -11,6 +11,7 @@ internal static class Program
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
AppGlobals.Initialize();
Application.Run(new Form1());
}
}

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="TelerikWinFormsThemeName" value="Windows11CompactDark" />
</appSettings>
</configuration>

View File

@@ -0,0 +1,17 @@
using Pilz.UI.Telerik.Symbols;
using Pilz.UI.Telerik.Theming;
using Telerik.WinControls.Themes;
namespace ModpackUpdater.Apps;
public static class AppGlobals
{
public static IRadSymbolFactory<AppSymbols> Symbols { get; } = new AppSymbolFactory();
public static void Initialize()
{
ThemeHelper.ApplyApplicationTheme(ApplicationTheme.Auto,
() => new Windows11CompactTheme(),
() => new Windows11CompactDarkTheme());
}
}

View File

@@ -2,12 +2,10 @@
using Pilz.UI.Telerik.Symbols;
using System.Reflection;
namespace ModpackUpdater.Apps.Client;
namespace ModpackUpdater.Apps;
public class AppSymbolFactory : RadSymbolFactory<AppSymbols>
internal class AppSymbolFactory : RadSymbolFactory<AppSymbols>
{
public static IRadSymbolFactory<AppSymbols> Instance { get; } = new AppSymbolFactory();
public override Assembly GetImageResourceAssembly()
{
return Assembly.GetExecutingAssembly();

View File

@@ -1,4 +1,4 @@
namespace ModpackUpdater.Apps.Client;
namespace ModpackUpdater.Apps;
public enum AppSymbols
{

View File

@@ -0,0 +1,54 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<None Remove="CustomThemes\Office2019DarkBluePurple.tssp" />
<None Remove="Symbols\checkmark.svg" />
<None Remove="Symbols\close.svg" />
<None Remove="Symbols\delete.svg" />
<None Remove="Symbols\done.svg" />
<None Remove="Symbols\download_from_ftp.svg" />
<None Remove="Symbols\general_warning_sign.svg" />
<None Remove="Symbols\opened_folder.svg" />
<None Remove="Symbols\paste.svg" />
<None Remove="Symbols\refresh.svg" />
<None Remove="Symbols\replay.svg" />
<None Remove="Symbols\save.svg" />
<None Remove="Symbols\services.svg" />
<None Remove="Symbols\software_installer.svg" />
<None Remove="Symbols\update_done.svg" />
<None Remove="Symbols\wrench.svg" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="CustomThemes\Office2019DarkBluePurple.tssp" />
<EmbeddedResource Include="Symbols\checkmark.svg" />
<EmbeddedResource Include="Symbols\close.svg" />
<EmbeddedResource Include="Symbols\delete.svg" />
<EmbeddedResource Include="Symbols\done.svg" />
<EmbeddedResource Include="Symbols\download_from_ftp.svg" />
<EmbeddedResource Include="Symbols\general_warning_sign.svg" />
<EmbeddedResource Include="Symbols\opened_folder.svg" />
<EmbeddedResource Include="Symbols\paste.svg" />
<EmbeddedResource Include="Symbols\refresh.svg" />
<EmbeddedResource Include="Symbols\replay.svg" />
<EmbeddedResource Include="Symbols\save.svg" />
<EmbeddedResource Include="Symbols\services.svg" />
<EmbeddedResource Include="Symbols\software_installer.svg" />
<EmbeddedResource Include="Symbols\update_done.svg" />
<EmbeddedResource Include="Symbols\wrench.svg" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Pilz.UI.Telerik" Version="2.7.2" />
<PackageReference Include="UI.for.WinForms.Common" Version="2024.3.806" />
<PackageReference Include="UI.for.WinForms.Themes" Version="2024.3.806" />
</ItemGroup>
</Project>

View File

@@ -15,6 +15,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libs", "Libs", "{96B711FA-1
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModpackUpdater.Apps.Manager", "ModpackUpdater.Apps.Manager\ModpackUpdater.Apps.Manager.csproj", "{227A37AA-73F0-431D-B976-B9B3A8ADD8C2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModpackUpdater.Apps", "ModpackUpdater.Apps\ModpackUpdater.Apps.csproj", "{EF2EAFAF-01CD-46BD-BE45-0125B51316A4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -37,6 +39,10 @@ Global
{227A37AA-73F0-431D-B976-B9B3A8ADD8C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{227A37AA-73F0-431D-B976-B9B3A8ADD8C2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{227A37AA-73F0-431D-B976-B9B3A8ADD8C2}.Release|Any CPU.Build.0 = Release|Any CPU
{EF2EAFAF-01CD-46BD-BE45-0125B51316A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EF2EAFAF-01CD-46BD-BE45-0125B51316A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EF2EAFAF-01CD-46BD-BE45-0125B51316A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EF2EAFAF-01CD-46BD-BE45-0125B51316A4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -46,6 +52,7 @@ Global
{0E6B6470-8C1D-0CDD-3681-461297A01960} = {96B711FA-1AF2-469B-BC02-6D1E540E8E9D}
{D3A92EBD-FF6E-09D0-00A1-20221AAA198E} = {96B711FA-1AF2-469B-BC02-6D1E540E8E9D}
{227A37AA-73F0-431D-B976-B9B3A8ADD8C2} = {743892CF-E482-4FBD-9BAB-02920C140F2B}
{EF2EAFAF-01CD-46BD-BE45-0125B51316A4} = {743892CF-E482-4FBD-9BAB-02920C140F2B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {322E6A6B-9F3E-4E88-8945-C98A9EF613BF}