From 8291dec7a39a2bf1a329bb5cb88a82c36ff9a129 Mon Sep 17 00:00:00 2001 From: rounk-ctrl <70931017+rounk-ctrl@users.noreply.github.com> Date: Sun, 17 Sep 2023 10:28:17 +0400 Subject: [PATCH] store msstyle in temp dir --- Rectify11Installer/Core/Installer.cs | 32 ++++++++++++++++++++++------ Rectify11Installer/Core/Theme.cs | 4 ++-- Rectify11Installer/Program.cs | 13 ++++------- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/Rectify11Installer/Core/Installer.cs b/Rectify11Installer/Core/Installer.cs index 16701f0b1..ecbb40a66 100644 --- a/Rectify11Installer/Core/Installer.cs +++ b/Rectify11Installer/Core/Installer.cs @@ -33,6 +33,11 @@ public async Task Install(FrmWizard frm) Logger.WriteLine("Preparing Installation"); Logger.WriteLine("──────────────────────"); + if (!Directory.Exists(Variables.r11Folder)) + { + Directory.CreateDirectory(Variables.r11Folder); + } + // goofy fix using var reg = Registry.LocalMachine.OpenSubKey(@"SOFTWARE", true)?.CreateSubKey("Rectify11", true); reg.DeleteValue("x86PendingFiles", false); @@ -63,9 +68,16 @@ public async Task Install(FrmWizard frm) { Logger.WriteLine("Error while copying installer", ex); } - // create restore point - frm.InstallerProgress = "Begin creating a restore point"; - await Task.Run(() => NativeMethods.CreateSystemRestorePoint(false)); + try + { + // create restore point + frm.InstallerProgress = "Begin creating a restore point"; + await Task.Run(() => NativeMethods.CreateSystemRestorePoint(false)); + } + catch + { + Logger.Warn("Error creating a restore point."); + } frm.InstallerProgress = "Installing runtimes"; if (!await Task.Run(InstallRuntimes)) @@ -487,12 +499,18 @@ await Task.Run(() => Interaction.Shell(Path.Combine(Variables.r11Folder, "aRun.e Logger.WriteLine("AddToControlPanel() succeeded"); InstallStatus.IsRectify11Installed = true; - Logger.WriteLine("══════════════════════════════════════════════"); - // create restore point - frm.InstallerProgress = "End creating a restore point"; - await Task.Run(() => CreateSystemRestorePoint(true)); + try + { + // create restore point + frm.InstallerProgress = "End creating a restore point"; + await Task.Run(() => CreateSystemRestorePoint(true)); + } + catch + { + //ignored + } // cleanup frm.InstallerProgress = "Cleaning up..."; diff --git a/Rectify11Installer/Core/Theme.cs b/Rectify11Installer/Core/Theme.cs index 2345578e9..9be74fd6c 100644 --- a/Rectify11Installer/Core/Theme.cs +++ b/Rectify11Installer/Core/Theme.cs @@ -36,8 +36,8 @@ public static void InitTheme() public static void LoadTheme() { - DarkStyle.Load(Path.Combine(Variables.r11Folder, "Dark.msstyles")); - LightStyle.Load(Path.Combine(Variables.r11Folder, "light.msstyles")); + DarkStyle.Load(Path.Combine(Path.GetTempPath(), "Dark.msstyles")); + LightStyle.Load(Path.Combine(Path.GetTempPath(), "light.msstyles")); } public static StylePart GetNavArrowPart(VisualStyle v, NavigationButtonType type) diff --git a/Rectify11Installer/Program.cs b/Rectify11Installer/Program.cs index fa1242493..8bac72880 100644 --- a/Rectify11Installer/Program.cs +++ b/Rectify11Installer/Program.cs @@ -82,16 +82,11 @@ private static void Main(string[] args) DarkMode.SetPreferredAppMode(DarkMode.PreferredAppMode.AllowDark); } } - if (!Directory.Exists(Variables.r11Folder)) - { - Directory.CreateDirectory(Variables.r11Folder); - } - if ((!File.Exists(Path.Combine(Variables.r11Folder, "Dark.msstyles"))) && (!File.Exists(Path.Combine(Variables.r11Folder, "light.msstyles")))) - { - File.WriteAllBytes(Path.Combine(Variables.r11Folder, "Dark.msstyles"), Properties.Resources.Dark); - File.WriteAllBytes(Path.Combine(Variables.r11Folder, "light.msstyles"), Properties.Resources.light); - } + // overwrite + File.WriteAllBytes(Path.Combine(Path.GetTempPath(), "Dark.msstyles"), Properties.Resources.Dark); + File.WriteAllBytes(Path.Combine(Path.GetTempPath(), "light.msstyles"), Properties.Resources.light); + Theme.LoadTheme(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false);