diff --git a/Optimizer/Constants.cs b/Optimizer/Constants.cs index 28888d51..ade51433 100644 --- a/Optimizer/Constants.cs +++ b/Optimizer/Constants.cs @@ -1,11 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Optimizer +namespace Optimizer { internal static class Constants { diff --git a/Optimizer/FontHelper.cs b/Optimizer/FontHelper.cs index 71dff3c2..38372105 100644 --- a/Optimizer/FontHelper.cs +++ b/Optimizer/FontHelper.cs @@ -1,6 +1,9 @@ -using System; +using Microsoft.Win32; +using System; +using System.Collections.Generic; using System.Drawing; using System.Drawing.Text; +using System.Linq; namespace Optimizer { @@ -28,5 +31,75 @@ internal static void LoadFont() Poppins15 = new Font(fonts.Families[0], 13f); } + + internal static IEnumerable GetAvailableFonts() + { + return new InstalledFontCollection().Families.Select(x => x.Name); + } + + internal static void ChangeGlobalFont(string fontName) + { + try + { + using (RegistryKey fontsKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts", true)) + { + fontsKey.SetValue("Segoe UI (TrueType)", ""); + fontsKey.SetValue("Segoe UI Bold (TrueType)", ""); + fontsKey.SetValue("Segoe UI Bold Italic (TrueType)", ""); + fontsKey.SetValue("Segoe UI Italic (TrueType)", ""); + fontsKey.SetValue("Segoe UI Light (TrueType)", ""); + fontsKey.SetValue("Segoe UI Semibold (TrueType)", ""); + fontsKey.SetValue("Segoe UI Symbol (TrueType)", ""); + } + + using (RegistryKey fontSubstitutesKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontSubstitutes", true)) + { + fontSubstitutesKey.SetValue("Segoe UI", fontName); + } + } + catch (Exception ex) + { + ErrorLogger.LogError("FontHelper.ChangeGlobalFont", ex.Message, ex.StackTrace); + } + } + + internal static void RestoreDefaultGlobalFont() + { + try + { + using (RegistryKey fontsKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts", true)) + { + fontsKey.SetValue("Segoe UI (TrueType)", "segoeui.ttf"); + fontsKey.SetValue("Segoe UI Black (TrueType)", "seguibl.ttf"); + fontsKey.SetValue("Segoe UI Black Italic (TrueType)", "seguibli.ttf"); + fontsKey.SetValue("Segoe UI Bold (TrueType)", "segoeuib.ttf"); + fontsKey.SetValue("Segoe UI Bold Italic (TrueType)", "segoeuiz.ttf"); + fontsKey.SetValue("Segoe UI Emoji (TrueType)", "seguiemj.ttf"); + fontsKey.SetValue("Segoe UI Historic (TrueType)", "seguihis.ttf"); + fontsKey.SetValue("Segoe UI Italic (TrueType)", "segoeuii.ttf"); + fontsKey.SetValue("Segoe UI Light (TrueType)", "segoeuil.ttf"); + fontsKey.SetValue("Segoe UI Light Italic (TrueType)", "seguili.ttf"); + fontsKey.SetValue("Segoe UI Semibold (TrueType)", "seguisb.ttf"); + fontsKey.SetValue("Segoe UI Semibold Italic (TrueType)", "seguisbi.ttf"); + fontsKey.SetValue("Segoe UI Semilight (TrueType)", "segoeuisl.ttf"); + fontsKey.SetValue("Segoe UI Semilight Italic (TrueType)", "seguisli.ttf"); + fontsKey.SetValue("Segoe UI Symbol (TrueType)", "seguisym.ttf"); + fontsKey.SetValue("Segoe MDL2 Assets (TrueType)", "segmdl2.ttf"); + fontsKey.SetValue("Segoe Print (TrueType)", "segoepr.ttf"); + fontsKey.SetValue("Segoe Print Bold (TrueType)", "segoeprb.ttf"); + fontsKey.SetValue("Segoe Script (TrueType)", "segoesc.ttf"); + fontsKey.SetValue("Segoe Script Bold (TrueType)", "segoescb.ttf"); + } + + using (RegistryKey fontSubstitutesKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontSubstitutes", true)) + { + fontSubstitutesKey.DeleteValue("Segoe UI", false); + } + } + catch (Exception ex) + { + ErrorLogger.LogError("FontHelper.RestoreDefaultGlobalFont", ex.Message, ex.StackTrace); + } + } } } diff --git a/Optimizer/Options.cs b/Optimizer/Options.cs index 7f45fe16..6bebf1b9 100644 --- a/Optimizer/Options.cs +++ b/Optimizer/Options.cs @@ -216,7 +216,7 @@ internal static void LoadSettings() else { // DEFAULT OPTIONS - + CurrentOptions.Theme = Color.FromArgb(153, 102, 204); CurrentOptions.AppsFolder = Path.Combine(KnownFolders.GetPath(KnownFolder.Downloads), Constants.DOWNLOADS_FOLDER); Directory.CreateDirectory(Options.CurrentOptions.AppsFolder); diff --git a/Optimizer/Program.cs b/Optimizer/Program.cs index dc6704b7..6adaca2f 100644 --- a/Optimizer/Program.cs +++ b/Optimizer/Program.cs @@ -275,7 +275,7 @@ static void Main(string[] switches) private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { Exception error = (Exception)e.ExceptionObject; - ErrorLogger.LogError("[Program.Main-UnhandledException]", error.Message, error.StackTrace); + ErrorLogger.LogError("Program.Main-UnhandledException", error.Message, error.StackTrace); } private static void LoadSettings() diff --git a/Optimizer/SilentOps.cs b/Optimizer/SilentOps.cs index ad87e71b..e464ba8b 100644 --- a/Optimizer/SilentOps.cs +++ b/Optimizer/SilentOps.cs @@ -1086,7 +1086,7 @@ internal static void ProcessTweaksWindows11() if (CurrentSilentConfig.Tweaks.DisableVirtualizationBasedTechnology.Value) { MessageBox.Show("no vbs"); - // OptimizeHelper.DisableVirtualizationBasedSecurity(); + // OptimizeHelper.DisableVirtualizationBasedSecurity(); } else { diff --git a/Optimizer/UserFoldersHelper.cs b/Optimizer/UserFoldersHelper.cs index 9a95e0a6..ed424e31 100644 --- a/Optimizer/UserFoldersHelper.cs +++ b/Optimizer/UserFoldersHelper.cs @@ -1,9 +1,6 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; namespace Optimizer {