diff --git a/Setup/App.xaml.cs b/Setup/App.xaml.cs deleted file mode 100644 index 9b81dea..0000000 --- a/Setup/App.xaml.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System.Windows; -using System.Windows.Media; -using Microsoft.Win32; - -namespace DeskCoreSetup; - -public partial class App : Application -{ - protected override void OnStartup(StartupEventArgs e) - { - base.OnStartup(e); - bool uninstall = e.Args.Any(a => a.Equals("--uninstall", StringComparison.OrdinalIgnoreCase)); - bool silent = e.Args.Any(a => a.Equals("/S", StringComparison.OrdinalIgnoreCase)); - bool launch = e.Args.Any(a => a.Equals("/launch", StringComparison.OrdinalIgnoreCase)); - var dirArg = e.Args.FirstOrDefault(a => a.StartsWith("/D=", StringComparison.OrdinalIgnoreCase))?.Substring(3); - - // Stille Installation/Deinstallation für Skripte: DeskCore-Setup.exe /S [/D=Ordner] bzw. --uninstall /S - if (silent) - { - var progress = new Progress<(double, string)>(_ => { }); - try - { - if (uninstall) Installer.Uninstall(removeData: false, progress); - else - { - var dir = dirArg ?? Installer.InstalledDir ?? Installer.DefaultDir; - Installer.Install(dir, desktopLink: Installer.InstalledDir is null || Installer.DesktopLinkExists, - autostart: Installer.AutostartEnabled, progress, installRuntime: true); - // nach einem Update aus DeskCore heraus: gleich wieder starten - if (launch) System.Diagnostics.Process.Start(System.IO.Path.Combine(dir, Installer.ExeName)); - } - Shutdown(0); - } - catch (Exception ex) - { - // ohne Oberfläche: Fehler für Skripte nachvollziehbar ablegen - try { System.IO.File.WriteAllText(System.IO.Path.Combine(System.IO.Path.GetTempPath(), "DeskCore-Setup.log"), $"[{DateTime.Now}] {ex}"); } catch { } - Shutdown(1); - } - return; - } - - ApplyTheme(); - new MainWindow(uninstall).Show(); - } - - /// Hell/Dunkel und Akzentfarbe wie in Windows eingestellt. - private void ApplyTheme() - { - bool light = ReadDword(@"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize", "AppsUseLightTheme") != 0; - Resources.MergedDictionaries[0] = new ResourceDictionary - { - Source = new Uri($"pack://application:,,,/Themes/Colors.{(light ? "Light" : "Dark")}.xaml"), - }; - int abgr = ReadDword(@"Software\Microsoft\Windows\DWM", "AccentColor") is var v and not -1 ? v : unchecked((int)0xFFD77800); - var accent = Color.FromRgb((byte)abgr, (byte)(abgr >> 8), (byte)(abgr >> 16)); - var a = light ? Mix(accent, Colors.Black, 0.12) : Mix(accent, Colors.White, 0.45); - Resources["AccentBrush"] = new SolidColorBrush(a); - Resources["AccentHoverBrush"] = new SolidColorBrush(light ? Mix(a, Colors.White, 0.1) : Mix(a, Colors.Black, 0.1)); - Resources["OnAccentBrush"] = new SolidColorBrush(light ? Colors.White : Colors.Black); - Resources["AccentSubtleBrush"] = new SolidColorBrush(Color.FromArgb(light ? (byte)0x22 : (byte)0x30, a.R, a.G, a.B)); - Resources["AccentSubtleStrokeBrush"] = new SolidColorBrush(Color.FromArgb(light ? (byte)0x55 : (byte)0x60, a.R, a.G, a.B)); - } - - private static int ReadDword(string key, string name) - { - try - { - using var k = Registry.CurrentUser.OpenSubKey(key); - return k?.GetValue(name) is int i ? i : -1; - } - catch { return -1; } - } - - private static Color Mix(Color c, Color with, double t) => Color.FromRgb( - (byte)(c.R + (with.R - c.R) * t), (byte)(c.G + (with.G - c.G) * t), (byte)(c.B + (with.B - c.B) * t)); -}