2
0
deadmoon 1 жил өмнө
parent
commit
4d1520cde0

+ 1 - 8
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
     {

+ 74 - 1
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 @@ namespace Optimizer
 
             Poppins15 = new Font(fonts.Families[0], 13f);
         }
+
+        internal static IEnumerable<string> 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);
+            }
+        }
     }
 }

+ 1 - 1
Optimizer/Options.cs

@@ -216,7 +216,7 @@ namespace Optimizer
                 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);

+ 1 - 1
Optimizer/Program.cs

@@ -275,7 +275,7 @@ namespace Optimizer
         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()

+ 1 - 1
Optimizer/SilentOps.cs

@@ -1086,7 +1086,7 @@ namespace Optimizer
                 if (CurrentSilentConfig.Tweaks.DisableVirtualizationBasedTechnology.Value)
                 {
                     MessageBox.Show("no vbs");
-                   // OptimizeHelper.DisableVirtualizationBasedSecurity();
+                    // OptimizeHelper.DisableVirtualizationBasedSecurity();
                 }
                 else
                 {

+ 0 - 3
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
 {