ui: migrate client back to WinForms
-> let's use wine for comatibility again -> easier to maintain -> easier to build dynamic options with
This commit is contained in:
@@ -1,14 +1,9 @@
|
||||
using Castle.Core.Logging;
|
||||
using Gtk;
|
||||
using Microsoft.Win32;
|
||||
using ModpackUpdater.Manager;
|
||||
using Newtonsoft.Json;
|
||||
using Pilz;
|
||||
using Pilz.Configuration;
|
||||
using Pilz.UI.Gtk.Symbols;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
[assembly: AssemblyAppVersion("1.8.0.0")]
|
||||
|
||||
@@ -18,9 +13,7 @@ public static class Program
|
||||
{
|
||||
private static readonly SettingsManager settingsManager;
|
||||
private static readonly ILogger log = new ConsoleLogger();
|
||||
private static Application uiApp;
|
||||
|
||||
public static IGtkSymbolFactory<AppSymbols> Symbols { get; } = new AppSymbolFactory();
|
||||
public static ISettings Settings => settingsManager.Instance;
|
||||
public static ILogger Log => log;
|
||||
internal static Options Options { get; private set; }
|
||||
@@ -55,49 +48,9 @@ public static class Program
|
||||
|
||||
private static void RunApp(UpdateCheckOptionsAdv updateOptions)
|
||||
{
|
||||
if (UsesWindowsDarkTheme())
|
||||
Environment.SetEnvironmentVariable("GTK_THEME", "Adwaita:dark");
|
||||
|
||||
Application.Init();
|
||||
|
||||
uiApp = new Application("ModpackUpdater.Apps.Client", GLib.ApplicationFlags.None);
|
||||
uiApp.Register(GLib.Cancellable.Current);
|
||||
|
||||
var win = new MainWindow(updateOptions);
|
||||
uiApp.AddWindow(win);
|
||||
win.Show();
|
||||
|
||||
Application.Run();
|
||||
}
|
||||
|
||||
public static void Restart()
|
||||
{
|
||||
var process = Process.GetCurrentProcess();
|
||||
var arguments = Environment.GetCommandLineArgs();
|
||||
|
||||
ProcessStartInfo currentStartInfo = new()
|
||||
{
|
||||
FileName = Environment.ProcessPath,
|
||||
};
|
||||
|
||||
if (arguments.Length >= 2)
|
||||
{
|
||||
var sb = new StringBuilder((arguments.Length - 1) * 16);
|
||||
|
||||
for (int argumentIndex = 1; argumentIndex < arguments.Length; argumentIndex++)
|
||||
sb.Append($"\"{arguments[argumentIndex]}\" ");
|
||||
|
||||
currentStartInfo.Arguments = sb.ToString(0, sb.Length - 1);
|
||||
}
|
||||
|
||||
// Close the current application
|
||||
Application.Quit();
|
||||
|
||||
// Start a new process
|
||||
Process.Start(currentStartInfo);
|
||||
|
||||
// Close this proccess
|
||||
Environment.Exit(0);
|
||||
ApplicationConfiguration.Initialize();
|
||||
AppGlobals.Initialize();
|
||||
Application.Run(new MainForm(updateOptions));
|
||||
}
|
||||
|
||||
private static string GetSettingsPath(int? settingsVersion = 3)
|
||||
@@ -174,19 +127,4 @@ public static class Program
|
||||
return info.ConfigUrl;
|
||||
return configUrl;
|
||||
}
|
||||
|
||||
private static bool UsesWindowsDarkTheme()
|
||||
{
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
try
|
||||
{
|
||||
return Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize")?.GetValue("AppsUseLightTheme") as bool? ?? default;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
return default;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user