浏览代码

Major update with improvements and hotfixes v16.4

deadmoon 1 年之前
父节点
当前提交
e849a66487
共有 67 个文件被更改,包括 2188 次插入3745 次删除
  1. 8 0
      CHANGELOG.md
  2. 3 0
      FAQ.md
  3. 14 28
      Optimizer/ByteSize/BinaryByteSize.cs
  4. 50 100
      Optimizer/ByteSize/ByteSize.cs
  5. 12 24
      Optimizer/ByteSize/DecimalByteSize.cs
  6. 61 122
      Optimizer/CleanHelper.cs
  7. 42 84
      Optimizer/ColorHelper.cs
  8. 2 5
      Optimizer/Constants.cs
  9. 3 6
      Optimizer/Controls/AppCard.cs
  10. 9 18
      Optimizer/Controls/ColorOverrider.cs
  11. 97 194
      Optimizer/Controls/ColorPicker.cs
  12. 11 22
      Optimizer/Controls/ListViewColumnSorter.cs
  13. 6 12
      Optimizer/Controls/MoonCheck.cs
  14. 7 14
      Optimizer/Controls/MoonCheckList.cs
  15. 7 14
      Optimizer/Controls/MoonList.cs
  16. 27 54
      Optimizer/Controls/MoonMenuRenderer.cs
  17. 4 8
      Optimizer/Controls/MoonProgress.cs
  18. 6 12
      Optimizer/Controls/MoonRadio.cs
  19. 9 18
      Optimizer/Controls/MoonSelect.cs
  20. 39 78
      Optimizer/Controls/MoonTabs.cs
  21. 8 16
      Optimizer/Controls/MoonToggle.cs
  22. 9 18
      Optimizer/Controls/MoonTree.cs
  23. 11 22
      Optimizer/Controls/ToggleCard.cs
  24. 14 28
      Optimizer/CoreHelper.cs
  25. 4 8
      Optimizer/DebugHelper.cs
  26. 12 24
      Optimizer/EmbeddedAssembly.cs
  27. 11 22
      Optimizer/ErrorLogger.cs
  28. 12 24
      Optimizer/FileHandleHelper.cs
  29. 18 36
      Optimizer/FontHelper.cs
  30. 9 18
      Optimizer/Forms/AboutForm.cs
  31. 9 18
      Optimizer/Forms/FileUnlockForm.cs
  32. 51 102
      Optimizer/Forms/FirstRunForm.cs
  33. 15 30
      Optimizer/Forms/HelperForm.cs
  34. 9 18
      Optimizer/Forms/HostsEditorForm.cs
  35. 9 18
      Optimizer/Forms/InfoForm.cs
  36. 199 219
      Optimizer/Forms/MainForm.Designer.cs
  37. 169 339
      Optimizer/Forms/MainForm.cs
  38. 13 1
      Optimizer/Forms/MainForm.resx
  39. 3 6
      Optimizer/Forms/SplashForm.cs
  40. 11 22
      Optimizer/Forms/StartupPreviewForm.cs
  41. 32 64
      Optimizer/Forms/StartupRestoreForm.cs
  42. 6 12
      Optimizer/Forms/SubForm.cs
  43. 6 12
      Optimizer/Forms/UpdateForm.cs
  44. 43 86
      Optimizer/HostsHelper.cs
  45. 76 152
      Optimizer/IndiciumHelper.cs
  46. 56 112
      Optimizer/IntegratorHelper.cs
  47. 9 4
      Optimizer/Models/AppInfo.cs
  48. 20 26
      Optimizer/Models/Enums.cs
  49. 17 26
      Optimizer/Models/Hardware.cs
  50. 62 11
      Optimizer/Models/Options.cs
  51. 14 28
      Optimizer/Models/SilentConfig.cs
  52. 6 6
      Optimizer/Models/StartupBackupItem.cs
  53. 26 46
      Optimizer/Models/StartupItem.cs
  54. 58 0
      Optimizer/Models/WorkEvent.cs
  55. 46 0
      Optimizer/Models/WorkEventArgs.cs
  56. 153 284
      Optimizer/OptimizeHelper.cs
  57. 2 0
      Optimizer/Optimizer.csproj
  58. 28 56
      Optimizer/OptionsHelper.cs
  59. 24 46
      Optimizer/PingerHelper.cs
  60. 55 104
      Optimizer/Program.cs
  61. 216 432
      Optimizer/SilentOps.cs
  62. 30 60
      Optimizer/StartupHelper.cs
  63. 12 24
      Optimizer/TokenPrivilegeHelper.cs
  64. 15 31
      Optimizer/UWPHelper.cs
  65. 157 315
      Optimizer/Utilities.cs
  66. 5 5
      README.md
  67. 1 1
      version.txt

+ 8 - 0
CHANGELOG.md

@@ -1,3 +1,11 @@
+## [16.4] - 2023-12-29
+- New: FAQ section link in Options
+- New: Various performance improvements from code refactoring
+- Hotfix: Rare bug when checking for update (#444)
+- Hotfix: SmartScreen resets properly now (#453)
+- Hotfix: Apps download folder is now by default empty to avoid issues
+- Hotfix: Rare bug when fetching app feeds (#450)
+
 ## [16.3] - 2023-12-22
 ## [16.3] - 2023-12-22
 - New: Check for updates on launch option (#441, #423)
 - New: Check for updates on launch option (#441, #423)
 - New: Options for hiding Weather and Search in Restore Classic Windows Explorer (#447)
 - New: Options for hiding Weather and Search in Restore Classic Windows Explorer (#447)

+ 3 - 0
FAQ.md

@@ -48,6 +48,9 @@ If your clipboard history has stopped working, try these steps:
 1. Reset the "Disable Cloud Clipboard" setting in our application.
 1. Reset the "Disable Cloud Clipboard" setting in our application.
 2. Verify if the clipboard history is now functioning as expected.
 2. Verify if the clipboard history is now functioning as expected.
 
 
+### **My Phone Link suddenly stopped working!**
+You should reset the "Enhance Privacy" and restart your computer.
+
 ### **Should I disable Sensor Services?**
 ### **Should I disable Sensor Services?**
 If your device is a tablet, has various sensors (proximity, auto-brightness, etc.), or features a touch screen, it's recommended not to disable Sensor Services. These services likely contribute to the functionality of these features on your device.
 If your device is a tablet, has various sensors (proximity, auto-brightness, etc.), or features a touch screen, it's recommended not to disable Sensor Services. These services likely contribute to the functionality of these features on your device.
 
 

+ 14 - 28
Optimizer/ByteSize/BinaryByteSize.cs

@@ -1,10 +1,8 @@
 using System;
 using System;
 using System.Globalization;
 using System.Globalization;
 
 
-namespace Optimizer
-{
-    public partial struct ByteSize
-    {
+namespace Optimizer {
+    public partial struct ByteSize {
         public const long BytesInKibiByte = 1_024;
         public const long BytesInKibiByte = 1_024;
         public const long BytesInMebiByte = 1_048_576;
         public const long BytesInMebiByte = 1_048_576;
         public const long BytesInGibiByte = 1_073_741_824;
         public const long BytesInGibiByte = 1_073_741_824;
@@ -23,63 +21,51 @@ namespace Optimizer
         public double TebiBytes => Bytes / BytesInTebiByte;
         public double TebiBytes => Bytes / BytesInTebiByte;
         public double PebiBytes => Bytes / BytesInPebiByte;
         public double PebiBytes => Bytes / BytesInPebiByte;
 
 
-        public static ByteSize FromKibiBytes(double value)
-        {
+        public static ByteSize FromKibiBytes(double value) {
             return new ByteSize(value * BytesInKibiByte);
             return new ByteSize(value * BytesInKibiByte);
         }
         }
 
 
-        public static ByteSize FromMebiBytes(double value)
-        {
+        public static ByteSize FromMebiBytes(double value) {
             return new ByteSize(value * BytesInMebiByte);
             return new ByteSize(value * BytesInMebiByte);
         }
         }
 
 
-        public static ByteSize FromGibiBytes(double value)
-        {
+        public static ByteSize FromGibiBytes(double value) {
             return new ByteSize(value * BytesInGibiByte);
             return new ByteSize(value * BytesInGibiByte);
         }
         }
 
 
-        public static ByteSize FromTebiBytes(double value)
-        {
+        public static ByteSize FromTebiBytes(double value) {
             return new ByteSize(value * BytesInTebiByte);
             return new ByteSize(value * BytesInTebiByte);
         }
         }
 
 
-        public static ByteSize FromPebiBytes(double value)
-        {
+        public static ByteSize FromPebiBytes(double value) {
             return new ByteSize(value * BytesInPebiByte);
             return new ByteSize(value * BytesInPebiByte);
         }
         }
 
 
-        public ByteSize AddKibiBytes(double value)
-        {
+        public ByteSize AddKibiBytes(double value) {
             return this + ByteSize.FromKibiBytes(value);
             return this + ByteSize.FromKibiBytes(value);
         }
         }
 
 
-        public ByteSize AddMebiBytes(double value)
-        {
+        public ByteSize AddMebiBytes(double value) {
             return this + ByteSize.FromMebiBytes(value);
             return this + ByteSize.FromMebiBytes(value);
         }
         }
 
 
-        public ByteSize AddGibiBytes(double value)
-        {
+        public ByteSize AddGibiBytes(double value) {
             return this + ByteSize.FromGibiBytes(value);
             return this + ByteSize.FromGibiBytes(value);
         }
         }
 
 
-        public ByteSize AddTebiBytes(double value)
-        {
+        public ByteSize AddTebiBytes(double value) {
             return this + ByteSize.FromTebiBytes(value);
             return this + ByteSize.FromTebiBytes(value);
         }
         }
 
 
-        public ByteSize AddPebiBytes(double value)
-        {
+        public ByteSize AddPebiBytes(double value) {
             return this + ByteSize.FromPebiBytes(value);
             return this + ByteSize.FromPebiBytes(value);
         }
         }
 
 
-        public string ToBinaryString()
-        {
+        public string ToBinaryString() {
             return this.ToString("0.##", CultureInfo.CurrentCulture, useBinaryByte: true);
             return this.ToString("0.##", CultureInfo.CurrentCulture, useBinaryByte: true);
         }
         }
 
 
-        public string ToBinaryString(IFormatProvider formatProvider)
-        {
+        public string ToBinaryString(IFormatProvider formatProvider) {
             return this.ToString("0.##", formatProvider, useBinaryByte: true);
             return this.ToString("0.##", formatProvider, useBinaryByte: true);
         }
         }
     }
     }

+ 50 - 100
Optimizer/ByteSize/ByteSize.cs

@@ -1,14 +1,12 @@
 using System;
 using System;
 using System.Globalization;
 using System.Globalization;
 
 
-namespace Optimizer
-{
+namespace Optimizer {
     /// <summary>
     /// <summary>
     /// Represents a byte size value with support for decimal (KiloByte) and
     /// Represents a byte size value with support for decimal (KiloByte) and
     /// binary values (KibiByte).
     /// binary values (KibiByte).
     /// </summary>
     /// </summary>
-    public partial struct ByteSize : IComparable<ByteSize>, IEquatable<ByteSize>
-    {
+    public partial struct ByteSize : IComparable<ByteSize>, IEquatable<ByteSize> {
         public static readonly ByteSize MinValue = ByteSize.FromBits(long.MinValue);
         public static readonly ByteSize MinValue = ByteSize.FromBits(long.MinValue);
         public static readonly ByteSize MaxValue = ByteSize.FromBits(long.MaxValue);
         public static readonly ByteSize MaxValue = ByteSize.FromBits(long.MaxValue);
         public const long BitsInByte = 8;
         public const long BitsInByte = 8;
@@ -17,10 +15,8 @@ namespace Optimizer
         public long Bits { get; private set; }
         public long Bits { get; private set; }
         public double Bytes { get; private set; }
         public double Bytes { get; private set; }
 
 
-        public string LargestWholeNumberBinarySymbol
-        {
-            get
-            {
+        public string LargestWholeNumberBinarySymbol {
+            get {
                 // Absolute value is used to deal with negative values
                 // Absolute value is used to deal with negative values
                 if (Math.Abs(this.PebiBytes) >= 1)
                 if (Math.Abs(this.PebiBytes) >= 1)
                     return PebiByteSymbol;
                     return PebiByteSymbol;
@@ -44,10 +40,8 @@ namespace Optimizer
             }
             }
         }
         }
 
 
-        public string LargestWholeNumberDecimalSymbol
-        {
-            get
-            {
+        public string LargestWholeNumberDecimalSymbol {
+            get {
                 // Absolute value is used to deal with negative values
                 // Absolute value is used to deal with negative values
                 if (Math.Abs(this.PetaBytes) >= 1)
                 if (Math.Abs(this.PetaBytes) >= 1)
                     return PetaByteSymbol;
                     return PetaByteSymbol;
@@ -71,10 +65,8 @@ namespace Optimizer
             }
             }
         }
         }
 
 
-        public double LargestWholeNumberBinaryValue
-        {
-            get
-            {
+        public double LargestWholeNumberBinaryValue {
+            get {
                 // Absolute value is used to deal with negative values
                 // Absolute value is used to deal with negative values
                 if (Math.Abs(this.PebiBytes) >= 1)
                 if (Math.Abs(this.PebiBytes) >= 1)
                     return this.PebiBytes;
                     return this.PebiBytes;
@@ -98,10 +90,8 @@ namespace Optimizer
             }
             }
         }
         }
 
 
-        public double LargestWholeNumberDecimalValue
-        {
-            get
-            {
+        public double LargestWholeNumberDecimalValue {
+            get {
                 // Absolute value is used to deal with negative values
                 // Absolute value is used to deal with negative values
                 if (Math.Abs(this.PetaBytes) >= 1)
                 if (Math.Abs(this.PetaBytes) >= 1)
                     return this.PetaBytes;
                     return this.PetaBytes;
@@ -126,29 +116,25 @@ namespace Optimizer
         }
         }
 
 
         public ByteSize(long bits)
         public ByteSize(long bits)
-            : this()
-        {
+            : this() {
             Bits = bits;
             Bits = bits;
 
 
             Bytes = bits / BitsInByte;
             Bytes = bits / BitsInByte;
         }
         }
 
 
         public ByteSize(double bytes)
         public ByteSize(double bytes)
-            : this()
-        {
+            : this() {
             // Get ceiling because bits are whole units
             // Get ceiling because bits are whole units
             Bits = (long)Math.Ceiling(bytes * BitsInByte);
             Bits = (long)Math.Ceiling(bytes * BitsInByte);
 
 
             Bytes = bytes;
             Bytes = bytes;
         }
         }
 
 
-        public static ByteSize FromBits(long value)
-        {
+        public static ByteSize FromBits(long value) {
             return new ByteSize(value);
             return new ByteSize(value);
         }
         }
 
 
-        public static ByteSize FromBytes(double value)
-        {
+        public static ByteSize FromBytes(double value) {
             return new ByteSize(value);
             return new ByteSize(value);
         }
         }
 
 
@@ -158,18 +144,15 @@ namespace Optimizer
         /// largest prefix such that the corresponding value is greater than or
         /// largest prefix such that the corresponding value is greater than or
         /// equal to one.
         /// equal to one.
         /// </summary>
         /// </summary>
-        public override string ToString()
-        {
+        public override string ToString() {
             return this.ToString("0.##", CultureInfo.CurrentCulture);
             return this.ToString("0.##", CultureInfo.CurrentCulture);
         }
         }
 
 
-        public string ToString(string format)
-        {
+        public string ToString(string format) {
             return this.ToString(format, CultureInfo.CurrentCulture);
             return this.ToString(format, CultureInfo.CurrentCulture);
         }
         }
 
 
-        public string ToString(string format, IFormatProvider provider, bool useBinaryByte = false)
-        {
+        public string ToString(string format, IFormatProvider provider, bool useBinaryByte = false) {
             if (!format.Contains("#") && !format.Contains("0"))
             if (!format.Contains("#") && !format.Contains("0"))
                 format = "0.## " + format;
                 format = "0.## " + format;
 
 
@@ -209,18 +192,15 @@ namespace Optimizer
             if (format.IndexOf(ByteSize.BitSymbol) != -1)
             if (format.IndexOf(ByteSize.BitSymbol) != -1)
                 return output(this.Bits);
                 return output(this.Bits);
 
 
-            if (useBinaryByte)
-            {
+            if (useBinaryByte) {
                 return string.Format("{0} {1}", this.LargestWholeNumberBinaryValue.ToString(format, provider), this.LargestWholeNumberBinarySymbol);
                 return string.Format("{0} {1}", this.LargestWholeNumberBinaryValue.ToString(format, provider), this.LargestWholeNumberBinarySymbol);
             }
             }
-            else
-            {
+            else {
                 return string.Format("{0} {1}", this.LargestWholeNumberDecimalValue.ToString(format, provider), this.LargestWholeNumberDecimalSymbol);
                 return string.Format("{0} {1}", this.LargestWholeNumberDecimalValue.ToString(format, provider), this.LargestWholeNumberDecimalSymbol);
             }
             }
         }
         }
 
 
-        public override bool Equals(object value)
-        {
+        public override bool Equals(object value) {
             if (value == null)
             if (value == null)
                 return false;
                 return false;
 
 
@@ -233,107 +213,86 @@ namespace Optimizer
             return Equals(other);
             return Equals(other);
         }
         }
 
 
-        public bool Equals(ByteSize value)
-        {
+        public bool Equals(ByteSize value) {
             return this.Bits == value.Bits;
             return this.Bits == value.Bits;
         }
         }
 
 
-        public override int GetHashCode()
-        {
+        public override int GetHashCode() {
             return this.Bits.GetHashCode();
             return this.Bits.GetHashCode();
         }
         }
 
 
-        public int CompareTo(ByteSize other)
-        {
+        public int CompareTo(ByteSize other) {
             return this.Bits.CompareTo(other.Bits);
             return this.Bits.CompareTo(other.Bits);
         }
         }
 
 
-        public ByteSize Add(ByteSize bs)
-        {
+        public ByteSize Add(ByteSize bs) {
             return new ByteSize(this.Bytes + bs.Bytes);
             return new ByteSize(this.Bytes + bs.Bytes);
         }
         }
 
 
-        public ByteSize AddBits(long value)
-        {
+        public ByteSize AddBits(long value) {
             return this + FromBits(value);
             return this + FromBits(value);
         }
         }
 
 
-        public ByteSize AddBytes(double value)
-        {
+        public ByteSize AddBytes(double value) {
             return this + ByteSize.FromBytes(value);
             return this + ByteSize.FromBytes(value);
         }
         }
 
 
-        public ByteSize Subtract(ByteSize bs)
-        {
+        public ByteSize Subtract(ByteSize bs) {
             return new ByteSize(this.Bytes - bs.Bytes);
             return new ByteSize(this.Bytes - bs.Bytes);
         }
         }
 
 
-        public static ByteSize operator +(ByteSize b1, ByteSize b2)
-        {
+        public static ByteSize operator +(ByteSize b1, ByteSize b2) {
             return new ByteSize(b1.Bytes + b2.Bytes);
             return new ByteSize(b1.Bytes + b2.Bytes);
         }
         }
 
 
-        public static ByteSize operator ++(ByteSize b)
-        {
+        public static ByteSize operator ++(ByteSize b) {
             return new ByteSize(b.Bytes + 1);
             return new ByteSize(b.Bytes + 1);
         }
         }
 
 
-        public static ByteSize operator -(ByteSize b)
-        {
+        public static ByteSize operator -(ByteSize b) {
             return new ByteSize(-b.Bytes);
             return new ByteSize(-b.Bytes);
         }
         }
 
 
-        public static ByteSize operator -(ByteSize b1, ByteSize b2)
-        {
+        public static ByteSize operator -(ByteSize b1, ByteSize b2) {
             return new ByteSize(b1.Bytes - b2.Bytes);
             return new ByteSize(b1.Bytes - b2.Bytes);
         }
         }
 
 
-        public static ByteSize operator --(ByteSize b)
-        {
+        public static ByteSize operator --(ByteSize b) {
             return new ByteSize(b.Bytes - 1);
             return new ByteSize(b.Bytes - 1);
         }
         }
 
 
-        public static bool operator ==(ByteSize b1, ByteSize b2)
-        {
+        public static bool operator ==(ByteSize b1, ByteSize b2) {
             return b1.Bits == b2.Bits;
             return b1.Bits == b2.Bits;
         }
         }
 
 
-        public static bool operator !=(ByteSize b1, ByteSize b2)
-        {
+        public static bool operator !=(ByteSize b1, ByteSize b2) {
             return b1.Bits != b2.Bits;
             return b1.Bits != b2.Bits;
         }
         }
 
 
-        public static bool operator <(ByteSize b1, ByteSize b2)
-        {
+        public static bool operator <(ByteSize b1, ByteSize b2) {
             return b1.Bits < b2.Bits;
             return b1.Bits < b2.Bits;
         }
         }
 
 
-        public static bool operator <=(ByteSize b1, ByteSize b2)
-        {
+        public static bool operator <=(ByteSize b1, ByteSize b2) {
             return b1.Bits <= b2.Bits;
             return b1.Bits <= b2.Bits;
         }
         }
 
 
-        public static bool operator >(ByteSize b1, ByteSize b2)
-        {
+        public static bool operator >(ByteSize b1, ByteSize b2) {
             return b1.Bits > b2.Bits;
             return b1.Bits > b2.Bits;
         }
         }
 
 
-        public static bool operator >=(ByteSize b1, ByteSize b2)
-        {
+        public static bool operator >=(ByteSize b1, ByteSize b2) {
             return b1.Bits >= b2.Bits;
             return b1.Bits >= b2.Bits;
         }
         }
 
 
-        public static ByteSize Parse(string s)
-        {
+        public static ByteSize Parse(string s) {
             return Parse(s, NumberFormatInfo.CurrentInfo);
             return Parse(s, NumberFormatInfo.CurrentInfo);
         }
         }
-        public static ByteSize Parse(string s, IFormatProvider formatProvider)
-        {
+        public static ByteSize Parse(string s, IFormatProvider formatProvider) {
             return Parse(s, NumberStyles.Float | NumberStyles.AllowThousands, formatProvider);
             return Parse(s, NumberStyles.Float | NumberStyles.AllowThousands, formatProvider);
         }
         }
 
 
-        public static ByteSize Parse(string s, NumberStyles numberStyles, IFormatProvider formatProvider)
-        {
+        public static ByteSize Parse(string s, NumberStyles numberStyles, IFormatProvider formatProvider) {
 
 
             // Arg checking
             // Arg checking
             if (string.IsNullOrWhiteSpace(s))
             if (string.IsNullOrWhiteSpace(s))
@@ -351,8 +310,7 @@ namespace Optimizer
 
 
             // Pick first non-digit number
             // Pick first non-digit number
             for (num = 0; num < s.Length; num++)
             for (num = 0; num < s.Length; num++)
-                if (!(char.IsDigit(s[num]) || s[num] == decimalSeparator || s[num] == groupSeparator))
-                {
+                if (!(char.IsDigit(s[num]) || s[num] == decimalSeparator || s[num] == groupSeparator)) {
                     found = true;
                     found = true;
                     break;
                     break;
                 }
                 }
@@ -372,8 +330,7 @@ namespace Optimizer
                 throw new FormatException($"No number found in value '{s}'.");
                 throw new FormatException($"No number found in value '{s}'.");
 
 
             // Get the magnitude part
             // Get the magnitude part
-            switch (sizePart)
-            {
+            switch (sizePart) {
                 case "b":
                 case "b":
                     if (number % 1 != 0) // Can't have partial bits
                     if (number % 1 != 0) // Can't have partial bits
                         throw new FormatException($"Can't have partial bits for value '{s}'.");
                         throw new FormatException($"Can't have partial bits for value '{s}'.");
@@ -384,8 +341,7 @@ namespace Optimizer
                     return FromBytes(number);
                     return FromBytes(number);
             }
             }
 
 
-            switch (sizePart.ToLowerInvariant())
-            {
+            switch (sizePart.ToLowerInvariant()) {
                 // Binary
                 // Binary
                 case "kib":
                 case "kib":
                     return FromKibiBytes(number);
                     return FromKibiBytes(number);
@@ -423,29 +379,23 @@ namespace Optimizer
             }
             }
         }
         }
 
 
-        public static bool TryParse(string s, out ByteSize result)
-        {
-            try
-            {
+        public static bool TryParse(string s, out ByteSize result) {
+            try {
                 result = Parse(s);
                 result = Parse(s);
                 return true;
                 return true;
             }
             }
-            catch
-            {
+            catch {
                 result = new ByteSize();
                 result = new ByteSize();
                 return false;
                 return false;
             }
             }
         }
         }
 
 
-        public static bool TryParse(string s, NumberStyles numberStyles, IFormatProvider formatProvider, out ByteSize result)
-        {
-            try
-            {
+        public static bool TryParse(string s, NumberStyles numberStyles, IFormatProvider formatProvider, out ByteSize result) {
+            try {
                 result = Parse(s, numberStyles, formatProvider);
                 result = Parse(s, numberStyles, formatProvider);
                 return true;
                 return true;
             }
             }
-            catch
-            {
+            catch {
                 result = new ByteSize();
                 result = new ByteSize();
                 return false;
                 return false;
             }
             }

+ 12 - 24
Optimizer/ByteSize/DecimalByteSize.cs

@@ -1,7 +1,5 @@
-namespace Optimizer
-{
-    public partial struct ByteSize
-    {
+namespace Optimizer {
+    public partial struct ByteSize {
         public const long BytesInKiloByte = 1_000;
         public const long BytesInKiloByte = 1_000;
         public const long BytesInMegaByte = 1_000_000;
         public const long BytesInMegaByte = 1_000_000;
         public const long BytesInGigaByte = 1_000_000_000;
         public const long BytesInGigaByte = 1_000_000_000;
@@ -20,53 +18,43 @@
         public double TeraBytes => Bytes / BytesInTeraByte;
         public double TeraBytes => Bytes / BytesInTeraByte;
         public double PetaBytes => Bytes / BytesInPetaByte;
         public double PetaBytes => Bytes / BytesInPetaByte;
 
 
-        public static ByteSize FromKiloBytes(double value)
-        {
+        public static ByteSize FromKiloBytes(double value) {
             return new ByteSize(value * BytesInKiloByte);
             return new ByteSize(value * BytesInKiloByte);
         }
         }
 
 
-        public static ByteSize FromMegaBytes(double value)
-        {
+        public static ByteSize FromMegaBytes(double value) {
             return new ByteSize(value * BytesInMegaByte);
             return new ByteSize(value * BytesInMegaByte);
         }
         }
 
 
-        public static ByteSize FromGigaBytes(double value)
-        {
+        public static ByteSize FromGigaBytes(double value) {
             return new ByteSize(value * BytesInGigaByte);
             return new ByteSize(value * BytesInGigaByte);
         }
         }
 
 
-        public static ByteSize FromTeraBytes(double value)
-        {
+        public static ByteSize FromTeraBytes(double value) {
             return new ByteSize(value * BytesInTeraByte);
             return new ByteSize(value * BytesInTeraByte);
         }
         }
 
 
-        public static ByteSize FromPetaBytes(double value)
-        {
+        public static ByteSize FromPetaBytes(double value) {
             return new ByteSize(value * BytesInPetaByte);
             return new ByteSize(value * BytesInPetaByte);
         }
         }
 
 
-        public ByteSize AddKiloBytes(double value)
-        {
+        public ByteSize AddKiloBytes(double value) {
             return this + ByteSize.FromKiloBytes(value);
             return this + ByteSize.FromKiloBytes(value);
         }
         }
 
 
-        public ByteSize AddMegaBytes(double value)
-        {
+        public ByteSize AddMegaBytes(double value) {
             return this + ByteSize.FromMegaBytes(value);
             return this + ByteSize.FromMegaBytes(value);
         }
         }
 
 
-        public ByteSize AddGigaBytes(double value)
-        {
+        public ByteSize AddGigaBytes(double value) {
             return this + ByteSize.FromGigaBytes(value);
             return this + ByteSize.FromGigaBytes(value);
         }
         }
 
 
-        public ByteSize AddTeraBytes(double value)
-        {
+        public ByteSize AddTeraBytes(double value) {
             return this + ByteSize.FromTeraBytes(value);
             return this + ByteSize.FromTeraBytes(value);
         }
         }
 
 
-        public ByteSize AddPetaBytes(double value)
-        {
+        public ByteSize AddPetaBytes(double value) {
             return this + ByteSize.FromPetaBytes(value);
             return this + ByteSize.FromPetaBytes(value);
         }
         }
     }
     }

+ 61 - 122
Optimizer/CleanHelper.cs

@@ -4,10 +4,8 @@ using System.IO;
 using System.Linq;
 using System.Linq;
 using System.Runtime.InteropServices;
 using System.Runtime.InteropServices;
 
 
-namespace Optimizer
-{
-    internal static class CleanHelper
-    {
+namespace Optimizer {
+    internal static class CleanHelper {
         [DllImport("Shell32.dll")]
         [DllImport("Shell32.dll")]
         static extern int SHEmptyRecycleBin(IntPtr hwnd, string pszRootPath, RecycleFlag dwFlags);
         static extern int SHEmptyRecycleBin(IntPtr hwnd, string pszRootPath, RecycleFlag dwFlags);
 
 
@@ -120,31 +118,24 @@ namespace Optimizer
 
 
         internal static ByteSize PreviewSizeToBeFreed = new ByteSize(0);
         internal static ByteSize PreviewSizeToBeFreed = new ByteSize(0);
 
 
-        internal static void PreviewFolder(string path)
-        {
-            try
-            {
-                if (File.Exists(path))
-                {
+        internal static void PreviewFolder(string path) {
+            try {
+                if (File.Exists(path)) {
                     PreviewCleanList.Add(path);
                     PreviewCleanList.Add(path);
                     return;
                     return;
                 }
                 }
 
 
                 DirectoryInfo di = new DirectoryInfo(path);
                 DirectoryInfo di = new DirectoryInfo(path);
 
 
-                foreach (FileInfo file in di.GetFiles("*", SearchOption.AllDirectories))
-                {
-                    try
-                    {
+                foreach (FileInfo file in di.GetFiles("*", SearchOption.AllDirectories)) {
+                    try {
                         PreviewCleanList.Add(file.FullName);
                         PreviewCleanList.Add(file.FullName);
                     }
                     }
                     catch { }
                     catch { }
                 }
                 }
 
 
-                foreach (DirectoryInfo dir in di.GetDirectories("*", SearchOption.AllDirectories))
-                {
-                    try
-                    {
+                foreach (DirectoryInfo dir in di.GetDirectories("*", SearchOption.AllDirectories)) {
+                    try {
                         PreviewCleanList.Add(dir.FullName);
                         PreviewCleanList.Add(dir.FullName);
                     }
                     }
                     catch { }
                     catch { }
@@ -153,12 +144,9 @@ namespace Optimizer
             catch { }
             catch { }
         }
         }
 
 
-        internal static void Clean()
-        {
-            foreach (string x in PreviewCleanList)
-            {
-                try
-                {
+        internal static void Clean() {
+            foreach (string x in PreviewCleanList) {
+                try {
                     if (Directory.Exists(x)) Directory.Delete(x);
                     if (Directory.Exists(x)) Directory.Delete(x);
                     if (File.Exists(x)) File.Delete(x);
                     if (File.Exists(x)) File.Delete(x);
                 }
                 }
@@ -166,25 +154,21 @@ namespace Optimizer
             }
             }
         }
         }
 
 
-        internal static void EmptyRecycleBin()
-        {
+        internal static void EmptyRecycleBin() {
             SHEmptyRecycleBin(IntPtr.Zero, null, RecycleFlag.SHERB_NOSOUND | RecycleFlag.SHERB_NOCONFIRMATION);
             SHEmptyRecycleBin(IntPtr.Zero, null, RecycleFlag.SHERB_NOSOUND | RecycleFlag.SHERB_NOCONFIRMATION);
         }
         }
 
 
-        internal static void PreviewTemp()
-        {
+        internal static void PreviewTemp() {
             PreviewFolder(TempFolder);
             PreviewFolder(TempFolder);
             PreviewSizeToBeFreed += CalculateSize(TempFolder);
             PreviewSizeToBeFreed += CalculateSize(TempFolder);
         }
         }
 
 
-        internal static void PreviewMinidumps()
-        {
+        internal static void PreviewMinidumps() {
             PreviewFolder(Path.Combine(OSDriveWindows, "Minidump"));
             PreviewFolder(Path.Combine(OSDriveWindows, "Minidump"));
             PreviewSizeToBeFreed += CalculateSize(Path.Combine(OSDriveWindows, "Minidump"));
             PreviewSizeToBeFreed += CalculateSize(Path.Combine(OSDriveWindows, "Minidump"));
         }
         }
 
 
-        internal static void PreviewErrorReports()
-        {
+        internal static void PreviewErrorReports() {
             PreviewFolder(Path.Combine(ProfileAppDataLocal, "Microsoft\\Windows\\WER\\ReportArchive"));
             PreviewFolder(Path.Combine(ProfileAppDataLocal, "Microsoft\\Windows\\WER\\ReportArchive"));
             PreviewFolder(Path.Combine(ProfileAppDataLocal, "Microsoft\\Windows\\WER\\ReportQueue"));
             PreviewFolder(Path.Combine(ProfileAppDataLocal, "Microsoft\\Windows\\WER\\ReportQueue"));
             PreviewFolder(Path.Combine(ProfileAppDataLocal, "Microsoft\\Windows\\WER\\Temp"));
             PreviewFolder(Path.Combine(ProfileAppDataLocal, "Microsoft\\Windows\\WER\\Temp"));
@@ -204,20 +188,16 @@ namespace Optimizer
             PreviewSizeToBeFreed += CalculateSize(Path.Combine(ProgramData, "Microsoft\\Windows\\WER\\ERC"));
             PreviewSizeToBeFreed += CalculateSize(Path.Combine(ProgramData, "Microsoft\\Windows\\WER\\ERC"));
         }
         }
 
 
-        internal static ByteSize CalculateSize(string fileOrFolder)
-        {
+        internal static ByteSize CalculateSize(string fileOrFolder) {
             ByteSize totalSize = new ByteSize(0);
             ByteSize totalSize = new ByteSize(0);
             bool isFolder = Directory.Exists(fileOrFolder);
             bool isFolder = Directory.Exists(fileOrFolder);
 
 
-            try
-            {
-                if (isFolder)
-                {
+            try {
+                if (isFolder) {
                     DirectoryInfo dir = new DirectoryInfo(fileOrFolder);
                     DirectoryInfo dir = new DirectoryInfo(fileOrFolder);
                     totalSize += totalSize.AddBytes(dir.EnumerateFiles("*", SearchOption.AllDirectories).Sum(file => file.Length));
                     totalSize += totalSize.AddBytes(dir.EnumerateFiles("*", SearchOption.AllDirectories).Sum(file => file.Length));
                 }
                 }
-                else
-                {
+                else {
                     FileInfo file = new FileInfo(fileOrFolder);
                     FileInfo file = new FileInfo(fileOrFolder);
                     totalSize = totalSize.AddBytes(file.Length);
                     totalSize = totalSize.AddBytes(file.Length);
                 }
                 }
@@ -227,73 +207,56 @@ namespace Optimizer
             return totalSize;
             return totalSize;
         }
         }
 
 
-        internal static void PreviewEdgeClean(bool cache, bool cookies, bool seachHistory, bool session)
-        {
-            if (cache)
-            {
-                foreach (string x in edgeCache)
-                {
+        internal static void PreviewEdgeClean(bool cache, bool cookies, bool seachHistory, bool session) {
+            if (cache) {
+                foreach (string x in edgeCache) {
                     PreviewFolder(x);
                     PreviewFolder(x);
                     PreviewSizeToBeFreed += CalculateSize(x);
                     PreviewSizeToBeFreed += CalculateSize(x);
                 }
                 }
             }
             }
 
 
-            if (cookies)
-            {
-                foreach (string x in edgeCookies)
-                {
+            if (cookies) {
+                foreach (string x in edgeCookies) {
                     PreviewFolder(x);
                     PreviewFolder(x);
                     PreviewSizeToBeFreed += CalculateSize(x);
                     PreviewSizeToBeFreed += CalculateSize(x);
                 }
                 }
             }
             }
 
 
-            if (seachHistory)
-            {
+            if (seachHistory) {
                 PreviewFolder(edgeHistory);
                 PreviewFolder(edgeHistory);
                 PreviewSizeToBeFreed += CalculateSize(edgeHistory);
                 PreviewSizeToBeFreed += CalculateSize(edgeHistory);
             }
             }
 
 
-            if (session)
-            {
-                foreach (string x in edgeSession)
-                {
+            if (session) {
+                foreach (string x in edgeSession) {
                     PreviewFolder(x);
                     PreviewFolder(x);
                     PreviewSizeToBeFreed += CalculateSize(x);
                     PreviewSizeToBeFreed += CalculateSize(x);
                 }
                 }
             }
             }
         }
         }
 
 
-        internal static void PreviewInternetExplorerCache()
-        {
-            foreach (string x in ieCache)
-            {
+        internal static void PreviewInternetExplorerCache() {
+            foreach (string x in ieCache) {
                 PreviewFolder(x);
                 PreviewFolder(x);
                 PreviewSizeToBeFreed += CalculateSize(x);
                 PreviewSizeToBeFreed += CalculateSize(x);
             }
             }
         }
         }
 
 
-        internal static void PreviewFireFoxClean(bool cache, bool cookies, bool searchHistory)
-        {
-            if (Directory.Exists(firefoxRoaming))
-            {
-                foreach (string x in Directory.EnumerateDirectories(firefoxRoaming))
-                {
-                    if (x.ToLowerInvariant().Contains("release"))
-                    {
-                        if (cookies)
-                        {
+        internal static void PreviewFireFoxClean(bool cache, bool cookies, bool searchHistory) {
+            if (Directory.Exists(firefoxRoaming)) {
+                foreach (string x in Directory.EnumerateDirectories(firefoxRoaming)) {
+                    if (x.ToLowerInvariant().Contains("release")) {
+                        if (cookies) {
                             PreviewFolder(Path.Combine(x, "cookies.sqlite"));
                             PreviewFolder(Path.Combine(x, "cookies.sqlite"));
                             PreviewSizeToBeFreed += CalculateSize(Path.Combine(x, "cookies.sqlite"));
                             PreviewSizeToBeFreed += CalculateSize(Path.Combine(x, "cookies.sqlite"));
                         }
                         }
 
 
-                        if (searchHistory)
-                        {
+                        if (searchHistory) {
                             PreviewFolder(Path.Combine(x, "places.sqlite"));
                             PreviewFolder(Path.Combine(x, "places.sqlite"));
                             PreviewSizeToBeFreed += CalculateSize(Path.Combine(x, "places.sqlite"));
                             PreviewSizeToBeFreed += CalculateSize(Path.Combine(x, "places.sqlite"));
                         }
                         }
 
 
-                        if (cache)
-                        {
+                        if (cache) {
                             PreviewFolder(Path.Combine(x, "shader-cache"));
                             PreviewFolder(Path.Combine(x, "shader-cache"));
                             PreviewSizeToBeFreed += CalculateSize(Path.Combine(x, "shader-cache"));
                             PreviewSizeToBeFreed += CalculateSize(Path.Combine(x, "shader-cache"));
                         }
                         }
@@ -301,14 +264,10 @@ namespace Optimizer
                 }
                 }
             }
             }
 
 
-            if (cache)
-            {
-                if (Directory.Exists(firefoxLocal))
-                {
-                    foreach (string x in Directory.EnumerateDirectories(firefoxLocal))
-                    {
-                        if (x.ToLowerInvariant().Contains("release"))
-                        {
+            if (cache) {
+                if (Directory.Exists(firefoxLocal)) {
+                    foreach (string x in Directory.EnumerateDirectories(firefoxLocal)) {
+                        if (x.ToLowerInvariant().Contains("release")) {
                             PreviewFolder(Path.Combine(x, "cache2"));
                             PreviewFolder(Path.Combine(x, "cache2"));
                             PreviewSizeToBeFreed += CalculateSize(Path.Combine(x, "cache2"));
                             PreviewSizeToBeFreed += CalculateSize(Path.Combine(x, "cache2"));
                         }
                         }
@@ -317,91 +276,71 @@ namespace Optimizer
             }
             }
         }
         }
 
 
-        internal static void PreviewBraveClean(bool cache, bool cookies, bool searchHistory, bool session, bool passwords)
-        {
-            if (cache)
-            {
-                foreach (string x in braveUserDataCacheDirs)
-                {
+        internal static void PreviewBraveClean(bool cache, bool cookies, bool searchHistory, bool session, bool passwords) {
+            if (cache) {
+                foreach (string x in braveUserDataCacheDirs) {
                     PreviewFolder(Path.Combine(braveFolder, x));
                     PreviewFolder(Path.Combine(braveFolder, x));
                     PreviewSizeToBeFreed += CalculateSize(Path.Combine(braveFolder, x));
                     PreviewSizeToBeFreed += CalculateSize(Path.Combine(braveFolder, x));
                 }
                 }
             }
             }
 
 
-            if (session)
-            {
-                foreach (string x in braveSessionDirs)
-                {
+            if (session) {
+                foreach (string x in braveSessionDirs) {
                     PreviewFolder(x);
                     PreviewFolder(x);
                     PreviewSizeToBeFreed += CalculateSize(x);
                     PreviewSizeToBeFreed += CalculateSize(x);
                 }
                 }
             }
             }
 
 
-            if (cookies)
-            {
-                foreach (string x in braveCookiesDirs)
-                {
+            if (cookies) {
+                foreach (string x in braveCookiesDirs) {
                     PreviewFolder(x);
                     PreviewFolder(x);
                     PreviewSizeToBeFreed += CalculateSize(x);
                     PreviewSizeToBeFreed += CalculateSize(x);
                 }
                 }
             }
             }
 
 
-            if (searchHistory)
-            {
-                foreach (string x in braveHistoryDirs)
-                {
+            if (searchHistory) {
+                foreach (string x in braveHistoryDirs) {
                     PreviewFolder(x);
                     PreviewFolder(x);
                     PreviewSizeToBeFreed += CalculateSize(x);
                     PreviewSizeToBeFreed += CalculateSize(x);
                 }
                 }
             }
             }
 
 
-            if (passwords)
-            {
+            if (passwords) {
                 PreviewFolder(bravePasswordsDir);
                 PreviewFolder(bravePasswordsDir);
                 PreviewSizeToBeFreed += CalculateSize(bravePasswordsDir);
                 PreviewSizeToBeFreed += CalculateSize(bravePasswordsDir);
             }
             }
         }
         }
 
 
-        internal static void PreviewChromeClean(bool cache, bool cookies, bool searchHistory, bool session, bool passwords)
-        {
-            if (cache)
-            {
-                foreach (string x in chromeUserDataCacheDirs)
-                {
+        internal static void PreviewChromeClean(bool cache, bool cookies, bool searchHistory, bool session, bool passwords) {
+            if (cache) {
+                foreach (string x in chromeUserDataCacheDirs) {
                     PreviewFolder(Path.Combine(chromeFolder, x));
                     PreviewFolder(Path.Combine(chromeFolder, x));
                     PreviewSizeToBeFreed += CalculateSize(Path.Combine(chromeFolder, x));
                     PreviewSizeToBeFreed += CalculateSize(Path.Combine(chromeFolder, x));
                 }
                 }
             }
             }
 
 
-            if (session)
-            {
-                foreach (string x in chromeSessionDirs)
-                {
+            if (session) {
+                foreach (string x in chromeSessionDirs) {
                     PreviewFolder(x);
                     PreviewFolder(x);
                     PreviewSizeToBeFreed += CalculateSize(x);
                     PreviewSizeToBeFreed += CalculateSize(x);
                 }
                 }
             }
             }
 
 
-            if (cookies)
-            {
-                foreach (string x in chromeCookiesDirs)
-                {
+            if (cookies) {
+                foreach (string x in chromeCookiesDirs) {
                     PreviewFolder(x);
                     PreviewFolder(x);
                     PreviewSizeToBeFreed += CalculateSize(x);
                     PreviewSizeToBeFreed += CalculateSize(x);
                 }
                 }
             }
             }
 
 
-            if (searchHistory)
-            {
-                foreach (string x in chromeHistoryDirs)
-                {
+            if (searchHistory) {
+                foreach (string x in chromeHistoryDirs) {
                     PreviewFolder(x);
                     PreviewFolder(x);
                     PreviewSizeToBeFreed += CalculateSize(x);
                     PreviewSizeToBeFreed += CalculateSize(x);
                 }
                 }
             }
             }
 
 
-            if (passwords)
-            {
+            if (passwords) {
                 PreviewFolder(chromePasswordsDir);
                 PreviewFolder(chromePasswordsDir);
                 PreviewSizeToBeFreed += CalculateSize(chromePasswordsDir);
                 PreviewSizeToBeFreed += CalculateSize(chromePasswordsDir);
             }
             }

+ 42 - 84
Optimizer/ColorHelper.cs

@@ -2,12 +2,9 @@
 using System.Drawing;
 using System.Drawing;
 using System.Text;
 using System.Text;
 
 
-namespace Optimizer
-{
-    public static class ColorHelper
-    {
-        public static void HSVFromRGB(Color color, out double hue, out double saturation, out double value)
-        {
+namespace Optimizer {
+    public static class ColorHelper {
+        public static void HSVFromRGB(Color color, out double hue, out double saturation, out double value) {
             double min, max, delta, r, g, b;
             double min, max, delta, r, g, b;
             r = (double)color.R / 255d;
             r = (double)color.R / 255d;
             g = (double)color.G / 255d;
             g = (double)color.G / 255d;
@@ -19,8 +16,7 @@ namespace Optimizer
             delta = max - min;
             delta = max - min;
             if (max != 0)
             if (max != 0)
                 saturation = delta / max;
                 saturation = delta / max;
-            else
-            {
+            else {
                 saturation = 0;
                 saturation = 0;
                 hue = -1;
                 hue = -1;
                 return;
                 return;
@@ -36,15 +32,12 @@ namespace Optimizer
                 hue += 360;
                 hue += 360;
         }
         }
 
 
-        public static Color ColorFromHSV(double hue, double saturation, double value)
-        {
-            try
-            {
+        public static Color ColorFromHSV(double hue, double saturation, double value) {
+            try {
                 int i;
                 int i;
                 double f, p, q, t, r, g, b;
                 double f, p, q, t, r, g, b;
 
 
-                if (saturation == 0)
-                {
+                if (saturation == 0) {
                     r = g = b = value;
                     r = g = b = value;
                     return Color.FromArgb((int)(255 * r), (int)(255 * g), (int)(255 * b));
                     return Color.FromArgb((int)(255 * r), (int)(255 * g), (int)(255 * b));
                 }
                 }
@@ -54,8 +47,7 @@ namespace Optimizer
                 p = value * (1 - saturation);
                 p = value * (1 - saturation);
                 q = value * (1 - saturation * f);
                 q = value * (1 - saturation * f);
                 t = value * (1 - saturation * (1 - f));
                 t = value * (1 - saturation * (1 - f));
-                switch (i)
-                {
+                switch (i) {
                     case 0:
                     case 0:
                         r = value;
                         r = value;
                         g = t;
                         g = t;
@@ -89,14 +81,12 @@ namespace Optimizer
                 }
                 }
                 return Color.FromArgb((int)(255 * r), (int)(255 * g), (int)(255 * b));
                 return Color.FromArgb((int)(255 * r), (int)(255 * g), (int)(255 * b));
             }
             }
-            catch
-            {
+            catch {
             }
             }
             return Color.Empty;
             return Color.Empty;
         }
         }
 
 
-        public static Color ChangeColorBrightness(Color color, double darkenAmount)
-        {
+        public static Color ChangeColorBrightness(Color color, double darkenAmount) {
             HslColor hslColor = new HslColor(color);
             HslColor hslColor = new HslColor(color);
             hslColor.L *= darkenAmount;
             hslColor.L *= darkenAmount;
             return hslColor;
             return hslColor;
@@ -104,8 +94,7 @@ namespace Optimizer
     }
     }
 
 
     [Serializable]
     [Serializable]
-    public struct HslColor
-    {
+    public struct HslColor {
         #region Constants
         #region Constants
 
 
         public static readonly HslColor Empty;
         public static readonly HslColor Empty;
@@ -124,10 +113,8 @@ namespace Optimizer
 
 
         #region Static Constructors
         #region Static Constructors
 
 
-        static HslColor()
-        {
-            Empty = new HslColor
-            {
+        static HslColor() {
+            Empty = new HslColor {
                 IsEmpty = true
                 IsEmpty = true
             };
             };
         }
         }
@@ -137,11 +124,9 @@ namespace Optimizer
         #region Public Constructors
         #region Public Constructors
 
 
         public HslColor(double h, double s, double l)
         public HslColor(double h, double s, double l)
-            : this(255, h, s, l)
-        { }
+            : this(255, h, s, l) { }
 
 
-        public HslColor(int a, double h, double s, double l)
-        {
+        public HslColor(int a, double h, double s, double l) {
             this.alpha = a;
             this.alpha = a;
             this.hue = Math.Min(359, h);
             this.hue = Math.Min(359, h);
             this.saturation = Math.Min(1, s);
             this.saturation = Math.Min(1, s);
@@ -149,8 +134,7 @@ namespace Optimizer
             isEmpty = false;
             isEmpty = false;
         }
         }
 
 
-        public HslColor(Color color)
-        {
+        public HslColor(Color color) {
             this.alpha = color.A;
             this.alpha = color.A;
             this.hue = color.GetHue();
             this.hue = color.GetHue();
             this.saturation = color.GetSaturation();
             this.saturation = color.GetSaturation();
@@ -162,23 +146,19 @@ namespace Optimizer
 
 
         #region Operators
         #region Operators
 
 
-        public static bool operator ==(HslColor left, HslColor right)
-        {
+        public static bool operator ==(HslColor left, HslColor right) {
             return (((left.A == right.A) && (left.H == right.H)) && ((left.S == right.S) && (left.L == right.L)));
             return (((left.A == right.A) && (left.H == right.H)) && ((left.S == right.S) && (left.L == right.L)));
         }
         }
 
 
-        public static bool operator !=(HslColor left, HslColor right)
-        {
+        public static bool operator !=(HslColor left, HslColor right) {
             return !(left == right);
             return !(left == right);
         }
         }
 
 
-        public static implicit operator HslColor(Color color)
-        {
+        public static implicit operator HslColor(Color color) {
             return new HslColor(color);
             return new HslColor(color);
         }
         }
 
 
-        public static implicit operator Color(HslColor color)
-        {
+        public static implicit operator Color(HslColor color) {
             return color.ToRgbColor();
             return color.ToRgbColor();
         }
         }
 
 
@@ -186,25 +166,20 @@ namespace Optimizer
 
 
         #region Overridden Methods
         #region Overridden Methods
 
 
-        public override bool Equals(object obj)
-        {
-            if (obj is HslColor color)
-            {
-                if (((this.A == color.A) && (this.H == color.H)) && ((this.S == color.S) && (this.L == color.L)))
-                {
+        public override bool Equals(object obj) {
+            if (obj is HslColor color) {
+                if (((this.A == color.A) && (this.H == color.H)) && ((this.S == color.S) && (this.L == color.L))) {
                     return true;
                     return true;
                 }
                 }
             }
             }
             return false;
             return false;
         }
         }
 
 
-        public override int GetHashCode()
-        {
+        public override int GetHashCode() {
             return (((this.alpha.GetHashCode() ^ this.hue.GetHashCode()) ^ this.saturation.GetHashCode()) ^ this.luminance.GetHashCode());
             return (((this.alpha.GetHashCode() ^ this.hue.GetHashCode()) ^ this.saturation.GetHashCode()) ^ this.luminance.GetHashCode());
         }
         }
 
 
-        public override string ToString()
-        {
+        public override string ToString() {
             StringBuilder builder;
             StringBuilder builder;
 
 
             builder = new StringBuilder();
             builder = new StringBuilder();
@@ -225,54 +200,44 @@ namespace Optimizer
 
 
         #region Public Members
         #region Public Members
 
 
-        public double H
-        {
+        public double H {
             get { return this.hue; }
             get { return this.hue; }
-            set
-            {
+            set {
                 this.hue = value;
                 this.hue = value;
                 this.hue = (this.hue > 359.0) ? 0 : ((this.hue < 0.0) ? 359 : this.hue);
                 this.hue = (this.hue > 359.0) ? 0 : ((this.hue < 0.0) ? 359 : this.hue);
             }
             }
         }
         }
 
 
-        public double S
-        {
+        public double S {
             get { return this.saturation; }
             get { return this.saturation; }
             set { this.saturation = Math.Min(1, Math.Max(0, value)); }
             set { this.saturation = Math.Min(1, Math.Max(0, value)); }
         }
         }
 
 
-        public double L
-        {
+        public double L {
             get { return this.luminance; }
             get { return this.luminance; }
             set { this.luminance = Math.Min(1, Math.Max(0, value)); }
             set { this.luminance = Math.Min(1, Math.Max(0, value)); }
         }
         }
 
 
-        public int A
-        {
+        public int A {
             get { return this.alpha; }
             get { return this.alpha; }
             set { this.alpha = Math.Min(0, Math.Max(255, value)); }
             set { this.alpha = Math.Min(0, Math.Max(255, value)); }
         }
         }
 
 
-        public bool IsEmpty
-        {
+        public bool IsEmpty {
             get { return isEmpty; }
             get { return isEmpty; }
             internal set { isEmpty = value; }
             internal set { isEmpty = value; }
         }
         }
 
 
-        public Color ToRgbColor()
-        {
+        public Color ToRgbColor() {
             return this.ToRgbColor(this.A);
             return this.ToRgbColor(this.A);
         }
         }
 
 
-        public Color ToRgbColor(int alpha)
-        {
+        public Color ToRgbColor(int alpha) {
             double q;
             double q;
-            if (this.L < 0.5)
-            {
+            if (this.L < 0.5) {
                 q = this.L * (1 + this.S);
                 q = this.L * (1 + this.S);
             }
             }
-            else
-            {
+            else {
                 q = this.L + this.S - (this.L * this.S);
                 q = this.L + this.S - (this.L * this.S);
             }
             }
             double p = 2 * this.L - q;
             double p = 2 * this.L - q;
@@ -288,31 +253,24 @@ namespace Optimizer
                           0.0, 0.0, 0.0
                           0.0, 0.0, 0.0
                         };
                         };
 
 
-            for (int color = 0; color < colors.Length; color++)
-            {
-                if (tc[color] < 0)
-                {
+            for (int color = 0; color < colors.Length; color++) {
+                if (tc[color] < 0) {
                     tc[color] += 1;
                     tc[color] += 1;
                 }
                 }
-                if (tc[color] > 1)
-                {
+                if (tc[color] > 1) {
                     tc[color] -= 1;
                     tc[color] -= 1;
                 }
                 }
 
 
-                if (tc[color] < (1d / 6d))
-                {
+                if (tc[color] < (1d / 6d)) {
                     colors[color] = p + ((q - p) * 6 * tc[color]);
                     colors[color] = p + ((q - p) * 6 * tc[color]);
                 }
                 }
-                else if (tc[color] >= (1d / 6d) && tc[color] < (1d / 2d))
-                {
+                else if (tc[color] >= (1d / 6d) && tc[color] < (1d / 2d)) {
                     colors[color] = q;
                     colors[color] = q;
                 }
                 }
-                else if (tc[color] >= (1d / 2d) && tc[color] < (2d / 3d))
-                {
+                else if (tc[color] >= (1d / 2d) && tc[color] < (2d / 3d)) {
                     colors[color] = p + ((q - p) * 6 * (2d / 3d - tc[color]));
                     colors[color] = p + ((q - p) * 6 * (2d / 3d - tc[color]));
                 }
                 }
-                else
-                {
+                else {
                     colors[color] = p;
                     colors[color] = p;
                 }
                 }
 
 

+ 2 - 5
Optimizer/Constants.cs

@@ -1,8 +1,5 @@
-namespace Optimizer
-{
-    internal static class Constants
-    {
-        internal static string DOWNLOADS_FOLDER = "OptimizerDownloads";
+namespace Optimizer {
+    internal static class Constants {
         internal static string INTERNAL_DNS = "1.1.1.1";
         internal static string INTERNAL_DNS = "1.1.1.1";
         internal static string THEME_FLAG = "themeable";
         internal static string THEME_FLAG = "themeable";
         internal static int CONTRAST_THRESHOLD = 149;
         internal static int CONTRAST_THRESHOLD = 149;

+ 3 - 6
Optimizer/Controls/AppCard.cs

@@ -1,11 +1,8 @@
 using System.Windows.Forms;
 using System.Windows.Forms;
 
 
-namespace Optimizer
-{
-    public sealed partial class AppCard : UserControl
-    {
-        public AppCard()
-        {
+namespace Optimizer {
+    public sealed partial class AppCard : UserControl {
+        public AppCard() {
             InitializeComponent();
             InitializeComponent();
         }
         }
     }
     }

+ 9 - 18
Optimizer/Controls/ColorOverrider.cs

@@ -7,10 +7,8 @@ using System.Linq;
 using System.Reflection;
 using System.Reflection;
 
 
 
 
-namespace Optimizer
-{
-    public sealed class ColorOverrider
-    {
+namespace Optimizer {
+    public sealed class ColorOverrider {
         public static event Action SystemColorsChanging;
         public static event Action SystemColorsChanging;
         public static event Action SystemColorsChanged;
         public static event Action SystemColorsChanged;
 
 
@@ -21,8 +19,7 @@ namespace Optimizer
         private readonly FieldInfo _colorTableField;
         private readonly FieldInfo _colorTableField;
         private readonly PropertyInfo _threadDataProperty;
         private readonly PropertyInfo _threadDataProperty;
 
 
-        public ColorOverrider()
-        {
+        public ColorOverrider() {
             // force init color table
             // force init color table
             byte unused = SystemColors.Window.R;
             byte unused = SystemColors.Window.R;
 
 
@@ -56,8 +53,7 @@ namespace Optimizer
                 ?.GetValue(null);
                 ?.GetValue(null);
         }
         }
 
 
-        private void userPreferenceChanging(object sender, UserPreferenceChangingEventArgs e)
-        {
+        private void userPreferenceChanging(object sender, UserPreferenceChangingEventArgs e) {
             if (e.Category != UserPreferenceCategory.Color)
             if (e.Category != UserPreferenceCategory.Color)
                 return;
                 return;
 
 
@@ -65,8 +61,7 @@ namespace Optimizer
             fireColorsChangedEvents();
             fireColorsChangedEvents();
         }
         }
 
 
-        private static void fireColorsChangedEvents()
-        {
+        private static void fireColorsChangedEvents() {
             SystemColorsChanging?.Invoke();
             SystemColorsChanging?.Invoke();
             SystemColorsChanged?.Invoke();
             SystemColorsChanged?.Invoke();
         }
         }
@@ -74,8 +69,7 @@ namespace Optimizer
         private int[] readColorTable() =>
         private int[] readColorTable() =>
             (int[])_colorTableField.GetValue(null);
             (int[])_colorTableField.GetValue(null);
 
 
-        public void SetColor(KnownColor knownColor, int argb)
-        {
+        public void SetColor(KnownColor knownColor, int argb) {
             setColor(knownColor, argb);
             setColor(knownColor, argb);
 
 
             if (SystemBrushesKey != null)
             if (SystemBrushesKey != null)
@@ -93,8 +87,7 @@ namespace Optimizer
         public int GetOriginalColor(KnownColor knownColor) =>
         public int GetOriginalColor(KnownColor knownColor) =>
             OriginalColors[(int)knownColor];
             OriginalColors[(int)knownColor];
 
 
-        public int GetColor(KnownColor knownColor)
-        {
+        public int GetColor(KnownColor knownColor) {
             if (!KnownColors.Contains(knownColor))
             if (!KnownColors.Contains(knownColor))
                 throw new ArgumentException();
                 throw new ArgumentException();
 
 
@@ -105,10 +98,8 @@ namespace Optimizer
             KnownColors.Cast<int>()
             KnownColors.Cast<int>()
                 .ToDictionary(i => i, i => _colorTable[i]);
                 .ToDictionary(i => i, i => _colorTable[i]);
 
 
-        public void Load(IReadOnlyDictionary<int, int> saved)
-        {
-            foreach (var color in KnownColors)
-            {
+        public void Load(IReadOnlyDictionary<int, int> saved) {
+            foreach (var color in KnownColors) {
                 int v;
                 int v;
                 var value = saved.TryGetValue((int)color, out v);
                 var value = saved.TryGetValue((int)color, out v);
                 setColor(color, v);
                 setColor(color, v);

+ 97 - 194
Optimizer/Controls/ColorPicker.cs

@@ -5,12 +5,10 @@ using System.Drawing;
 using System.Drawing.Drawing2D;
 using System.Drawing.Drawing2D;
 using System.Windows.Forms;
 using System.Windows.Forms;
 
 
-namespace Optimizer.Controls
-{
+namespace Optimizer.Controls {
     [DefaultProperty("Color")]
     [DefaultProperty("Color")]
     [DefaultEvent("ColorChanged")]
     [DefaultEvent("ColorChanged")]
-    public partial class ColorPicker : Control
-    {
+    public partial class ColorPicker : Control {
         #region Fields
         #region Fields
 
 
         private Brush _brush;
         private Brush _brush;
@@ -29,8 +27,7 @@ namespace Optimizer.Controls
 
 
         #region Constructors
         #region Constructors
 
 
-        public ColorPicker()
-        {
+        public ColorPicker() {
             this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.Selectable | ControlStyles.StandardClick | ControlStyles.StandardDoubleClick, true);
             this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.Selectable | ControlStyles.StandardClick | ControlStyles.StandardDoubleClick, true);
             this.Color = Color.Black;
             this.Color = Color.Black;
             this.ColorStep = 4;
             this.ColorStep = 4;
@@ -65,17 +62,13 @@ namespace Optimizer.Controls
         #endregion
         #endregion
 
 
         #region Overridden Methods
         #region Overridden Methods
-        protected override void Dispose(bool disposing)
-        {
-            if (disposing)
-            {
-                if (_brush != null)
-                {
+        protected override void Dispose(bool disposing) {
+            if (disposing) {
+                if (_brush != null) {
                     _brush.Dispose();
                     _brush.Dispose();
                 }
                 }
 
 
-                if (this.SelectionGlyph != null)
-                {
+                if (this.SelectionGlyph != null) {
                     this.SelectionGlyph.Dispose();
                     this.SelectionGlyph.Dispose();
                 }
                 }
             }
             }
@@ -83,31 +76,26 @@ namespace Optimizer.Controls
             base.Dispose(disposing);
             base.Dispose(disposing);
         }
         }
 
 
-        protected override bool IsInputKey(Keys keyData)
-        {
+        protected override bool IsInputKey(Keys keyData) {
             bool result;
             bool result;
 
 
-            if ((keyData & Keys.Left) == Keys.Left || (keyData & Keys.Up) == Keys.Up || (keyData & Keys.Down) == Keys.Down || (keyData & Keys.Right) == Keys.Right || (keyData & Keys.PageUp) == Keys.PageUp || (keyData & Keys.PageDown) == Keys.PageDown)
-            {
+            if ((keyData & Keys.Left) == Keys.Left || (keyData & Keys.Up) == Keys.Up || (keyData & Keys.Down) == Keys.Down || (keyData & Keys.Right) == Keys.Right || (keyData & Keys.PageUp) == Keys.PageUp || (keyData & Keys.PageDown) == Keys.PageDown) {
                 result = true;
                 result = true;
             }
             }
-            else
-            {
+            else {
                 result = base.IsInputKey(keyData);
                 result = base.IsInputKey(keyData);
             }
             }
 
 
             return result;
             return result;
         }
         }
 
 
-        protected override void OnGotFocus(EventArgs e)
-        {
+        protected override void OnGotFocus(EventArgs e) {
             base.OnGotFocus(e);
             base.OnGotFocus(e);
 
 
             this.Invalidate();
             this.Invalidate();
         }
         }
 
 
-        protected override void OnKeyDown(KeyEventArgs e)
-        {
+        protected override void OnKeyDown(KeyEventArgs e) {
             HslColor color;
             HslColor color;
             double hue;
             double hue;
             int step;
             int step;
@@ -117,8 +105,7 @@ namespace Optimizer.Controls
 
 
             step = e.Shift ? this.LargeChange : this.SmallChange;
             step = e.Shift ? this.LargeChange : this.SmallChange;
 
 
-            switch (e.KeyCode)
-            {
+            switch (e.KeyCode) {
                 case Keys.Right:
                 case Keys.Right:
                 case Keys.Up:
                 case Keys.Up:
                     hue += step;
                     hue += step;
@@ -135,17 +122,14 @@ namespace Optimizer.Controls
                     break;
                     break;
             }
             }
 
 
-            if (hue >= 360)
-            {
+            if (hue >= 360) {
                 hue = 0;
                 hue = 0;
             }
             }
-            if (hue < 0)
-            {
+            if (hue < 0) {
                 hue = 359;
                 hue = 359;
             }
             }
 
 
-            if (hue != color.H)
-            {
+            if (hue != color.H) {
                 color.H = hue;
                 color.H = hue;
 
 
                 this.LockUpdates = true;
                 this.LockUpdates = true;
@@ -159,86 +143,71 @@ namespace Optimizer.Controls
             base.OnKeyDown(e);
             base.OnKeyDown(e);
         }
         }
 
 
-        protected override void OnLostFocus(EventArgs e)
-        {
+        protected override void OnLostFocus(EventArgs e) {
             base.OnLostFocus(e);
             base.OnLostFocus(e);
 
 
             this.Invalidate();
             this.Invalidate();
         }
         }
 
 
-        protected override void OnMouseDown(MouseEventArgs e)
-        {
+        protected override void OnMouseDown(MouseEventArgs e) {
             base.OnMouseDown(e);
             base.OnMouseDown(e);
 
 
-            if (!this.Focused && this.TabStop)
-            {
+            if (!this.Focused && this.TabStop) {
                 this.Focus();
                 this.Focus();
             }
             }
 
 
-            if (e.Button == MouseButtons.Left && this.IsPointInWheel(e.Location))
-            {
+            if (e.Button == MouseButtons.Left && this.IsPointInWheel(e.Location)) {
                 _dragStartedWithinWheel = true;
                 _dragStartedWithinWheel = true;
                 this.SetColor(e.Location);
                 this.SetColor(e.Location);
             }
             }
         }
         }
 
 
-        protected override void OnMouseMove(MouseEventArgs e)
-        {
+        protected override void OnMouseMove(MouseEventArgs e) {
             base.OnMouseMove(e);
             base.OnMouseMove(e);
 
 
-            if (e.Button == MouseButtons.Left && _dragStartedWithinWheel)
-            {
+            if (e.Button == MouseButtons.Left && _dragStartedWithinWheel) {
                 this.SetColor(e.Location);
                 this.SetColor(e.Location);
             }
             }
         }
         }
 
 
-        protected override void OnMouseUp(MouseEventArgs e)
-        {
+        protected override void OnMouseUp(MouseEventArgs e) {
             base.OnMouseUp(e);
             base.OnMouseUp(e);
 
 
             _dragStartedWithinWheel = false;
             _dragStartedWithinWheel = false;
         }
         }
 
 
-        protected override void OnPaddingChanged(EventArgs e)
-        {
+        protected override void OnPaddingChanged(EventArgs e) {
             base.OnPaddingChanged(e);
             base.OnPaddingChanged(e);
 
 
             this.RefreshWheel();
             this.RefreshWheel();
         }
         }
 
 
-        protected override void OnPaint(PaintEventArgs e)
-        {
+        protected override void OnPaint(PaintEventArgs e) {
             base.OnPaint(e);
             base.OnPaint(e);
 
 
-            if (this.AllowPainting)
-            {
+            if (this.AllowPainting) {
                 base.OnPaintBackground(e);
                 base.OnPaintBackground(e);
 
 
-                if (this.BackgroundImage == null && this.Parent != null && (this.BackColor == this.Parent.BackColor || this.Parent.BackColor.A != 255))
-                {
+                if (this.BackgroundImage == null && this.Parent != null && (this.BackColor == this.Parent.BackColor || this.Parent.BackColor.A != 255)) {
                     ButtonRenderer.DrawParentBackground(e.Graphics, this.DisplayRectangle, this);
                     ButtonRenderer.DrawParentBackground(e.Graphics, this.DisplayRectangle, this);
                 }
                 }
 
 
-                if (_brush != null)
-                {
+                if (_brush != null) {
                     e.Graphics.FillPie(_brush, this.ClientRectangle, 0, 360);
                     e.Graphics.FillPie(_brush, this.ClientRectangle, 0, 360);
                 }
                 }
 
 
                 e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
                 e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
-                using (Pen pen = new Pen(this.BackColor, 2))
-                {
+                using (Pen pen = new Pen(this.BackColor, 2)) {
                     e.Graphics.DrawEllipse(pen, new RectangleF(_centerPoint.X - _radius, _centerPoint.Y - _radius, _radius * 2, _radius * 2));
                     e.Graphics.DrawEllipse(pen, new RectangleF(_centerPoint.X - _radius, _centerPoint.Y - _radius, _radius * 2, _radius * 2));
                 }
                 }
 
 
-                if (!this.Color.IsEmpty)
-                {
+                if (!this.Color.IsEmpty) {
                     this.PaintCurrentColor(e);
                     this.PaintCurrentColor(e);
                 }
                 }
             }
             }
         }
         }
 
 
-        protected override void OnResize(EventArgs e)
-        {
+        protected override void OnResize(EventArgs e) {
             base.OnResize(e);
             base.OnResize(e);
 
 
             this.RefreshWheel();
             this.RefreshWheel();
@@ -250,13 +219,10 @@ namespace Optimizer.Controls
 
 
         [Category("Appearance")]
         [Category("Appearance")]
         [DefaultValue(typeof(Color), "Black")]
         [DefaultValue(typeof(Color), "Black")]
-        public virtual Color Color
-        {
+        public virtual Color Color {
             get { return _color; }
             get { return _color; }
-            set
-            {
-                if (this.Color != value)
-                {
+            set {
+                if (this.Color != value) {
                     _color = value;
                     _color = value;
 
 
                     this.OnColorChanged(EventArgs.Empty);
                     this.OnColorChanged(EventArgs.Empty);
@@ -266,18 +232,14 @@ namespace Optimizer.Controls
 
 
         [Category("Appearance")]
         [Category("Appearance")]
         [DefaultValue(4)]
         [DefaultValue(4)]
-        public virtual int ColorStep
-        {
+        public virtual int ColorStep {
             get { return _colorStep; }
             get { return _colorStep; }
-            set
-            {
-                if (value < 1 || value > 359)
-                {
+            set {
+                if (value < 1 || value > 359) {
                     throw new ArgumentOutOfRangeException("value", value, "Value must be between 1 and 359");
                     throw new ArgumentOutOfRangeException("value", value, "Value must be between 1 and 359");
                 }
                 }
 
 
-                if (this.ColorStep != value)
-                {
+                if (this.ColorStep != value) {
                     _colorStep = value;
                     _colorStep = value;
 
 
                     this.OnColorStepChanged(EventArgs.Empty);
                     this.OnColorStepChanged(EventArgs.Empty);
@@ -289,13 +251,10 @@ namespace Optimizer.Controls
         [DefaultValue(typeof(HslColor), "0, 0, 0")]
         [DefaultValue(typeof(HslColor), "0, 0, 0")]
         [Browsable(false)]
         [Browsable(false)]
         [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
         [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public virtual HslColor HslColor
-        {
+        public virtual HslColor HslColor {
             get { return _hslColor; }
             get { return _hslColor; }
-            set
-            {
-                if (this.HslColor != value)
-                {
+            set {
+                if (this.HslColor != value) {
                     _hslColor = value;
                     _hslColor = value;
 
 
                     this.OnHslColorChanged(EventArgs.Empty);
                     this.OnHslColorChanged(EventArgs.Empty);
@@ -305,13 +264,10 @@ namespace Optimizer.Controls
 
 
         [Category("Behavior")]
         [Category("Behavior")]
         [DefaultValue(5)]
         [DefaultValue(5)]
-        public virtual int LargeChange
-        {
+        public virtual int LargeChange {
             get { return _largeChange; }
             get { return _largeChange; }
-            set
-            {
-                if (this.LargeChange != value)
-                {
+            set {
+                if (this.LargeChange != value) {
                     _largeChange = value;
                     _largeChange = value;
 
 
                     this.OnLargeChangeChanged(EventArgs.Empty);
                     this.OnLargeChangeChanged(EventArgs.Empty);
@@ -321,13 +277,10 @@ namespace Optimizer.Controls
 
 
         [Category("Appearance")]
         [Category("Appearance")]
         [DefaultValue(10)]
         [DefaultValue(10)]
-        public virtual int SelectionSize
-        {
+        public virtual int SelectionSize {
             get { return _selectionSize; }
             get { return _selectionSize; }
-            set
-            {
-                if (this.SelectionSize != value)
-                {
+            set {
+                if (this.SelectionSize != value) {
                     _selectionSize = value;
                     _selectionSize = value;
 
 
                     this.OnSelectionSizeChanged(EventArgs.Empty);
                     this.OnSelectionSizeChanged(EventArgs.Empty);
@@ -337,13 +290,10 @@ namespace Optimizer.Controls
 
 
         [Category("Behavior")]
         [Category("Behavior")]
         [DefaultValue(1)]
         [DefaultValue(1)]
-        public virtual int SmallChange
-        {
+        public virtual int SmallChange {
             get { return _smallChange; }
             get { return _smallChange; }
-            set
-            {
-                if (this.SmallChange != value)
-                {
+            set {
+                if (this.SmallChange != value) {
                     _smallChange = value;
                     _smallChange = value;
 
 
                     this.OnSmallChangeChanged(EventArgs.Empty);
                     this.OnSmallChangeChanged(EventArgs.Empty);
@@ -355,8 +305,7 @@ namespace Optimizer.Controls
 
 
         #region Protected Properties
         #region Protected Properties
 
 
-        protected virtual bool AllowPainting
-        {
+        protected virtual bool AllowPainting {
             get { return _updateCount == 0; }
             get { return _updateCount == 0; }
         }
         }
 
 
@@ -372,20 +321,16 @@ namespace Optimizer.Controls
 
 
         #region Public Members
         #region Public Members
 
 
-        public virtual void BeginUpdate()
-        {
+        public virtual void BeginUpdate() {
             _updateCount++;
             _updateCount++;
         }
         }
 
 
-        public virtual void EndUpdate()
-        {
-            if (_updateCount > 0)
-            {
+        public virtual void EndUpdate() {
+            if (_updateCount > 0) {
                 _updateCount--;
                 _updateCount--;
             }
             }
 
 
-            if (this.AllowPainting)
-            {
+            if (this.AllowPainting) {
                 this.Invalidate();
                 this.Invalidate();
             }
             }
         }
         }
@@ -394,16 +339,14 @@ namespace Optimizer.Controls
 
 
         #region Protected Members
         #region Protected Members
 
 
-        protected virtual void CalculateWheel()
-        {
+        protected virtual void CalculateWheel() {
             List<PointF> points;
             List<PointF> points;
             List<Color> colors;
             List<Color> colors;
 
 
             points = new List<PointF>();
             points = new List<PointF>();
             colors = new List<Color>();
             colors = new List<Color>();
 
 
-            if (this.ClientSize.Width > 16 && this.ClientSize.Height > 16)
-            {
+            if (this.ClientSize.Width > 16 && this.ClientSize.Height > 16) {
                 int w;
                 int w;
                 int h;
                 int h;
 
 
@@ -413,8 +356,7 @@ namespace Optimizer.Controls
                 _centerPoint = new PointF(w / 2.0F, h / 2.0F);
                 _centerPoint = new PointF(w / 2.0F, h / 2.0F);
                 _radius = this.GetRadius(_centerPoint);
                 _radius = this.GetRadius(_centerPoint);
 
 
-                for (double angle = 0; angle < 360; angle += this.ColorStep)
-                {
+                for (double angle = 0; angle < 360; angle += this.ColorStep) {
                     double angleR;
                     double angleR;
                     PointF location;
                     PointF location;
 
 
@@ -429,43 +371,36 @@ namespace Optimizer.Controls
             this.Points = points.ToArray();
             this.Points = points.ToArray();
             this.Colors = colors.ToArray();
             this.Colors = colors.ToArray();
         }
         }
-        protected virtual Brush CreateGradientBrush()
-        {
+        protected virtual Brush CreateGradientBrush() {
             Brush result;
             Brush result;
 
 
-            if (this.Points.Length != 0 && this.Points.Length == this.Colors.Length)
-            {
-                result = new PathGradientBrush(this.Points, WrapMode.Clamp)
-                {
+            if (this.Points.Length != 0 && this.Points.Length == this.Colors.Length) {
+                result = new PathGradientBrush(this.Points, WrapMode.Clamp) {
                     CenterPoint = _centerPoint,
                     CenterPoint = _centerPoint,
                     CenterColor = Color.White,
                     CenterColor = Color.White,
                     SurroundColors = this.Colors
                     SurroundColors = this.Colors
                 };
                 };
             }
             }
-            else
-            {
+            else {
                 result = null;
                 result = null;
             }
             }
 
 
             return result;
             return result;
         }
         }
 
 
-        protected virtual Color GetContrastColor(Color c)
-        {
+        protected virtual Color GetContrastColor(Color c) {
             double brightness = c.R * 0.299 + c.G * 0.587 + c.B * 0.114;
             double brightness = c.R * 0.299 + c.G * 0.587 + c.B * 0.114;
             return brightness > 149 ? Color.Black : Color.White;
             return brightness > 149 ? Color.Black : Color.White;
         }
         }
 
 
-        protected virtual Image CreateSelectionGlyph()
-        {
+        protected virtual Image CreateSelectionGlyph() {
             Image image;
             Image image;
             int halfSize;
             int halfSize;
 
 
             halfSize = this.SelectionSize / 2;
             halfSize = this.SelectionSize / 2;
             image = new Bitmap(this.SelectionSize + 1, this.SelectionSize + 1);
             image = new Bitmap(this.SelectionSize + 1, this.SelectionSize + 1);
 
 
-            using (Graphics g = Graphics.FromImage(image))
-            {
+            using (Graphics g = Graphics.FromImage(image)) {
                 g.SmoothingMode = SmoothingMode.AntiAlias;
                 g.SmoothingMode = SmoothingMode.AntiAlias;
                 g.PixelOffsetMode = PixelOffsetMode.HighQuality;
                 g.PixelOffsetMode = PixelOffsetMode.HighQuality;
                 g.InterpolationMode = InterpolationMode.High;
                 g.InterpolationMode = InterpolationMode.High;
@@ -477,13 +412,11 @@ namespace Optimizer.Controls
             return image;
             return image;
         }
         }
 
 
-        protected PointF GetColorLocation(Color color)
-        {
+        protected PointF GetColorLocation(Color color) {
             return this.GetColorLocation(new HslColor(color));
             return this.GetColorLocation(new HslColor(color));
         }
         }
 
 
-        protected virtual PointF GetColorLocation(HslColor color)
-        {
+        protected virtual PointF GetColorLocation(HslColor color) {
             double angle;
             double angle;
             double radius;
             double radius;
 
 
@@ -493,8 +426,7 @@ namespace Optimizer.Controls
             return this.GetColorLocation(angle, radius);
             return this.GetColorLocation(angle, radius);
         }
         }
 
 
-        protected PointF GetColorLocation(double angleR, double radius)
-        {
+        protected PointF GetColorLocation(double angleR, double radius) {
             double x;
             double x;
             double y;
             double y;
 
 
@@ -504,13 +436,11 @@ namespace Optimizer.Controls
             return new PointF((float)x, (float)y);
             return new PointF((float)x, (float)y);
         }
         }
 
 
-        protected float GetRadius(PointF centerPoint)
-        {
+        protected float GetRadius(PointF centerPoint) {
             return Math.Min(centerPoint.X, centerPoint.Y) - (Math.Max(this.Padding.Horizontal, this.Padding.Vertical) + (this.SelectionSize / 2));
             return Math.Min(centerPoint.X, centerPoint.Y) - (Math.Max(this.Padding.Horizontal, this.Padding.Vertical) + (this.SelectionSize / 2));
         }
         }
 
 
-        protected bool IsPointInWheel(Point point)
-        {
+        protected bool IsPointInWheel(Point point) {
             PointF normalized;
             PointF normalized;
 
 
             normalized = new PointF(point.X - _centerPoint.X, point.Y - _centerPoint.Y);
             normalized = new PointF(point.X - _centerPoint.X, point.Y - _centerPoint.Y);
@@ -518,12 +448,10 @@ namespace Optimizer.Controls
             return (normalized.X * normalized.X + normalized.Y * normalized.Y) <= (_radius * _radius);
             return (normalized.X * normalized.X + normalized.Y * normalized.Y) <= (_radius * _radius);
         }
         }
 
 
-        protected virtual void OnColorChanged(EventArgs e)
-        {
+        protected virtual void OnColorChanged(EventArgs e) {
             EventHandler handler;
             EventHandler handler;
 
 
-            if (!this.LockUpdates)
-            {
+            if (!this.LockUpdates) {
                 this.HslColor = new HslColor(this.Color);
                 this.HslColor = new HslColor(this.Color);
             }
             }
 
 
@@ -532,62 +460,52 @@ namespace Optimizer.Controls
 
 
             handler = this.ColorChanged;
             handler = this.ColorChanged;
 
 
-            if (handler != null)
-            {
+            if (handler != null) {
                 handler(this, e);
                 handler(this, e);
             }
             }
         }
         }
 
 
-        protected virtual void OnColorStepChanged(EventArgs e)
-        {
+        protected virtual void OnColorStepChanged(EventArgs e) {
             EventHandler handler;
             EventHandler handler;
 
 
             this.RefreshWheel();
             this.RefreshWheel();
 
 
             handler = this.ColorStepChanged;
             handler = this.ColorStepChanged;
 
 
-            if (handler != null)
-            {
+            if (handler != null) {
                 handler(this, e);
                 handler(this, e);
             }
             }
         }
         }
 
 
-        protected virtual void OnHslColorChanged(EventArgs e)
-        {
+        protected virtual void OnHslColorChanged(EventArgs e) {
             EventHandler handler;
             EventHandler handler;
 
 
-            if (!this.LockUpdates)
-            {
+            if (!this.LockUpdates) {
                 this.Color = this.HslColor.ToRgbColor();
                 this.Color = this.HslColor.ToRgbColor();
             }
             }
             this.Invalidate();
             this.Invalidate();
 
 
             handler = this.HslColorChanged;
             handler = this.HslColorChanged;
 
 
-            if (handler != null)
-            {
+            if (handler != null) {
                 handler(this, e);
                 handler(this, e);
             }
             }
         }
         }
 
 
-        protected virtual void OnLargeChangeChanged(EventArgs e)
-        {
+        protected virtual void OnLargeChangeChanged(EventArgs e) {
             EventHandler handler;
             EventHandler handler;
 
 
             handler = this.LargeChangeChanged;
             handler = this.LargeChangeChanged;
 
 
-            if (handler != null)
-            {
+            if (handler != null) {
                 handler(this, e);
                 handler(this, e);
             }
             }
         }
         }
 
 
-        protected virtual void OnSelectionSizeChanged(EventArgs e)
-        {
+        protected virtual void OnSelectionSizeChanged(EventArgs e) {
             EventHandler handler;
             EventHandler handler;
 
 
-            if (this.SelectionGlyph != null)
-            {
+            if (this.SelectionGlyph != null) {
                 this.SelectionGlyph.Dispose();
                 this.SelectionGlyph.Dispose();
             }
             }
 
 
@@ -596,61 +514,51 @@ namespace Optimizer.Controls
 
 
             handler = this.SelectionSizeChanged;
             handler = this.SelectionSizeChanged;
 
 
-            if (handler != null)
-            {
+            if (handler != null) {
                 handler(this, e);
                 handler(this, e);
             }
             }
         }
         }
 
 
-        protected virtual void OnSmallChangeChanged(EventArgs e)
-        {
+        protected virtual void OnSmallChangeChanged(EventArgs e) {
             EventHandler handler;
             EventHandler handler;
 
 
             handler = this.SmallChangeChanged;
             handler = this.SmallChangeChanged;
 
 
-            if (handler != null)
-            {
+            if (handler != null) {
                 handler(this, e);
                 handler(this, e);
             }
             }
         }
         }
 
 
-        protected void PaintColor(PaintEventArgs e, HslColor color)
-        {
+        protected void PaintColor(PaintEventArgs e, HslColor color) {
             this.PaintColor(e, color, false);
             this.PaintColor(e, color, false);
         }
         }
 
 
-        protected virtual void PaintColor(PaintEventArgs e, HslColor color, bool includeFocus)
-        {
+        protected virtual void PaintColor(PaintEventArgs e, HslColor color, bool includeFocus) {
             PointF location;
             PointF location;
 
 
             location = this.GetColorLocation(color);
             location = this.GetColorLocation(color);
 
 
-            if (!float.IsNaN(location.X) && !float.IsNaN(location.Y))
-            {
+            if (!float.IsNaN(location.X) && !float.IsNaN(location.Y)) {
                 int x;
                 int x;
                 int y;
                 int y;
 
 
                 x = (int)location.X - (this.SelectionSize / 2);
                 x = (int)location.X - (this.SelectionSize / 2);
                 y = (int)location.Y - (this.SelectionSize / 2);
                 y = (int)location.Y - (this.SelectionSize / 2);
 
 
-                if (this.SelectionGlyph == null)
-                {
+                if (this.SelectionGlyph == null) {
                     e.Graphics.DrawRectangle(Pens.Black, x, y, this.SelectionSize, this.SelectionSize);
                     e.Graphics.DrawRectangle(Pens.Black, x, y, this.SelectionSize, this.SelectionSize);
                 }
                 }
-                else
-                {
+                else {
                     e.Graphics.DrawImage(this.SelectionGlyph, x, y);
                     e.Graphics.DrawImage(this.SelectionGlyph, x, y);
                 }
                 }
             }
             }
         }
         }
 
 
-        protected virtual void PaintCurrentColor(PaintEventArgs e)
-        {
+        protected virtual void PaintCurrentColor(PaintEventArgs e) {
             this.PaintColor(e, this.HslColor, true);
             this.PaintColor(e, this.HslColor, true);
         }
         }
 
 
-        protected virtual void SetColor(Point point)
-        {
+        protected virtual void SetColor(Point point) {
             double dx;
             double dx;
             double dy;
             double dy;
             double angle;
             double angle;
@@ -663,17 +571,14 @@ namespace Optimizer.Controls
             distance = Math.Pow((Math.Pow(dx, 2) + (Math.Pow(dy, 2))), 0.5);
             distance = Math.Pow((Math.Pow(dx, 2) + (Math.Pow(dy, 2))), 0.5);
             saturation = distance / _radius;
             saturation = distance / _radius;
 
 
-            if (distance < 6)
-            {
+            if (distance < 6) {
                 saturation = 0;
                 saturation = 0;
             }
             }
 
 
-            if (point.X < _centerPoint.X)
-            {
+            if (point.X < _centerPoint.X) {
                 angle = 180 - angle;
                 angle = 180 - angle;
             }
             }
-            if (point.Y > _centerPoint.Y)
-            {
+            if (point.Y > _centerPoint.Y) {
                 angle = 360 - angle;
                 angle = 360 - angle;
             }
             }
 
 
@@ -687,10 +592,8 @@ namespace Optimizer.Controls
 
 
         #region Private Members
         #region Private Members
 
 
-        private void RefreshWheel()
-        {
-            if (_brush != null)
-            {
+        private void RefreshWheel() {
+            if (_brush != null) {
                 _brush.Dispose();
                 _brush.Dispose();
             }
             }
 
 

+ 11 - 22
Optimizer/Controls/ListViewColumnSorter.cs

@@ -2,59 +2,48 @@
 using System.Collections;
 using System.Collections;
 using System.Windows.Forms;
 using System.Windows.Forms;
 
 
-namespace Optimizer
-{
-    internal sealed class ListViewColumnSorter : IComparer
-    {
+namespace Optimizer {
+    internal sealed class ListViewColumnSorter : IComparer {
         int _columnToSort;
         int _columnToSort;
         SortOrder _sortOrder;
         SortOrder _sortOrder;
         CaseInsensitiveComparer _comparer;
         CaseInsensitiveComparer _comparer;
 
 
-        public ListViewColumnSorter()
-        {
+        public ListViewColumnSorter() {
             _columnToSort = 0;
             _columnToSort = 0;
             _sortOrder = SortOrder.None;
             _sortOrder = SortOrder.None;
             _comparer = new CaseInsensitiveComparer();
             _comparer = new CaseInsensitiveComparer();
         }
         }
 
 
-        public int CurrentColumn
-        {
+        public int CurrentColumn {
             get { return _columnToSort; }
             get { return _columnToSort; }
             set { _columnToSort = value; }
             set { _columnToSort = value; }
         }
         }
 
 
-        public SortOrder SortOrder
-        {
+        public SortOrder SortOrder {
             get { return _sortOrder; }
             get { return _sortOrder; }
             set { _sortOrder = value; }
             set { _sortOrder = value; }
         }
         }
 
 
-        public int Compare(object x, object y)
-        {
+        public int Compare(object x, object y) {
             int compareResult;
             int compareResult;
 
 
             ListViewItem listViewX = (ListViewItem)x;
             ListViewItem listViewX = (ListViewItem)x;
             ListViewItem listViewY = (ListViewItem)y;
             ListViewItem listViewY = (ListViewItem)y;
 
 
-            try
-            {
+            try {
                 compareResult = _comparer.Compare(Convert.ToInt64(listViewX.SubItems[_columnToSort].Text), Convert.ToInt64(listViewY.SubItems[_columnToSort].Text));
                 compareResult = _comparer.Compare(Convert.ToInt64(listViewX.SubItems[_columnToSort].Text), Convert.ToInt64(listViewY.SubItems[_columnToSort].Text));
             }
             }
-            catch
-            {
+            catch {
                 compareResult = _comparer.Compare(listViewX.SubItems[_columnToSort].Text, listViewY.SubItems[_columnToSort].Text);
                 compareResult = _comparer.Compare(listViewX.SubItems[_columnToSort].Text, listViewY.SubItems[_columnToSort].Text);
             }
             }
 
 
-            if (_sortOrder == SortOrder.Ascending)
-            {
+            if (_sortOrder == SortOrder.Ascending) {
                 return compareResult;
                 return compareResult;
             }
             }
-            else if (_sortOrder == SortOrder.Descending)
-            {
+            else if (_sortOrder == SortOrder.Descending) {
                 return -compareResult;
                 return -compareResult;
             }
             }
-            else
-            {
+            else {
                 return 0;
                 return 0;
             }
             }
         }
         }

+ 6 - 12
Optimizer/Controls/MoonCheck.cs

@@ -2,29 +2,23 @@
 using System.Drawing;
 using System.Drawing;
 using System.Windows.Forms;
 using System.Windows.Forms;
 
 
-namespace Optimizer
-{
-    public sealed class MoonCheck : CheckBox
-    {
-        public MoonCheck()
-        {
+namespace Optimizer {
+    public sealed class MoonCheck : CheckBox {
+        public MoonCheck() {
             DoubleBuffered = true;
             DoubleBuffered = true;
         }
         }
 
 
-        protected override void OnCheckedChanged(EventArgs e)
-        {
+        protected override void OnCheckedChanged(EventArgs e) {
             base.OnCheckedChanged(e);
             base.OnCheckedChanged(e);
 
 
             // custom theming
             // custom theming
-            if (this.Checked)
-            {
+            if (this.Checked) {
                 this.Tag = "themeable";
                 this.Tag = "themeable";
                 this.Font = new Font(this.Font, FontStyle.Underline);
                 this.Font = new Font(this.Font, FontStyle.Underline);
 
 
                 this.ForeColor = OptionsHelper.ForegroundColor;
                 this.ForeColor = OptionsHelper.ForegroundColor;
             }
             }
-            else
-            {
+            else {
                 this.Tag = string.Empty;
                 this.Tag = string.Empty;
                 this.ForeColor = Color.White;
                 this.ForeColor = Color.White;
                 this.Font = new Font(this.Font, FontStyle.Regular);
                 this.Font = new Font(this.Font, FontStyle.Regular);

+ 7 - 14
Optimizer/Controls/MoonCheckList.cs

@@ -1,28 +1,21 @@
 using System.Drawing;
 using System.Drawing;
 using System.Windows.Forms;
 using System.Windows.Forms;
 
 
-namespace Optimizer
-{
-    public sealed class MoonCheckList : CheckedListBox
-    {
-        public MoonCheckList()
-        {
+namespace Optimizer {
+    public sealed class MoonCheckList : CheckedListBox {
+        public MoonCheckList() {
             DoubleBuffered = true;
             DoubleBuffered = true;
         }
         }
 
 
-        protected override void OnDrawItem(DrawItemEventArgs e)
-        {
+        protected override void OnDrawItem(DrawItemEventArgs e) {
             Color foreColor = Color.White;
             Color foreColor = Color.White;
             Color accentColor = OptionsHelper.ForegroundColor;
             Color accentColor = OptionsHelper.ForegroundColor;
 
 
-            if (this.Items.Count > 0)
-            {
-                if (e.Index >= 0)
-                {
+            if (this.Items.Count > 0) {
+                if (e.Index >= 0) {
                     foreColor = GetItemChecked(e.Index) ? accentColor : foreColor;
                     foreColor = GetItemChecked(e.Index) ? accentColor : foreColor;
                 }
                 }
-                else
-                {
+                else {
                     foreColor = e.ForeColor;
                     foreColor = e.ForeColor;
                 }
                 }
             }
             }

+ 7 - 14
Optimizer/Controls/MoonList.cs

@@ -1,12 +1,9 @@
 using System.Drawing;
 using System.Drawing;
 using System.Windows.Forms;
 using System.Windows.Forms;
 
 
-namespace Optimizer
-{
-    public sealed class MoonList : ListBox
-    {
-        public MoonList()
-        {
+namespace Optimizer {
+    public sealed class MoonList : ListBox {
+        public MoonList() {
             this.DrawMode = DrawMode.OwnerDrawVariable;
             this.DrawMode = DrawMode.OwnerDrawVariable;
             this.BorderStyle = BorderStyle.None;
             this.BorderStyle = BorderStyle.None;
 
 
@@ -14,8 +11,7 @@ namespace Optimizer
             this.DrawItem += MoonListBox_DrawItem;
             this.DrawItem += MoonListBox_DrawItem;
         }
         }
 
 
-        private void MoonListBox_DrawItem(object sender, DrawItemEventArgs e)
-        {
+        private void MoonListBox_DrawItem(object sender, DrawItemEventArgs e) {
             if (e.Index < 0) return;
             if (e.Index < 0) return;
             if (this.Items.Count <= 0) return;
             if (this.Items.Count <= 0) return;
 
 
@@ -23,13 +19,11 @@ namespace Optimizer
 
 
             Brush myBrush = new SolidBrush(Color.White);
             Brush myBrush = new SolidBrush(Color.White);
 
 
-            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
-            {
+            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) {
                 e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(50, 50, 50)), e.Bounds);
                 e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(50, 50, 50)), e.Bounds);
             }
             }
 
 
-            else
-            {
+            else {
                 e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(20, 20, 20)), e.Bounds);
                 e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(20, 20, 20)), e.Bounds);
 
 
             }
             }
@@ -38,8 +32,7 @@ namespace Optimizer
             e.DrawFocusRectangle();
             e.DrawFocusRectangle();
         }
         }
 
 
-        private void MoonListBox_MeasureItem(object sender, MeasureItemEventArgs e)
-        {
+        private void MoonListBox_MeasureItem(object sender, MeasureItemEventArgs e) {
             e.ItemHeight = this.Font.Height;
             e.ItemHeight = this.Font.Height;
         }
         }
     }
     }

+ 27 - 54
Optimizer/Controls/MoonMenuRenderer.cs

@@ -1,12 +1,9 @@
 using System.Drawing;
 using System.Drawing;
 using System.Windows.Forms;
 using System.Windows.Forms;
 
 
-namespace Optimizer
-{
-    internal sealed class MoonMenuRenderer : ToolStripProfessionalRenderer
-    {
-        internal MoonMenuRenderer() : base(new MoonColors())
-        {
+namespace Optimizer {
+    internal sealed class MoonMenuRenderer : ToolStripProfessionalRenderer {
+        internal MoonMenuRenderer() : base(new MoonColors()) {
 
 
         }
         }
 
 
@@ -26,8 +23,7 @@ namespace Optimizer
         //    base.OnRenderSeparator(e);
         //    base.OnRenderSeparator(e);
         //}
         //}
 
 
-        protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e)
-        {
+        protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e) {
             var tsMenuItem = e.Item as ToolStripMenuItem;
             var tsMenuItem = e.Item as ToolStripMenuItem;
             if (tsMenuItem != null)
             if (tsMenuItem != null)
                 e.ArrowColor = Color.DimGray;
                 e.ArrowColor = Color.DimGray;
@@ -35,92 +31,69 @@ namespace Optimizer
         }
         }
     }
     }
 
 
-    internal class MoonColors : ProfessionalColorTable
-    {
-        public override Color SeparatorLight
-        {
+    internal class MoonColors : ProfessionalColorTable {
+        public override Color SeparatorLight {
             get { return Color.DimGray; }
             get { return Color.DimGray; }
         }
         }
 
 
-        public override Color SeparatorDark
-        {
+        public override Color SeparatorDark {
             get { return Color.DimGray; }
             get { return Color.DimGray; }
         }
         }
 
 
-        public override Color ToolStripDropDownBackground
-        {
-            get
-            {
+        public override Color ToolStripDropDownBackground {
+            get {
                 return OptionsHelper.BackgroundColor;
                 return OptionsHelper.BackgroundColor;
             }
             }
         }
         }
 
 
-        public override Color ImageMarginGradientBegin
-        {
-            get
-            {
+        public override Color ImageMarginGradientBegin {
+            get {
                 return OptionsHelper.BackgroundColor;
                 return OptionsHelper.BackgroundColor;
             }
             }
         }
         }
-        public override Color ImageMarginGradientMiddle
-        {
-            get
-            {
+        public override Color ImageMarginGradientMiddle {
+            get {
                 return OptionsHelper.BackgroundColor;
                 return OptionsHelper.BackgroundColor;
             }
             }
         }
         }
-        public override Color ImageMarginGradientEnd
-        {
-            get
-            {
+        public override Color ImageMarginGradientEnd {
+            get {
                 return OptionsHelper.BackgroundColor;
                 return OptionsHelper.BackgroundColor;
             }
             }
         }
         }
 
 
-        public override Color ToolStripBorder
-        {
-            get
-            {
+        public override Color ToolStripBorder {
+            get {
                 return OptionsHelper.BackgroundColor;
                 return OptionsHelper.BackgroundColor;
             }
             }
         }
         }
 
 
-        public override Color MenuBorder
-        {
-            get
-            {
+        public override Color MenuBorder {
+            get {
                 return OptionsHelper.BackAccentColor;
                 return OptionsHelper.BackAccentColor;
             }
             }
         }
         }
 
 
-        public override Color MenuItemSelected
-        {
-            get
-            {
+        public override Color MenuItemSelected {
+            get {
                 return OptionsHelper.BackAccentColor;
                 return OptionsHelper.BackAccentColor;
             }
             }
         }
         }
 
 
-        public override Color MenuItemSelectedGradientBegin
-        {
-            get
-            {
+        public override Color MenuItemSelectedGradientBegin {
+            get {
                 return OptionsHelper.BackAccentColor;
                 return OptionsHelper.BackAccentColor;
             }
             }
         }
         }
 
 
-        public override Color MenuItemSelectedGradientEnd
-        {
-            get
-            {
+        public override Color MenuItemSelectedGradientEnd {
+            get {
                 return OptionsHelper.BackAccentColor;
                 return OptionsHelper.BackAccentColor;
             }
             }
         }
         }
 
 
-        public override Color MenuItemBorder
-        {
-            get
-            {
+        public override Color MenuItemBorder {
+            get {
                 return OptionsHelper.BackAccentColor;
                 return OptionsHelper.BackAccentColor;
             }
             }
         }
         }

+ 4 - 8
Optimizer/Controls/MoonProgress.cs

@@ -2,18 +2,14 @@
 using System.Drawing.Drawing2D;
 using System.Drawing.Drawing2D;
 using System.Windows.Forms;
 using System.Windows.Forms;
 
 
-namespace Optimizer
-{
-    internal sealed class MoonProgress : ProgressBar
-    {
-        public MoonProgress()
-        {
+namespace Optimizer {
+    internal sealed class MoonProgress : ProgressBar {
+        public MoonProgress() {
             DoubleBuffered = true;
             DoubleBuffered = true;
             this.SetStyle(ControlStyles.UserPaint, true);
             this.SetStyle(ControlStyles.UserPaint, true);
         }
         }
 
 
-        protected override void OnPaint(PaintEventArgs e)
-        {
+        protected override void OnPaint(PaintEventArgs e) {
             LinearGradientBrush brush = null;
             LinearGradientBrush brush = null;
             Rectangle rec = new Rectangle(0, 0, this.Width, this.Height);
             Rectangle rec = new Rectangle(0, 0, this.Width, this.Height);
 
 

+ 6 - 12
Optimizer/Controls/MoonRadio.cs

@@ -2,29 +2,23 @@
 using System.Drawing;
 using System.Drawing;
 using System.Windows.Forms;
 using System.Windows.Forms;
 
 
-namespace Optimizer
-{
-    public sealed class MoonRadio : RadioButton
-    {
-        public MoonRadio()
-        {
+namespace Optimizer {
+    public sealed class MoonRadio : RadioButton {
+        public MoonRadio() {
             DoubleBuffered = true;
             DoubleBuffered = true;
         }
         }
 
 
-        protected override void OnCheckedChanged(EventArgs e)
-        {
+        protected override void OnCheckedChanged(EventArgs e) {
             base.OnCheckedChanged(e);
             base.OnCheckedChanged(e);
 
 
             // custom theming
             // custom theming
-            if (this.Checked)
-            {
+            if (this.Checked) {
                 this.Tag = "themeable";
                 this.Tag = "themeable";
                 this.Font = new Font(this.Font, FontStyle.Underline);
                 this.Font = new Font(this.Font, FontStyle.Underline);
 
 
                 this.ForeColor = OptionsHelper.ForegroundColor;
                 this.ForeColor = OptionsHelper.ForegroundColor;
             }
             }
-            else
-            {
+            else {
                 this.Tag = string.Empty;
                 this.Tag = string.Empty;
                 this.ForeColor = Color.White;
                 this.ForeColor = Color.White;
                 this.Font = new Font(this.Font, FontStyle.Regular);
                 this.Font = new Font(this.Font, FontStyle.Regular);

+ 9 - 18
Optimizer/Controls/MoonSelect.cs

@@ -1,27 +1,21 @@
 using System.Drawing;
 using System.Drawing;
 using System.Windows.Forms;
 using System.Windows.Forms;
 
 
-namespace Optimizer
-{
-    public sealed class MoonSelect : ComboBox
-    {
+namespace Optimizer {
+    public sealed class MoonSelect : ComboBox {
         private const int WM_PAINT = 0xF;
         private const int WM_PAINT = 0xF;
         private int buttonWidth = SystemInformation.HorizontalScrollBarArrowWidth;
         private int buttonWidth = SystemInformation.HorizontalScrollBarArrowWidth;
         Color borderColor = Color.Blue;
         Color borderColor = Color.Blue;
 
 
-        public Color BorderColor
-        {
+        public Color BorderColor {
             get { return borderColor; }
             get { return borderColor; }
             set { borderColor = value; Invalidate(); }
             set { borderColor = value; Invalidate(); }
         }
         }
 
 
-        protected override void WndProc(ref Message m)
-        {
+        protected override void WndProc(ref Message m) {
             base.WndProc(ref m);
             base.WndProc(ref m);
-            if (m.Msg == WM_PAINT && DropDownStyle != ComboBoxStyle.Simple)
-            {
-                using (var g = Graphics.FromHwnd(Handle))
-                {
+            if (m.Msg == WM_PAINT && DropDownStyle != ComboBoxStyle.Simple) {
+                using (var g = Graphics.FromHwnd(Handle)) {
                     var adjustMent = 0;
                     var adjustMent = 0;
                     if (FlatStyle == FlatStyle.Popup ||
                     if (FlatStyle == FlatStyle.Popup ||
                        (FlatStyle == FlatStyle.Flat &&
                        (FlatStyle == FlatStyle.Flat &&
@@ -35,17 +29,14 @@ namespace Optimizer
                     if (DropDownStyle == ComboBoxStyle.DropDownList && !Enabled)
                     if (DropDownStyle == ComboBoxStyle.DropDownList && !Enabled)
                         innerBorderColor = SystemColors.Control;
                         innerBorderColor = SystemColors.Control;
 
 
-                    if (DropDownStyle == ComboBoxStyle.DropDownList || Enabled == false)
-                    {
-                        using (var p = new Pen(innerBorderColor, innerBorderWisth))
-                        {
+                    if (DropDownStyle == ComboBoxStyle.DropDownList || Enabled == false) {
+                        using (var p = new Pen(innerBorderColor, innerBorderWisth)) {
                             p.Alignment = System.Drawing.Drawing2D.PenAlignment.Inset;
                             p.Alignment = System.Drawing.Drawing2D.PenAlignment.Inset;
                             g.DrawRectangle(p, 1, 1,
                             g.DrawRectangle(p, 1, 1,
                                 Width - buttonWidth - adjustMent - 1, Height - 1);
                                 Width - buttonWidth - adjustMent - 1, Height - 1);
                         }
                         }
                     }
                     }
-                    using (var p = new Pen(BorderColor))
-                    {
+                    using (var p = new Pen(BorderColor)) {
                         g.DrawRectangle(p, 0, 0, Width - 1, Height - 1);
                         g.DrawRectangle(p, 0, 0, Width - 1, Height - 1);
                         g.DrawLine(p, Width - buttonWidth - adjustMent,
                         g.DrawLine(p, Width - buttonWidth - adjustMent,
                             0, Width - buttonWidth - adjustMent, Height);
                             0, Width - buttonWidth - adjustMent, Height);

+ 39 - 78
Optimizer/Controls/MoonTabs.cs

@@ -6,14 +6,12 @@ using System.Runtime.InteropServices;
 using System.Security.Permissions;
 using System.Security.Permissions;
 using System.Windows.Forms;
 using System.Windows.Forms;
 
 
-namespace Optimizer
-{
+namespace Optimizer {
     [
     [
         ComVisible(true), ClassInterface(ClassInterfaceType.AutoDispatch),
         ComVisible(true), ClassInterface(ClassInterfaceType.AutoDispatch),
         DefaultProperty("TabPages"), DefaultEvent("SelectedIndexChanged")
         DefaultProperty("TabPages"), DefaultEvent("SelectedIndexChanged")
     ]
     ]
-    public sealed class MoonTabs : TabControl
-    {
+    public sealed class MoonTabs : TabControl {
         [System.Runtime.InteropServices.DllImport("user32.dll")]
         [System.Runtime.InteropServices.DllImport("user32.dll")]
         private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp);
         private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp);
 
 
@@ -22,8 +20,7 @@ namespace Optimizer
 
 
         private int _BorderSize = 0;
         private int _BorderSize = 0;
         [Category("Custom"), Description("The size of the components border."), DefaultValue(0)]
         [Category("Custom"), Description("The size of the components border."), DefaultValue(0)]
-        public int BorderSize
-        {
+        public int BorderSize {
             get => _BorderSize;
             get => _BorderSize;
             set => _BorderSize = 0;
             set => _BorderSize = 0;
         }
         }
@@ -33,8 +30,7 @@ namespace Optimizer
 
 
         private int _DividerSize = 0;
         private int _DividerSize = 0;
         [Category("Custom"), Description("The size of the components Divider."), DefaultValue(0)]
         [Category("Custom"), Description("The size of the components Divider."), DefaultValue(0)]
-        public int DividerSize
-        {
+        public int DividerSize {
             get => _DividerSize;
             get => _DividerSize;
             set => _DividerSize = value.LimitToRange(0, 0);
             set => _DividerSize = value.LimitToRange(0, 0);
         }
         }
@@ -50,11 +46,9 @@ namespace Optimizer
         private Point ptPreviousLocation, ptMaxDrag;
         private Point ptPreviousLocation, ptMaxDrag;
         private int DraggedIndex = -1;
         private int DraggedIndex = -1;
 
 
-        protected override CreateParams CreateParams
-        {
+        protected override CreateParams CreateParams {
             [SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
             [SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
-            get
-            {
+            get {
                 CreateParams cp = base.CreateParams;
                 CreateParams cp = base.CreateParams;
                 cp.ExStyle |= 0x02000000;
                 cp.ExStyle |= 0x02000000;
                 return cp;
                 return cp;
@@ -62,14 +56,12 @@ namespace Optimizer
         }
         }
 
 
         // OVERRIDE TAB HEADER WIDTH
         // OVERRIDE TAB HEADER WIDTH
-        protected override void OnHandleCreated(EventArgs e)
-        {
+        protected override void OnHandleCreated(EventArgs e) {
             base.OnHandleCreated(e);
             base.OnHandleCreated(e);
 
 
             // Send TCM_SETMINTABWIDTH
             // Send TCM_SETMINTABWIDTH
             string maxTitle = string.Empty;
             string maxTitle = string.Empty;
-            foreach (TabPage x in this.TabPages)
-            {
+            foreach (TabPage x in this.TabPages) {
                 if (x.Text.Length > maxTitle.Length) maxTitle = x.Text;
                 if (x.Text.Length > maxTitle.Length) maxTitle = x.Text;
             }
             }
             Size textSize = TextRenderer.MeasureText(maxTitle, this.Font);
             Size textSize = TextRenderer.MeasureText(maxTitle, this.Font);
@@ -77,8 +69,7 @@ namespace Optimizer
             SendMessage(this.Handle, 0x1300 + 49, IntPtr.Zero, (IntPtr)textSize.Width);
             SendMessage(this.Handle, 0x1300 + 49, IntPtr.Zero, (IntPtr)textSize.Width);
         }
         }
 
 
-        public MoonTabs()
-        {
+        public MoonTabs() {
             SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer |
             SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer |
                      ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.CacheText, true);
                      ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.CacheText, true);
 
 
@@ -92,8 +83,7 @@ namespace Optimizer
 
 
         private void SetDragState() => bDrag = (CanDrag && bMouseDown && bShiftKey);
         private void SetDragState() => bDrag = (CanDrag && bMouseDown && bShiftKey);
 
 
-        protected override void OnMouseDown(MouseEventArgs e)
-        {
+        protected override void OnMouseDown(MouseEventArgs e) {
             bMouseDown = true;
             bMouseDown = true;
             SetDragState();
             SetDragState();
             Rectangle rectDrag = GetTabRect(SelectedIndex);
             Rectangle rectDrag = GetTabRect(SelectedIndex);
@@ -102,27 +92,21 @@ namespace Optimizer
             Bitmap src = new Bitmap(Width, Height);
             Bitmap src = new Bitmap(Width, Height);
             DrawToBitmap(src, ClientRectangle);
             DrawToBitmap(src, ClientRectangle);
 
 
-            using (Graphics g = Graphics.FromImage(bitDrag = new Bitmap(rectDrag.Width, rectDrag.Height)))
-            {
+            using (Graphics g = Graphics.FromImage(bitDrag = new Bitmap(rectDrag.Width, rectDrag.Height))) {
                 g.DrawImage(src, new Rectangle(0, 0, bitDrag.Width, bitDrag.Height), rectDrag, GraphicsUnit.Pixel);
                 g.DrawImage(src, new Rectangle(0, 0, bitDrag.Width, bitDrag.Height), rectDrag, GraphicsUnit.Pixel);
             }
             }
         }
         }
 
 
-        protected override void OnMouseMove(MouseEventArgs e)
-        {
-            if (bDrag)
-            {
-                if (Alignment == TabAlignment.Top || Alignment == TabAlignment.Bottom)
-                {
+        protected override void OnMouseMove(MouseEventArgs e) {
+            if (bDrag) {
+                if (Alignment == TabAlignment.Top || Alignment == TabAlignment.Bottom) {
                     ptPreviousLocation = new Point(((e.X < 0) ? 0 : (e.X > ptMaxDrag.X) ? ptMaxDrag.X : e.X), (Alignment == TabAlignment.Top ? BorderSize : ptMaxDrag.Y));
                     ptPreviousLocation = new Point(((e.X < 0) ? 0 : (e.X > ptMaxDrag.X) ? ptMaxDrag.X : e.X), (Alignment == TabAlignment.Top ? BorderSize : ptMaxDrag.Y));
                 }
                 }
 
 
-                if (Alignment == TabAlignment.Right || Alignment == TabAlignment.Left)
-                {
+                if (Alignment == TabAlignment.Right || Alignment == TabAlignment.Left) {
                     ptPreviousLocation = new Point(ptMaxDrag.X, ((e.Y < 0) ? 0 : (e.Y > ptMaxDrag.Y) ? ptMaxDrag.Y : e.Y));
                     ptPreviousLocation = new Point(ptMaxDrag.X, ((e.Y < 0) ? 0 : (e.Y > ptMaxDrag.Y) ? ptMaxDrag.Y : e.Y));
                 }
                 }
-                for (int i = 0; i < TabCount; i++)
-                {
+                for (int i = 0; i < TabCount; i++) {
                     if (GetTabRect(i).Contains(PointToClient(Cursor.Position))) { DraggedIndex = i; break; }
                     if (GetTabRect(i).Contains(PointToClient(Cursor.Position))) { DraggedIndex = i; break; }
                 }
                 }
 
 
@@ -130,10 +114,8 @@ namespace Optimizer
             }
             }
         }
         }
 
 
-        protected override void OnMouseUp(MouseEventArgs e)
-        {
-            void SwapTabPages(TabPage inDestTab)
-            {
+        protected override void OnMouseUp(MouseEventArgs e) {
+            void SwapTabPages(TabPage inDestTab) {
                 int SourceIndex = TabPages.IndexOf(SelectedTab);
                 int SourceIndex = TabPages.IndexOf(SelectedTab);
                 int DestinationIndex = TabPages.IndexOf(inDestTab);
                 int DestinationIndex = TabPages.IndexOf(inDestTab);
 
 
@@ -146,8 +128,7 @@ namespace Optimizer
 
 
             bDrag = bMouseDown = false;
             bDrag = bMouseDown = false;
 
 
-            if (DraggedIndex > -1)
-            {
+            if (DraggedIndex > -1) {
                 SwapTabPages(TabPages[DraggedIndex]);
                 SwapTabPages(TabPages[DraggedIndex]);
                 DraggedIndex = -1;
                 DraggedIndex = -1;
             }
             }
@@ -160,8 +141,7 @@ namespace Optimizer
 
 
         protected override void OnKeyUp(KeyEventArgs e) { bDrag = bShiftKey = false; SetDragState(); }
         protected override void OnKeyUp(KeyEventArgs e) { bDrag = bShiftKey = false; SetDragState(); }
 
 
-        protected override void OnPaint(PaintEventArgs e)
-        {
+        protected override void OnPaint(PaintEventArgs e) {
             if (DesignMode) return;
             if (DesignMode) return;
 
 
             e.Graphics.Clear(Color.FromArgb(40, 40, 40));
             e.Graphics.Clear(Color.FromArgb(40, 40, 40));
@@ -169,11 +149,9 @@ namespace Optimizer
             Rectangle container = new Rectangle(0, 0, Width - (BorderSize % 2), Height - (BorderSize % 2));
             Rectangle container = new Rectangle(0, 0, Width - (BorderSize % 2), Height - (BorderSize % 2));
             Rectangle containerHead = default(Rectangle);
             Rectangle containerHead = default(Rectangle);
 
 
-            if (TabCount > 0)
-            {
+            if (TabCount > 0) {
                 using (SolidBrush brushBackgroundTab = new SolidBrush(Color.FromArgb(40, 40, 40)))
                 using (SolidBrush brushBackgroundTab = new SolidBrush(Color.FromArgb(40, 40, 40)))
-                using (SolidBrush brushDivider = new SolidBrush(OptionsHelper.ForegroundColor))
-                {
+                using (SolidBrush brushDivider = new SolidBrush(OptionsHelper.ForegroundColor)) {
                     {
                     {
                         e.Graphics.FillRectangle(brushBackgroundTab, DisplayRectangle);
                         e.Graphics.FillRectangle(brushBackgroundTab, DisplayRectangle);
                     }
                     }
@@ -181,8 +159,7 @@ namespace Optimizer
                     {
                     {
                         Rectangle rectDivider = GetTabRect(SelectedIndex);
                         Rectangle rectDivider = GetTabRect(SelectedIndex);
 
 
-                        if (Alignment == TabAlignment.Top || Alignment == TabAlignment.Bottom)
-                        {
+                        if (Alignment == TabAlignment.Top || Alignment == TabAlignment.Bottom) {
                             e.Graphics.FillRectangle(brushDivider,
                             e.Graphics.FillRectangle(brushDivider,
                                                      0,
                                                      0,
                                                      (((Alignment == TabAlignment.Top) ? (TabPages[SelectedIndex].Top - DividerSize - (DividerSize % 2)) :
                                                      (((Alignment == TabAlignment.Top) ? (TabPages[SelectedIndex].Top - DividerSize - (DividerSize % 2)) :
@@ -191,8 +168,7 @@ namespace Optimizer
                                                     );
                                                     );
                         }
                         }
 
 
-                        if (Alignment == TabAlignment.Right || Alignment == TabAlignment.Left)
-                        {
+                        if (Alignment == TabAlignment.Right || Alignment == TabAlignment.Left) {
                             e.Graphics.FillRectangle(brushDivider,
                             e.Graphics.FillRectangle(brushDivider,
                                                      ((Alignment == TabAlignment.Right) ? (TabPages[SelectedIndex].Right + (DividerSize % 2)) : TabPages[SelectedIndex].Left - DividerSize - (DividerSize % 2)),
                                                      ((Alignment == TabAlignment.Right) ? (TabPages[SelectedIndex].Right + (DividerSize % 2)) : TabPages[SelectedIndex].Left - DividerSize - (DividerSize % 2)),
                                                      BorderSize,
                                                      BorderSize,
@@ -215,25 +191,21 @@ namespace Optimizer
             using (SolidBrush brushInActiveIndicator = new SolidBrush(OptionsHelper.ForegroundColor))
             using (SolidBrush brushInActiveIndicator = new SolidBrush(OptionsHelper.ForegroundColor))
             using (brushActiveText = new SolidBrush(OptionsHelper.TextColor))
             using (brushActiveText = new SolidBrush(OptionsHelper.TextColor))
             using (SolidBrush brushInActiveText = new SolidBrush(Color.White))
             using (SolidBrush brushInActiveText = new SolidBrush(Color.White))
-            using (SolidBrush brushDrag = new SolidBrush(ControlPaint.Dark(OptionsHelper.ForegroundColor)))
-            {
+            using (SolidBrush brushDrag = new SolidBrush(ControlPaint.Dark(OptionsHelper.ForegroundColor))) {
                 //if (MoonManager.THEME_PREFERENCE == THEME.LIGHT) brushActiveText = new SolidBrush(Color.White);
                 //if (MoonManager.THEME_PREFERENCE == THEME.LIGHT) brushActiveText = new SolidBrush(Color.White);
 
 
                 penBorder.Alignment = penActive.Alignment = PenAlignment.Inset;
                 penBorder.Alignment = penActive.Alignment = PenAlignment.Inset;
                 e.Graphics.DrawRectangle(penBorder, container);
                 e.Graphics.DrawRectangle(penBorder, container);
 
 
-                if (TabCount > 0)
-                {
+                if (TabCount > 0) {
                     ptMaxDrag = new Point(0, 0);
                     ptMaxDrag = new Point(0, 0);
 
 
-                    for (int i = 0; i < TabCount; i++)
-                    {
+                    for (int i = 0; i < TabCount; i++) {
                         containerHead = GetTabRect(i);
                         containerHead = GetTabRect(i);
 
 
                         e.Graphics.FillRectangle((SelectedIndex == i) ? (bDrag ? brushDrag : brushActive) : brushInActive, containerHead);
                         e.Graphics.FillRectangle((SelectedIndex == i) ? (bDrag ? brushDrag : brushActive) : brushInActive, containerHead);
 
 
-                        if (BorderEdges && (i == SelectedIndex))
-                        {
+                        if (BorderEdges && (i == SelectedIndex)) {
                             Point ptA = new Point(0, 0); Point ptB = new Point(0, 0);
                             Point ptA = new Point(0, 0); Point ptB = new Point(0, 0);
                             Point ptC = new Point(0, 0); Point ptD = new Point(0, 0);
                             Point ptC = new Point(0, 0); Point ptD = new Point(0, 0);
 
 
@@ -241,24 +213,20 @@ namespace Optimizer
                             ptA.Y = ptB.Y = ptC.Y = containerHead.Y;
                             ptA.Y = ptB.Y = ptC.Y = containerHead.Y;
                             ptA.Y = ptC.Y = ptD.Y = containerHead.Y + containerHead.Height - 1;
                             ptA.Y = ptC.Y = ptD.Y = containerHead.Y + containerHead.Height - 1;
 
 
-                            if (Alignment == TabAlignment.Top || Alignment == TabAlignment.Bottom)
-                            {
+                            if (Alignment == TabAlignment.Top || Alignment == TabAlignment.Bottom) {
                                 ptD.X = ptC.X = containerHead.X + containerHead.Width;
                                 ptD.X = ptC.X = containerHead.X + containerHead.Width;
                                 ptC.Y = containerHead.Y;
                                 ptC.Y = containerHead.Y;
 
 
-                                if (Alignment == TabAlignment.Bottom)
-                                {
+                                if (Alignment == TabAlignment.Bottom) {
                                     MoonTabHelper.Swap(ref ptA, ref ptB); MoonTabHelper.Swap(ref ptC, ref ptD);
                                     MoonTabHelper.Swap(ref ptA, ref ptB); MoonTabHelper.Swap(ref ptC, ref ptD);
                                 }
                                 }
                             }
                             }
 
 
-                            if (Alignment == TabAlignment.Right || Alignment == TabAlignment.Left)
-                            {
+                            if (Alignment == TabAlignment.Right || Alignment == TabAlignment.Left) {
                                 ptA.Y = containerHead.Y;
                                 ptA.Y = containerHead.Y;
                                 ptB.X = ptC.X = containerHead.X + containerHead.Width - 1;
                                 ptB.X = ptC.X = containerHead.X + containerHead.Width - 1;
 
 
-                                if (Alignment == TabAlignment.Left)
-                                {
+                                if (Alignment == TabAlignment.Left) {
                                     MoonTabHelper.Swap(ref ptA, ref ptC); MoonTabHelper.Swap(ref ptB, ref ptD);
                                     MoonTabHelper.Swap(ref ptA, ref ptC); MoonTabHelper.Swap(ref ptB, ref ptD);
                                 }
                                 }
                             }
                             }
@@ -271,20 +239,17 @@ namespace Optimizer
                         {
                         {
                             Rectangle rectDivider = default(Rectangle);
                             Rectangle rectDivider = default(Rectangle);
 
 
-                            if (Alignment == TabAlignment.Top || Alignment == TabAlignment.Bottom)
-                            {
+                            if (Alignment == TabAlignment.Top || Alignment == TabAlignment.Bottom) {
                                 rectDivider = new Rectangle(containerHead.X, containerHead.Y + ((Alignment == TabAlignment.Top) ? containerHead.Height : -DividerSize), containerHead.Width, DividerSize);
                                 rectDivider = new Rectangle(containerHead.X, containerHead.Y + ((Alignment == TabAlignment.Top) ? containerHead.Height : -DividerSize), containerHead.Width, DividerSize);
                             }
                             }
-                            if (Alignment == TabAlignment.Right || Alignment == TabAlignment.Left)
-                            {
+                            if (Alignment == TabAlignment.Right || Alignment == TabAlignment.Left) {
                                 rectDivider = new Rectangle(containerHead.X - ((Alignment == TabAlignment.Right) ? DividerSize : -containerHead.Width), containerHead.Y, DividerSize, containerHead.Height);
                                 rectDivider = new Rectangle(containerHead.X - ((Alignment == TabAlignment.Right) ? DividerSize : -containerHead.Width), containerHead.Y, DividerSize, containerHead.Height);
                             }
                             }
 
 
                             e.Graphics.FillRectangle(((MoonTabHelper.TagToInt(TabPages[i]) == 1) ? brushAlternative : ((i == SelectedIndex) ? brushActiveIndicator : brushInActiveIndicator)), rectDivider);
                             e.Graphics.FillRectangle(((MoonTabHelper.TagToInt(TabPages[i]) == 1) ? brushAlternative : ((i == SelectedIndex) ? brushActiveIndicator : brushInActiveIndicator)), rectDivider);
                         }
                         }
 
 
-                        if (!(bDrag && i == SelectedIndex))
-                        {
+                        if (!(bDrag && i == SelectedIndex)) {
                             int angle = 0;
                             int angle = 0;
                             {
                             {
                                 if (Alignment == TabAlignment.Right) angle = 90;
                                 if (Alignment == TabAlignment.Right) angle = 90;
@@ -311,8 +276,7 @@ namespace Optimizer
                             e.Graphics.ResetTransform();
                             e.Graphics.ResetTransform();
                         }
                         }
 
 
-                        if (bMouseDown)
-                        {
+                        if (bMouseDown) {
                             if (Alignment == TabAlignment.Top || Alignment == TabAlignment.Bottom) { if (i > 0) { ptMaxDrag.X += GetTabRect(i).Width; } }
                             if (Alignment == TabAlignment.Top || Alignment == TabAlignment.Bottom) { if (i > 0) { ptMaxDrag.X += GetTabRect(i).Width; } }
                             if (Alignment == TabAlignment.Top) { ptMaxDrag.Y = BorderSize; }
                             if (Alignment == TabAlignment.Top) { ptMaxDrag.Y = BorderSize; }
                             if (Alignment == TabAlignment.Bottom) { ptMaxDrag.Y = containerHead.Y; };
                             if (Alignment == TabAlignment.Bottom) { ptMaxDrag.Y = containerHead.Y; };
@@ -329,17 +293,14 @@ namespace Optimizer
 
 
     }
     }
 
 
-    public static class MoonTabHelper
-    {
-        public static int LimitToRange(this int value, int inclusiveMinimum, int inclusiveMaximum)
-        {
+    public static class MoonTabHelper {
+        public static int LimitToRange(this int value, int inclusiveMinimum, int inclusiveMaximum) {
             if (value < inclusiveMinimum) { return inclusiveMinimum; }
             if (value < inclusiveMinimum) { return inclusiveMinimum; }
             if (value > inclusiveMaximum) { return inclusiveMaximum; }
             if (value > inclusiveMaximum) { return inclusiveMaximum; }
             return value;
             return value;
         }
         }
 
 
-        public static void Swap<T>(ref T a, ref T b)
-        {
+        public static void Swap<T>(ref T a, ref T b) {
             T temp = a;
             T temp = a;
             a = b; b = temp;
             a = b; b = temp;
         }
         }

+ 8 - 16
Optimizer/Controls/MoonToggle.cs

@@ -3,39 +3,32 @@ using System.Drawing;
 using System.Drawing.Drawing2D;
 using System.Drawing.Drawing2D;
 using System.Windows.Forms;
 using System.Windows.Forms;
 
 
-namespace Optimizer
-{
-    public sealed class MoonToggle : CheckBox
-    {
+namespace Optimizer {
+    public sealed class MoonToggle : CheckBox {
         bool solidStyle = true;
         bool solidStyle = true;
 
 
         [Browsable(true)]
         [Browsable(true)]
-        public override string Text
-        {
+        public override string Text {
             get { return base.Text; }
             get { return base.Text; }
             set { }
             set { }
         }
         }
 
 
         [DefaultValue(true)]
         [DefaultValue(true)]
-        public bool SolidStyle
-        {
+        public bool SolidStyle {
             get { return solidStyle; }
             get { return solidStyle; }
-            set
-            {
+            set {
                 solidStyle = value;
                 solidStyle = value;
                 this.Invalidate();
                 this.Invalidate();
             }
             }
         }
         }
 
 
-        public MoonToggle()
-        {
+        public MoonToggle() {
             this.DoubleBuffered = true;
             this.DoubleBuffered = true;
             this.MinimumSize = new Size(46, 22);
             this.MinimumSize = new Size(46, 22);
             this.ForeColor = Color.White;
             this.ForeColor = Color.White;
         }
         }
 
 
-        private GraphicsPath GetFigurePath()
-        {
+        private GraphicsPath GetFigurePath() {
             int arcSize = this.Height - 1;
             int arcSize = this.Height - 1;
             Rectangle leftArc = new Rectangle(0, 0, arcSize, arcSize);
             Rectangle leftArc = new Rectangle(0, 0, arcSize, arcSize);
             Rectangle rightArc = new Rectangle(this.Width - arcSize - 2, 0, arcSize, arcSize);
             Rectangle rightArc = new Rectangle(this.Width - arcSize - 2, 0, arcSize, arcSize);
@@ -49,8 +42,7 @@ namespace Optimizer
             return path;
             return path;
         }
         }
 
 
-        protected override void OnPaint(PaintEventArgs pevent)
-        {
+        protected override void OnPaint(PaintEventArgs pevent) {
             int toggleSize = this.Height - 5;
             int toggleSize = this.Height - 5;
             pevent.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
             pevent.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
             pevent.Graphics.Clear(this.Parent.BackColor);
             pevent.Graphics.Clear(this.Parent.BackColor);

+ 9 - 18
Optimizer/Controls/MoonTree.cs

@@ -1,10 +1,8 @@
 using System.Drawing;
 using System.Drawing;
 using System.Windows.Forms;
 using System.Windows.Forms;
 
 
-namespace Optimizer
-{
-    public sealed class MoonTree : TreeView
-    {
+namespace Optimizer {
+    public sealed class MoonTree : TreeView {
         string[] rootNodes =
         string[] rootNodes =
         {
         {
             "cpu", "ram", "mobo", "gpu", "disk", "inet", "audio", "dev"
             "cpu", "ram", "mobo", "gpu", "disk", "inet", "audio", "dev"
@@ -12,26 +10,22 @@ namespace Optimizer
 
 
         string _primaryItemTag = "_primary";
         string _primaryItemTag = "_primary";
 
 
-        public MoonTree()
-        {
+        public MoonTree() {
             this.DrawMode = TreeViewDrawMode.OwnerDrawAll;
             this.DrawMode = TreeViewDrawMode.OwnerDrawAll;
             this.BackColor = Color.FromArgb(20, 20, 20);
             this.BackColor = Color.FromArgb(20, 20, 20);
             this.ForeColor = Color.White;
             this.ForeColor = Color.White;
             this.BorderStyle = BorderStyle.None;
             this.BorderStyle = BorderStyle.None;
         }
         }
 
 
-        private bool FindName(string name)
-        {
-            foreach (string x in rootNodes)
-            {
+        private bool FindName(string name) {
+            foreach (string x in rootNodes) {
                 if (x == name) return true;
                 if (x == name) return true;
             }
             }
 
 
             return false;
             return false;
         }
         }
 
 
-        protected override void OnDrawNode(DrawTreeNodeEventArgs e)
-        {
+        protected override void OnDrawNode(DrawTreeNodeEventArgs e) {
             Rectangle r = new Rectangle();
             Rectangle r = new Rectangle();
             r.X = 0;
             r.X = 0;
             r.Y = e.Bounds.Y;
             r.Y = e.Bounds.Y;
@@ -39,12 +33,10 @@ namespace Optimizer
             r.Height = e.Bounds.Height;
             r.Height = e.Bounds.Height;
             r.Width = 100000;
             r.Width = 100000;
 
 
-            if (e.Node.IsSelected)
-            {
+            if (e.Node.IsSelected) {
                 e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(50, 50, 50)), r); //e.Bounds
                 e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(50, 50, 50)), r); //e.Bounds
             }
             }
-            else
-            {
+            else {
                 e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(20, 20, 20)), r); //e.Bounds
                 e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(20, 20, 20)), r); //e.Bounds
             }
             }
 
 
@@ -52,8 +44,7 @@ namespace Optimizer
             else if (e.Node.Tag != null && e.Node.Tag.ToString() == _primaryItemTag) TextRenderer.DrawText(e.Graphics, e.Node.Text, this.Font, e.Node.Bounds, OptionsHelper.ForegroundColor);
             else if (e.Node.Tag != null && e.Node.Tag.ToString() == _primaryItemTag) TextRenderer.DrawText(e.Graphics, e.Node.Text, this.Font, e.Node.Bounds, OptionsHelper.ForegroundColor);
             else TextRenderer.DrawText(e.Graphics, e.Node.Text, this.Font, e.Node.Bounds, Color.White);
             else TextRenderer.DrawText(e.Graphics, e.Node.Text, this.Font, e.Node.Bounds, Color.White);
 
 
-            if (this.ImageList != null && this.ImageList.Images.Count > 0 && e.Node.SelectedImageIndex > -1)
-            {
+            if (this.ImageList != null && this.ImageList.Images.Count > 0 && e.Node.SelectedImageIndex > -1) {
                 e.Graphics.DrawImage(this.ImageList.Images[e.Node.SelectedImageIndex], e.Bounds.Left + 15 * e.Node.Level + 5, e.Bounds.Top);
                 e.Graphics.DrawImage(this.ImageList.Images[e.Node.SelectedImageIndex], e.Bounds.Left + 15 * e.Node.Level + 5, e.Bounds.Top);
             }
             }
         }
         }

+ 11 - 22
Optimizer/Controls/ToggleCard.cs

@@ -1,16 +1,13 @@
 using System;
 using System;
 using System.Windows.Forms;
 using System.Windows.Forms;
 
 
-namespace Optimizer
-{
-    public sealed partial class ToggleCard : UserControl
-    {
+namespace Optimizer {
+    public sealed partial class ToggleCard : UserControl {
         public event EventHandler ToggleClicked;
         public event EventHandler ToggleClicked;
 
 
         SubForm _subForm;
         SubForm _subForm;
 
 
-        public ToggleCard()
-        {
+        public ToggleCard() {
             InitializeComponent();
             InitializeComponent();
 
 
             this.DoubleBuffered = true;
             this.DoubleBuffered = true;
@@ -28,11 +25,9 @@ namespace Optimizer
             Panel.AccessibleName = LabelText;
             Panel.AccessibleName = LabelText;
         }
         }
 
 
-        public string LabelText
-        {
+        public string LabelText {
             get { return Label.Text; }
             get { return Label.Text; }
-            set
-            {
+            set {
                 Label.Text = value;
                 Label.Text = value;
                 this.AccessibleName = value;
                 this.AccessibleName = value;
                 Label.AccessibleName = value;
                 Label.AccessibleName = value;
@@ -41,36 +36,30 @@ namespace Optimizer
             }
             }
         }
         }
 
 
-        public bool ToggleChecked
-        {
+        public bool ToggleChecked {
             get { return Toggle.Checked; }
             get { return Toggle.Checked; }
             set { Toggle.Checked = value; }
             set { Toggle.Checked = value; }
         }
         }
 
 
-        private void Toggle_CheckedChanged(object sender, EventArgs e)
-        {
+        private void Toggle_CheckedChanged(object sender, EventArgs e) {
             if (ToggleClicked != null) ToggleClicked(sender, e);
             if (ToggleClicked != null) ToggleClicked(sender, e);
         }
         }
 
 
-        private void Label_MouseLeave(object sender, EventArgs e)
-        {
+        private void Label_MouseLeave(object sender, EventArgs e) {
             Label.Font = new System.Drawing.Font(Label.Font, System.Drawing.FontStyle.Regular);
             Label.Font = new System.Drawing.Font(Label.Font, System.Drawing.FontStyle.Regular);
         }
         }
 
 
-        private void Label_MouseEnter(object sender, EventArgs e)
-        {
+        private void Label_MouseEnter(object sender, EventArgs e) {
             Label.Font = new System.Drawing.Font(Label.Font, System.Drawing.FontStyle.Underline);
             Label.Font = new System.Drawing.Font(Label.Font, System.Drawing.FontStyle.Underline);
         }
         }
 
 
-        private void Label_Click(object sender, EventArgs e)
-        {
+        private void Label_Click(object sender, EventArgs e) {
             if (Label.Tag == null) return;
             if (Label.Tag == null) return;
             _subForm.SetTip(Label.Tag.ToString());
             _subForm.SetTip(Label.Tag.ToString());
             _subForm.ShowDialog(this);
             _subForm.ShowDialog(this);
         }
         }
 
 
-        private void Label_MouseHover(object sender, EventArgs e)
-        {
+        private void Label_MouseHover(object sender, EventArgs e) {
             Label.Font = new System.Drawing.Font(Label.Font, System.Drawing.FontStyle.Underline);
             Label.Font = new System.Drawing.Font(Label.Font, System.Drawing.FontStyle.Underline);
         }
         }
     }
     }

+ 14 - 28
Optimizer/CoreHelper.cs

@@ -1,10 +1,8 @@
 using System.IO;
 using System.IO;
 using System.Text;
 using System.Text;
 
 
-namespace Optimizer
-{
-    internal static class CoreHelper
-    {
+namespace Optimizer {
+    internal static class CoreHelper {
         internal readonly static string CoreFolder = CleanHelper.ProgramData + "\\Optimizer\\";
         internal readonly static string CoreFolder = CleanHelper.ProgramData + "\\Optimizer\\";
         internal readonly static string ReadyMadeMenusFolder = CleanHelper.ProgramData + "\\Optimizer\\ReadyMadeMenus\\";
         internal readonly static string ReadyMadeMenusFolder = CleanHelper.ProgramData + "\\Optimizer\\ReadyMadeMenus\\";
         internal readonly static string ScriptsFolder = CleanHelper.ProgramData + "\\Optimizer\\Required\\";
         internal readonly static string ScriptsFolder = CleanHelper.ProgramData + "\\Optimizer\\Required\\";
@@ -68,48 +66,36 @@ namespace Optimizer
             Properties.Resources.DisableClassicPhotoViewer
             Properties.Resources.DisableClassicPhotoViewer
         };
         };
 
 
-        internal static void Deploy()
-        {
-            if (!Directory.Exists(CoreFolder))
-            {
+        internal static void Deploy() {
+            if (!Directory.Exists(CoreFolder)) {
                 Directory.CreateDirectory(CoreFolder);
                 Directory.CreateDirectory(CoreFolder);
             }
             }
-            if (!Directory.Exists(ReadyMadeMenusFolder))
-            {
+            if (!Directory.Exists(ReadyMadeMenusFolder)) {
                 Directory.CreateDirectory(ReadyMadeMenusFolder);
                 Directory.CreateDirectory(ReadyMadeMenusFolder);
             }
             }
-            if (!Directory.Exists(ScriptsFolder))
-            {
+            if (!Directory.Exists(ScriptsFolder)) {
                 Directory.CreateDirectory(ScriptsFolder);
                 Directory.CreateDirectory(ScriptsFolder);
             }
             }
-            if (!Directory.Exists(ExtractedIconsFolder))
-            {
+            if (!Directory.Exists(ExtractedIconsFolder)) {
                 Directory.CreateDirectory(ExtractedIconsFolder);
                 Directory.CreateDirectory(ExtractedIconsFolder);
             }
             }
-            if (!Directory.Exists(FavIconsFolder))
-            {
+            if (!Directory.Exists(FavIconsFolder)) {
                 Directory.CreateDirectory(FavIconsFolder);
                 Directory.CreateDirectory(FavIconsFolder);
             }
             }
-            if (!Directory.Exists(StartupItemsBackupFolder))
-            {
+            if (!Directory.Exists(StartupItemsBackupFolder)) {
                 Directory.CreateDirectory(StartupItemsBackupFolder);
                 Directory.CreateDirectory(StartupItemsBackupFolder);
             }
             }
 
 
-            for (int i = 0; i < readyMadeMenusItems.Length; i++)
-            {
+            for (int i = 0; i < readyMadeMenusItems.Length; i++) {
                 if (!File.Exists(readyMadeMenusItems[i])) File.WriteAllText(readyMadeMenusItems[i], readyMadeMenusFiles[i]);
                 if (!File.Exists(readyMadeMenusItems[i])) File.WriteAllText(readyMadeMenusItems[i], readyMadeMenusFiles[i]);
             }
             }
 
 
-            for (int i = 0; i < scriptItems.Length; i++)
-            {
-                if (!File.Exists(scriptItems[i]))
-                {
-                    if (scriptItems[i].Contains("OneDrive"))
-                    {
+            for (int i = 0; i < scriptItems.Length; i++) {
+                if (!File.Exists(scriptItems[i])) {
+                    if (scriptItems[i].Contains("OneDrive")) {
                         File.WriteAllBytes(scriptItems[i], Encoding.UTF8.GetBytes(scriptFiles[i]));
                         File.WriteAllBytes(scriptItems[i], Encoding.UTF8.GetBytes(scriptFiles[i]));
                     }
                     }
-                    else
-                    {
+                    else {
                         File.WriteAllText(scriptItems[i], scriptFiles[i]);
                         File.WriteAllText(scriptItems[i], scriptFiles[i]);
                     }
                     }
                 }
                 }

+ 4 - 8
Optimizer/DebugHelper.cs

@@ -4,14 +4,11 @@ using System.Linq;
 using System.Text;
 using System.Text;
 using System.Windows.Forms;
 using System.Windows.Forms;
 
 
-namespace Optimizer
-{
+namespace Optimizer {
     // Collection of useful debugging methods and utilities
     // Collection of useful debugging methods and utilities
-    internal sealed class DebugHelper
-    {
+    internal sealed class DebugHelper {
         // For comparing and detecting missing keys between two translation JSON files
         // For comparing and detecting missing keys between two translation JSON files
-        internal static void FindDifferenceInTwoJsons()
-        {
+        internal static void FindDifferenceInTwoJsons() {
             JObject file1 = JObject.Parse(Properties.Resources.EN);
             JObject file1 = JObject.Parse(Properties.Resources.EN);
             JObject file2 = JObject.Parse(Properties.Resources.RU);
             JObject file2 = JObject.Parse(Properties.Resources.RU);
 
 
@@ -21,8 +18,7 @@ namespace Optimizer
             var missingProps = p1.Where(expected => !p2.Where(actual => actual.Name == expected.Name).Any());
             var missingProps = p1.Where(expected => !p2.Where(actual => actual.Name == expected.Name).Any());
 
 
             StringBuilder sb = new StringBuilder();
             StringBuilder sb = new StringBuilder();
-            foreach (var x in missingProps)
-            {
+            foreach (var x in missingProps) {
                 sb.Append(x.Name + Environment.NewLine);
                 sb.Append(x.Name + Environment.NewLine);
             }
             }
             MessageBox.Show(sb.ToString());
             MessageBox.Show(sb.ToString());

+ 12 - 24
Optimizer/EmbeddedAssembly.cs

@@ -4,36 +4,30 @@ using System.IO;
 using System.Reflection;
 using System.Reflection;
 using System.Security.Cryptography;
 using System.Security.Cryptography;
 
 
-namespace Optimizer
-{
-    internal sealed class EmbeddedAssembly
-    {
+namespace Optimizer {
+    internal sealed class EmbeddedAssembly {
         static Dictionary<string, Assembly> _dictionary;
         static Dictionary<string, Assembly> _dictionary;
 
 
-        internal static void Load(string embeddedResource, string fileName)
-        {
+        internal static void Load(string embeddedResource, string fileName) {
             if (_dictionary == null) _dictionary = new Dictionary<string, Assembly>();
             if (_dictionary == null) _dictionary = new Dictionary<string, Assembly>();
 
 
             byte[] bytes = null;
             byte[] bytes = null;
             Assembly assembly = null;
             Assembly assembly = null;
             Assembly currentAssembly = Assembly.GetExecutingAssembly();
             Assembly currentAssembly = Assembly.GetExecutingAssembly();
 
 
-            using (Stream stream = currentAssembly.GetManifestResourceStream(embeddedResource))
-            {
+            using (Stream stream = currentAssembly.GetManifestResourceStream(embeddedResource)) {
                 if (stream == null) throw new Exception($"{embeddedResource} is not found in Embedded Resources.");
                 if (stream == null) throw new Exception($"{embeddedResource} is not found in Embedded Resources.");
 
 
                 bytes = new byte[(int)stream.Length];
                 bytes = new byte[(int)stream.Length];
                 stream.Read(bytes, 0, (int)stream.Length);
                 stream.Read(bytes, 0, (int)stream.Length);
 
 
-                try
-                {
+                try {
                     assembly = Assembly.Load(bytes);
                     assembly = Assembly.Load(bytes);
 
 
                     _dictionary.Add(assembly.FullName, assembly);
                     _dictionary.Add(assembly.FullName, assembly);
                     return;
                     return;
                 }
                 }
-                catch (Exception ex)
-                {
+                catch (Exception ex) {
                     Logger.LogError("EmbeddedAssembly.Load", ex.Message, ex.StackTrace);
                     Logger.LogError("EmbeddedAssembly.Load", ex.Message, ex.StackTrace);
                 }
                 }
             }
             }
@@ -41,30 +35,25 @@ namespace Optimizer
             bool fileOk = false;
             bool fileOk = false;
             string tempFile = string.Empty;
             string tempFile = string.Empty;
 
 
-            using (SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider())
-            {
+            using (SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider()) {
                 string fileHash = BitConverter.ToString(sha1.ComputeHash(bytes)).Replace("-", string.Empty);
                 string fileHash = BitConverter.ToString(sha1.ComputeHash(bytes)).Replace("-", string.Empty);
 
 
                 tempFile = Path.GetTempPath() + fileName;
                 tempFile = Path.GetTempPath() + fileName;
 
 
-                if (File.Exists(tempFile))
-                {
+                if (File.Exists(tempFile)) {
                     byte[] byteArray = File.ReadAllBytes(tempFile);
                     byte[] byteArray = File.ReadAllBytes(tempFile);
                     string fileHash2 = BitConverter.ToString(sha1.ComputeHash(byteArray)).Replace("-", string.Empty);
                     string fileHash2 = BitConverter.ToString(sha1.ComputeHash(byteArray)).Replace("-", string.Empty);
 
 
-                    if (fileHash == fileHash2)
-                    {
+                    if (fileHash == fileHash2) {
                         fileOk = true;
                         fileOk = true;
                     }
                     }
                 }
                 }
-                else
-                {
+                else {
                     fileOk = false;
                     fileOk = false;
                 }
                 }
             }
             }
 
 
-            if (!fileOk)
-            {
+            if (!fileOk) {
                 File.WriteAllBytes(tempFile, bytes);
                 File.WriteAllBytes(tempFile, bytes);
             }
             }
 
 
@@ -72,8 +61,7 @@ namespace Optimizer
             _dictionary.Add(assembly.FullName, assembly);
             _dictionary.Add(assembly.FullName, assembly);
         }
         }
 
 
-        internal static Assembly Get(string assemblyFullName)
-        {
+        internal static Assembly Get(string assemblyFullName) {
             if (_dictionary == null || _dictionary.Count == 0) return null;
             if (_dictionary == null || _dictionary.Count == 0) return null;
             if (_dictionary.ContainsKey(assemblyFullName)) return _dictionary[assemblyFullName];
             if (_dictionary.ContainsKey(assemblyFullName)) return _dictionary[assemblyFullName];
             return null;
             return null;

+ 11 - 22
Optimizer/ErrorLogger.cs

@@ -2,16 +2,13 @@
 using System.IO;
 using System.IO;
 using System.Text;
 using System.Text;
 
 
-namespace Optimizer
-{
-    internal static class Logger
-    {
+namespace Optimizer {
+    internal static class Logger {
         internal static string ErrorLogFile = Path.Combine(CoreHelper.CoreFolder, "Optimizer.log");
         internal static string ErrorLogFile = Path.Combine(CoreHelper.CoreFolder, "Optimizer.log");
 
 
         static StringBuilder _silentReportLog;
         static StringBuilder _silentReportLog;
 
 
-        private static void LogErrorSilent(string functionName, string errorMessage, string errorStackTrace)
-        {
+        private static void LogErrorSilent(string functionName, string errorMessage, string errorStackTrace) {
             _silentReportLog.AppendLine(string.Format("[ERROR] [{0}] in function [{1}]", DateTime.Now.ToString(), functionName));
             _silentReportLog.AppendLine(string.Format("[ERROR] [{0}] in function [{1}]", DateTime.Now.ToString(), functionName));
             _silentReportLog.AppendLine();
             _silentReportLog.AppendLine();
             _silentReportLog.AppendLine(errorMessage);
             _silentReportLog.AppendLine(errorMessage);
@@ -21,14 +18,12 @@ namespace Optimizer
             _silentReportLog.AppendLine();
             _silentReportLog.AppendLine();
         }
         }
 
 
-        internal static void LogInfoSilent(string message)
-        {
+        internal static void LogInfoSilent(string message) {
             _silentReportLog.AppendLine($"[OK] {message}");
             _silentReportLog.AppendLine($"[OK] {message}");
             _silentReportLog.AppendLine();
             _silentReportLog.AppendLine();
         }
         }
 
 
-        internal static void InitializeSilentReport()
-        {
+        internal static void InitializeSilentReport() {
             _silentReportLog = new StringBuilder();
             _silentReportLog = new StringBuilder();
 
 
             _silentReportLog.AppendLine(Utilities.GetWindowsDetails());
             _silentReportLog.AppendLine(Utilities.GetWindowsDetails());
@@ -39,27 +34,21 @@ namespace Optimizer
             _silentReportLog.AppendLine();
             _silentReportLog.AppendLine();
         }
         }
 
 
-        internal static void GenerateSilentReport()
-        {
-            try
-            {
+        internal static void GenerateSilentReport() {
+            try {
                 File.WriteAllText($"Optimizer.SilentReport.{DateTime.Now.ToString("yyyyMMddTHHmm")}.log", _silentReportLog.ToString());
                 File.WriteAllText($"Optimizer.SilentReport.{DateTime.Now.ToString("yyyyMMddTHHmm")}.log", _silentReportLog.ToString());
             }
             }
             catch { }
             catch { }
         }
         }
 
 
-        internal static void LogError(string functionName, string errorMessage, string errorStackTrace)
-        {
-            if (Program.SILENT_MODE)
-            {
+        internal static void LogError(string functionName, string errorMessage, string errorStackTrace) {
+            if (Program.SILENT_MODE) {
                 LogErrorSilent(functionName, errorMessage, errorStackTrace);
                 LogErrorSilent(functionName, errorMessage, errorStackTrace);
                 return;
                 return;
             }
             }
 
 
-            try
-            {
-                if (!File.Exists(ErrorLogFile) || (File.Exists(ErrorLogFile) && File.ReadAllText(ErrorLogFile).Trim() == string.Empty))
-                {
+            try {
+                if (!File.Exists(ErrorLogFile) || (File.Exists(ErrorLogFile) && File.ReadAllText(ErrorLogFile).Trim() == string.Empty)) {
                     File.AppendAllText(ErrorLogFile, Utilities.GetWindowsDetails());
                     File.AppendAllText(ErrorLogFile, Utilities.GetWindowsDetails());
                     File.AppendAllText(ErrorLogFile, Environment.NewLine);
                     File.AppendAllText(ErrorLogFile, Environment.NewLine);
                     File.AppendAllText(ErrorLogFile, string.Format("Optimizer {0} - .NET Framework {1} - Experimental build: {2}", Program.GetCurrentVersionTostring(), Utilities.GetNETFramework(), Program.EXPERIMENTAL_BUILD));
                     File.AppendAllText(ErrorLogFile, string.Format("Optimizer {0} - .NET Framework {1} - Experimental build: {2}", Program.GetCurrentVersionTostring(), Utilities.GetNETFramework(), Program.EXPERIMENTAL_BUILD));

+ 12 - 24
Optimizer/FileHandleHelper.cs

@@ -3,20 +3,16 @@ using System.Collections.Generic;
 using System.Diagnostics;
 using System.Diagnostics;
 using System.Runtime.InteropServices;
 using System.Runtime.InteropServices;
 
 
-namespace Optimizer
-{
-    public static class FileHandleHelper
-    {
-        public static List<Process> GetProcessesLockingFile(string path)
-        {
+namespace Optimizer {
+    public static class FileHandleHelper {
+        public static List<Process> GetProcessesLockingFile(string path) {
             uint handle;
             uint handle;
             string key = Guid.NewGuid().ToString();
             string key = Guid.NewGuid().ToString();
             int res = RmStartSession(out handle, 0, key);
             int res = RmStartSession(out handle, 0, key);
 
 
             if (res != 0) return null;
             if (res != 0) return null;
 
 
-            try
-            {
+            try {
                 const int MORE_DATA = 234;
                 const int MORE_DATA = 234;
                 uint pnProcInfoNeeded, pnProcInfo = 0, lpdwRebootReasons = RmRebootReasonNone;
                 uint pnProcInfoNeeded, pnProcInfo = 0, lpdwRebootReasons = RmRebootReasonNone;
 
 
@@ -28,14 +24,12 @@ namespace Optimizer
 
 
                 res = RmGetList(handle, out pnProcInfoNeeded, ref pnProcInfo, null, ref lpdwRebootReasons);
                 res = RmGetList(handle, out pnProcInfoNeeded, ref pnProcInfo, null, ref lpdwRebootReasons);
 
 
-                if (res == MORE_DATA)
-                {
+                if (res == MORE_DATA) {
                     return EnumerateProcesses(pnProcInfoNeeded, handle, lpdwRebootReasons);
                     return EnumerateProcesses(pnProcInfoNeeded, handle, lpdwRebootReasons);
                 }
                 }
                 else if (res != 0) return null;
                 else if (res != 0) return null;
             }
             }
-            finally
-            {
+            finally {
                 RmEndSession(handle);
                 RmEndSession(handle);
             }
             }
 
 
@@ -44,8 +38,7 @@ namespace Optimizer
 
 
 
 
         [StructLayout(LayoutKind.Sequential)]
         [StructLayout(LayoutKind.Sequential)]
-        public struct RM_UNIQUE_PROCESS
-        {
+        public struct RM_UNIQUE_PROCESS {
             public int dwProcessId;
             public int dwProcessId;
             public System.Runtime.InteropServices.ComTypes.FILETIME ProcessStartTime;
             public System.Runtime.InteropServices.ComTypes.FILETIME ProcessStartTime;
         }
         }
@@ -54,8 +47,7 @@ namespace Optimizer
         const int CCH_RM_MAX_APP_NAME = 255;
         const int CCH_RM_MAX_APP_NAME = 255;
         const int CCH_RM_MAX_SVC_NAME = 63;
         const int CCH_RM_MAX_SVC_NAME = 63;
 
 
-        public enum RM_APP_TYPE
-        {
+        public enum RM_APP_TYPE {
             RmUnknownApp = 0,
             RmUnknownApp = 0,
             RmMainWindow = 1,
             RmMainWindow = 1,
             RmOtherWindow = 2,
             RmOtherWindow = 2,
@@ -66,8 +58,7 @@ namespace Optimizer
         }
         }
 
 
         [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
         [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
-        public struct RM_PROCESS_INFO
-        {
+        public struct RM_PROCESS_INFO {
             public RM_UNIQUE_PROCESS Process;
             public RM_UNIQUE_PROCESS Process;
 
 
             [MarshalAs(UnmanagedType.ByValTStr, SizeConst = CCH_RM_MAX_APP_NAME + 1)] public string strAppName;
             [MarshalAs(UnmanagedType.ByValTStr, SizeConst = CCH_RM_MAX_APP_NAME + 1)] public string strAppName;
@@ -96,8 +87,7 @@ namespace Optimizer
             ref uint pnProcInfo, [In, Out] RM_PROCESS_INFO[] rgAffectedApps,
             ref uint pnProcInfo, [In, Out] RM_PROCESS_INFO[] rgAffectedApps,
             ref uint lpdwRebootReasons);
             ref uint lpdwRebootReasons);
 
 
-        private static List<Process> EnumerateProcesses(uint pnProcInfoNeeded, uint handle, uint lpdwRebootReasons)
-        {
+        private static List<Process> EnumerateProcesses(uint pnProcInfoNeeded, uint handle, uint lpdwRebootReasons) {
             var processes = new List<Process>(10);
             var processes = new List<Process>(10);
 
 
             var processInfo = new RM_PROCESS_INFO[pnProcInfoNeeded];
             var processInfo = new RM_PROCESS_INFO[pnProcInfoNeeded];
@@ -108,10 +98,8 @@ namespace Optimizer
 
 
             if (res != 0) return null;
             if (res != 0) return null;
 
 
-            for (int i = 0; i < pnProcInfo; i++)
-            {
-                try
-                {
+            for (int i = 0; i < pnProcInfo; i++) {
+                try {
                     processes.Add(Process.GetProcessById(processInfo[i].Process.dwProcessId));
                     processes.Add(Process.GetProcessById(processInfo[i].Process.dwProcessId));
                 }
                 }
                 catch { }
                 catch { }

+ 18 - 36
Optimizer/FontHelper.cs

@@ -5,10 +5,8 @@ using System.Drawing;
 using System.Drawing.Text;
 using System.Drawing.Text;
 using System.Linq;
 using System.Linq;
 
 
-namespace Optimizer
-{
-    internal static class FontHelper
-    {
+namespace Optimizer {
+    internal static class FontHelper {
         [System.Runtime.InteropServices.DllImport("gdi32.dll")]
         [System.Runtime.InteropServices.DllImport("gdi32.dll")]
         private static extern IntPtr AddFontMemResourceEx(IntPtr pbFont, uint cbFont,
         private static extern IntPtr AddFontMemResourceEx(IntPtr pbFont, uint cbFont,
             IntPtr pdv, [System.Runtime.InteropServices.In] ref uint pcFonts);
             IntPtr pdv, [System.Runtime.InteropServices.In] ref uint pcFonts);
@@ -17,8 +15,7 @@ namespace Optimizer
 
 
         internal static Font Poppins15;
         internal static Font Poppins15;
 
 
-        internal static void LoadFont()
-        {
+        internal static void LoadFont() {
             byte[] fontData = Properties.Resources.Poppins_Regular;
             byte[] fontData = Properties.Resources.Poppins_Regular;
             IntPtr fontPtr = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(fontData.Length);
             IntPtr fontPtr = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(fontData.Length);
             System.Runtime.InteropServices.Marshal.Copy(fontData, 0, fontPtr, fontData.Length);
             System.Runtime.InteropServices.Marshal.Copy(fontData, 0, fontPtr, fontData.Length);
@@ -32,17 +29,13 @@ namespace Optimizer
             Poppins15 = new Font(fonts.Families[0], 13f);
             Poppins15 = new Font(fonts.Families[0], 13f);
         }
         }
 
 
-        internal static IEnumerable<string> GetAvailableFonts()
-        {
+        internal static IEnumerable<string> GetAvailableFonts() {
             return new InstalledFontCollection().Families.Select(x => x.Name);
             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))
-                {
+        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 (TrueType)", "");
                     fontsKey.SetValue("Segoe UI Bold (TrueType)", "");
                     fontsKey.SetValue("Segoe UI Bold (TrueType)", "");
                     fontsKey.SetValue("Segoe UI Bold Italic (TrueType)", "");
                     fontsKey.SetValue("Segoe UI Bold Italic (TrueType)", "");
@@ -52,39 +45,30 @@ namespace Optimizer
                     fontsKey.SetValue("Segoe UI Symbol (TrueType)", "");
                     fontsKey.SetValue("Segoe UI Symbol (TrueType)", "");
                 }
                 }
 
 
-                using (RegistryKey fontSubstitutesKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontSubstitutes", true))
-                {
+                using (RegistryKey fontSubstitutesKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontSubstitutes", true)) {
                     fontSubstitutesKey.SetValue("Segoe UI", fontName);
                     fontSubstitutesKey.SetValue("Segoe UI", fontName);
                 }
                 }
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("FontHelper.ChangeGlobalFont", ex.Message, ex.StackTrace);
                 Logger.LogError("FontHelper.ChangeGlobalFont", ex.Message, ex.StackTrace);
             }
             }
         }
         }
 
 
-        internal static string GetCurrentGlobalFont()
-        {
-            try
-            {
-                using (RegistryKey fontSubstitutesKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontSubstitutes", false))
-                {
+        internal static string GetCurrentGlobalFont() {
+            try {
+                using (RegistryKey fontSubstitutesKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontSubstitutes", false)) {
                     return fontSubstitutesKey.GetValue("Segoe UI", string.Empty) as string;
                     return fontSubstitutesKey.GetValue("Segoe UI", string.Empty) as string;
                 }
                 }
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("FontHelper.GetCurrentGlobalFont", ex.Message, ex.StackTrace);
                 Logger.LogError("FontHelper.GetCurrentGlobalFont", ex.Message, ex.StackTrace);
                 return string.Empty;
                 return string.Empty;
             }
             }
         }
         }
 
 
-        internal static void RestoreDefaultGlobalFont()
-        {
-            try
-            {
-                using (RegistryKey fontsKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts", true))
-                {
+        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 (TrueType)", "segoeui.ttf");
                     fontsKey.SetValue("Segoe UI Black (TrueType)", "seguibl.ttf");
                     fontsKey.SetValue("Segoe UI Black (TrueType)", "seguibl.ttf");
                     fontsKey.SetValue("Segoe UI Black Italic (TrueType)", "seguibli.ttf");
                     fontsKey.SetValue("Segoe UI Black Italic (TrueType)", "seguibli.ttf");
@@ -107,13 +91,11 @@ namespace Optimizer
                     fontsKey.SetValue("Segoe Script Bold (TrueType)", "segoescb.ttf");
                     fontsKey.SetValue("Segoe Script Bold (TrueType)", "segoescb.ttf");
                 }
                 }
 
 
-                using (RegistryKey fontSubstitutesKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontSubstitutes", true))
-                {
+                using (RegistryKey fontSubstitutesKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontSubstitutes", true)) {
                     fontSubstitutesKey.DeleteValue("Segoe UI", false);
                     fontSubstitutesKey.DeleteValue("Segoe UI", false);
                 }
                 }
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("FontHelper.RestoreDefaultGlobalFont", ex.Message, ex.StackTrace);
                 Logger.LogError("FontHelper.RestoreDefaultGlobalFont", ex.Message, ex.StackTrace);
             }
             }
         }
         }

+ 9 - 18
Optimizer/Forms/AboutForm.cs

@@ -2,28 +2,23 @@
 using System.Diagnostics;
 using System.Diagnostics;
 using System.Windows.Forms;
 using System.Windows.Forms;
 
 
-namespace Optimizer
-{
-    public sealed partial class AboutForm : Form
-    {
-        public AboutForm()
-        {
+namespace Optimizer {
+    public sealed partial class AboutForm : Form {
+        public AboutForm() {
             InitializeComponent();
             InitializeComponent();
             OptionsHelper.ApplyTheme(this);
             OptionsHelper.ApplyTheme(this);
 
 
             pictureBox1.BackColor = OptionsHelper.CurrentOptions.Theme;
             pictureBox1.BackColor = OptionsHelper.CurrentOptions.Theme;
         }
         }
 
 
-        private void About_Load(object sender, EventArgs e)
-        {
+        private void About_Load(object sender, EventArgs e) {
             t1.Interval = 50;
             t1.Interval = 50;
             t2.Interval = 50;
             t2.Interval = 50;
 
 
             t1.Start();
             t1.Start();
         }
         }
 
 
-        private void t1_Tick(object sender, EventArgs e)
-        {
+        private void t1_Tick(object sender, EventArgs e) {
             string s0 = "";
             string s0 = "";
             string s1 = "O";
             string s1 = "O";
             string s2 = "Op";
             string s2 = "Op";
@@ -35,8 +30,7 @@ namespace Optimizer
             string s8 = "Optimize";
             string s8 = "Optimize";
             string s9 = "Optimizer";
             string s9 = "Optimizer";
 
 
-            switch (l1.Text)
-            {
+            switch (l1.Text) {
                 case "":
                 case "":
                     l1.Text = s1;
                     l1.Text = s1;
                     break;
                     break;
@@ -72,8 +66,7 @@ namespace Optimizer
             }
             }
         }
         }
 
 
-        private void t2_Tick(object sender, EventArgs e)
-        {
+        private void t2_Tick(object sender, EventArgs e) {
             string s0 = "";
             string s0 = "";
             string s1 = "d";
             string s1 = "d";
             string s2 = "de";
             string s2 = "de";
@@ -86,8 +79,7 @@ namespace Optimizer
             string s9 = "deadmoon © ";
             string s9 = "deadmoon © ";
             string s10 = "deadmoon © ∞";
             string s10 = "deadmoon © ∞";
 
 
-            switch (l2.Text)
-            {
+            switch (l2.Text) {
                 case "":
                 case "":
                     l2.Text = s1;
                     l2.Text = s1;
                     break;
                     break;
@@ -125,8 +117,7 @@ namespace Optimizer
             }
             }
         }
         }
 
 
-        private void l2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
-        {
+        private void l2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) {
             Process.Start("https://github.com/hellzerg/optimizer");
             Process.Start("https://github.com/hellzerg/optimizer");
         }
         }
     }
     }

+ 9 - 18
Optimizer/Forms/FileUnlockForm.cs

@@ -6,14 +6,11 @@ using System.IO;
 using System.Linq;
 using System.Linq;
 using System.Windows.Forms;
 using System.Windows.Forms;
 
 
-namespace Optimizer
-{
-    public sealed partial class FileUnlockForm : Form
-    {
+namespace Optimizer {
+    public sealed partial class FileUnlockForm : Form {
         List<Process> _lockingProcesses;
         List<Process> _lockingProcesses;
 
 
-        public FileUnlockForm()
-        {
+        public FileUnlockForm() {
             InitializeComponent();
             InitializeComponent();
             CheckForIllegalCrossThreadCalls = false;
             CheckForIllegalCrossThreadCalls = false;
             OptionsHelper.ApplyTheme(this);
             OptionsHelper.ApplyTheme(this);
@@ -22,13 +19,11 @@ namespace Optimizer
             btnKill.Text = OptionsHelper.TranslationList["btnKill"].ToString();
             btnKill.Text = OptionsHelper.TranslationList["btnKill"].ToString();
         }
         }
 
 
-        private void FileUnlockForm_Load(object sender, EventArgs e)
-        {
+        private void FileUnlockForm_Load(object sender, EventArgs e) {
 
 
         }
         }
 
 
-        private void btnFind_Click(object sender, EventArgs e)
-        {
+        private void btnFind_Click(object sender, EventArgs e) {
             if (string.IsNullOrEmpty(txtFile.Text)) return;
             if (string.IsNullOrEmpty(txtFile.Text)) return;
             if (!File.Exists(txtFile.Text)) return;
             if (!File.Exists(txtFile.Text)) return;
 
 
@@ -40,17 +35,13 @@ namespace Optimizer
             listProcesses.Items.AddRange(_lockingProcesses.Select(x => $"[{x.Id}] {x.ProcessName}").ToArray());
             listProcesses.Items.AddRange(_lockingProcesses.Select(x => $"[{x.Id}] {x.ProcessName}").ToArray());
         }
         }
 
 
-        private void btnKill_Click(object sender, EventArgs e)
-        {
+        private void btnKill_Click(object sender, EventArgs e) {
             if (listProcesses.CheckedItems.Count <= 0) return;
             if (listProcesses.CheckedItems.Count <= 0) return;
 
 
-            foreach (string x in listProcesses.CheckedItems)
-            {
+            foreach (string x in listProcesses.CheckedItems) {
                 IEnumerable<Process> prs = Process.GetProcesses().Where(pr => pr.ProcessName == x.Replace(x.Substring(0, x.IndexOf("]") + 1), string.Empty).Trim());
                 IEnumerable<Process> prs = Process.GetProcesses().Where(pr => pr.ProcessName == x.Replace(x.Substring(0, x.IndexOf("]") + 1), string.Empty).Trim());
-                foreach (Process z in prs)
-                {
-                    try
-                    {
+                foreach (Process z in prs) {
+                    try {
                         z.Kill();
                         z.Kill();
                     }
                     }
                     catch { continue; }
                     catch { continue; }

+ 51 - 102
Optimizer/Forms/FirstRunForm.cs

@@ -1,24 +1,19 @@
 using System;
 using System;
 using System.Windows.Forms;
 using System.Windows.Forms;
 
 
-namespace Optimizer
-{
-    public sealed partial class FirstRunForm : Form
-    {
-        public FirstRunForm()
-        {
+namespace Optimizer {
+    public sealed partial class FirstRunForm : Form {
+        public FirstRunForm() {
             InitializeComponent();
             InitializeComponent();
             this.DoubleBuffered = true;
             this.DoubleBuffered = true;
             OptionsHelper.ApplyTheme(this);
             OptionsHelper.ApplyTheme(this);
         }
         }
 
 
-        private void btnStart_Click(object sender, EventArgs e)
-        {
+        private void btnStart_Click(object sender, EventArgs e) {
             this.Close();
             this.Close();
         }
         }
 
 
-        private void FirstRunForm_Load(object sender, EventArgs e)
-        {
+        private void FirstRunForm_Load(object sender, EventArgs e) {
             radioArabic.Text = Constants.ARABIC;
             radioArabic.Text = Constants.ARABIC;
             radioPortuguese.Text = Constants.PORTUGUESE;
             radioPortuguese.Text = Constants.PORTUGUESE;
             radioChinese.Text = Constants.CHINESE;
             radioChinese.Text = Constants.CHINESE;
@@ -45,279 +40,233 @@ namespace Optimizer
             radioEnglish.Text = Constants.ENGLISH;
             radioEnglish.Text = Constants.ENGLISH;
         }
         }
 
 
-        private void pictureBox86_Click(object sender, EventArgs e)
-        {
+        private void pictureBox86_Click(object sender, EventArgs e) {
             radioEnglish.PerformClick();
             radioEnglish.PerformClick();
         }
         }
 
 
-        private void pictureBox87_Click(object sender, EventArgs e)
-        {
+        private void pictureBox87_Click(object sender, EventArgs e) {
             radioRussian.PerformClick();
             radioRussian.PerformClick();
         }
         }
 
 
-        private void pictureBox88_Click(object sender, EventArgs e)
-        {
+        private void pictureBox88_Click(object sender, EventArgs e) {
             radioHellenic.PerformClick();
             radioHellenic.PerformClick();
         }
         }
 
 
-        private void radioEnglish_CheckedChanged(object sender, EventArgs e)
-        {
+        private void radioEnglish_CheckedChanged(object sender, EventArgs e) {
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.EN;
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.EN;
             OptionsHelper.SaveSettings();
             OptionsHelper.SaveSettings();
             OptionsHelper.LoadTranslation();
             OptionsHelper.LoadTranslation();
         }
         }
 
 
-        private void radioRussian_CheckedChanged(object sender, EventArgs e)
-        {
+        private void radioRussian_CheckedChanged(object sender, EventArgs e) {
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.RU;
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.RU;
             OptionsHelper.SaveSettings();
             OptionsHelper.SaveSettings();
             OptionsHelper.LoadTranslation();
             OptionsHelper.LoadTranslation();
         }
         }
 
 
-        private void radioHellenic_CheckedChanged(object sender, EventArgs e)
-        {
+        private void radioHellenic_CheckedChanged(object sender, EventArgs e) {
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.EL;
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.EL;
             OptionsHelper.SaveSettings();
             OptionsHelper.SaveSettings();
             OptionsHelper.LoadTranslation();
             OptionsHelper.LoadTranslation();
         }
         }
 
 
-        private void pictureBox1_Click(object sender, EventArgs e)
-        {
+        private void pictureBox1_Click(object sender, EventArgs e) {
             radioTurkish.PerformClick();
             radioTurkish.PerformClick();
         }
         }
 
 
-        private void radioTurkish_CheckedChanged(object sender, EventArgs e)
-        {
+        private void radioTurkish_CheckedChanged(object sender, EventArgs e) {
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.TR;
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.TR;
             OptionsHelper.SaveSettings();
             OptionsHelper.SaveSettings();
             OptionsHelper.LoadTranslation();
             OptionsHelper.LoadTranslation();
         }
         }
 
 
-        private void radioGerman_CheckedChanged(object sender, EventArgs e)
-        {
+        private void radioGerman_CheckedChanged(object sender, EventArgs e) {
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.DE;
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.DE;
             OptionsHelper.SaveSettings();
             OptionsHelper.SaveSettings();
             OptionsHelper.LoadTranslation();
             OptionsHelper.LoadTranslation();
         }
         }
 
 
-        private void pictureBox2_Click(object sender, EventArgs e)
-        {
+        private void pictureBox2_Click(object sender, EventArgs e) {
             radioGerman.PerformClick();
             radioGerman.PerformClick();
         }
         }
 
 
-        private void pictureBox3_Click(object sender, EventArgs e)
-        {
+        private void pictureBox3_Click(object sender, EventArgs e) {
             radioSpanish.PerformClick();
             radioSpanish.PerformClick();
         }
         }
 
 
-        private void radioSpanish_CheckedChanged(object sender, EventArgs e)
-        {
+        private void radioSpanish_CheckedChanged(object sender, EventArgs e) {
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.ES;
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.ES;
             OptionsHelper.SaveSettings();
             OptionsHelper.SaveSettings();
             OptionsHelper.LoadTranslation();
             OptionsHelper.LoadTranslation();
         }
         }
 
 
-        private void radioPortuguese_CheckedChanged(object sender, EventArgs e)
-        {
+        private void radioPortuguese_CheckedChanged(object sender, EventArgs e) {
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.PT;
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.PT;
             OptionsHelper.SaveSettings();
             OptionsHelper.SaveSettings();
             OptionsHelper.LoadTranslation();
             OptionsHelper.LoadTranslation();
         }
         }
 
 
-        private void pictureBox4_Click(object sender, EventArgs e)
-        {
+        private void pictureBox4_Click(object sender, EventArgs e) {
             radioPortuguese.PerformClick();
             radioPortuguese.PerformClick();
         }
         }
 
 
-        private void radioFrench_CheckedChanged(object sender, EventArgs e)
-        {
+        private void radioFrench_CheckedChanged(object sender, EventArgs e) {
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.FR;
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.FR;
             OptionsHelper.SaveSettings();
             OptionsHelper.SaveSettings();
             OptionsHelper.LoadTranslation();
             OptionsHelper.LoadTranslation();
         }
         }
 
 
-        private void pictureBox5_Click(object sender, EventArgs e)
-        {
+        private void pictureBox5_Click(object sender, EventArgs e) {
             radioFrench.PerformClick();
             radioFrench.PerformClick();
         }
         }
 
 
-        private void radioitalian_CheckedChanged(object sender, EventArgs e)
-        {
+        private void radioitalian_CheckedChanged(object sender, EventArgs e) {
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.IT;
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.IT;
             OptionsHelper.SaveSettings();
             OptionsHelper.SaveSettings();
             OptionsHelper.LoadTranslation();
             OptionsHelper.LoadTranslation();
         }
         }
 
 
-        private void pictureBox6_Click(object sender, EventArgs e)
-        {
+        private void pictureBox6_Click(object sender, EventArgs e) {
             radioItalian.PerformClick();
             radioItalian.PerformClick();
         }
         }
 
 
-        private void pictureBox7_Click(object sender, EventArgs e)
-        {
+        private void pictureBox7_Click(object sender, EventArgs e) {
             radioChinese.PerformClick();
             radioChinese.PerformClick();
         }
         }
 
 
-        private void radioChinese_CheckedChanged(object sender, EventArgs e)
-        {
+        private void radioChinese_CheckedChanged(object sender, EventArgs e) {
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.CN;
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.CN;
             OptionsHelper.SaveSettings();
             OptionsHelper.SaveSettings();
             OptionsHelper.LoadTranslation();
             OptionsHelper.LoadTranslation();
         }
         }
 
 
-        private void pictureBox8_Click(object sender, EventArgs e)
-        {
+        private void pictureBox8_Click(object sender, EventArgs e) {
             radioCzech.PerformClick();
             radioCzech.PerformClick();
         }
         }
 
 
-        private void radioCzech_CheckedChanged(object sender, EventArgs e)
-        {
+        private void radioCzech_CheckedChanged(object sender, EventArgs e) {
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.CZ;
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.CZ;
             OptionsHelper.SaveSettings();
             OptionsHelper.SaveSettings();
             OptionsHelper.LoadTranslation();
             OptionsHelper.LoadTranslation();
         }
         }
 
 
-        private void radioTaiwan_CheckedChanged(object sender, EventArgs e)
-        {
+        private void radioTaiwan_CheckedChanged(object sender, EventArgs e) {
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.TW;
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.TW;
             OptionsHelper.SaveSettings();
             OptionsHelper.SaveSettings();
             OptionsHelper.LoadTranslation();
             OptionsHelper.LoadTranslation();
         }
         }
 
 
-        private void pictureBox9_Click(object sender, EventArgs e)
-        {
+        private void pictureBox9_Click(object sender, EventArgs e) {
             radioTaiwan.PerformClick();
             radioTaiwan.PerformClick();
         }
         }
 
 
-        private void radioKorean_CheckedChanged(object sender, EventArgs e)
-        {
+        private void radioKorean_CheckedChanged(object sender, EventArgs e) {
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.KO;
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.KO;
             OptionsHelper.SaveSettings();
             OptionsHelper.SaveSettings();
             OptionsHelper.LoadTranslation();
             OptionsHelper.LoadTranslation();
         }
         }
 
 
-        private void pictureBox10_Click(object sender, EventArgs e)
-        {
+        private void pictureBox10_Click(object sender, EventArgs e) {
             radioChinese.PerformClick();
             radioChinese.PerformClick();
         }
         }
 
 
-        private void pictureBox11_Click(object sender, EventArgs e)
-        {
+        private void pictureBox11_Click(object sender, EventArgs e) {
             radioPolish.PerformClick();
             radioPolish.PerformClick();
         }
         }
 
 
-        private void radioPolish_CheckedChanged(object sender, EventArgs e)
-        {
+        private void radioPolish_CheckedChanged(object sender, EventArgs e) {
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.PL;
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.PL;
             OptionsHelper.SaveSettings();
             OptionsHelper.SaveSettings();
             OptionsHelper.LoadTranslation();
             OptionsHelper.LoadTranslation();
         }
         }
 
 
-        private void radioArabic_CheckedChanged(object sender, EventArgs e)
-        {
+        private void radioArabic_CheckedChanged(object sender, EventArgs e) {
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.AR;
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.AR;
             OptionsHelper.SaveSettings();
             OptionsHelper.SaveSettings();
             OptionsHelper.LoadTranslation();
             OptionsHelper.LoadTranslation();
         }
         }
 
 
-        private void pictureBox12_Click(object sender, EventArgs e)
-        {
+        private void pictureBox12_Click(object sender, EventArgs e) {
             radioArabic.PerformClick();
             radioArabic.PerformClick();
         }
         }
 
 
-        private void pictureBox13_Click(object sender, EventArgs e)
-        {
+        private void pictureBox13_Click(object sender, EventArgs e) {
             radioKurdish.PerformClick();
             radioKurdish.PerformClick();
         }
         }
 
 
-        private void radioKurdish_CheckedChanged(object sender, EventArgs e)
-        {
+        private void radioKurdish_CheckedChanged(object sender, EventArgs e) {
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.KU;
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.KU;
             OptionsHelper.SaveSettings();
             OptionsHelper.SaveSettings();
             OptionsHelper.LoadTranslation();
             OptionsHelper.LoadTranslation();
         }
         }
 
 
-        private void pictureBox14_Click(object sender, EventArgs e)
-        {
+        private void pictureBox14_Click(object sender, EventArgs e) {
             radioHungarian.PerformClick();
             radioHungarian.PerformClick();
         }
         }
 
 
-        private void radioHungarian_CheckedChanged(object sender, EventArgs e)
-        {
+        private void radioHungarian_CheckedChanged(object sender, EventArgs e) {
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.HU;
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.HU;
             OptionsHelper.SaveSettings();
             OptionsHelper.SaveSettings();
             OptionsHelper.LoadTranslation();
             OptionsHelper.LoadTranslation();
         }
         }
 
 
-        private void radioRomanian_CheckedChanged(object sender, EventArgs e)
-        {
+        private void radioRomanian_CheckedChanged(object sender, EventArgs e) {
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.RO;
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.RO;
             OptionsHelper.SaveSettings();
             OptionsHelper.SaveSettings();
             OptionsHelper.LoadTranslation();
             OptionsHelper.LoadTranslation();
         }
         }
 
 
-        private void pictureBox15_Click(object sender, EventArgs e)
-        {
+        private void pictureBox15_Click(object sender, EventArgs e) {
             radioRomanian.PerformClick();
             radioRomanian.PerformClick();
         }
         }
 
 
-        private void radioDutch_CheckedChanged(object sender, EventArgs e)
-        {
+        private void radioDutch_CheckedChanged(object sender, EventArgs e) {
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.NL;
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.NL;
             OptionsHelper.SaveSettings();
             OptionsHelper.SaveSettings();
             OptionsHelper.LoadTranslation();
             OptionsHelper.LoadTranslation();
         }
         }
 
 
-        private void pictureBox16_Click(object sender, EventArgs e)
-        {
+        private void pictureBox16_Click(object sender, EventArgs e) {
             radioDutch.PerformClick();
             radioDutch.PerformClick();
         }
         }
 
 
-        private void radioJapanese_CheckedChanged(object sender, EventArgs e)
-        {
+        private void radioJapanese_CheckedChanged(object sender, EventArgs e) {
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.JA;
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.JA;
             OptionsHelper.SaveSettings();
             OptionsHelper.SaveSettings();
             OptionsHelper.LoadTranslation();
             OptionsHelper.LoadTranslation();
         }
         }
 
 
-        private void pictureBox17_Click(object sender, EventArgs e)
-        {
+        private void pictureBox17_Click(object sender, EventArgs e) {
             radioJapanese.PerformClick();
             radioJapanese.PerformClick();
         }
         }
 
 
-        private void radioFarsi_CheckedChanged(object sender, EventArgs e)
-        {
+        private void radioFarsi_CheckedChanged(object sender, EventArgs e) {
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.FA;
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.FA;
             OptionsHelper.SaveSettings();
             OptionsHelper.SaveSettings();
             OptionsHelper.LoadTranslation();
             OptionsHelper.LoadTranslation();
         }
         }
 
 
-        private void pictureBox18_Click(object sender, EventArgs e)
-        {
+        private void pictureBox18_Click(object sender, EventArgs e) {
             radioFarsi.PerformClick();
             radioFarsi.PerformClick();
         }
         }
 
 
-        private void pictureBox19_Click(object sender, EventArgs e)
-        {
+        private void pictureBox19_Click(object sender, EventArgs e) {
             radioNepali.PerformClick();
             radioNepali.PerformClick();
         }
         }
 
 
-        private void radioNepali_CheckedChanged(object sender, EventArgs e)
-        {
+        private void radioNepali_CheckedChanged(object sender, EventArgs e) {
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.NE;
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.NE;
             OptionsHelper.SaveSettings();
             OptionsHelper.SaveSettings();
             OptionsHelper.LoadTranslation();
             OptionsHelper.LoadTranslation();
         }
         }
 
 
-        private void radioBulgarian_CheckedChanged(object sender, EventArgs e)
-        {
+        private void radioBulgarian_CheckedChanged(object sender, EventArgs e) {
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.BG;
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.BG;
             OptionsHelper.SaveSettings();
             OptionsHelper.SaveSettings();
             OptionsHelper.LoadTranslation();
             OptionsHelper.LoadTranslation();
         }
         }
 
 
-        private void radioUkrainian_CheckedChanged(object sender, EventArgs e)
-        {
+        private void radioUkrainian_CheckedChanged(object sender, EventArgs e) {
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.UA;
             OptionsHelper.CurrentOptions.LanguageCode = LanguageCode.UA;
             OptionsHelper.SaveSettings();
             OptionsHelper.SaveSettings();
             OptionsHelper.LoadTranslation();
             OptionsHelper.LoadTranslation();

+ 15 - 30
Optimizer/Forms/HelperForm.cs

@@ -3,40 +3,31 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
 using System.Windows.Forms;
 using System.Windows.Forms;
 
 
-namespace Optimizer
-{
-    public sealed partial class HelperForm : System.Windows.Forms.Form
-    {
+namespace Optimizer {
+    public sealed partial class HelperForm : System.Windows.Forms.Form {
         MainForm _main;
         MainForm _main;
         MessageType _type;
         MessageType _type;
 
 
-        private void Confirm()
-        {
-            if (_type == MessageType.Error)
-            {
+        private void Confirm() {
+            if (_type == MessageType.Error) {
                 this.Close();
                 this.Close();
             }
             }
-            if (_type == MessageType.Startup)
-            {
+            if (_type == MessageType.Startup) {
                 _main.RemoveAllStartupItems();
                 _main.RemoveAllStartupItems();
             }
             }
-            if (_type == MessageType.Restart)
-            {
+            if (_type == MessageType.Restart) {
                 OptionsHelper.SaveSettings();
                 OptionsHelper.SaveSettings();
                 Utilities.Reboot();
                 Utilities.Reboot();
             }
             }
-            if (_type == MessageType.Hosts)
-            {
+            if (_type == MessageType.Hosts) {
                 _main.RemoveAllHostsEntries();
                 _main.RemoveAllHostsEntries();
             }
             }
-            if (_type == MessageType.Integrator)
-            {
+            if (_type == MessageType.Integrator) {
                 _main.RemoveAllDesktopItems();
                 _main.RemoveAllDesktopItems();
             }
             }
         }
         }
 
 
-        internal HelperForm(MainForm main, MessageType m, string text)
-        {
+        internal HelperForm(MainForm main, MessageType m, string text) {
             InitializeComponent();
             InitializeComponent();
             OptionsHelper.ApplyTheme(this);
             OptionsHelper.ApplyTheme(this);
 
 
@@ -45,8 +36,7 @@ namespace Optimizer
 
 
             lblMessage.Text = text;
             lblMessage.Text = text;
 
 
-            if (_type == MessageType.Error)
-            {
+            if (_type == MessageType.Error) {
                 btnNo.Visible = false;
                 btnNo.Visible = false;
                 btnYes.Text = OptionsHelper.TranslationList["btnOk"];
                 btnYes.Text = OptionsHelper.TranslationList["btnOk"];
 
 
@@ -60,31 +50,26 @@ namespace Optimizer
             if (OptionsHelper.CurrentOptions.LanguageCode != LanguageCode.EN) Translate();
             if (OptionsHelper.CurrentOptions.LanguageCode != LanguageCode.EN) Translate();
         }
         }
 
 
-        private void btnNo_Click(object sender, EventArgs e)
-        {
+        private void btnNo_Click(object sender, EventArgs e) {
             this.Close();
             this.Close();
         }
         }
 
 
-        private void btnYes_Click(object sender, EventArgs e)
-        {
+        private void btnYes_Click(object sender, EventArgs e) {
             Confirm();
             Confirm();
             this.Close();
             this.Close();
         }
         }
 
 
-        private void Messager_Load(object sender, EventArgs e)
-        {
+        private void Messager_Load(object sender, EventArgs e) {
             CheckForIllegalCrossThreadCalls = false;
             CheckForIllegalCrossThreadCalls = false;
             this.BringToFront();
             this.BringToFront();
         }
         }
 
 
-        private void Translate()
-        {
+        private void Translate() {
             Dictionary<string, string> translationList = OptionsHelper.TranslationList.ToObject<Dictionary<string, string>>();
             Dictionary<string, string> translationList = OptionsHelper.TranslationList.ToObject<Dictionary<string, string>>();
 
 
             Control element;
             Control element;
 
 
-            foreach (var x in translationList)
-            {
+            foreach (var x in translationList) {
                 if (x.Key == null || x.Key == string.Empty) continue;
                 if (x.Key == null || x.Key == string.Empty) continue;
                 element = this.Controls.Find(x.Key, true).FirstOrDefault();
                 element = this.Controls.Find(x.Key, true).FirstOrDefault();
 
 

+ 9 - 18
Optimizer/Forms/HostsEditorForm.cs

@@ -3,19 +3,15 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
 using System.Windows.Forms;
 using System.Windows.Forms;
 
 
-namespace Optimizer
-{
-    public sealed partial class HostsEditorForm : Form
-    {
+namespace Optimizer {
+    public sealed partial class HostsEditorForm : Form {
         string[] _toSave = null;
         string[] _toSave = null;
 
 
-        public HostsEditorForm()
-        {
+        public HostsEditorForm() {
             InitializeComponent();
             InitializeComponent();
             OptionsHelper.ApplyTheme(this);
             OptionsHelper.ApplyTheme(this);
 
 
-            if (HostsHelper.GetReadOnly())
-            {
+            if (HostsHelper.GetReadOnly()) {
                 savebtn.Enabled = false;
                 savebtn.Enabled = false;
             }
             }
 
 
@@ -23,8 +19,7 @@ namespace Optimizer
             if (OptionsHelper.CurrentOptions.LanguageCode != LanguageCode.EN) Translate();
             if (OptionsHelper.CurrentOptions.LanguageCode != LanguageCode.EN) Translate();
         }
         }
 
 
-        private void HostsEditor_Load(object sender, EventArgs e)
-        {
+        private void HostsEditor_Load(object sender, EventArgs e) {
             //foreach (string line in HostsHelper.ReadHosts())
             //foreach (string line in HostsHelper.ReadHosts())
             //{
             //{
             //    textBox1.Text += line + HostsHelper.NewLine;
             //    textBox1.Text += line + HostsHelper.NewLine;
@@ -35,15 +30,13 @@ namespace Optimizer
             textBox1.Focus();
             textBox1.Focus();
         }
         }
 
 
-        private void Translate()
-        {
+        private void Translate() {
             this.Text = OptionsHelper.TranslationList["HostsEditorForm"];
             this.Text = OptionsHelper.TranslationList["HostsEditorForm"];
             Dictionary<string, string> translationList = OptionsHelper.TranslationList.ToObject<Dictionary<string, string>>();
             Dictionary<string, string> translationList = OptionsHelper.TranslationList.ToObject<Dictionary<string, string>>();
 
 
             Control element;
             Control element;
 
 
-            foreach (var x in translationList)
-            {
+            foreach (var x in translationList) {
                 if (x.Key == null || x.Key == string.Empty) continue;
                 if (x.Key == null || x.Key == string.Empty) continue;
                 element = this.Controls.Find(x.Key, true).FirstOrDefault();
                 element = this.Controls.Find(x.Key, true).FirstOrDefault();
 
 
@@ -53,13 +46,11 @@ namespace Optimizer
             }
             }
         }
         }
 
 
-        private void button1_Click(object sender, EventArgs e)
-        {
+        private void button1_Click(object sender, EventArgs e) {
             this.Close();
             this.Close();
         }
         }
 
 
-        private void button7_Click(object sender, EventArgs e)
-        {
+        private void button7_Click(object sender, EventArgs e) {
             _toSave = textBox1.Lines;
             _toSave = textBox1.Lines;
             HostsHelper.SaveHosts(_toSave);
             HostsHelper.SaveHosts(_toSave);
 
 

+ 9 - 18
Optimizer/Forms/InfoForm.cs

@@ -3,12 +3,9 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
 using System.Windows.Forms;
 using System.Windows.Forms;
 
 
-namespace Optimizer
-{
-    public sealed partial class InfoForm : Form
-    {
-        public InfoForm(string info)
-        {
+namespace Optimizer {
+    public sealed partial class InfoForm : Form {
+        public InfoForm(string info) {
             InitializeComponent();
             InitializeComponent();
             CheckForIllegalCrossThreadCalls = false;
             CheckForIllegalCrossThreadCalls = false;
 
 
@@ -20,14 +17,12 @@ namespace Optimizer
             if (OptionsHelper.CurrentOptions.LanguageCode != LanguageCode.EN) Translate();
             if (OptionsHelper.CurrentOptions.LanguageCode != LanguageCode.EN) Translate();
         }
         }
 
 
-        private void Translate()
-        {
+        private void Translate() {
             Dictionary<string, string> translationList = OptionsHelper.TranslationList.ToObject<Dictionary<string, string>>();
             Dictionary<string, string> translationList = OptionsHelper.TranslationList.ToObject<Dictionary<string, string>>();
 
 
             Control element;
             Control element;
 
 
-            foreach (var x in translationList)
-            {
+            foreach (var x in translationList) {
                 if (x.Key == null || x.Key == string.Empty) continue;
                 if (x.Key == null || x.Key == string.Empty) continue;
                 element = this.Controls.Find(x.Key, true).FirstOrDefault();
                 element = this.Controls.Find(x.Key, true).FirstOrDefault();
 
 
@@ -37,20 +32,16 @@ namespace Optimizer
             }
             }
         }
         }
 
 
-        private void btnOK_Click(object sender, EventArgs e)
-        {
+        private void btnOK_Click(object sender, EventArgs e) {
             this.Close();
             this.Close();
         }
         }
 
 
-        private void Info_Load(object sender, EventArgs e)
-        {
+        private void Info_Load(object sender, EventArgs e) {
 
 
         }
         }
 
 
-        private void copyIPB_Click(object sender, EventArgs e)
-        {
-            try
-            {
+        private void copyIPB_Click(object sender, EventArgs e) {
+            try {
                 Clipboard.SetText(txtInfo.Text);
                 Clipboard.SetText(txtInfo.Text);
             }
             }
             catch { }
             catch { }

文件差异内容过多而无法显示
+ 199 - 219
Optimizer/Forms/MainForm.Designer.cs


文件差异内容过多而无法显示
+ 169 - 339
Optimizer/Forms/MainForm.cs


+ 13 - 1
Optimizer/Forms/MainForm.resx

@@ -454,6 +454,18 @@ by pressing the SHIFT key.
 It can also create custom commands
 It can also create custom commands
 for Run Dialog, making it easy to launch
 for Run Dialog, making it easy to launch
 any application only by typing your desired keyword.</value>
 any application only by typing your desired keyword.</value>
+  </data>
+  <data name="pictureBox7.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+    <value>
+        iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
+        wQAADsEBuJFr7QAAAWVJREFUaEPtlktuQjEQBL3gMO8Wuf+pggwtAaGMxvOxXyRKqhXtmR6RRGkZHMfx
+        61HP90CFImpsPbQ8U63J56e1y99llWptDrRghVofgwavVDV80MAdqs4cNGinqmWDBpxB1fsMPTyTqsnQ
+        A48E5Tz2P+eq+w49sDoDvZ9RdV+hoEUvNGtG1X5AIYsRaJ5V1b5DAasRaN6Mqh//5X2GPu+OoKxV1Y8f
+        YJWgnNWl5bsE5Wb8HmCVoNysSw4YQdlZyw8YQVmPpQeMoKzXsgNGUDZiyQEjKBt12QGUy3DJAZTJMv0A
+        gnJZfr+B3f7/A6r+I63+0eneynfoQ68E5TJU/foDOpSNqvp3KOBxBGUjqvYDCnkcQdmIqv0KBWclKBdR
+        dd+hsMdn6POoqsvQgzOpmp+hh2dQ9WzQgJ2q1hw0aIeq44MGrlQ1YtDgFWp9DrSgUq3Nh5ZlqjX10PKI
+        GrsHKmRRzwO0dgXfFG/e7E/jBAAAAABJRU5ErkJggg==
+</value>
   </data>
   </data>
   <data name="pictureBox6.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
   <data name="pictureBox6.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
     <value>
     <value>
@@ -749,7 +761,7 @@ any application only by typing your desired keyword.</value>
         AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
         AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
         LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
         LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
         ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAC0
         ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAC0
-        GgAAAk1TRnQBSQFMAgEBCQEAAXABDwFwAQ8BIAEAASABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAGA
+        GgAAAk1TRnQBSQFMAgEBCQEAAYABDwGAAQ8BIAEAASABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAGA
         AwABYAMAAQEBAAEgBgABwP8A/wD/AP8A/wD/AP8A/wAeAANHAYB0//8AiQADRwGAdP//AIkAAyoBQANH
         AwABYAMAAQEBAAEgBgABwP8A/wD/AP8A/wD/AP8A/wAeAANHAYB0//8AiQADRwGAdP//AIkAAyoBQANH
         AYADRwGAA0cBgANHAYADRwGAA0cBgANHAYADRwGAA0cBgANHAYADRwGAA0cBgANHAYADRwGAA0cBgANH
         AYADRwGAA0cBgANHAYADRwGAA0cBgANHAYADRwGAA0cBgANHAYADRwGAA0cBgANHAYADRwGAA0cBgANH
         AYADRwGAA0cBgANHAYADRwGAA0cBgANHAYADRwGAA0cBgANHAYADRwGAA0cBgANHAYADRwGA/wD/AP8A
         AYADRwGAA0cBgANHAYADRwGAA0cBgANHAYADRwGAA0cBgANHAYADRwGAA0cBgANHAYADRwGA/wD/AP8A

+ 3 - 6
Optimizer/Forms/SplashForm.cs

@@ -1,11 +1,8 @@
 using System.Windows.Forms;
 using System.Windows.Forms;
 
 
-namespace Optimizer
-{
-    public sealed partial class SplashForm : Form
-    {
-        public SplashForm()
-        {
+namespace Optimizer {
+    public sealed partial class SplashForm : Form {
+        public SplashForm() {
             InitializeComponent();
             InitializeComponent();
 
 
             this.DoubleBuffered = true;
             this.DoubleBuffered = true;

+ 11 - 22
Optimizer/Forms/StartupPreviewForm.cs

@@ -4,14 +4,11 @@ using System.IO;
 using System.Linq;
 using System.Linq;
 using System.Windows.Forms;
 using System.Windows.Forms;
 
 
-namespace Optimizer
-{
-    public sealed partial class StartupPreviewForm : Form
-    {
+namespace Optimizer {
+    public sealed partial class StartupPreviewForm : Form {
         string _token = string.Empty;
         string _token = string.Empty;
 
 
-        public StartupPreviewForm(List<BackupStartupItem> items)
-        {
+        public StartupPreviewForm(List<BackupStartupItem> items) {
             InitializeComponent();
             InitializeComponent();
 
 
             CheckForIllegalCrossThreadCalls = false;
             CheckForIllegalCrossThreadCalls = false;
@@ -20,14 +17,11 @@ namespace Optimizer
             // translate UI elements
             // translate UI elements
             if (OptionsHelper.CurrentOptions.LanguageCode != LanguageCode.EN) Translate();
             if (OptionsHelper.CurrentOptions.LanguageCode != LanguageCode.EN) Translate();
 
 
-            foreach (BackupStartupItem x in items)
-            {
-                if (File.Exists(SanitizePath(x.FileLocation)))
-                {
+            foreach (BackupStartupItem x in items) {
+                if (File.Exists(SanitizePath(x.FileLocation))) {
                     _token = "[✓] ";
                     _token = "[✓] ";
                 }
                 }
-                else
-                {
+                else {
                     _token = "[⚠] ";
                     _token = "[⚠] ";
                 }
                 }
 
 
@@ -35,16 +29,14 @@ namespace Optimizer
             }
             }
         }
         }
 
 
-        private void Translate()
-        {
+        private void Translate() {
             this.Text = OptionsHelper.TranslationList["StartupPreviewForm"];
             this.Text = OptionsHelper.TranslationList["StartupPreviewForm"];
 
 
             Dictionary<string, string> translationList = OptionsHelper.TranslationList.ToObject<Dictionary<string, string>>();
             Dictionary<string, string> translationList = OptionsHelper.TranslationList.ToObject<Dictionary<string, string>>();
 
 
             Control element;
             Control element;
 
 
-            foreach (var x in translationList)
-            {
+            foreach (var x in translationList) {
                 if (x.Key == null || x.Key == string.Empty) continue;
                 if (x.Key == null || x.Key == string.Empty) continue;
                 element = this.Controls.Find(x.Key, true).FirstOrDefault();
                 element = this.Controls.Find(x.Key, true).FirstOrDefault();
 
 
@@ -54,18 +46,15 @@ namespace Optimizer
             }
             }
         }
         }
 
 
-        private void StartupPreviewForm_Load(object sender, EventArgs e)
-        {
+        private void StartupPreviewForm_Load(object sender, EventArgs e) {
             this.Focus();
             this.Focus();
         }
         }
 
 
-        private string SanitizePath(string s)
-        {
+        private string SanitizePath(string s) {
             s = s.Replace("\"", string.Empty);
             s = s.Replace("\"", string.Empty);
             int i;
             int i;
 
 
-            while (s.Contains("/"))
-            {
+            while (s.Contains("/")) {
                 i = s.LastIndexOf("/");
                 i = s.LastIndexOf("/");
                 s = s.Substring(0, i);
                 s = s.Substring(0, i);
             }
             }

+ 32 - 64
Optimizer/Forms/StartupRestoreForm.cs

@@ -6,14 +6,11 @@ using System.IO;
 using System.Linq;
 using System.Linq;
 using System.Windows.Forms;
 using System.Windows.Forms;
 
 
-namespace Optimizer
-{
-    public sealed partial class StartupRestoreForm : Form
-    {
+namespace Optimizer {
+    public sealed partial class StartupRestoreForm : Form {
         string[] _backups;
         string[] _backups;
 
 
-        public StartupRestoreForm()
-        {
+        public StartupRestoreForm() {
             InitializeComponent();
             InitializeComponent();
 
 
             CheckForIllegalCrossThreadCalls = false;
             CheckForIllegalCrossThreadCalls = false;
@@ -25,32 +22,28 @@ namespace Optimizer
             RefreshBackups();
             RefreshBackups();
         }
         }
 
 
-        private void RefreshBackups()
-        {
+        private void RefreshBackups() {
             _backups = Directory.GetFiles(CoreHelper.StartupItemsBackupFolder, "*.json");
             _backups = Directory.GetFiles(CoreHelper.StartupItemsBackupFolder, "*.json");
             Array.Reverse(_backups);
             Array.Reverse(_backups);
             listRestoreItems.Items.Clear();
             listRestoreItems.Items.Clear();
 
 
             txtNoBackups.Visible = _backups.Length == 0;
             txtNoBackups.Visible = _backups.Length == 0;
 
 
-            foreach (string x in _backups)
-            {
+            foreach (string x in _backups) {
                 listRestoreItems.Items.Add(Path.GetFileNameWithoutExtension(x));
                 listRestoreItems.Items.Add(Path.GetFileNameWithoutExtension(x));
             }
             }
 
 
             if (_backups.Any()) listRestoreItems.SelectedIndex = 0;
             if (_backups.Any()) listRestoreItems.SelectedIndex = 0;
         }
         }
 
 
-        private void Translate()
-        {
+        private void Translate() {
             this.Text = OptionsHelper.TranslationList["StartupRestoreForm"];
             this.Text = OptionsHelper.TranslationList["StartupRestoreForm"];
 
 
             Dictionary<string, string> translationList = OptionsHelper.TranslationList.ToObject<Dictionary<string, string>>();
             Dictionary<string, string> translationList = OptionsHelper.TranslationList.ToObject<Dictionary<string, string>>();
 
 
             Control element;
             Control element;
 
 
-            foreach (var x in translationList)
-            {
+            foreach (var x in translationList) {
                 if (x.Key == null || x.Key == string.Empty) continue;
                 if (x.Key == null || x.Key == string.Empty) continue;
                 element = this.Controls.Find(x.Key, true).FirstOrDefault();
                 element = this.Controls.Find(x.Key, true).FirstOrDefault();
 
 
@@ -60,24 +53,18 @@ namespace Optimizer
             }
             }
         }
         }
 
 
-        private void StartupRestoreForm_Load(object sender, EventArgs e)
-        {
+        private void StartupRestoreForm_Load(object sender, EventArgs e) {
 
 
         }
         }
 
 
         // DeleteStartupBackup
         // DeleteStartupBackup
-        private void button2_Click(object sender, EventArgs e)
-        {
-            if (listRestoreItems.SelectedIndex > -1)
-            {
-                if (MessageBox.Show("Do you really want to delete this backup?", "Delete Backup?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
-                {
-                    try
-                    {
+        private void button2_Click(object sender, EventArgs e) {
+            if (listRestoreItems.SelectedIndex > -1) {
+                if (MessageBox.Show("Do you really want to delete this backup?", "Delete Backup?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) {
+                    try {
                         File.Delete(_backups[listRestoreItems.SelectedIndex]);
                         File.Delete(_backups[listRestoreItems.SelectedIndex]);
                     }
                     }
-                    catch (Exception ex)
-                    {
+                    catch (Exception ex) {
                         Logger.LogError("StartupRestoreForm.DeleteStartupBackup", ex.Message, ex.StackTrace);
                         Logger.LogError("StartupRestoreForm.DeleteStartupBackup", ex.Message, ex.StackTrace);
                     }
                     }
 
 
@@ -86,88 +73,69 @@ namespace Optimizer
             }
             }
         }
         }
 
 
-        private void ShowPreview()
-        {
-            if (listRestoreItems.SelectedIndex > -1)
-            {
+        private void ShowPreview() {
+            if (listRestoreItems.SelectedIndex > -1) {
                 List<BackupStartupItem> backup = JsonConvert.DeserializeObject<List<BackupStartupItem>>(File.ReadAllText(_backups[listRestoreItems.SelectedIndex]));
                 List<BackupStartupItem> backup = JsonConvert.DeserializeObject<List<BackupStartupItem>>(File.ReadAllText(_backups[listRestoreItems.SelectedIndex]));
                 StartupPreviewForm f = new StartupPreviewForm(backup);
                 StartupPreviewForm f = new StartupPreviewForm(backup);
                 f.ShowDialog(this);
                 f.ShowDialog(this);
             }
             }
         }
         }
 
 
-        private void button39_Click(object sender, EventArgs e)
-        {
+        private void button39_Click(object sender, EventArgs e) {
             ShowPreview();
             ShowPreview();
         }
         }
 
 
-        private void listRestoreItems_MouseDoubleClick(object sender, MouseEventArgs e)
-        {
+        private void listRestoreItems_MouseDoubleClick(object sender, MouseEventArgs e) {
             ShowPreview();
             ShowPreview();
         }
         }
 
 
         // RestoreStartupBackup
         // RestoreStartupBackup
-        private void button1_Click(object sender, EventArgs e)
-        {
-            if (listRestoreItems.SelectedIndex > -1)
-            {
+        private void button1_Click(object sender, EventArgs e) {
+            if (listRestoreItems.SelectedIndex > -1) {
                 List<BackupStartupItem> backup = JsonConvert.DeserializeObject<List<BackupStartupItem>>(File.ReadAllText(_backups[listRestoreItems.SelectedIndex]));
                 List<BackupStartupItem> backup = JsonConvert.DeserializeObject<List<BackupStartupItem>>(File.ReadAllText(_backups[listRestoreItems.SelectedIndex]));
 
 
                 string keyPath = string.Empty;
                 string keyPath = string.Empty;
                 RegistryKey hive = null;
                 RegistryKey hive = null;
 
 
-                foreach (BackupStartupItem x in backup)
-                {
-                    if (x.RegistryLocation == StartupItemLocation.HKLM.ToString())
-                    {
+                foreach (BackupStartupItem x in backup) {
+                    if (x.RegistryLocation == StartupItemLocation.HKLM.ToString()) {
                         hive = Registry.LocalMachine;
                         hive = Registry.LocalMachine;
 
 
-                        if (x.StartupType == StartupItemType.Run.ToString())
-                        {
+                        if (x.StartupType == StartupItemType.Run.ToString()) {
                             keyPath = StartupHelper.LocalMachineRun;
                             keyPath = StartupHelper.LocalMachineRun;
                         }
                         }
-                        else if (x.StartupType == StartupItemType.RunOnce.ToString())
-                        {
+                        else if (x.StartupType == StartupItemType.RunOnce.ToString()) {
                             keyPath = StartupHelper.LocalMachineRunOnce;
                             keyPath = StartupHelper.LocalMachineRunOnce;
                         }
                         }
                     }
                     }
-                    else if (x.RegistryLocation == StartupItemLocation.HKLMWoW.ToString())
-                    {
+                    else if (x.RegistryLocation == StartupItemLocation.HKLMWoW.ToString()) {
                         hive = Registry.LocalMachine;
                         hive = Registry.LocalMachine;
 
 
-                        if (x.StartupType == StartupItemType.Run.ToString())
-                        {
+                        if (x.StartupType == StartupItemType.Run.ToString()) {
                             keyPath = StartupHelper.LocalMachineRunWoW;
                             keyPath = StartupHelper.LocalMachineRunWoW;
                         }
                         }
-                        else if (x.StartupType == StartupItemType.RunOnce.ToString())
-                        {
+                        else if (x.StartupType == StartupItemType.RunOnce.ToString()) {
                             keyPath = StartupHelper.LocalMachineRunOnceWow;
                             keyPath = StartupHelper.LocalMachineRunOnceWow;
                         }
                         }
                     }
                     }
-                    else if (x.RegistryLocation == StartupItemLocation.HKCU.ToString())
-                    {
+                    else if (x.RegistryLocation == StartupItemLocation.HKCU.ToString()) {
                         hive = Registry.CurrentUser;
                         hive = Registry.CurrentUser;
 
 
-                        if (x.StartupType == StartupItemType.Run.ToString())
-                        {
+                        if (x.StartupType == StartupItemType.Run.ToString()) {
                             keyPath = StartupHelper.CurrentUserRun;
                             keyPath = StartupHelper.CurrentUserRun;
                         }
                         }
-                        else if (x.StartupType == StartupItemType.RunOnce.ToString())
-                        {
+                        else if (x.StartupType == StartupItemType.RunOnce.ToString()) {
                             keyPath = StartupHelper.CurrentUserRunOnce;
                             keyPath = StartupHelper.CurrentUserRunOnce;
                         }
                         }
                     }
                     }
 
 
-                    if (hive != null)
-                    {
-                        try
-                        {
+                    if (hive != null) {
+                        try {
                             RegistryKey key = hive.OpenSubKey(keyPath, true);
                             RegistryKey key = hive.OpenSubKey(keyPath, true);
                             key.SetValue(x.Name, x.FileLocation, RegistryValueKind.String);
                             key.SetValue(x.Name, x.FileLocation, RegistryValueKind.String);
 
 
                         }
                         }
-                        catch (Exception ex)
-                        {
+                        catch (Exception ex) {
                             Logger.LogError("StartupRestoreForm.RestoreStartupBackup", ex.Message, ex.StackTrace);
                             Logger.LogError("StartupRestoreForm.RestoreStartupBackup", ex.Message, ex.StackTrace);
                         }
                         }
                     }
                     }

+ 6 - 12
Optimizer/Forms/SubForm.cs

@@ -1,12 +1,9 @@
 using System;
 using System;
 using System.Windows.Forms;
 using System.Windows.Forms;
 
 
-namespace Optimizer
-{
-    public sealed partial class SubForm : Form
-    {
-        public SubForm()
-        {
+namespace Optimizer {
+    public sealed partial class SubForm : Form {
+        public SubForm() {
             InitializeComponent();
             InitializeComponent();
 
 
             CheckForIllegalCrossThreadCalls = false;
             CheckForIllegalCrossThreadCalls = false;
@@ -17,20 +14,17 @@ namespace Optimizer
             btnStart.Select();
             btnStart.Select();
         }
         }
 
 
-        internal void SetTip(string tip)
-        {
+        internal void SetTip(string tip) {
             txtInfo.Text = tip;
             txtInfo.Text = tip;
             btnStart.Focus();
             btnStart.Focus();
             btnStart.Select();
             btnStart.Select();
         }
         }
 
 
-        private void btnStart_Click(object sender, EventArgs e)
-        {
+        private void btnStart_Click(object sender, EventArgs e) {
             this.Close();
             this.Close();
         }
         }
 
 
-        private void SubForm_Load(object sender, EventArgs e)
-        {
+        private void SubForm_Load(object sender, EventArgs e) {
             OptionsHelper.ApplyTheme(this);
             OptionsHelper.ApplyTheme(this);
         }
         }
     }
     }

+ 6 - 12
Optimizer/Forms/UpdateForm.cs

@@ -2,20 +2,16 @@
 using System.Drawing;
 using System.Drawing;
 using System.Windows.Forms;
 using System.Windows.Forms;
 
 
-namespace Optimizer
-{
-    public sealed partial class UpdateForm : Form
-    {
-        public UpdateForm(string message, bool newUpdate, string changelog, string latestVersion)
-        {
+namespace Optimizer {
+    public sealed partial class UpdateForm : Form {
+        public UpdateForm(string message, bool newUpdate, string changelog, string latestVersion) {
             InitializeComponent();
             InitializeComponent();
             CheckForIllegalCrossThreadCalls = false;
             CheckForIllegalCrossThreadCalls = false;
             OptionsHelper.ApplyTheme(this);
             OptionsHelper.ApplyTheme(this);
 
 
             txtMessage.Text = message;
             txtMessage.Text = message;
 
 
-            if (newUpdate)
-            {
+            if (newUpdate) {
                 this.Size = new Size(600, 545);
                 this.Size = new Size(600, 545);
                 btnOK.Text = OptionsHelper.TranslationList["btnYes"].ToString();
                 btnOK.Text = OptionsHelper.TranslationList["btnYes"].ToString();
                 btnNo.Text = OptionsHelper.TranslationList["btnNo"].ToString();
                 btnNo.Text = OptionsHelper.TranslationList["btnNo"].ToString();
@@ -31,8 +27,7 @@ namespace Optimizer
                 txtInfo.Visible = true;
                 txtInfo.Visible = true;
                 txtChanges.Visible = true;
                 txtChanges.Visible = true;
             }
             }
-            else
-            {
+            else {
                 this.Size = new Size(600, 188);
                 this.Size = new Size(600, 188);
                 btnOK.Text = OptionsHelper.TranslationList["btnAbout"].ToString();
                 btnOK.Text = OptionsHelper.TranslationList["btnAbout"].ToString();
                 btnNo.Visible = false;
                 btnNo.Visible = false;
@@ -45,8 +40,7 @@ namespace Optimizer
             }
             }
         }
         }
 
 
-        private void UpdateForm_Load(object sender, EventArgs e)
-        {
+        private void UpdateForm_Load(object sender, EventArgs e) {
 
 
         }
         }
     }
     }

+ 43 - 86
Optimizer/HostsHelper.cs

@@ -6,44 +6,34 @@ using System.Text;
 using System.Text.RegularExpressions;
 using System.Text.RegularExpressions;
 using System.Windows.Forms;
 using System.Windows.Forms;
 
 
-namespace Optimizer
-{
-    internal static class HostsHelper
-    {
+namespace Optimizer {
+    internal static class HostsHelper {
         internal static string NewLine = Environment.NewLine;
         internal static string NewLine = Environment.NewLine;
         internal static readonly string HostsFile = CleanHelper.System32Folder + "\\drivers\\etc\\hosts";
         internal static readonly string HostsFile = CleanHelper.System32Folder + "\\drivers\\etc\\hosts";
 
 
-        internal static void RestoreDefaultHosts()
-        {
-            try
-            {
-                if (File.Exists(HostsFile))
-                {
+        internal static void RestoreDefaultHosts() {
+            try {
+                if (File.Exists(HostsFile)) {
                     File.Delete(HostsFile);
                     File.Delete(HostsFile);
                 }
                 }
 
 
                 File.WriteAllBytes(HostsFile, Properties.Resources.hosts);
                 File.WriteAllBytes(HostsFile, Properties.Resources.hosts);
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("HostsHelper.RestoreDefaultHosts", ex.Message, ex.StackTrace);
                 Logger.LogError("HostsHelper.RestoreDefaultHosts", ex.Message, ex.StackTrace);
                 MessageBox.Show(OptionsHelper.TranslationList("dnsCacheM").ToString(), "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 MessageBox.Show(OptionsHelper.TranslationList("dnsCacheM").ToString(), "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             }
         }
         }
 
 
-        internal static string[] ReadHosts()
-        {
+        internal static string[] ReadHosts() {
             StringBuilder sb = new StringBuilder();
             StringBuilder sb = new StringBuilder();
 
 
-            try
-            {
-                using (StreamReader sr = File.OpenText(HostsFile))
-                {
+            try {
+                using (StreamReader sr = File.OpenText(HostsFile)) {
                     sb.Append(sr.ReadToEnd());
                     sb.Append(sr.ReadToEnd());
                 }
                 }
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("HostsHelper.ReadHosts", ex.Message, ex.StackTrace);
                 Logger.LogError("HostsHelper.ReadHosts", ex.Message, ex.StackTrace);
             }
             }
 
 
@@ -51,63 +41,50 @@ namespace Optimizer
             //return File.ReadAllLines(HostsFile);
             //return File.ReadAllLines(HostsFile);
         }
         }
 
 
-        internal static string ReadHostsFast()
-        {
+        internal static string ReadHostsFast() {
             StringBuilder sb = new StringBuilder();
             StringBuilder sb = new StringBuilder();
 
 
-            try
-            {
-                using (StreamReader sr = File.OpenText(HostsFile))
-                {
+            try {
+                using (StreamReader sr = File.OpenText(HostsFile)) {
                     sb.Append(sr.ReadToEnd());
                     sb.Append(sr.ReadToEnd());
                 }
                 }
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("HostsHelper.ReadHostsFast", ex.Message, ex.StackTrace);
                 Logger.LogError("HostsHelper.ReadHostsFast", ex.Message, ex.StackTrace);
             }
             }
 
 
             return sb.ToString();
             return sb.ToString();
         }
         }
 
 
-        internal static void LocateHosts()
-        {
+        internal static void LocateHosts() {
             Utilities.FindFile(HostsFile);
             Utilities.FindFile(HostsFile);
         }
         }
 
 
-        internal static void SaveHosts(string[] lines)
-        {
-            for (int i = 0; i < lines.Length; i++)
-            {
-                if (!lines[i].StartsWith("#") && (!string.IsNullOrEmpty(lines[i])))
-                {
+        internal static void SaveHosts(string[] lines) {
+            for (int i = 0; i < lines.Length; i++) {
+                if (!lines[i].StartsWith("#") && (!string.IsNullOrEmpty(lines[i]))) {
                     lines[i] = SanitizeEntry(lines[i]);
                     lines[i] = SanitizeEntry(lines[i]);
                 }
                 }
             }
             }
 
 
-            try
-            {
+            try {
                 File.WriteAllText(HostsFile, string.Empty);
                 File.WriteAllText(HostsFile, string.Empty);
                 File.WriteAllLines(HostsFile, lines);
                 File.WriteAllLines(HostsFile, lines);
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("HostsHelper.SaveHosts", ex.Message, ex.StackTrace);
                 Logger.LogError("HostsHelper.SaveHosts", ex.Message, ex.StackTrace);
                 MessageBox.Show(OptionsHelper.TranslationList("dnsCacheM").ToString(), "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 MessageBox.Show(OptionsHelper.TranslationList("dnsCacheM").ToString(), "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             }
         }
         }
 
 
-        internal static List<string> GetHostsEntries()
-        {
+        internal static List<string> GetHostsEntries() {
             List<string> entries = new List<string>();
             List<string> entries = new List<string>();
 
 
             //string[] lines = File.ReadAllLines(HostsFile);
             //string[] lines = File.ReadAllLines(HostsFile);
             string[] lines = ReadHosts();
             string[] lines = ReadHosts();
 
 
-            foreach (string line in lines)
-            {
-                if (!line.StartsWith("#") && (!string.IsNullOrEmpty(line)))
-                {
+            foreach (string line in lines) {
+                if (!line.StartsWith("#") && (!string.IsNullOrEmpty(line))) {
                     entries.Add(line.Replace(" ", " : "));
                     entries.Add(line.Replace(" ", " : "));
                 }
                 }
             }
             }
@@ -115,88 +92,68 @@ namespace Optimizer
             return entries;
             return entries;
         }
         }
 
 
-        internal static void AddEntry(string entry)
-        {
-            try
-            {
+        internal static void AddEntry(string entry) {
+            try {
                 File.AppendAllText(HostsFile, NewLine + $"{entry}");
                 File.AppendAllText(HostsFile, NewLine + $"{entry}");
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("HostsHelper.AddEntry", ex.Message, ex.StackTrace);
                 Logger.LogError("HostsHelper.AddEntry", ex.Message, ex.StackTrace);
                 MessageBox.Show(OptionsHelper.TranslationList("dnsCacheM").ToString(), "DNS Cache is running", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 MessageBox.Show(OptionsHelper.TranslationList("dnsCacheM").ToString(), "DNS Cache is running", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             }
         }
         }
 
 
-        internal static void RemoveEntry(string entry)
-        {
-            try
-            {
+        internal static void RemoveEntry(string entry) {
+            try {
                 File.WriteAllLines(HostsFile, File.ReadLines(HostsFile).Where(x => x != entry).ToList());
                 File.WriteAllLines(HostsFile, File.ReadLines(HostsFile).Where(x => x != entry).ToList());
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("HostsHelper.RemoveEntry", ex.Message, ex.StackTrace);
                 Logger.LogError("HostsHelper.RemoveEntry", ex.Message, ex.StackTrace);
                 MessageBox.Show(OptionsHelper.TranslationList("dnsCacheM").ToString(), "DNS Cache is running", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 MessageBox.Show(OptionsHelper.TranslationList("dnsCacheM").ToString(), "DNS Cache is running", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             }
         }
         }
 
 
-        internal static void RemoveEntryFromTemplate(string domain)
-        {
-            try
-            {
+        internal static void RemoveEntryFromTemplate(string domain) {
+            try {
                 File.WriteAllLines(HostsFile, File.ReadLines(HostsFile).Where(x => !x.Contains(domain)).ToList());
                 File.WriteAllLines(HostsFile, File.ReadLines(HostsFile).Where(x => !x.Contains(domain)).ToList());
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("HostsHelper.RemoveEntryFromTemplate", ex.Message, ex.StackTrace);
                 Logger.LogError("HostsHelper.RemoveEntryFromTemplate", ex.Message, ex.StackTrace);
             }
             }
         }
         }
 
 
-        internal static void RemoveAllEntries(List<string> collection)
-        {
-            try
-            {
-                foreach (string text in collection)
-                {
+        internal static void RemoveAllEntries(List<string> collection) {
+            try {
+                foreach (string text in collection) {
                     File.WriteAllLines(HostsFile, File.ReadLines(HostsFile).Where(l => l != text).ToList());
                     File.WriteAllLines(HostsFile, File.ReadLines(HostsFile).Where(l => l != text).ToList());
                 }
                 }
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("HostsHelper.RemoveAllEntries", ex.Message, ex.StackTrace);
                 Logger.LogError("HostsHelper.RemoveAllEntries", ex.Message, ex.StackTrace);
                 MessageBox.Show(OptionsHelper.TranslationList("dnsCacheM").ToString(), "DNS Cache is running", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 MessageBox.Show(OptionsHelper.TranslationList("dnsCacheM").ToString(), "DNS Cache is running", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             }
         }
         }
 
 
-        internal static string SanitizeEntry(string entry)
-        {
+        internal static string SanitizeEntry(string entry) {
             // remove multiple white spaces and keep only one
             // remove multiple white spaces and keep only one
             return Regex.Replace(entry, @"\s{2,}", " ");
             return Regex.Replace(entry, @"\s{2,}", " ");
         }
         }
 
 
-        internal static bool GetReadOnly()
-        {
-            try
-            {
+        internal static bool GetReadOnly() {
+            try {
                 return new FileInfo(HostsFile).IsReadOnly;
                 return new FileInfo(HostsFile).IsReadOnly;
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("HostsHelper.ReadOnly", ex.Message, ex.StackTrace);
                 Logger.LogError("HostsHelper.ReadOnly", ex.Message, ex.StackTrace);
                 return false;
                 return false;
             }
             }
         }
         }
 
 
-        internal static void ReadOnly(bool enable)
-        {
-            try
-            {
+        internal static void ReadOnly(bool enable) {
+            try {
                 FileInfo fi = new FileInfo(HostsFile);
                 FileInfo fi = new FileInfo(HostsFile);
                 fi.IsReadOnly = enable;
                 fi.IsReadOnly = enable;
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("HostsHelper.ReadOnly", ex.Message, ex.StackTrace);
                 Logger.LogError("HostsHelper.ReadOnly", ex.Message, ex.StackTrace);
             }
             }
         }
         }

+ 76 - 152
Optimizer/IndiciumHelper.cs

@@ -3,10 +3,8 @@ using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Management;
 using System.Management;
 
 
-namespace Optimizer
-{
-    public static class IndiciumHelper
-    {
+namespace Optimizer {
+    public static class IndiciumHelper {
         public static List<Volume> Volumes = new List<Volume>();
         public static List<Volume> Volumes = new List<Volume>();
         public static List<Volume> Opticals = new List<Volume>();
         public static List<Volume> Opticals = new List<Volume>();
         public static List<Volume> Removables = new List<Volume>();
         public static List<Volume> Removables = new List<Volume>();
@@ -17,16 +15,13 @@ namespace Optimizer
         public static List<Keyboard> Keyboards = new List<Keyboard>();
         public static List<Keyboard> Keyboards = new List<Keyboard>();
         public static List<PointingDevice> PointingDevices = new List<PointingDevice>();
         public static List<PointingDevice> PointingDevices = new List<PointingDevice>();
 
 
-        public static List<CPU> GetCPUs()
-        {
+        public static List<CPU> GetCPUs() {
             List<CPU> CPUs = new List<CPU>();
             List<CPU> CPUs = new List<CPU>();
             CPU cpu;
             CPU cpu;
 
 
-            try
-            {
+            try {
                 ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_Processor");
                 ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_Processor");
-                foreach (ManagementObject mo in searcher.Get())
-                {
+                foreach (ManagementObject mo in searcher.Get()) {
                     cpu = new CPU();
                     cpu = new CPU();
 
 
                     cpu.Name = Convert.ToString(mo.Properties["Name"].Value);
                     cpu.Name = Convert.ToString(mo.Properties["Name"].Value);
@@ -39,30 +34,25 @@ namespace Optimizer
 
 
                     cpu.LogicalCpus = Convert.ToUInt32(mo.Properties["NumberOfLogicalProcessors"].Value);
                     cpu.LogicalCpus = Convert.ToUInt32(mo.Properties["NumberOfLogicalProcessors"].Value);
 
 
-                    if (Utilities.CurrentWindowsVersion != WindowsVersion.Windows7)
-                    {
+                    if (Utilities.CurrentWindowsVersion != WindowsVersion.Windows7) {
                         bool temp = Convert.ToBoolean(mo.Properties["VirtualizationFirmwareEnabled"].Value);
                         bool temp = Convert.ToBoolean(mo.Properties["VirtualizationFirmwareEnabled"].Value);
                         cpu.Virtualization = (temp) ? "Yes" : "No";
                         cpu.Virtualization = (temp) ? "Yes" : "No";
                     }
                     }
-                    else
-                    {
+                    else {
                         cpu.Virtualization = "-";
                         cpu.Virtualization = "-";
                     }
                     }
 
 
                     cpu.Stepping = Convert.ToString(mo.Properties["Description"].Value);
                     cpu.Stepping = Convert.ToString(mo.Properties["Description"].Value);
                     cpu.Revision = Convert.ToString(mo.Properties["Revision"].Value);
                     cpu.Revision = Convert.ToString(mo.Properties["Revision"].Value);
 
 
-                    try
-                    {
+                    try {
                         ManagementObjectSearcher searcher2 = new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem");
                         ManagementObjectSearcher searcher2 = new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem");
-                        foreach (ManagementObject mo2 in searcher2.Get())
-                        {
+                        foreach (ManagementObject mo2 in searcher2.Get()) {
                             bool temp2 = Convert.ToBoolean(mo2.Properties["DataExecutionPrevention_Available"].Value);
                             bool temp2 = Convert.ToBoolean(mo2.Properties["DataExecutionPrevention_Available"].Value);
                             cpu.DataExecutionPrevention = (temp2) ? "Yes" : "No";
                             cpu.DataExecutionPrevention = (temp2) ? "Yes" : "No";
                         }
                         }
                     }
                     }
-                    catch
-                    {
+                    catch {
                         cpu.DataExecutionPrevention = "-";
                         cpu.DataExecutionPrevention = "-";
                     }
                     }
 
 
@@ -71,54 +61,44 @@ namespace Optimizer
                     CPUs.Add(cpu);
                     CPUs.Add(cpu);
                 }
                 }
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("IndiciumHelper.GetCPUs", ex.Message, ex.StackTrace);
                 Logger.LogError("IndiciumHelper.GetCPUs", ex.Message, ex.StackTrace);
             }
             }
 
 
             return CPUs;
             return CPUs;
         }
         }
 
 
-        private static string GetCPUNameAlternative()
-        {
-            using (RegistryKey key = Registry.LocalMachine.OpenSubKey(@"HARDWARE\DESCRIPTION\System\CentralProcessor\0", false))
-            {
+        private static string GetCPUNameAlternative() {
+            using (RegistryKey key = Registry.LocalMachine.OpenSubKey(@"HARDWARE\DESCRIPTION\System\CentralProcessor\0", false)) {
                 return key.GetValue("ProcessorNameString").ToString();
                 return key.GetValue("ProcessorNameString").ToString();
             }
             }
         }
         }
 
 
-        public static VirtualMemory GetVM()
-        {
+        public static VirtualMemory GetVM() {
             VirtualMemory vm = new VirtualMemory();
             VirtualMemory vm = new VirtualMemory();
 
 
-            try
-            {
+            try {
                 ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem");
                 ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem");
-                foreach (ManagementObject mo in searcher.Get())
-                {
+                foreach (ManagementObject mo in searcher.Get()) {
                     vm.TotalVirtualMemory = ByteSize.FromKiloBytes(Convert.ToUInt64(mo.Properties["TotalVirtualMemorySize"].Value));
                     vm.TotalVirtualMemory = ByteSize.FromKiloBytes(Convert.ToUInt64(mo.Properties["TotalVirtualMemorySize"].Value));
                     vm.AvailableVirtualMemory = ByteSize.FromKiloBytes(Convert.ToUInt64(mo.Properties["FreeVirtualMemory"].Value));
                     vm.AvailableVirtualMemory = ByteSize.FromKiloBytes(Convert.ToUInt64(mo.Properties["FreeVirtualMemory"].Value));
                     vm.UsedVirtualMemory = vm.TotalVirtualMemory.Subtract(vm.AvailableVirtualMemory);
                     vm.UsedVirtualMemory = vm.TotalVirtualMemory.Subtract(vm.AvailableVirtualMemory);
                 }
                 }
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("IndiciumHelper.GetVM", ex.Message, ex.StackTrace);
                 Logger.LogError("IndiciumHelper.GetVM", ex.Message, ex.StackTrace);
             }
             }
 
 
             return vm;
             return vm;
         }
         }
 
 
-        public static List<RAM> GetRAM()
-        {
+        public static List<RAM> GetRAM() {
             List<RAM> modules = new List<RAM>();
             List<RAM> modules = new List<RAM>();
             RAM module;
             RAM module;
 
 
-            try
-            {
+            try {
                 ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMemory");
                 ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMemory");
-                foreach (ManagementObject mo in searcher.Get())
-                {
+                foreach (ManagementObject mo in searcher.Get()) {
                     module = new RAM();
                     module = new RAM();
 
 
                     module.BankLabel = Convert.ToString(mo.Properties["BankLabel"].Value);
                     module.BankLabel = Convert.ToString(mo.Properties["BankLabel"].Value);
@@ -133,23 +113,19 @@ namespace Optimizer
                     modules.Add(module);
                     modules.Add(module);
                 }
                 }
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("IndiciumHelper.GetRAM", ex.Message, ex.StackTrace);
                 Logger.LogError("IndiciumHelper.GetRAM", ex.Message, ex.StackTrace);
             }
             }
 
 
             return modules;
             return modules;
         }
         }
 
 
-        public static List<Motherboard> GetMotherboards()
-        {
+        public static List<Motherboard> GetMotherboards() {
             List<Motherboard> mobos = new List<Motherboard>();
             List<Motherboard> mobos = new List<Motherboard>();
 
 
-            try
-            {
+            try {
                 ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_BaseBoard");
                 ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_BaseBoard");
-                foreach (ManagementObject mo in searcher.Get())
-                {
+                foreach (ManagementObject mo in searcher.Get()) {
                     Motherboard mobo = new Motherboard();
                     Motherboard mobo = new Motherboard();
 
 
                     mobo.Model = Convert.ToString(mo.Properties["Model"].Value);
                     mobo.Model = Convert.ToString(mo.Properties["Model"].Value);
@@ -157,39 +133,32 @@ namespace Optimizer
                     mobo.Product = Convert.ToString(mo.Properties["Product"].Value);
                     mobo.Product = Convert.ToString(mo.Properties["Product"].Value);
                     mobo.Version = Convert.ToString(mo.Properties["Version"].Value);
                     mobo.Version = Convert.ToString(mo.Properties["Version"].Value);
 
 
-                    try
-                    {
+                    try {
                         ManagementObjectSearcher searcher2 = new ManagementObjectSearcher("SELECT * FROM Win32_IDEController");
                         ManagementObjectSearcher searcher2 = new ManagementObjectSearcher("SELECT * FROM Win32_IDEController");
-                        foreach (ManagementObject mo2 in searcher2.Get())
-                        {
+                        foreach (ManagementObject mo2 in searcher2.Get()) {
                             mobo.Chipset = Convert.ToString(mo2.Properties["Description"].Value);
                             mobo.Chipset = Convert.ToString(mo2.Properties["Description"].Value);
                         }
                         }
                     }
                     }
                     catch { }
                     catch { }
 
 
-                    try
-                    {
+                    try {
                         ManagementObjectSearcher searcher3 = new ManagementObjectSearcher("SELECT * FROM Win32_IDEController");
                         ManagementObjectSearcher searcher3 = new ManagementObjectSearcher("SELECT * FROM Win32_IDEController");
-                        foreach (ManagementObject mo3 in searcher3.Get())
-                        {
+                        foreach (ManagementObject mo3 in searcher3.Get()) {
                             mobo.Revision = Convert.ToString(mo3.Properties["RevisionNumber"].Value);
                             mobo.Revision = Convert.ToString(mo3.Properties["RevisionNumber"].Value);
                         }
                         }
                     }
                     }
                     catch { }
                     catch { }
 
 
-                    try
-                    {
+                    try {
                         ManagementObjectSearcher searcher4 = new ManagementObjectSearcher("SELECT * FROM Win32_ComputerSystem");
                         ManagementObjectSearcher searcher4 = new ManagementObjectSearcher("SELECT * FROM Win32_ComputerSystem");
-                        foreach (ManagementObject mo4 in searcher4.Get())
-                        {
+                        foreach (ManagementObject mo4 in searcher4.Get()) {
                             mobo.SystemModel = Convert.ToString(mo4.Properties["Model"].Value);
                             mobo.SystemModel = Convert.ToString(mo4.Properties["Model"].Value);
                         }
                         }
                     }
                     }
                     catch { }
                     catch { }
 
 
                     ManagementObjectSearcher searcher5 = new ManagementObjectSearcher("SELECT * FROM Win32_BIOS");
                     ManagementObjectSearcher searcher5 = new ManagementObjectSearcher("SELECT * FROM Win32_BIOS");
-                    foreach (ManagementObject mo5 in searcher5.Get())
-                    {
+                    foreach (ManagementObject mo5 in searcher5.Get()) {
                         mobo.BIOSName = Convert.ToString(mo5.Properties["Name"].Value);
                         mobo.BIOSName = Convert.ToString(mo5.Properties["Name"].Value);
                         mobo.BIOSManufacturer = Convert.ToString(mo5.Properties["Manufacturer"].Value);
                         mobo.BIOSManufacturer = Convert.ToString(mo5.Properties["Manufacturer"].Value);
                         mobo.BIOSVersion = Convert.ToString(mo5.Properties["Version"].Value);
                         mobo.BIOSVersion = Convert.ToString(mo5.Properties["Version"].Value);
@@ -200,23 +169,19 @@ namespace Optimizer
                     mobos.Add(mobo);
                     mobos.Add(mobo);
                 }
                 }
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("IndiciumHelper.GetMotherboards", ex.Message, ex.StackTrace);
                 Logger.LogError("IndiciumHelper.GetMotherboards", ex.Message, ex.StackTrace);
             }
             }
 
 
             return mobos;
             return mobos;
         }
         }
 
 
-        public static List<Disk> GetDisks()
-        {
+        public static List<Disk> GetDisks() {
             List<Disk> disks = new List<Disk>();
             List<Disk> disks = new List<Disk>();
 
 
-            try
-            {
+            try {
                 ManagementObjectSearcher searcher2 = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive");
                 ManagementObjectSearcher searcher2 = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive");
-                foreach (ManagementObject mo2 in searcher2.Get())
-                {
+                foreach (ManagementObject mo2 in searcher2.Get()) {
                     Disk disk = new Disk();
                     Disk disk = new Disk();
 
 
                     disk.Model = Convert.ToString(mo2.Properties["Model"].Value);
                     disk.Model = Convert.ToString(mo2.Properties["Model"].Value);
@@ -228,21 +193,17 @@ namespace Optimizer
                     disks.Add(disk);
                     disks.Add(disk);
                 }
                 }
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("IndiciumHelper.GetDisks", ex.Message, ex.StackTrace);
                 Logger.LogError("IndiciumHelper.GetDisks", ex.Message, ex.StackTrace);
             }
             }
 
 
             return disks;
             return disks;
         }
         }
 
 
-        public static void GetVolumes()
-        {
-            try
-            {
+        public static void GetVolumes() {
+            try {
                 ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_Volume");
                 ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_Volume");
-                foreach (ManagementObject mo in searcher.Get())
-                {
+                foreach (ManagementObject mo in searcher.Get()) {
                     Volume volume = new Volume();
                     Volume volume = new Volume();
 
 
                     volume.BlockSize = Convert.ToUInt64(mo.Properties["BlockSize"].Value);
                     volume.BlockSize = Convert.ToUInt64(mo.Properties["BlockSize"].Value);
@@ -259,33 +220,26 @@ namespace Optimizer
                     volume.Indexing = (temp2) ? "Yes" : "No";
                     volume.Indexing = (temp2) ? "Yes" : "No";
                     volume.Label = Convert.ToString(mo.Properties["Label"].Value);
                     volume.Label = Convert.ToString(mo.Properties["Label"].Value);
 
 
-                    if (i == 2)
-                    {
+                    if (i == 2) {
                         Removables.Add(volume);
                         Removables.Add(volume);
                     }
                     }
-                    else if (i == 5)
-                    {
+                    else if (i == 5) {
                         Opticals.Add(volume);
                         Opticals.Add(volume);
                     }
                     }
-                    else
-                    {
+                    else {
                         Volumes.Add(volume);
                         Volumes.Add(volume);
                     }
                     }
                 }
                 }
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("IndiciumHelper.GetVolumes", ex.Message, ex.StackTrace);
                 Logger.LogError("IndiciumHelper.GetVolumes", ex.Message, ex.StackTrace);
             }
             }
         }
         }
 
 
-        public static void GetPeripherals()
-        {
-            try
-            {
+        public static void GetPeripherals() {
+            try {
                 ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_Keyboard");
                 ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_Keyboard");
-                foreach (ManagementObject mo in searcher.Get())
-                {
+                foreach (ManagementObject mo in searcher.Get()) {
                     Keyboard keyboard = new Keyboard();
                     Keyboard keyboard = new Keyboard();
 
 
                     keyboard.Name = Convert.ToString(mo.Properties["Description"].Value);
                     keyboard.Name = Convert.ToString(mo.Properties["Description"].Value);
@@ -298,16 +252,13 @@ namespace Optimizer
                     Keyboards.Add(keyboard);
                     Keyboards.Add(keyboard);
                 }
                 }
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("IndiciumHelper.GetKeyboards", ex.Message, ex.StackTrace);
                 Logger.LogError("IndiciumHelper.GetKeyboards", ex.Message, ex.StackTrace);
             }
             }
 
 
-            try
-            {
+            try {
                 ManagementObjectSearcher searcher2 = new ManagementObjectSearcher("SELECT * FROM Win32_PointingDevice");
                 ManagementObjectSearcher searcher2 = new ManagementObjectSearcher("SELECT * FROM Win32_PointingDevice");
-                foreach (ManagementObject mo2 in searcher2.Get())
-                {
+                foreach (ManagementObject mo2 in searcher2.Get()) {
                     PointingDevice pointingDevice = new PointingDevice();
                     PointingDevice pointingDevice = new PointingDevice();
 
 
                     pointingDevice.Name = Convert.ToString(mo2.Properties["Description"].Value);
                     pointingDevice.Name = Convert.ToString(mo2.Properties["Description"].Value);
@@ -325,21 +276,17 @@ namespace Optimizer
                     PointingDevices.Add(pointingDevice);
                     PointingDevices.Add(pointingDevice);
                 }
                 }
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("IndiciumHelper.GetPointingDevices", ex.Message, ex.StackTrace);
                 Logger.LogError("IndiciumHelper.GetPointingDevices", ex.Message, ex.StackTrace);
             }
             }
         }
         }
 
 
-        public static List<GPU> GetGPUs()
-        {
+        public static List<GPU> GetGPUs() {
             List<GPU> GPUs = new List<GPU>();
             List<GPU> GPUs = new List<GPU>();
 
 
-            try
-            {
+            try {
                 ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_VideoController");
                 ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_VideoController");
-                foreach (ManagementObject mo in searcher.Get())
-                {
+                foreach (ManagementObject mo in searcher.Get()) {
                     GPU gpu = new GPU();
                     GPU gpu = new GPU();
 
 
                     gpu.Name = Convert.ToString(mo.Properties["Name"].Value);
                     gpu.Name = Convert.ToString(mo.Properties["Name"].Value);
@@ -354,21 +301,17 @@ namespace Optimizer
                     GPUs.Add(gpu);
                     GPUs.Add(gpu);
                 }
                 }
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("IndiciumHelper.GetGPUs", ex.Message, ex.StackTrace);
                 Logger.LogError("IndiciumHelper.GetGPUs", ex.Message, ex.StackTrace);
             }
             }
 
 
             return GPUs;
             return GPUs;
         }
         }
 
 
-        public static void GetNetworkAdapters()
-        {
-            try
-            {
+        public static void GetNetworkAdapters() {
+            try {
                 ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapter");
                 ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapter");
-                foreach (ManagementObject mo in searcher.Get())
-                {
+                foreach (ManagementObject mo in searcher.Get()) {
                     NetworkDevice adapter = new NetworkDevice();
                     NetworkDevice adapter = new NetworkDevice();
 
 
                     adapter.AdapterType = Convert.ToString(mo.Properties["AdapterType"].Value);
                     adapter.AdapterType = Convert.ToString(mo.Properties["AdapterType"].Value);
@@ -379,31 +322,25 @@ namespace Optimizer
                     adapter.MacAddress = Convert.ToString(mo.Properties["MacAddress"].Value);
                     adapter.MacAddress = Convert.ToString(mo.Properties["MacAddress"].Value);
                     adapter.ServiceName = Convert.ToString(mo.Properties["ServiceName"].Value);
                     adapter.ServiceName = Convert.ToString(mo.Properties["ServiceName"].Value);
 
 
-                    if (temp)
-                    {
+                    if (temp) {
                         PhysicalAdapters.Add(adapter);
                         PhysicalAdapters.Add(adapter);
                     }
                     }
-                    else
-                    {
+                    else {
                         VirtualAdapters.Add(adapter);
                         VirtualAdapters.Add(adapter);
                     }
                     }
                 }
                 }
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("IndiciumHelper.GetNetworkAdapters", ex.Message, ex.StackTrace);
                 Logger.LogError("IndiciumHelper.GetNetworkAdapters", ex.Message, ex.StackTrace);
             }
             }
         }
         }
 
 
-        public static List<AudioDevice> GetAudioDevices()
-        {
+        public static List<AudioDevice> GetAudioDevices() {
             List<AudioDevice> audioDevices = new List<AudioDevice>();
             List<AudioDevice> audioDevices = new List<AudioDevice>();
 
 
-            try
-            {
+            try {
                 ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_SoundDevice");
                 ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_SoundDevice");
-                foreach (ManagementObject mo in searcher.Get())
-                {
+                foreach (ManagementObject mo in searcher.Get()) {
                     AudioDevice device = new AudioDevice();
                     AudioDevice device = new AudioDevice();
 
 
                     device.ProductName = Convert.ToString(mo.Properties["ProductName"].Value);
                     device.ProductName = Convert.ToString(mo.Properties["ProductName"].Value);
@@ -413,20 +350,17 @@ namespace Optimizer
                     audioDevices.Add(device);
                     audioDevices.Add(device);
                 }
                 }
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("IndiciumHelper.GetAudioDevices", ex.Message, ex.StackTrace);
                 Logger.LogError("IndiciumHelper.GetAudioDevices", ex.Message, ex.StackTrace);
             }
             }
 
 
             return audioDevices;
             return audioDevices;
         }
         }
 
 
-        private static string SanitizeDriveType(UInt32 i)
-        {
+        private static string SanitizeDriveType(UInt32 i) {
             string result = string.Empty;
             string result = string.Empty;
 
 
-            switch (i)
-            {
+            switch (i) {
                 case 0:
                 case 0:
                     result = "Unknown";
                     result = "Unknown";
                     break;
                     break;
@@ -453,12 +387,10 @@ namespace Optimizer
             return result;
             return result;
         }
         }
 
 
-        private static string SanitizeVideoMemoryType(UInt16 i)
-        {
+        private static string SanitizeVideoMemoryType(UInt16 i) {
             string result = string.Empty;
             string result = string.Empty;
 
 
-            switch (i)
-            {
+            switch (i) {
                 case 1:
                 case 1:
                     result = "Other";
                     result = "Other";
                     break;
                     break;
@@ -503,12 +435,10 @@ namespace Optimizer
             return result;
             return result;
         }
         }
 
 
-        private static string SanitizeFormFactor(UInt16 i)
-        {
+        private static string SanitizeFormFactor(UInt16 i) {
             string result = string.Empty;
             string result = string.Empty;
 
 
-            switch (i)
-            {
+            switch (i) {
                 case 0:
                 case 0:
                     result = "Unknown";
                     result = "Unknown";
                     break;
                     break;
@@ -586,12 +516,10 @@ namespace Optimizer
             return result;
             return result;
         }
         }
 
 
-        private static string SanitizeMemoryType(UInt16 i)
-        {
+        private static string SanitizeMemoryType(UInt16 i) {
             string result = string.Empty;
             string result = string.Empty;
 
 
-            switch (i)
-            {
+            switch (i) {
                 case 0:
                 case 0:
                     result = "Unknown";
                     result = "Unknown";
                     break;
                     break;
@@ -672,12 +600,10 @@ namespace Optimizer
             return result;
             return result;
         }
         }
 
 
-        private static string SanitizeDeviceInterface(UInt16 i)
-        {
+        private static string SanitizeDeviceInterface(UInt16 i) {
             string result = string.Empty;
             string result = string.Empty;
 
 
-            switch (i)
-            {
+            switch (i) {
                 case 1:
                 case 1:
                     result = "Other";
                     result = "Other";
                     break;
                     break;
@@ -716,12 +642,10 @@ namespace Optimizer
             return result;
             return result;
         }
         }
 
 
-        private static string SanitizePointingType(UInt16 i)
-        {
+        private static string SanitizePointingType(UInt16 i) {
             string result = string.Empty;
             string result = string.Empty;
 
 
-            switch (i)
-            {
+            switch (i) {
                 case 1:
                 case 1:
                     result = "Other";
                     result = "Other";
                     break;
                     break;

+ 56 - 112
Optimizer/IntegratorHelper.cs

@@ -7,16 +7,12 @@ using System.IO;
 using System.Net;
 using System.Net;
 using System.Windows.Forms;
 using System.Windows.Forms;
 
 
-namespace Optimizer
-{
-    public static class IntegratorHelper
-    {
+namespace Optimizer {
+    public static class IntegratorHelper {
         internal static string FolderDefaultIcon = @"%systemroot%\system32\imageres.dll,-112";
         internal static string FolderDefaultIcon = @"%systemroot%\system32\imageres.dll,-112";
 
 
-        internal static void CreateCustomCommand(string file, string keyword)
-        {
-            if (!keyword.EndsWith(".exe"))
-            {
+        internal static void CreateCustomCommand(string file, string keyword) {
+            if (!keyword.EndsWith(".exe")) {
                 keyword = keyword + ".exe";
                 keyword = keyword + ".exe";
             }
             }
 
 
@@ -27,14 +23,11 @@ namespace Optimizer
             Registry.SetValue(key, "Path", file.Substring(0, file.LastIndexOf("\\")));
             Registry.SetValue(key, "Path", file.Substring(0, file.LastIndexOf("\\")));
         }
         }
 
 
-        internal static List<string> GetCustomCommands()
-        {
+        internal static List<string> GetCustomCommands() {
             List<string> items = new List<string>();
             List<string> items = new List<string>();
 
 
-            using (RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\"))
-            {
-                foreach (string command in key.GetSubKeyNames())
-                {
+            using (RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\")) {
+                foreach (string command in key.GetSubKeyNames()) {
                     items.Add(command);
                     items.Add(command);
                 }
                 }
             }
             }
@@ -42,27 +35,21 @@ namespace Optimizer
             return items;
             return items;
         }
         }
 
 
-        internal static void DeleteCustomCommand(string command)
-        {
+        internal static void DeleteCustomCommand(string command) {
             Registry.LocalMachine.DeleteSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" + command, false);
             Registry.LocalMachine.DeleteSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" + command, false);
         }
         }
 
 
-        private static void CreateDefaultCommand(string itemName)
-        {
-            using (RegistryKey key = Registry.ClassesRoot.OpenSubKey(@"DesktopBackground\Shell\" + itemName, true))
-            {
+        private static void CreateDefaultCommand(string itemName) {
+            using (RegistryKey key = Registry.ClassesRoot.OpenSubKey(@"DesktopBackground\Shell\" + itemName, true)) {
                 key.CreateSubKey("command", RegistryKeyPermissionCheck.Default);
                 key.CreateSubKey("command", RegistryKeyPermissionCheck.Default);
             }
             }
         }
         }
 
 
-        internal static List<string> GetDesktopItems()
-        {
+        internal static List<string> GetDesktopItems() {
             List<string> items = new List<string>();
             List<string> items = new List<string>();
 
 
-            using (RegistryKey key = Registry.ClassesRoot.OpenSubKey(@"DesktopBackground\Shell", false))
-            {
-                foreach (string item in key.GetSubKeyNames())
-                {
+            using (RegistryKey key = Registry.ClassesRoot.OpenSubKey(@"DesktopBackground\Shell", false)) {
+                foreach (string item in key.GetSubKeyNames()) {
                     // filter the list, so the default items will not be visible
                     // filter the list, so the default items will not be visible
                     if (item.Contains("Gadgets")) continue;
                     if (item.Contains("Gadgets")) continue;
                     if (item.Contains("Display")) continue;
                     if (item.Contains("Display")) continue;
@@ -75,91 +62,69 @@ namespace Optimizer
             return items;
             return items;
         }
         }
 
 
-        internal static void RemoveItem(string name)
-        {
-            try
-            {
-                using (RegistryKey key = Registry.ClassesRoot.OpenSubKey(@"DesktopBackground\Shell", true))
-                {
-                    try
-                    {
+        internal static void RemoveItem(string name) {
+            try {
+                using (RegistryKey key = Registry.ClassesRoot.OpenSubKey(@"DesktopBackground\Shell", true)) {
+                    try {
                         key.DeleteSubKeyTree(name, false);
                         key.DeleteSubKeyTree(name, false);
                     }
                     }
-                    catch (Exception ex)
-                    {
+                    catch (Exception ex) {
                         Logger.LogError("Integrator.RemoveItem", ex.Message, ex.StackTrace);
                         Logger.LogError("Integrator.RemoveItem", ex.Message, ex.StackTrace);
                     }
                     }
                 }
                 }
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("Integrator.RemoveItem", ex.Message, ex.StackTrace);
                 Logger.LogError("Integrator.RemoveItem", ex.Message, ex.StackTrace);
             }
             }
         }
         }
 
 
-        internal static bool DesktopItemExists(string name)
-        {
-            try
-            {
+        internal static bool DesktopItemExists(string name) {
+            try {
                 return Registry.ClassesRoot.OpenSubKey(@"DesktopBackground\Shell\" + name, false) != null;
                 return Registry.ClassesRoot.OpenSubKey(@"DesktopBackground\Shell\" + name, false) != null;
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("Integrator.ItemExists", ex.Message, ex.StackTrace);
                 Logger.LogError("Integrator.ItemExists", ex.Message, ex.StackTrace);
                 return false;
                 return false;
             }
             }
         }
         }
 
 
-        internal static bool TakeOwnershipExists()
-        {
-            try
-            {
+        internal static bool TakeOwnershipExists() {
+            try {
                 return Registry.ClassesRoot.OpenSubKey(@"*\shell\runas", false).GetValue("").ToString() == "Take Ownership";
                 return Registry.ClassesRoot.OpenSubKey(@"*\shell\runas", false).GetValue("").ToString() == "Take Ownership";
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("Integrator.TakeOwnershipExists", ex.Message, ex.StackTrace);
                 Logger.LogError("Integrator.TakeOwnershipExists", ex.Message, ex.StackTrace);
                 return false;
                 return false;
             }
             }
         }
         }
 
 
-        internal static bool OpenWithCMDExists()
-        {
-            try
-            {
+        internal static bool OpenWithCMDExists() {
+            try {
                 return Registry.ClassesRoot.OpenSubKey(@"Directory\shell\OpenWithCMD", false) != null;
                 return Registry.ClassesRoot.OpenSubKey(@"Directory\shell\OpenWithCMD", false) != null;
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("Integrator.OpenWithCMDExists", ex.Message, ex.StackTrace);
                 Logger.LogError("Integrator.OpenWithCMDExists", ex.Message, ex.StackTrace);
                 return false;
                 return false;
             }
             }
         }
         }
 
 
-        internal static void RemoveAllItems(List<string> items)
-        {
-            using (RegistryKey key = Registry.ClassesRoot.OpenSubKey(@"DesktopBackground\Shell", true))
-            {
-                foreach (string item in items)
-                {
-                    try
-                    {
+        internal static void RemoveAllItems(List<string> items) {
+            using (RegistryKey key = Registry.ClassesRoot.OpenSubKey(@"DesktopBackground\Shell", true)) {
+                foreach (string item in items) {
+                    try {
                         key.DeleteSubKeyTree(item, false);
                         key.DeleteSubKeyTree(item, false);
                     }
                     }
-                    catch (Exception ex)
-                    {
+                    catch (Exception ex) {
                         Logger.LogError("Integrator.RemoveAllItems", ex.Message, ex.StackTrace);
                         Logger.LogError("Integrator.RemoveAllItems", ex.Message, ex.StackTrace);
                     }
                     }
                 }
                 }
             }
             }
         }
         }
 
 
-        internal static string ExtractIconFromExecutable(string itemName, string fileName)
-        {
+        internal static string ExtractIconFromExecutable(string itemName, string fileName) {
             string iconPath = string.Empty;
             string iconPath = string.Empty;
 
 
-            if (File.Exists(fileName))
-            {
+            if (File.Exists(fileName)) {
                 Icon ico = Icon.ExtractAssociatedIcon(fileName);
                 Icon ico = Icon.ExtractAssociatedIcon(fileName);
 
 
                 Clipboard.SetImage(ico.ToBitmap());
                 Clipboard.SetImage(ico.ToBitmap());
@@ -172,45 +137,36 @@ namespace Optimizer
             return iconPath;
             return iconPath;
         }
         }
 
 
-        internal static string DownloadFavicon(string link, string name)
-        {
+        internal static string DownloadFavicon(string link, string name) {
             string favicon = string.Empty;
             string favicon = string.Empty;
 
 
-            try
-            {
+            try {
                 Uri url = new Uri(link);
                 Uri url = new Uri(link);
-                if (url.HostNameType == UriHostNameType.Dns)
-                {
+                if (url.HostNameType == UriHostNameType.Dns) {
                     Image.FromStream(((HttpWebResponse)WebRequest.Create("http://" + url.Host + "/favicon.ico").GetResponse()).GetResponseStream()).Save(CoreHelper.FavIconsFolder + name + ".ico", ImageFormat.Bmp);
                     Image.FromStream(((HttpWebResponse)WebRequest.Create("http://" + url.Host + "/favicon.ico").GetResponse()).GetResponseStream()).Save(CoreHelper.FavIconsFolder + name + ".ico", ImageFormat.Bmp);
 
 
                     favicon = CoreHelper.FavIconsFolder + name + ".ico";
                     favicon = CoreHelper.FavIconsFolder + name + ".ico";
                 }
                 }
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("Integrator.DownloadFavicon", ex.Message, ex.StackTrace);
                 Logger.LogError("Integrator.DownloadFavicon", ex.Message, ex.StackTrace);
             }
             }
 
 
             return favicon;
             return favicon;
         }
         }
 
 
-        internal static void AddItem(string name, string item, string icon, DesktopTypePosition position, bool shift, DesktopItemType type)
-        {
-            using (RegistryKey key = Registry.ClassesRoot.OpenSubKey(@"DesktopBackground\Shell", true))
-            {
+        internal static void AddItem(string name, string item, string icon, DesktopTypePosition position, bool shift, DesktopItemType type) {
+            using (RegistryKey key = Registry.ClassesRoot.OpenSubKey(@"DesktopBackground\Shell", true)) {
                 key.CreateSubKey(name, RegistryKeyPermissionCheck.Default);
                 key.CreateSubKey(name, RegistryKeyPermissionCheck.Default);
             }
             }
 
 
             CreateDefaultCommand(name);
             CreateDefaultCommand(name);
 
 
-            if (shift)
-            {
+            if (shift) {
                 Registry.SetValue(@"HKEY_CLASSES_ROOT\DesktopBackground\Shell\" + name, "Extended", "");
                 Registry.SetValue(@"HKEY_CLASSES_ROOT\DesktopBackground\Shell\" + name, "Extended", "");
             }
             }
-            else
-            {
-                using (RegistryKey key = Registry.ClassesRoot.OpenSubKey(@"DesktopBackground\Shell\" + name, true))
-                {
+            else {
+                using (RegistryKey key = Registry.ClassesRoot.OpenSubKey(@"DesktopBackground\Shell\" + name, true)) {
                     key.CreateSubKey(name, RegistryKeyPermissionCheck.Default);
                     key.CreateSubKey(name, RegistryKeyPermissionCheck.Default);
                 }
                 }
             }
             }
@@ -218,8 +174,7 @@ namespace Optimizer
             Registry.SetValue(@"HKEY_CLASSES_ROOT\DesktopBackground\Shell\" + name, "Icon", icon);
             Registry.SetValue(@"HKEY_CLASSES_ROOT\DesktopBackground\Shell\" + name, "Icon", icon);
             Registry.SetValue(@"HKEY_CLASSES_ROOT\DesktopBackground\Shell\" + name, "Position", position.ToString());
             Registry.SetValue(@"HKEY_CLASSES_ROOT\DesktopBackground\Shell\" + name, "Position", position.ToString());
 
 
-            switch (type)
-            {
+            switch (type) {
                 case DesktopItemType.Program:
                 case DesktopItemType.Program:
                     Registry.SetValue(@"HKEY_CLASSES_ROOT\DesktopBackground\Shell\" + name + "\\command", "", item);
                     Registry.SetValue(@"HKEY_CLASSES_ROOT\DesktopBackground\Shell\" + name + "\\command", "", item);
                     break;
                     break;
@@ -241,49 +196,38 @@ namespace Optimizer
             }
             }
         }
         }
 
 
-        internal static void InstallOpenWithCMD()
-        {
+        internal static void InstallOpenWithCMD() {
             Utilities.ImportRegistryScript(CoreHelper.ScriptsFolder + "AddOpenWithCMD.reg");
             Utilities.ImportRegistryScript(CoreHelper.ScriptsFolder + "AddOpenWithCMD.reg");
         }
         }
 
 
-        internal static void DeleteOpenWithCMD()
-        {
+        internal static void DeleteOpenWithCMD() {
             Registry.ClassesRoot.DeleteSubKeyTree(@"Directory\shell\OpenWithCMD", false);
             Registry.ClassesRoot.DeleteSubKeyTree(@"Directory\shell\OpenWithCMD", false);
             Registry.ClassesRoot.DeleteSubKeyTree(@"Directory\Background\shell\OpenWithCMD", false);
             Registry.ClassesRoot.DeleteSubKeyTree(@"Directory\Background\shell\OpenWithCMD", false);
             Registry.ClassesRoot.DeleteSubKeyTree(@"Drive\shell\OpenWithCMD", false);
             Registry.ClassesRoot.DeleteSubKeyTree(@"Drive\shell\OpenWithCMD", false);
         }
         }
 
 
-        internal static void InstallTakeOwnership(bool remove)
-        {
-            if (!File.Exists(CoreHelper.ReadyMadeMenusFolder + "InstallTakeOwnership.reg"))
-            {
-                try
-                {
+        internal static void InstallTakeOwnership(bool remove) {
+            if (!File.Exists(CoreHelper.ReadyMadeMenusFolder + "InstallTakeOwnership.reg")) {
+                try {
                     File.WriteAllText(CoreHelper.ReadyMadeMenusFolder + "InstallTakeOwnership.reg", Properties.Resources.InstallTakeOwnership);
                     File.WriteAllText(CoreHelper.ReadyMadeMenusFolder + "InstallTakeOwnership.reg", Properties.Resources.InstallTakeOwnership);
                 }
                 }
-                catch (Exception ex)
-                {
+                catch (Exception ex) {
                     Logger.LogError("Integrator.TakeOwnership", ex.Message, ex.StackTrace);
                     Logger.LogError("Integrator.TakeOwnership", ex.Message, ex.StackTrace);
                 }
                 }
             }
             }
-            if (!File.Exists(CoreHelper.ReadyMadeMenusFolder + "RemoveTakeOwnership.reg"))
-            {
-                try
-                {
+            if (!File.Exists(CoreHelper.ReadyMadeMenusFolder + "RemoveTakeOwnership.reg")) {
+                try {
                     File.WriteAllText(CoreHelper.ReadyMadeMenusFolder + "RemoveTakeOwnership.reg", Properties.Resources.RemoveTakeOwnership);
                     File.WriteAllText(CoreHelper.ReadyMadeMenusFolder + "RemoveTakeOwnership.reg", Properties.Resources.RemoveTakeOwnership);
                 }
                 }
-                catch (Exception ex)
-                {
+                catch (Exception ex) {
                     Logger.LogError("Integrator.TakeOwnership", ex.Message, ex.StackTrace);
                     Logger.LogError("Integrator.TakeOwnership", ex.Message, ex.StackTrace);
                 }
                 }
             }
             }
 
 
-            if (!remove)
-            {
+            if (!remove) {
                 Utilities.ImportRegistryScript(CoreHelper.ReadyMadeMenusFolder + "InstallTakeOwnership.reg");
                 Utilities.ImportRegistryScript(CoreHelper.ReadyMadeMenusFolder + "InstallTakeOwnership.reg");
             }
             }
-            else
-            {
+            else {
                 Utilities.ImportRegistryScript(CoreHelper.ReadyMadeMenusFolder + "RemoveTakeOwnership.reg");
                 Utilities.ImportRegistryScript(CoreHelper.ReadyMadeMenusFolder + "RemoveTakeOwnership.reg");
             }
             }
         }
         }

+ 9 - 4
Optimizer/Models/AppInfo.cs

@@ -1,7 +1,12 @@
-namespace Optimizer
-{
-    public sealed class AppInfo
-    {
+namespace Optimizer {
+    /// <summary>
+    /// Represents an app from feed, containing:
+    /// - Title
+    /// - Download link for both 32 and 64 bit variant
+    /// - Image
+    /// - Group
+    /// </summary>
+    public sealed class AppInfo {
         public string Title { get; set; }
         public string Title { get; set; }
         public string Link64 { get; set; }
         public string Link64 { get; set; }
         public string Link { get; set; }
         public string Link { get; set; }

+ 20 - 26
Optimizer/Models/Enums.cs

@@ -1,13 +1,17 @@
-namespace Optimizer
-{
-    internal enum LogType
-    {
+namespace Optimizer {
+    internal enum LogType {
         Information,
         Information,
         Error,
         Error,
     }
     }
 
 
-    internal enum WindowsVersion
-    {
+    internal enum EventType {
+        Modified,
+        Renamed,
+        Created,
+        Deleted
+    }
+
+    internal enum WindowsVersion {
         Unsupported = 0,
         Unsupported = 0,
         Windows7 = 7,
         Windows7 = 7,
         Windows8 = 8,
         Windows8 = 8,
@@ -15,8 +19,7 @@
         Windows11 = 11
         Windows11 = 11
     }
     }
 
 
-    public enum StartupItemLocation
-    {
+    public enum StartupItemLocation {
         LMStartupFolder,
         LMStartupFolder,
         CUStartupFolder,
         CUStartupFolder,
         HKLM,
         HKLM,
@@ -24,15 +27,13 @@
         HKCU
         HKCU
     }
     }
 
 
-    public enum StartupItemType
-    {
+    public enum StartupItemType {
         None,
         None,
         Run,
         Run,
         RunOnce
         RunOnce
     }
     }
 
 
-    internal enum MessageType
-    {
+    internal enum MessageType {
         Error,
         Error,
         Startup,
         Startup,
         Restart,
         Restart,
@@ -40,8 +41,7 @@
         Integrator
         Integrator
     }
     }
 
 
-    internal enum DesktopItemType
-    {
+    internal enum DesktopItemType {
         Program,
         Program,
         Folder,
         Folder,
         Link,
         Link,
@@ -49,44 +49,38 @@
         Command
         Command
     }
     }
 
 
-    internal enum DesktopTypePosition
-    {
+    internal enum DesktopTypePosition {
         Top,
         Top,
         Middle,
         Middle,
         Bottom
         Bottom
     }
     }
 
 
-    internal enum RecycleFlag : int
-    {
+    internal enum RecycleFlag : int {
         SHERB_NOCONFIRMATION = 0x00000001,
         SHERB_NOCONFIRMATION = 0x00000001,
         SHERB_NOPROGRESSUI = 0x00000001,
         SHERB_NOPROGRESSUI = 0x00000001,
         SHERB_NOSOUND = 0x00000004
         SHERB_NOSOUND = 0x00000004
     }
     }
 
 
-    public enum ToggleSwitchAlignment
-    {
+    public enum ToggleSwitchAlignment {
         Near,
         Near,
         Center,
         Center,
         Far
         Far
     }
     }
 
 
-    public enum ToggleSwitchButtonAlignment
-    {
+    public enum ToggleSwitchButtonAlignment {
         Left,
         Left,
         Center,
         Center,
         Right
         Right
     }
     }
 
 
-    public enum RestartType
-    {
+    public enum RestartType {
         Normal,
         Normal,
         SafeMode,
         SafeMode,
         DisableDefender,
         DisableDefender,
         EnableDefender
         EnableDefender
     }
     }
 
 
-    public enum LanguageCode
-    {
+    public enum LanguageCode {
         EN, // english
         EN, // english
         RU, // russian
         RU, // russian
         EL, // hellenic
         EL, // hellenic

+ 17 - 26
Optimizer/Models/Hardware.cs

@@ -1,10 +1,12 @@
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 
 
-namespace Optimizer
-{
-    public sealed class CPU
-    {
+namespace Optimizer {
+    /// <summary>
+    /// A full representation of all the computer components with the most usual details
+    /// </summary>
+
+    public sealed class CPU {
         public string Name { get; set; }
         public string Name { get; set; }
         public ByteSize L2CacheSize { get; set; }
         public ByteSize L2CacheSize { get; set; }
         public ByteSize L3CacheSize { get; set; }
         public ByteSize L3CacheSize { get; set; }
@@ -17,8 +19,7 @@ namespace Optimizer
         public string Revision { get; set; }
         public string Revision { get; set; }
     }
     }
 
 
-    public sealed class RAM
-    {
+    public sealed class RAM {
         public string BankLabel { get; set; }
         public string BankLabel { get; set; }
         public ByteSize Capacity { get; set; }
         public ByteSize Capacity { get; set; }
         public string FormFactor { get; set; }
         public string FormFactor { get; set; }
@@ -27,15 +28,13 @@ namespace Optimizer
         public UInt32 Speed { get; set; }
         public UInt32 Speed { get; set; }
     }
     }
 
 
-    public sealed class VirtualMemory
-    {
+    public sealed class VirtualMemory {
         public ByteSize TotalVirtualMemory { get; set; }
         public ByteSize TotalVirtualMemory { get; set; }
         public ByteSize AvailableVirtualMemory { get; set; }
         public ByteSize AvailableVirtualMemory { get; set; }
         public ByteSize UsedVirtualMemory { get; set; }
         public ByteSize UsedVirtualMemory { get; set; }
     }
     }
 
 
-    public sealed class GPU
-    {
+    public sealed class GPU {
         public string Name { get; set; }
         public string Name { get; set; }
         public ByteSize Memory { get; set; }
         public ByteSize Memory { get; set; }
         public UInt32 ResolutionX { get; set; }
         public UInt32 ResolutionX { get; set; }
@@ -45,8 +44,7 @@ namespace Optimizer
         public string VideoMemoryType { get; set; }
         public string VideoMemoryType { get; set; }
     }
     }
 
 
-    public sealed class Disk
-    {
+    public sealed class Disk {
         public UInt32 BytesPerSector { get; set; }
         public UInt32 BytesPerSector { get; set; }
         public string FirmwareRevision { get; set; }
         public string FirmwareRevision { get; set; }
         public string MediaType { get; set; }
         public string MediaType { get; set; }
@@ -54,8 +52,7 @@ namespace Optimizer
         public ByteSize Capacity { get; set; }
         public ByteSize Capacity { get; set; }
     }
     }
 
 
-    public sealed class Volume
-    {
+    public sealed class Volume {
         public UInt64 BlockSize { get; set; }
         public UInt64 BlockSize { get; set; }
         public ByteSize Capacity { get; set; }
         public ByteSize Capacity { get; set; }
         public string Compressed { get; set; }
         public string Compressed { get; set; }
@@ -68,8 +65,7 @@ namespace Optimizer
         public string Label { get; set; }
         public string Label { get; set; }
     }
     }
 
 
-    public sealed class NetworkDevice
-    {
+    public sealed class NetworkDevice {
         public string AdapterType { get; set; }
         public string AdapterType { get; set; }
         public string Manufacturer { get; set; }
         public string Manufacturer { get; set; }
         public string ProductName { get; set; }
         public string ProductName { get; set; }
@@ -78,8 +74,7 @@ namespace Optimizer
         public string ServiceName { get; set; }
         public string ServiceName { get; set; }
     }
     }
 
 
-    public sealed class Keyboard
-    {
+    public sealed class Keyboard {
         public string Name { get; set; }
         public string Name { get; set; }
         public string Layout { get; set; }
         public string Layout { get; set; }
         public string Status { get; set; }
         public string Status { get; set; }
@@ -87,8 +82,7 @@ namespace Optimizer
         public string Locked { get; set; }
         public string Locked { get; set; }
     }
     }
 
 
-    public sealed class PointingDevice
-    {
+    public sealed class PointingDevice {
         public string Name { get; set; }
         public string Name { get; set; }
         public string Manufacturer { get; set; }
         public string Manufacturer { get; set; }
         public string Status { get; set; }
         public string Status { get; set; }
@@ -99,15 +93,13 @@ namespace Optimizer
         public string DeviceInterface { get; set; }
         public string DeviceInterface { get; set; }
     }
     }
 
 
-    public sealed class AudioDevice
-    {
+    public sealed class AudioDevice {
         public string ProductName { get; set; }
         public string ProductName { get; set; }
         public string Manufacturer { get; set; }
         public string Manufacturer { get; set; }
         public string Status { get; set; }
         public string Status { get; set; }
     }
     }
 
 
-    public sealed class Motherboard
-    {
+    public sealed class Motherboard {
         public string Model { get; set; }
         public string Model { get; set; }
         public string Manufacturer { get; set; }
         public string Manufacturer { get; set; }
         public string Chipset { get; set; }
         public string Chipset { get; set; }
@@ -122,8 +114,7 @@ namespace Optimizer
         public string BIOSBuildNumber { get; set; }
         public string BIOSBuildNumber { get; set; }
     }
     }
 
 
-    public static class HardwareSummary
-    {
+    public static class HardwareSummary {
         public static List<string> CPUs = new List<string>();
         public static List<string> CPUs = new List<string>();
         public static string TotalRAM = string.Empty;
         public static string TotalRAM = string.Empty;
         public static List<string> Motherboards = new List<string>();
         public static List<string> Motherboards = new List<string>();

+ 62 - 11
Optimizer/Models/Options.cs

@@ -1,18 +1,42 @@
 using System;
 using System;
 using System.Drawing;
 using System.Drawing;
 
 
-namespace Optimizer
-{
+namespace Optimizer {
     [Serializable]
     [Serializable]
-    public sealed class Options
-    {
+    public sealed class Options {
+        /// <summary>
+        /// Represents the theme color in RGB
+        /// </summary>
         public Color Theme { get; set; }
         public Color Theme { get; set; }
+
+        /// <summary>
+        /// The folder in which the apps are downloaded from Apps tool
+        /// </summary>
         public string AppsFolder { get; set; }
         public string AppsFolder { get; set; }
+
+        /// <summary>
+        /// Configures if the app will appear in the taskbar icons
+        /// </summary>
         public bool EnableTray { get; set; }
         public bool EnableTray { get; set; }
+
+        /// <summary>
+        /// Configures if the app will start with Windows
+        /// </summary>
         public bool AutoStart { get; set; }
         public bool AutoStart { get; set; }
+
+        /// <summary>
+        /// The DNS that the app will use for checking the internet connectivity
+        /// </summary>
         public string InternalDNS { get; set; }
         public string InternalDNS { get; set; }
+
+        /// <summary>
+        /// Configures if the app will check for updates automatically on each run
+        /// </summary>
         public bool UpdateOnLaunch { get; set; }
         public bool UpdateOnLaunch { get; set; }
 
 
+        /// <summary>
+        /// Each option from this section will completely disable the respective tool (useful for troubleshooting)
+        /// </summary>
         public bool DisableIndicium { get; set; }
         public bool DisableIndicium { get; set; }
         public bool DisableAppsTool { get; set; }
         public bool DisableAppsTool { get; set; }
         public bool DisableHostsEditor { get; set; }
         public bool DisableHostsEditor { get; set; }
@@ -22,12 +46,21 @@ namespace Optimizer
         public bool DisableIntegrator { get; set; }
         public bool DisableIntegrator { get; set; }
         public bool DisablePinger { get; set; }
         public bool DisablePinger { get; set; }
 
 
+        /// <summary>
+        /// Telemetry-related info, unique to each instance
+        /// </summary>
         //public string TelemetryClientID { get; set; }
         //public string TelemetryClientID { get; set; }
         //public bool DisableOptimizerTelemetry { get; set; }
         //public bool DisableOptimizerTelemetry { get; set; }
 
 
+        /// <summary>
+        /// The saved language of the app
+        /// </summary>
         public LanguageCode LanguageCode { get; set; }
         public LanguageCode LanguageCode { get; set; }
 
 
-        // universal
+        /// <summary>
+        /// The state of the general tweaks
+        /// Changing them will not disable/enable the respective tweak
+        /// </summary>
         public bool EnablePerformanceTweaks { get; set; }
         public bool EnablePerformanceTweaks { get; set; }
         public bool DisableNetworkThrottling { get; set; }
         public bool DisableNetworkThrottling { get; set; }
         public bool DisableWindowsDefender { get; set; }
         public bool DisableWindowsDefender { get; set; }
@@ -49,21 +82,33 @@ namespace Optimizer
         public bool DisableNTFSTimeStamp { get; set; }
         public bool DisableNTFSTimeStamp { get; set; }
         public bool DisableSearch { get; set; }
         public bool DisableSearch { get; set; }
 
 
-        // apps telemetry
+        /// <summary>
+        /// The state of the apps telemetry tweaks
+        /// Changing them will not disable/enable the respective tweak
+        /// </summary>
         public bool DisableOffice2016Telemetry { get; set; }
         public bool DisableOffice2016Telemetry { get; set; }
         public bool DisableVisualStudioTelemetry { get; set; }
         public bool DisableVisualStudioTelemetry { get; set; }
         public bool DisableFirefoxTemeletry { get; set; }
         public bool DisableFirefoxTemeletry { get; set; }
         public bool DisableChromeTelemetry { get; set; }
         public bool DisableChromeTelemetry { get; set; }
         public bool DisableNVIDIATelemetry { get; set; }
         public bool DisableNVIDIATelemetry { get; set; }
 
 
-        // edge
+        /// <summary>
+        /// The state of the Edge-related tweaks
+        /// Changing them will not disable/enable the respective tweak
+        /// </summary>
         public bool DisableEdgeDiscoverBar { get; set; }
         public bool DisableEdgeDiscoverBar { get; set; }
         public bool DisableEdgeTelemetry { get; set; }
         public bool DisableEdgeTelemetry { get; set; }
 
 
-        // windows 8
+        /// <summary>
+        /// The state of the Windows 8/8.1 tweaks
+        /// Changing them will not disable/enable the respective tweak
+        /// </summary>
         public bool DisableOneDrive { get; set; }
         public bool DisableOneDrive { get; set; }
 
 
-        // windows 10
+        /// <summary>
+        /// The state of the Windows 10 tweaks
+        /// Changing them will not disable/enable the respective tweak
+        /// </summary>
         public bool EnableLegacyVolumeSlider { get; set; }
         public bool EnableLegacyVolumeSlider { get; set; }
         public bool DisableQuickAccessHistory { get; set; }
         public bool DisableQuickAccessHistory { get; set; }
         public bool DisableStartMenuAds { get; set; }
         public bool DisableStartMenuAds { get; set; }
@@ -86,7 +131,10 @@ namespace Optimizer
         public bool EnableGamingMode { get; set; }
         public bool EnableGamingMode { get; set; }
         public bool RestoreClassicPhotoViewer { get; set; }
         public bool RestoreClassicPhotoViewer { get; set; }
 
 
-        // windows 11
+        /// <summary>
+        /// The state of the Windows 11 tweaks
+        /// Changing them will not disable/enable the respective tweak
+        /// </summary>
         public bool TaskbarToLeft { get; set; }
         public bool TaskbarToLeft { get; set; }
         public bool DisableSnapAssist { get; set; }
         public bool DisableSnapAssist { get; set; }
         public bool DisableWidgets { get; set; }
         public bool DisableWidgets { get; set; }
@@ -98,7 +146,10 @@ namespace Optimizer
         public bool DisableVBS { get; set; }
         public bool DisableVBS { get; set; }
         public bool DisableCoPilotAI { get; set; }
         public bool DisableCoPilotAI { get; set; }
 
 
-        // advanced
+        /// <summary>
+        /// The state of the advanced tweaks
+        /// Changing them will not disable/enable the respective tweak
+        /// </summary>
         public bool DisableHPET { get; set; }
         public bool DisableHPET { get; set; }
         public bool EnableLoginVerbose { get; set; }
         public bool EnableLoginVerbose { get; set; }
     }
     }

+ 14 - 28
Optimizer/Models/SilentConfig.cs

@@ -1,11 +1,9 @@
 using Newtonsoft.Json;
 using Newtonsoft.Json;
 using System;
 using System;
 
 
-namespace Optimizer
-{
+namespace Optimizer {
     [Serializable]
     [Serializable]
-    public sealed class SilentConfig
-    {
+    public sealed class SilentConfig {
         [JsonProperty("WindowsVersion", Required = Required.Always, NullValueHandling = NullValueHandling.Ignore)]
         [JsonProperty("WindowsVersion", Required = Required.Always, NullValueHandling = NullValueHandling.Ignore)]
         public int WindowsVersion { get; set; }
         public int WindowsVersion { get; set; }
 
 
@@ -38,8 +36,7 @@ namespace Optimizer
     }
     }
 
 
     [Serializable]
     [Serializable]
-    public sealed class AdvancedTweaks
-    {
+    public sealed class AdvancedTweaks {
         [JsonProperty("DisableHPET", NullValueHandling = NullValueHandling.Ignore)]
         [JsonProperty("DisableHPET", NullValueHandling = NullValueHandling.Ignore)]
         public bool? DisableHPET { get; set; }
         public bool? DisableHPET { get; set; }
 
 
@@ -54,8 +51,7 @@ namespace Optimizer
     }
     }
 
 
     [Serializable]
     [Serializable]
-    public sealed class Cleaner
-    {
+    public sealed class Cleaner {
         [JsonProperty("TempFiles", NullValueHandling = NullValueHandling.Ignore)]
         [JsonProperty("TempFiles", NullValueHandling = NullValueHandling.Ignore)]
         public bool? TempFiles { get; set; }
         public bool? TempFiles { get; set; }
 
 
@@ -85,8 +81,7 @@ namespace Optimizer
     }
     }
 
 
     [Serializable]
     [Serializable]
-    public sealed class BaseBrowser
-    {
+    public sealed class BaseBrowser {
         [JsonProperty("Cache", NullValueHandling = NullValueHandling.Ignore)]
         [JsonProperty("Cache", NullValueHandling = NullValueHandling.Ignore)]
         public bool? Cache { get; set; }
         public bool? Cache { get; set; }
 
 
@@ -104,8 +99,7 @@ namespace Optimizer
     }
     }
 
 
     [Serializable]
     [Serializable]
-    public sealed class HostsEditor
-    {
+    public sealed class HostsEditor {
         [JsonProperty("Block", NullValueHandling = NullValueHandling.Ignore)]
         [JsonProperty("Block", NullValueHandling = NullValueHandling.Ignore)]
         public string[] Block { get; set; }
         public string[] Block { get; set; }
 
 
@@ -120,8 +114,7 @@ namespace Optimizer
     }
     }
 
 
     [Serializable]
     [Serializable]
-    public sealed class AddHostsEntry
-    {
+    public sealed class AddHostsEntry {
         [JsonProperty("Domain", NullValueHandling = NullValueHandling.Ignore)]
         [JsonProperty("Domain", NullValueHandling = NullValueHandling.Ignore)]
         public string Domain { get; set; }
         public string Domain { get; set; }
 
 
@@ -130,8 +123,7 @@ namespace Optimizer
     }
     }
 
 
     [Serializable]
     [Serializable]
-    public sealed class Integrator
-    {
+    public sealed class Integrator {
         [JsonProperty("TakeOwnership", NullValueHandling = NullValueHandling.Ignore)]
         [JsonProperty("TakeOwnership", NullValueHandling = NullValueHandling.Ignore)]
         public bool? TakeOwnership { get; set; }
         public bool? TakeOwnership { get; set; }
 
 
@@ -140,8 +132,7 @@ namespace Optimizer
     }
     }
 
 
     [Serializable]
     [Serializable]
-    public sealed class Pinger
-    {
+    public sealed class Pinger {
         [JsonProperty("SetDNS", NullValueHandling = NullValueHandling.Ignore)]
         [JsonProperty("SetDNS", NullValueHandling = NullValueHandling.Ignore)]
         public string SetDns { get; set; }
         public string SetDns { get; set; }
 
 
@@ -156,8 +147,7 @@ namespace Optimizer
     }
     }
 
 
     [Serializable]
     [Serializable]
-    public sealed class PostAction
-    {
+    public sealed class PostAction {
         [JsonProperty("Restart", NullValueHandling = NullValueHandling.Ignore)]
         [JsonProperty("Restart", NullValueHandling = NullValueHandling.Ignore)]
         public bool? Restart { get; set; }
         public bool? Restart { get; set; }
 
 
@@ -166,8 +156,7 @@ namespace Optimizer
     }
     }
 
 
     [Serializable]
     [Serializable]
-    public sealed class ProcessControl
-    {
+    public sealed class ProcessControl {
         [JsonProperty("Prevent", NullValueHandling = NullValueHandling.Ignore)]
         [JsonProperty("Prevent", NullValueHandling = NullValueHandling.Ignore)]
         public string[] Prevent { get; set; }
         public string[] Prevent { get; set; }
 
 
@@ -176,8 +165,7 @@ namespace Optimizer
     }
     }
 
 
     [Serializable]
     [Serializable]
-    public sealed class RegistryFix
-    {
+    public sealed class RegistryFix {
         [JsonProperty("TaskManager", NullValueHandling = NullValueHandling.Ignore)]
         [JsonProperty("TaskManager", NullValueHandling = NullValueHandling.Ignore)]
         public bool? TaskManager { get; set; }
         public bool? TaskManager { get; set; }
 
 
@@ -204,8 +192,7 @@ namespace Optimizer
     }
     }
 
 
     [Serializable]
     [Serializable]
-    public sealed class SvchostProcessSplitting
-    {
+    public sealed class SvchostProcessSplitting {
         [JsonProperty("Disable", NullValueHandling = NullValueHandling.Ignore)]
         [JsonProperty("Disable", NullValueHandling = NullValueHandling.Ignore)]
         public bool? Disable { get; set; }
         public bool? Disable { get; set; }
 
 
@@ -214,8 +201,7 @@ namespace Optimizer
     }
     }
 
 
     [Serializable]
     [Serializable]
-    public sealed class Tweaks
-    {
+    public sealed class Tweaks {
         public bool? EnablePerformanceTweaks { get; set; }
         public bool? EnablePerformanceTweaks { get; set; }
         public bool? DisableNetworkThrottling { get; set; }
         public bool? DisableNetworkThrottling { get; set; }
         public bool? DisableWindowsDefender { get; set; }
         public bool? DisableWindowsDefender { get; set; }

+ 6 - 6
Optimizer/Models/StartupBackupItem.cs

@@ -1,17 +1,17 @@
 using System;
 using System;
 
 
-namespace Optimizer
-{
+namespace Optimizer {
+    /// <summary>
+    /// Represents a backup of a Windows base startup item
+    /// </summary>
     [Serializable]
     [Serializable]
-    public sealed class BackupStartupItem
-    {
+    public sealed class BackupStartupItem {
         public string Name { get; set; }
         public string Name { get; set; }
         public string FileLocation { get; set; }
         public string FileLocation { get; set; }
         public string RegistryLocation { get; set; }
         public string RegistryLocation { get; set; }
         public string StartupType { get; set; }
         public string StartupType { get; set; }
 
 
-        public BackupStartupItem(string name, string fileLocation, string registryLocation, string startupType)
-        {
+        public BackupStartupItem(string name, string fileLocation, string registryLocation, string startupType) {
             Name = name;
             Name = name;
             FileLocation = fileLocation;
             FileLocation = fileLocation;
             RegistryLocation = registryLocation;
             RegistryLocation = registryLocation;

+ 26 - 46
Optimizer/Models/StartupItem.cs

@@ -2,10 +2,11 @@
 using System;
 using System;
 using System.IO;
 using System.IO;
 
 
-namespace Optimizer
-{
-    internal class StartupItem
-    {
+namespace Optimizer {
+    /// <summary>
+    /// Represents a base Windows startup item
+    /// </summary>
+    internal class StartupItem {
         internal string Name { get; set; }
         internal string Name { get; set; }
         internal string FileLocation { get; set; }
         internal string FileLocation { get; set; }
         internal StartupItemLocation RegistryLocation { get; set; }
         internal StartupItemLocation RegistryLocation { get; set; }
@@ -15,92 +16,71 @@ namespace Optimizer
         internal virtual void LocateFile() { }
         internal virtual void LocateFile() { }
         internal virtual void LocateKey() { }
         internal virtual void LocateKey() { }
 
 
-        public override string ToString()
-        {
+        public override string ToString() {
             if (RegistryLocation == StartupItemLocation.LMStartupFolder) return RegistryLocation.ToString();
             if (RegistryLocation == StartupItemLocation.LMStartupFolder) return RegistryLocation.ToString();
             return string.Format("{0}:{1}", RegistryLocation, StartupType);
             return string.Format("{0}:{1}", RegistryLocation, StartupType);
         }
         }
     }
     }
 
 
-    internal sealed class FolderStartupItem : StartupItem
-    {
+    internal sealed class FolderStartupItem : StartupItem {
         internal string Shortcut { get; set; }
         internal string Shortcut { get; set; }
 
 
-        internal override void Remove()
-        {
-            try
-            {
-                if (File.Exists(Shortcut))
-                {
+        internal override void Remove() {
+            try {
+                if (File.Exists(Shortcut)) {
                     File.Delete(Shortcut);
                     File.Delete(Shortcut);
                 }
                 }
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("FolderStartupItem.Remove", ex.Message, ex.StackTrace);
                 Logger.LogError("FolderStartupItem.Remove", ex.Message, ex.StackTrace);
             }
             }
         }
         }
 
 
-        internal override void LocateFile()
-        {
-            try
-            {
+        internal override void LocateFile() {
+            try {
                 Utilities.FindFile(FileLocation);
                 Utilities.FindFile(FileLocation);
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("FolderStartupItem.LocateFile", ex.Message, ex.StackTrace);
                 Logger.LogError("FolderStartupItem.LocateFile", ex.Message, ex.StackTrace);
             }
             }
         }
         }
     }
     }
 
 
-    internal sealed class RegistryStartupItem : StartupItem
-    {
+    internal sealed class RegistryStartupItem : StartupItem {
         internal RegistryKey Key { get; set; }
         internal RegistryKey Key { get; set; }
 
 
-        internal override void LocateKey()
-        {
-            try
-            {
+        internal override void LocateKey() {
+            try {
                 Utilities.FindKeyInRegistry(Key.ToString());
                 Utilities.FindKeyInRegistry(Key.ToString());
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("RegistryStartupItem.LocateKey", ex.Message, ex.StackTrace);
                 Logger.LogError("RegistryStartupItem.LocateKey", ex.Message, ex.StackTrace);
             }
             }
         }
         }
 
 
-        internal override void Remove()
-        {
-            try
-            {
+        internal override void Remove() {
+            try {
                 Key.DeleteValue(Name, false);
                 Key.DeleteValue(Name, false);
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("RegistryStartupItem.Remove", ex.Message, ex.StackTrace);
                 Logger.LogError("RegistryStartupItem.Remove", ex.Message, ex.StackTrace);
             }
             }
         }
         }
 
 
-        internal override void LocateFile()
-        {
-            try
-            {
+        internal override void LocateFile() {
+            try {
                 Utilities.FindFile(SanitizePath(FileLocation));
                 Utilities.FindFile(SanitizePath(FileLocation));
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("RegistryStartupItem.LocateFile", ex.Message, ex.StackTrace);
                 Logger.LogError("RegistryStartupItem.LocateFile", ex.Message, ex.StackTrace);
             }
             }
         }
         }
 
 
-        internal string SanitizePath(string s)
-        {
+        internal string SanitizePath(string s) {
             s = s.Replace("\"", string.Empty);
             s = s.Replace("\"", string.Empty);
             int i;
             int i;
 
 
-            while (s.Contains("/"))
-            {
+            while (s.Contains("/")) {
                 i = s.LastIndexOf("/");
                 i = s.LastIndexOf("/");
                 s = s.Substring(0, i);
                 s = s.Substring(0, i);
             }
             }

+ 58 - 0
Optimizer/Models/WorkEvent.cs

@@ -0,0 +1,58 @@
+//using System;
+//using System.Collections.Generic;
+//using System.Linq;
+//using System.Text;
+//using System.Threading.Tasks;
+
+//namespace Optimizer.Models {
+//    public sealed class WorkEvent : List<WorkEventArgs> {
+//        static object _lockObject = new object();
+//        static object _syncRoot = new object();
+//        static volatile WorkEvent _instance;
+
+//        private WorkEvent() { }
+
+//        public static WorkEvent Instance {
+//            get {
+//                if (_instance == null) {
+//                    lock (_syncRoot) {
+//                        if (_instance == null) {
+//                            _instance = new WorkEvent();
+//                        }
+//                    }
+//                }
+
+//                return _instance;
+//            }
+//        }
+
+//        public new void Add(WorkEventArgs wea) {
+//            lock (_lockObject) {
+//                base.Add(wea);
+//            }
+//        }
+
+//        public new void Remove(WorkEventArgs wea) {
+//            lock (_lockObject) {
+//                base.Remove(wea);
+//            }
+//        }
+
+//        public WorkEventArgs GetEventObject() {
+//            if (this.Count > 0) {
+//                if (this[0] != null) {
+//                    WorkEventArgs dwoTemp = this[0];
+//                    Remove(this[0]);
+//                    return dwoTemp;
+
+//                }
+//                else {
+//                    return null;
+//                }
+//            }
+//            else {
+//                return null;
+//            }
+//        }
+//    }
+//}

+ 46 - 0
Optimizer/Models/WorkEventArgs.cs

@@ -0,0 +1,46 @@
+//using System;
+//using System.Collections.Generic;
+//using System.Linq;
+//using System.Text;
+//using System.Threading.Tasks;
+//using System.Windows.Forms;
+
+//namespace Optimizer.Models {
+//    public sealed class WorkEventArgs {
+//        string _fileName;
+//        string _eventType;
+//        ListViewItem _currentItem;
+
+//        public WorkEventArgs(string fileName, string eventType, ListViewItem currentItem) {
+//            _fileName = fileName;
+//            _eventType = eventType;
+
+//            if (currentItem != null) {
+//                _currentItem = currentItem;
+//            }
+//        }
+
+//        public string FileName {
+//            get {
+//                return _fileName;
+//            }
+//        }
+
+//        public string EventType {
+//            get {
+//                return _eventType;
+//            }
+//        }
+
+//        public ListViewItem CurrentItem {
+//            get {
+//                if (_currentItem != null) {
+//                    return _currentItem;
+//                }
+//                else {
+//                    return null;
+//                }
+//            }
+//        }
+//    }
+//}

文件差异内容过多而无法显示
+ 153 - 284
Optimizer/OptimizeHelper.cs


+ 2 - 0
Optimizer/Optimizer.csproj

@@ -203,6 +203,8 @@
     </Compile>
     </Compile>
     <Compile Include="Constants.cs" />
     <Compile Include="Constants.cs" />
     <Compile Include="Models\Options.cs" />
     <Compile Include="Models\Options.cs" />
+    <Compile Include="Models\WorkEvent.cs" />
+    <Compile Include="Models\WorkEventArgs.cs" />
     <Compile Include="NetworkAdapter.cs" />
     <Compile Include="NetworkAdapter.cs" />
     <Compile Include="NetworkMonitor.cs" />
     <Compile Include="NetworkMonitor.cs" />
     <Compile Include="OptimizeHelper.cs" />
     <Compile Include="OptimizeHelper.cs" />

+ 28 - 56
Optimizer/OptionsHelper.cs

@@ -6,10 +6,8 @@ using System.IO;
 using System.Linq;
 using System.Linq;
 using System.Windows.Forms;
 using System.Windows.Forms;
 
 
-namespace Optimizer
-{
-    internal static class OptionsHelper
-    {
+namespace Optimizer {
+    internal static class OptionsHelper {
         internal static Color ForegroundColor = Color.FromArgb(153, 102, 204);
         internal static Color ForegroundColor = Color.FromArgb(153, 102, 204);
         internal static Color ForegroundAccentColor = Color.FromArgb(134, 89, 179);
         internal static Color ForegroundAccentColor = Color.FromArgb(134, 89, 179);
         internal static Color BackgroundColor = Color.FromArgb(10, 10, 10);
         internal static Color BackgroundColor = Color.FromArgb(10, 10, 10);
@@ -22,30 +20,25 @@ namespace Optimizer
 
 
         internal static dynamic TranslationList;
         internal static dynamic TranslationList;
 
 
-        internal static Color GetContrastColor(Color c)
-        {
+        internal static Color GetContrastColor(Color c) {
             double brightness = c.R * 0.299 + c.G * 0.587 + c.B * 0.114;
             double brightness = c.R * 0.299 + c.G * 0.587 + c.B * 0.114;
             return brightness > Constants.CONTRAST_THRESHOLD ? Color.Black : Color.White;
             return brightness > Constants.CONTRAST_THRESHOLD ? Color.Black : Color.White;
         }
         }
 
 
-        internal static void ApplyTheme(Form f)
-        {
+        internal static void ApplyTheme(Form f) {
             SetTheme(f, CurrentOptions.Theme, ColorHelper.ChangeColorBrightness(CurrentOptions.Theme, 0.7));
             SetTheme(f, CurrentOptions.Theme, ColorHelper.ChangeColorBrightness(CurrentOptions.Theme, 0.7));
         }
         }
 
 
-        private static void SetTheme(Form f, Color c1, Color c2)
-        {
+        private static void SetTheme(Form f, Color c1, Color c2) {
             dynamic c;
             dynamic c;
             ForegroundColor = c1;
             ForegroundColor = c1;
             ForegroundAccentColor = c2;
             ForegroundAccentColor = c2;
             TextColor = GetContrastColor(CurrentOptions.Theme);
             TextColor = GetContrastColor(CurrentOptions.Theme);
 
 
-            Utilities.GetSelfAndChildrenRecursive(f).ToList().ForEach(x =>
-            {
+            Utilities.GetSelfAndChildrenRecursive(f).ToList().ForEach(x => {
                 c = x;
                 c = x;
 
 
-                if (x is Button)
-                {
+                if (x is Button) {
                     c.ForeColor = TextColor;
                     c.ForeColor = TextColor;
                     c.BackColor = c1;
                     c.BackColor = c1;
                     c.FlatAppearance.BorderColor = c1;
                     c.FlatAppearance.BorderColor = c1;
@@ -54,20 +47,16 @@ namespace Optimizer
                     c.FlatAppearance.BorderSize = 0;
                     c.FlatAppearance.BorderSize = 0;
                 }
                 }
 
 
-                if (x is LinkLabel)
-                {
-                    if ((string)c.Tag == Constants.THEME_FLAG)
-                    {
+                if (x is LinkLabel) {
+                    if ((string)c.Tag == Constants.THEME_FLAG) {
                         c.LinkColor = c1;
                         c.LinkColor = c1;
                         c.VisitedLinkColor = c1;
                         c.VisitedLinkColor = c1;
                         c.ActiveLinkColor = c2;
                         c.ActiveLinkColor = c2;
                     }
                     }
                 }
                 }
 
 
-                if (x is CheckBox || x is RadioButton || x is Label)
-                {
-                    if ((string)c.Tag == Constants.THEME_FLAG)
-                    {
+                if (x is CheckBox || x is RadioButton || x is Label) {
+                    if ((string)c.Tag == Constants.THEME_FLAG) {
                         c.ForeColor = c1;
                         c.ForeColor = c1;
                     }
                     }
                 }
                 }
@@ -76,21 +65,16 @@ namespace Optimizer
             });
             });
         }
         }
 
 
-        internal static void LegacyCheck()
-        {
-            if (File.Exists(SettingsFile))
-            {
-                if (File.ReadAllText(SettingsFile).Contains("FirstRun"))
-                {
+        internal static void LegacyCheck() {
+            if (File.Exists(SettingsFile)) {
+                if (File.ReadAllText(SettingsFile).Contains("FirstRun")) {
                     File.Delete(SettingsFile);
                     File.Delete(SettingsFile);
                 }
                 }
             }
             }
         }
         }
 
 
-        internal static void SaveSettings()
-        {
-            if (File.Exists(SettingsFile))
-            {
+        internal static void SaveSettings() {
+            if (File.Exists(SettingsFile)) {
                 string jsonFile = File.ReadAllText(SettingsFile);
                 string jsonFile = File.ReadAllText(SettingsFile);
                 string jsonMemory = JsonConvert.SerializeObject(CurrentOptions);
                 string jsonMemory = JsonConvert.SerializeObject(CurrentOptions);
 
 
@@ -101,8 +85,7 @@ namespace Optimizer
 
 
                 using (FileStream fs = File.Open(SettingsFile, FileMode.OpenOrCreate))
                 using (FileStream fs = File.Open(SettingsFile, FileMode.OpenOrCreate))
                 using (StreamWriter sw = new StreamWriter(fs))
                 using (StreamWriter sw = new StreamWriter(fs))
-                using (JsonWriter jw = new JsonTextWriter(sw))
-                {
+                using (JsonWriter jw = new JsonTextWriter(sw)) {
                     jw.Formatting = Formatting.Indented;
                     jw.Formatting = Formatting.Indented;
 
 
                     JsonSerializer serializer = new JsonSerializer();
                     JsonSerializer serializer = new JsonSerializer();
@@ -111,23 +94,18 @@ namespace Optimizer
             }
             }
         }
         }
 
 
-        internal static void LoadSettings()
-        {
-            if (!File.Exists(SettingsFile) || File.ReadAllText(SettingsFile).Contains("\"Color\":"))
-            {
+        internal static void LoadSettings() {
+            if (!File.Exists(SettingsFile) || File.ReadAllText(SettingsFile).Contains("\"Color\":")) {
                 // settings migration for new color picker
                 // settings migration for new color picker
-                if (File.Exists(SettingsFile) && File.ReadAllText(SettingsFile).Contains("\"Color\":"))
-                {
+                if (File.Exists(SettingsFile) && File.ReadAllText(SettingsFile).Contains("\"Color\":")) {
                     Options tmpJson = JsonConvert.DeserializeObject<Options>(File.ReadAllText(SettingsFile));
                     Options tmpJson = JsonConvert.DeserializeObject<Options>(File.ReadAllText(SettingsFile));
                     tmpJson.Theme = Color.FromArgb(153, 102, 204);
                     tmpJson.Theme = Color.FromArgb(153, 102, 204);
                     CurrentOptions = tmpJson;
                     CurrentOptions = tmpJson;
                 }
                 }
-                else
-                {
+                else {
                     // DEFAULT OPTIONS
                     // DEFAULT OPTIONS
                     CurrentOptions.Theme = Color.FromArgb(153, 102, 204);
                     CurrentOptions.Theme = Color.FromArgb(153, 102, 204);
-                    CurrentOptions.AppsFolder = Path.Combine(Utilities.GetUserDownloadsFolder(), Constants.DOWNLOADS_FOLDER);
-                    Directory.CreateDirectory(OptionsHelper.CurrentOptions.AppsFolder);
+                    CurrentOptions.AppsFolder = string.Empty;
                     CurrentOptions.EnableTray = false;
                     CurrentOptions.EnableTray = false;
                     CurrentOptions.AutoStart = false;
                     CurrentOptions.AutoStart = false;
                     CurrentOptions.InternalDNS = Constants.INTERNAL_DNS;
                     CurrentOptions.InternalDNS = Constants.INTERNAL_DNS;
@@ -216,8 +194,7 @@ namespace Optimizer
 
 
                     using (FileStream fs = File.Open(SettingsFile, FileMode.CreateNew))
                     using (FileStream fs = File.Open(SettingsFile, FileMode.CreateNew))
                     using (StreamWriter sw = new StreamWriter(fs))
                     using (StreamWriter sw = new StreamWriter(fs))
-                    using (JsonWriter jw = new JsonTextWriter(sw))
-                    {
+                    using (JsonWriter jw = new JsonTextWriter(sw)) {
                         jw.Formatting = Formatting.Indented;
                         jw.Formatting = Formatting.Indented;
 
 
                         JsonSerializer serializer = new JsonSerializer();
                         JsonSerializer serializer = new JsonSerializer();
@@ -225,14 +202,12 @@ namespace Optimizer
                     }
                     }
                 }
                 }
             }
             }
-            else
-            {
+            else {
                 CurrentOptions = JsonConvert.DeserializeObject<Options>(File.ReadAllText(SettingsFile));
                 CurrentOptions = JsonConvert.DeserializeObject<Options>(File.ReadAllText(SettingsFile));
             }
             }
 
 
             // prevent options from corruption
             // prevent options from corruption
-            if (CurrentOptions.Theme == Color.Empty || CurrentOptions.Theme == Color.FromArgb(0, 0, 0, 0))
-            {
+            if (CurrentOptions.Theme == Color.Empty || CurrentOptions.Theme == Color.FromArgb(0, 0, 0, 0)) {
                 CurrentOptions.Theme = Color.FromArgb(153, 102, 204);
                 CurrentOptions.Theme = Color.FromArgb(153, 102, 204);
             }
             }
             // generate random telemetry ID if not present
             // generate random telemetry ID if not present
@@ -245,11 +220,9 @@ namespace Optimizer
             LoadTranslation();
             LoadTranslation();
         }
         }
 
 
-        internal static void LoadTranslation()
-        {
+        internal static void LoadTranslation() {
             // load proper translation list
             // load proper translation list
-            try
-            {
+            try {
                 if (CurrentOptions.LanguageCode == LanguageCode.EN) TranslationList = JObject.Parse(Properties.Resources.EN);
                 if (CurrentOptions.LanguageCode == LanguageCode.EN) TranslationList = JObject.Parse(Properties.Resources.EN);
                 if (CurrentOptions.LanguageCode == LanguageCode.RU) TranslationList = JObject.Parse(Properties.Resources.RU);
                 if (CurrentOptions.LanguageCode == LanguageCode.RU) TranslationList = JObject.Parse(Properties.Resources.RU);
                 if (CurrentOptions.LanguageCode == LanguageCode.EL) TranslationList = JObject.Parse(Properties.Resources.EL);
                 if (CurrentOptions.LanguageCode == LanguageCode.EL) TranslationList = JObject.Parse(Properties.Resources.EL);
@@ -275,8 +248,7 @@ namespace Optimizer
                 if (CurrentOptions.LanguageCode == LanguageCode.NE) TranslationList = JObject.Parse(Properties.Resources.NE);
                 if (CurrentOptions.LanguageCode == LanguageCode.NE) TranslationList = JObject.Parse(Properties.Resources.NE);
                 if (CurrentOptions.LanguageCode == LanguageCode.BG) TranslationList = JObject.Parse(Properties.Resources.BG);
                 if (CurrentOptions.LanguageCode == LanguageCode.BG) TranslationList = JObject.Parse(Properties.Resources.BG);
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("Options.LoadTranslation", ex.Message, ex.StackTrace);
                 Logger.LogError("Options.LoadTranslation", ex.Message, ex.StackTrace);
                 TranslationList = JObject.Parse(Properties.Resources.EN);
                 TranslationList = JObject.Parse(Properties.Resources.EN);
             }
             }

+ 24 - 46
Optimizer/PingerHelper.cs

@@ -5,10 +5,8 @@ using System.Net;
 using System.Net.NetworkInformation;
 using System.Net.NetworkInformation;
 using System.Net.Sockets;
 using System.Net.Sockets;
 
 
-namespace Optimizer
-{
-    internal static class PingerHelper
-    {
+namespace Optimizer {
+    internal static class PingerHelper {
         internal static string[] DNSOptions =
         internal static string[] DNSOptions =
         {
         {
             "Automatic",
             "Automatic",
@@ -53,10 +51,8 @@ namespace Optimizer
 
 
         static IPAddress addressToPing;
         static IPAddress addressToPing;
 
 
-        internal static NetworkInterface[] GetActiveNetworkAdapters()
-        {
-            try
-            {
+        internal static NetworkInterface[] GetActiveNetworkAdapters() {
+            try {
                 if (ShowHiddenAdapters) NetworkAdapters = NetworkInterface.GetAllNetworkInterfaces();
                 if (ShowHiddenAdapters) NetworkAdapters = NetworkInterface.GetAllNetworkInterfaces();
 
 
                 if (!ShowHiddenAdapters) NetworkAdapters = NetworkInterface.GetAllNetworkInterfaces().Where(
                 if (!ShowHiddenAdapters) NetworkAdapters = NetworkInterface.GetAllNetworkInterfaces().Where(
@@ -64,8 +60,7 @@ namespace Optimizer
                     (a.NetworkInterfaceType == NetworkInterfaceType.Wireless80211 || a.NetworkInterfaceType == NetworkInterfaceType.Ethernet) &&
                     (a.NetworkInterfaceType == NetworkInterfaceType.Wireless80211 || a.NetworkInterfaceType == NetworkInterfaceType.Ethernet) &&
                     a.GetIPProperties().GatewayAddresses.Any(g => g.Address.AddressFamily.ToString() == "InterNetwork")).ToArray();
                     a.GetIPProperties().GatewayAddresses.Any(g => g.Address.AddressFamily.ToString() == "InterNetwork")).ToArray();
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("PingerHelper.GetActiveNetworkAdapters", ex.Message, ex.StackTrace);
                 Logger.LogError("PingerHelper.GetActiveNetworkAdapters", ex.Message, ex.StackTrace);
                 return null;
                 return null;
             }
             }
@@ -73,33 +68,27 @@ namespace Optimizer
             return NetworkAdapters;
             return NetworkAdapters;
         }
         }
 
 
-        internal static IEnumerable<string> GetDNSFromNetworkAdapter(NetworkInterface nic)
-        {
-            try
-            {
+        internal static IEnumerable<string> GetDNSFromNetworkAdapter(NetworkInterface nic) {
+            try {
                 return nic.GetIPProperties().DnsAddresses.Select(z => z.ToString());
                 return nic.GetIPProperties().DnsAddresses.Select(z => z.ToString());
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("PingerHelper.GetDNSFromNetworkAdapter", ex.Message, ex.StackTrace);
                 Logger.LogError("PingerHelper.GetDNSFromNetworkAdapter", ex.Message, ex.StackTrace);
                 return null;
                 return null;
             }
             }
         }
         }
 
 
-        internal static void SetDNS(string nic, string[] dnsv4, string[] dnsv6)
-        {
+        internal static void SetDNS(string nic, string[] dnsv4, string[] dnsv6) {
             string cmdv4Alternate = string.Empty;
             string cmdv4Alternate = string.Empty;
             string cmdv6Alternate = string.Empty;
             string cmdv6Alternate = string.Empty;
 
 
             string cmdv4Primary = $"netsh interface ipv4 set dnsservers {nic} static {dnsv4[0]} primary";
             string cmdv4Primary = $"netsh interface ipv4 set dnsservers {nic} static {dnsv4[0]} primary";
-            if (dnsv4.Length == 2)
-            {
+            if (dnsv4.Length == 2) {
                 cmdv4Alternate = $"netsh interface ipv4 add dnsservers {nic} {dnsv4[1]} index=2";
                 cmdv4Alternate = $"netsh interface ipv4 add dnsservers {nic} {dnsv4[1]} index=2";
             }
             }
 
 
             string cmdv6Primary = $"netsh interface ipv6 set dnsservers {nic} static {dnsv6[0]} primary";
             string cmdv6Primary = $"netsh interface ipv6 set dnsservers {nic} static {dnsv6[0]} primary";
-            if (dnsv6.Length == 2)
-            {
+            if (dnsv6.Length == 2) {
                 cmdv6Alternate = $"netsh interface ipv6 add dnsservers {nic} {dnsv6[1]} index=2";
                 cmdv6Alternate = $"netsh interface ipv6 add dnsservers {nic} {dnsv6[1]} index=2";
             }
             }
 
 
@@ -110,8 +99,7 @@ namespace Optimizer
             Utilities.RunCommand(cmdv6Alternate);
             Utilities.RunCommand(cmdv6Alternate);
         }
         }
 
 
-        internal static void ResetDefaultDNS(string nic)
-        {
+        internal static void ResetDefaultDNS(string nic) {
             string cmdv4 = $"netsh interface ipv4 set dnsservers {nic} dhcp";
             string cmdv4 = $"netsh interface ipv4 set dnsservers {nic} dhcp";
             string cmdv6 = $"netsh interface ipv6 set dnsservers {nic} dhcp";
             string cmdv6 = $"netsh interface ipv6 set dnsservers {nic} dhcp";
 
 
@@ -119,40 +107,33 @@ namespace Optimizer
             Utilities.RunCommand(cmdv6);
             Utilities.RunCommand(cmdv6);
         }
         }
 
 
-        internal static void ResetDefaultDNSForAllNICs()
-        {
-            foreach (string nic in NetworkAdapters.Select(x => x.Name))
-            {
+        internal static void ResetDefaultDNSForAllNICs() {
+            foreach (string nic in NetworkAdapters.Select(x => x.Name)) {
                 ResetDefaultDNS(nic);
                 ResetDefaultDNS(nic);
             }
             }
         }
         }
 
 
-        internal static void SetDNSForAllNICs(string[] dnsv4, string[] dnsv6)
-        {
-            foreach (string nic in NetworkAdapters.Select(x => x.Name))
-            {
+        internal static void SetDNSForAllNICs(string[] dnsv4, string[] dnsv6) {
+            foreach (string nic in NetworkAdapters.Select(x => x.Name)) {
                 SetDNS(nic, dnsv4, dnsv6);
                 SetDNS(nic, dnsv4, dnsv6);
             }
             }
         }
         }
 
 
-        internal static PingReply PingHost(string nameOrAddress)
-        {
+        internal static PingReply PingHost(string nameOrAddress) {
             PingReply reply;
             PingReply reply;
-            try
-            {
+            try {
                 addressToPing = Dns.GetHostAddresses(nameOrAddress).First(address => address.AddressFamily == AddressFamily.InterNetwork);
                 addressToPing = Dns.GetHostAddresses(nameOrAddress).First(address => address.AddressFamily == AddressFamily.InterNetwork);
 
 
                 reply = pinger.Send(addressToPing);
                 reply = pinger.Send(addressToPing);
                 return reply;
                 return reply;
             }
             }
-            catch
-            {
+            catch {
                 return null;
                 return null;
             }
             }
         }
         }
 
 
-        internal static bool IsInternetAvailable()
-        {
+        // It uses the InternalDNS setting for this
+        internal static bool IsInternetAvailable() {
             const int timeout = 1000;
             const int timeout = 1000;
             string host = OptionsHelper.CurrentOptions.InternalDNS ?? Constants.INTERNAL_DNS;
             string host = OptionsHelper.CurrentOptions.InternalDNS ?? Constants.INTERNAL_DNS;
 
 
@@ -160,19 +141,16 @@ namespace Optimizer
             var buffer = new byte[32];
             var buffer = new byte[32];
             var pingOptions = new PingOptions();
             var pingOptions = new PingOptions();
 
 
-            try
-            {
+            try {
                 var reply = ping.Send(host, timeout, buffer, pingOptions);
                 var reply = ping.Send(host, timeout, buffer, pingOptions);
                 return (reply != null && reply.Status == IPStatus.Success);
                 return (reply != null && reply.Status == IPStatus.Success);
             }
             }
-            catch (Exception)
-            {
+            catch (Exception) {
                 return false;
                 return false;
             }
             }
         }
         }
 
 
-        internal static void FlushDNSCache()
-        {
+        internal static void FlushDNSCache() {
             Utilities.RunCommand("ipconfig /flushdns");
             Utilities.RunCommand("ipconfig /flushdns");
         }
         }
 
 

+ 55 - 104
Optimizer/Program.cs

@@ -6,24 +6,20 @@ using System.Reflection;
 using System.Threading;
 using System.Threading;
 using System.Windows.Forms;
 using System.Windows.Forms;
 
 
-namespace Optimizer
-{
-    static class Program
-    {
-        /* VERSION PROPERTIES */
-        /* DO NOT LEAVE THEM EMPTY */
+namespace Optimizer {
+    static class Program {
+        /// <summary>
+        /// Version properties. Do NOT leave them empty
+        /// </summary>
         internal readonly static float Major = 16;
         internal readonly static float Major = 16;
-        internal readonly static float Minor = 3;
+        internal readonly static float Minor = 4;
         internal readonly static bool EXPERIMENTAL_BUILD = false;
         internal readonly static bool EXPERIMENTAL_BUILD = false;
-        /* END OF VERSION PROPERTIES */
 
 
-        internal static string GetCurrentVersionTostring()
-        {
-            return Major.ToString() + "." + Minor.ToString();
+        internal static string GetCurrentVersionTostring() {
+            return $"{Major.ToString()}.{Minor.ToString()}";
         }
         }
 
 
-        internal static float GetCurrentVersion()
-        {
+        internal static float GetCurrentVersionToFloat() {
             return float.Parse(GetCurrentVersionTostring());
             return float.Parse(GetCurrentVersionTostring());
         }
         }
 
 
@@ -56,18 +52,16 @@ namespace Optimizer
         private static extern bool SetProcessDPIAware();
         private static extern bool SetProcessDPIAware();
 
 
         [STAThread]
         [STAThread]
-        static void Main(string[] switches)
-        {
+        static void Main(string[] switches) {
             AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
             AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
             AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
             AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
             EmbeddedAssembly.Load(_jsonAssembly, _jsonAssembly.Replace("Optimizer.", string.Empty));
             EmbeddedAssembly.Load(_jsonAssembly, _jsonAssembly.Replace("Optimizer.", string.Empty));
 
 
             DPI_PREFERENCE = Convert.ToInt32(Microsoft.Win32.Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ThemeManager", "LastLoadedDPI", "96"));
             DPI_PREFERENCE = Convert.ToInt32(Microsoft.Win32.Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ThemeManager", "LastLoadedDPI", "96"));
-            if (DPI_PREFERENCE <= 0)
-            {
+            if (DPI_PREFERENCE <= 0) {
                 DPI_PREFERENCE = 96;
                 DPI_PREFERENCE = 96;
             }
             }
-            
+
             if (Environment.OSVersion.Version.Major >= 6) SetProcessDPIAware();
             if (Environment.OSVersion.Version.Major >= 6) SetProcessDPIAware();
             Application.EnableVisualStyles();
             Application.EnableVisualStyles();
             Application.SetCompatibleTextRenderingDefault(false);
             Application.SetCompatibleTextRenderingDefault(false);
@@ -75,15 +69,13 @@ namespace Optimizer
             // single-instance mechanism
             // single-instance mechanism
             MUTEX = new Mutex(true, MUTEX_GUID, out _notRunning);
             MUTEX = new Mutex(true, MUTEX_GUID, out _notRunning);
 
 
-            if (!_notRunning)
-            {
+            if (!_notRunning) {
                 MessageBox.Show(_alreadyRunningMsg, "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 MessageBox.Show(_alreadyRunningMsg, "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 Environment.Exit(0);
                 Environment.Exit(0);
                 return;
                 return;
             }
             }
 
 
-            if (!Utilities.IsAdmin())
-            {
+            if (!Utilities.IsAdmin()) {
                 string file = Process.GetCurrentProcess().MainModule.FileName;
                 string file = Process.GetCurrentProcess().MainModule.FileName;
                 ProcessStartInfo p = new ProcessStartInfo(file);
                 ProcessStartInfo p = new ProcessStartInfo(file);
                 p.Verb = "runas";
                 p.Verb = "runas";
@@ -93,8 +85,7 @@ namespace Optimizer
                 return;
                 return;
             }
             }
 
 
-            if (!Utilities.IsCompatible())
-            {
+            if (!Utilities.IsCompatible()) {
                 HelperForm f = new HelperForm(null, MessageType.Error, _unsupportedMessage);
                 HelperForm f = new HelperForm(null, MessageType.Error, _unsupportedMessage);
                 f.ShowDialog();
                 f.ShowDialog();
                 Environment.Exit(0);
                 Environment.Exit(0);
@@ -104,47 +95,40 @@ namespace Optimizer
             CoreHelper.Deploy();
             CoreHelper.Deploy();
             FontHelper.LoadFont();
             FontHelper.LoadFont();
 
 
-            if (switches.Length == 1)
-            {
+            if (switches.Length == 1) {
                 string arg = switches[0].Trim().ToLowerInvariant();
                 string arg = switches[0].Trim().ToLowerInvariant();
 
 
                 // UNSAFE mode switch (allows running on Windows Server 2008+)
                 // UNSAFE mode switch (allows running on Windows Server 2008+)
-                if (arg == "/unsafe")
-                {
+                if (arg == "/unsafe") {
                     UNSAFE_MODE = true;
                     UNSAFE_MODE = true;
                     StartMainForm();
                     StartMainForm();
                     return;
                     return;
                 }
                 }
 
 
-                if (arg == "/repair")
-                {
+                if (arg == "/repair") {
                     Utilities.Repair(true);
                     Utilities.Repair(true);
                     return;
                     return;
                 }
                 }
 
 
-                if (arg == "/disablehpet")
-                {
+                if (arg == "/disablehpet") {
                     Utilities.DisableHPET();
                     Utilities.DisableHPET();
                     Environment.Exit(0);
                     Environment.Exit(0);
                     return;
                     return;
                 }
                 }
-                if (arg == "/enablehpet")
-                {
+                if (arg == "/enablehpet") {
                     Utilities.EnableHPET();
                     Utilities.EnableHPET();
                     Environment.Exit(0);
                     Environment.Exit(0);
                     return;
                     return;
                 }
                 }
 
 
                 // [!!!] unlock all cores instruction 
                 // [!!!] unlock all cores instruction 
-                if (arg == "/unlockcores")
-                {
+                if (arg == "/unlockcores") {
                     Utilities.UnlockAllCores();
                     Utilities.UnlockAllCores();
                     Environment.Exit(0);
                     Environment.Exit(0);
                     return;
                     return;
                 }
                 }
 
 
-                if (arg.StartsWith("/svchostsplit="))
-                {
+                if (arg.StartsWith("/svchostsplit=")) {
                     string x = arg.Replace("/svchostsplit=", string.Empty);
                     string x = arg.Replace("/svchostsplit=", string.Empty);
                     bool isValid = !x.Any(c => !char.IsDigit(c));
                     bool isValid = !x.Any(c => !char.IsDigit(c));
                     if (isValid && int.TryParse(x, out int result)) Utilities.DisableSvcHostProcessSplitting(result);
                     if (isValid && int.TryParse(x, out int result)) Utilities.DisableSvcHostProcessSplitting(result);
@@ -152,15 +136,13 @@ namespace Optimizer
                     return;
                     return;
                 }
                 }
 
 
-                if (arg == "/resetsvchostsplit")
-                {
+                if (arg == "/resetsvchostsplit") {
                     Utilities.EnableSvcHostProcessSplitting();
                     Utilities.EnableSvcHostProcessSplitting();
                     Environment.Exit(0);
                     Environment.Exit(0);
                     return;
                     return;
                 }
                 }
 
 
-                if (arg == "/version")
-                {
+                if (arg == "/version") {
                     if (!EXPERIMENTAL_BUILD) MessageBox.Show($"Optimizer: {GetCurrentVersionTostring()}\n\nCoded by: deadmoon © ∞\n\nhttps://github.com/hellzerg/optimizer", "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     if (!EXPERIMENTAL_BUILD) MessageBox.Show($"Optimizer: {GetCurrentVersionTostring()}\n\nCoded by: deadmoon © ∞\n\nhttps://github.com/hellzerg/optimizer", "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     else MessageBox.Show("Optimizer: EXPERIMENTAL BUILD. PLEASE DELETE AFTER TESTING.\n\nCoded by: deadmoon © ∞\n\nhttps://github.com/hellzerg/optimizer", "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     else MessageBox.Show("Optimizer: EXPERIMENTAL BUILD. PLEASE DELETE AFTER TESTING.\n\nCoded by: deadmoon © ∞\n\nhttps://github.com/hellzerg/optimizer", "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
 
 
@@ -168,45 +150,38 @@ namespace Optimizer
                     return;
                     return;
                 }
                 }
                 // instruct to restart in safe-mode
                 // instruct to restart in safe-mode
-                if (arg == "/restart=safemode")
-                {
+                if (arg == "/restart=safemode") {
                     RestartInSafeMode();
                     RestartInSafeMode();
                 }
                 }
 
 
                 // instruct to restart normally
                 // instruct to restart normally
-                if (arg == "/restart=normal")
-                {
+                if (arg == "/restart=normal") {
                     RestartInNormalMode();
                     RestartInNormalMode();
                 }
                 }
 
 
                 // disable defender automatically
                 // disable defender automatically
-                if (arg == "/restart=disabledefender")
-                {
+                if (arg == "/restart=disabledefender") {
                     SetRunOnceDisableDefender();
                     SetRunOnceDisableDefender();
                 }
                 }
 
 
                 // enable defender automatically
                 // enable defender automatically
-                if (arg == "/restart=enabledefender")
-                {
+                if (arg == "/restart=enabledefender") {
                     SetRunOnceEnableDefender();
                     SetRunOnceEnableDefender();
                 }
                 }
 
 
                 // return from safe-mode automatically
                 // return from safe-mode automatically
-                if (arg == "/silentdisabledefender")
-                {
+                if (arg == "/silentdisabledefender") {
                     DisableDefenderInSafeMode();
                     DisableDefenderInSafeMode();
                     RestartInNormalMode();
                     RestartInNormalMode();
                 }
                 }
 
 
-                if (arg == "/silentenabledefender")
-                {
+                if (arg == "/silentenabledefender") {
                     EnableDefenderInSafeMode();
                     EnableDefenderInSafeMode();
                     RestartInNormalMode();
                     RestartInNormalMode();
                 }
                 }
 
 
                 // disables Defender in SAFE MODE (for Windows 10 1903+ / works in Windows 11 as well)
                 // disables Defender in SAFE MODE (for Windows 10 1903+ / works in Windows 11 as well)
-                if (arg == "/disabledefender")
-                {
+                if (arg == "/disabledefender") {
                     DisableDefenderInSafeMode();
                     DisableDefenderInSafeMode();
 
 
                     MessageBox.Show("Windows Defender has been completely disabled successfully.", "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     MessageBox.Show("Windows Defender has been completely disabled successfully.", "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
@@ -216,8 +191,7 @@ namespace Optimizer
 
 
 
 
                 // other options for disabling specific tools
                 // other options for disabling specific tools
-                if (arg.StartsWith("/disable="))
-                {
+                if (arg.StartsWith("/disable=")) {
                     string x = arg.Replace("/disable=", string.Empty);
                     string x = arg.Replace("/disable=", string.Empty);
                     string[] opts = x.Split(',');
                     string[] opts = x.Split(',');
 
 
@@ -235,13 +209,11 @@ namespace Optimizer
                     return;
                     return;
                 }
                 }
 
 
-                if (arg.StartsWith("/config="))
-                {
+                if (arg.StartsWith("/config=")) {
                     UNSAFE_MODE = true;
                     UNSAFE_MODE = true;
                     string fileName = arg.Replace("/config=", string.Empty);
                     string fileName = arg.Replace("/config=", string.Empty);
 
 
-                    if (!File.Exists(fileName))
-                    {
+                    if (!File.Exists(fileName)) {
                         MessageBox.Show(_confNotFoundMsg, "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
                         MessageBox.Show(_confNotFoundMsg, "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
                         Environment.Exit(0);
                         Environment.Exit(0);
                         return;
                         return;
@@ -249,14 +221,12 @@ namespace Optimizer
 
 
                     SilentOps.GetSilentConfig(fileName);
                     SilentOps.GetSilentConfig(fileName);
 
 
-                    if (SilentOps.CurrentSilentConfig == null)
-                    {
+                    if (SilentOps.CurrentSilentConfig == null) {
                         MessageBox.Show(_confInvalidFormatMsg, "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
                         MessageBox.Show(_confInvalidFormatMsg, "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
                         Environment.Exit(0);
                         Environment.Exit(0);
                         return;
                         return;
                     }
                     }
-                    if (!SilentOps.ProcessWindowsVersionCompatibility())
-                    {
+                    if (!SilentOps.ProcessWindowsVersionCompatibility()) {
                         MessageBox.Show(_confInvalidVersionMsg, "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
                         MessageBox.Show(_confInvalidVersionMsg, "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
                         Environment.Exit(0);
                         Environment.Exit(0);
                         return;
                         return;
@@ -267,38 +237,31 @@ namespace Optimizer
                     OptionsHelper.SaveSettings();
                     OptionsHelper.SaveSettings();
                 }
                 }
             }
             }
-            else
-            {
+            else {
                 StartMainForm();
                 StartMainForm();
             }
             }
         }
         }
 
 
-        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
-        {
+        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) {
             Exception error = (Exception)e.ExceptionObject;
             Exception error = (Exception)e.ExceptionObject;
             Logger.LogError("Program.Main-UnhandledException", error.Message, error.StackTrace);
             Logger.LogError("Program.Main-UnhandledException", error.Message, error.StackTrace);
         }
         }
 
 
-        private static void LoadSettings()
-        {
+        private static void LoadSettings() {
             // for backward compatibility (legacy)
             // for backward compatibility (legacy)
             OptionsHelper.LegacyCheck();
             OptionsHelper.LegacyCheck();
 
 
             // load settings, if there is no settings, load defaults
             // load settings, if there is no settings, load defaults
-            try
-            {
+            try {
                 // show FirstRunForm/Language Selector if app is running first time
                 // show FirstRunForm/Language Selector if app is running first time
-                if (!File.Exists(OptionsHelper.SettingsFile))
-                {
+                if (!File.Exists(OptionsHelper.SettingsFile)) {
                     OptionsHelper.LoadSettings();
                     OptionsHelper.LoadSettings();
-                    if (!SILENT_MODE)
-                    {
+                    if (!SILENT_MODE) {
                         FirstRunForm frf = new FirstRunForm();
                         FirstRunForm frf = new FirstRunForm();
                         frf.ShowDialog();
                         frf.ShowDialog();
                     }
                     }
                 }
                 }
-                else
-                {
+                else {
                     OptionsHelper.LoadSettings();
                     OptionsHelper.LoadSettings();
                 }
                 }
 
 
@@ -316,15 +279,13 @@ namespace Optimizer
                 _argInvalidMsg = OptionsHelper.TranslationList["argInvalidMsg"];
                 _argInvalidMsg = OptionsHelper.TranslationList["argInvalidMsg"];
                 _alreadyRunningMsg = OptionsHelper.TranslationList["alreadyRunningMsg"];
                 _alreadyRunningMsg = OptionsHelper.TranslationList["alreadyRunningMsg"];
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("Program.Main-LoadSettings", ex.Message, ex.StackTrace);
                 Logger.LogError("Program.Main-LoadSettings", ex.Message, ex.StackTrace);
                 Environment.Exit(0);
                 Environment.Exit(0);
             }
             }
         }
         }
 
 
-        internal static void RestartInSafeMode()
-        {
+        internal static void RestartInSafeMode() {
             Utilities.RunCommand("bcdedit /set {current} safeboot Minimal");
             Utilities.RunCommand("bcdedit /set {current} safeboot Minimal");
             Thread.Sleep(500);
             Thread.Sleep(500);
             Utilities.Reboot();
             Utilities.Reboot();
@@ -332,8 +293,7 @@ namespace Optimizer
             Environment.Exit(0);
             Environment.Exit(0);
         }
         }
 
 
-        internal static void RestartInNormalMode()
-        {
+        internal static void RestartInNormalMode() {
             Utilities.RunCommand("bcdedit /deletevalue {current} safeboot");
             Utilities.RunCommand("bcdedit /deletevalue {current} safeboot");
             Thread.Sleep(500);
             Thread.Sleep(500);
             Utilities.Reboot();
             Utilities.Reboot();
@@ -341,8 +301,7 @@ namespace Optimizer
             Environment.Exit(0);
             Environment.Exit(0);
         }
         }
 
 
-        private static void DisableDefenderInSafeMode()
-        {
+        private static void DisableDefenderInSafeMode() {
             File.WriteAllText("DisableDefenderSafeMode.bat", Properties.Resources.DisableDefenderSafeMode1903Plus);
             File.WriteAllText("DisableDefenderSafeMode.bat", Properties.Resources.DisableDefenderSafeMode1903Plus);
 
 
             Utilities.RunBatchFile("DisableDefenderSafeMode.bat");
             Utilities.RunBatchFile("DisableDefenderSafeMode.bat");
@@ -353,8 +312,7 @@ namespace Optimizer
             File.Delete("DisableDefenderSafeMode.bat");
             File.Delete("DisableDefenderSafeMode.bat");
         }
         }
 
 
-        private static void EnableDefenderInSafeMode()
-        {
+        private static void EnableDefenderInSafeMode() {
             File.WriteAllText("EnableDefenderSafeMode.bat", Properties.Resources.EnableDefenderSafeMode1903Plus);
             File.WriteAllText("EnableDefenderSafeMode.bat", Properties.Resources.EnableDefenderSafeMode1903Plus);
 
 
             Utilities.RunBatchFile("EnableDefenderSafeMode.bat");
             Utilities.RunBatchFile("EnableDefenderSafeMode.bat");
@@ -365,22 +323,19 @@ namespace Optimizer
             File.Delete("EnableDefenderSafeMode.bat");
             File.Delete("EnableDefenderSafeMode.bat");
         }
         }
 
 
-        internal static void SetRunOnceDisableDefender()
-        {
+        internal static void SetRunOnceDisableDefender() {
             // set RunOnce instruction
             // set RunOnce instruction
             Microsoft.Win32.Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce", "*OptimizerDisableDefender", Assembly.GetExecutingAssembly().Location + " /silentdisabledefender", Microsoft.Win32.RegistryValueKind.String);
             Microsoft.Win32.Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce", "*OptimizerDisableDefender", Assembly.GetExecutingAssembly().Location + " /silentdisabledefender", Microsoft.Win32.RegistryValueKind.String);
             RestartInSafeMode();
             RestartInSafeMode();
         }
         }
 
 
-        internal static void SetRunOnceEnableDefender()
-        {
+        internal static void SetRunOnceEnableDefender() {
             // set RunOnce instruction
             // set RunOnce instruction
             Microsoft.Win32.Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce", "*OptimizerEnableDefender", Assembly.GetExecutingAssembly().Location + " /silentenabledefender", Microsoft.Win32.RegistryValueKind.String);
             Microsoft.Win32.Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce", "*OptimizerEnableDefender", Assembly.GetExecutingAssembly().Location + " /silentenabledefender", Microsoft.Win32.RegistryValueKind.String);
             RestartInSafeMode();
             RestartInSafeMode();
         }
         }
 
 
-        private static void StartMainForm()
-        {
+        private static void StartMainForm() {
             LoadSettings();
             LoadSettings();
             StartSplashForm();
             StartSplashForm();
 
 
@@ -389,8 +344,7 @@ namespace Optimizer
             Application.Run(_MainForm);
             Application.Run(_MainForm);
         }
         }
 
 
-        private static void StartMainForm(bool?[] codes)
-        {
+        private static void StartMainForm(bool?[] codes) {
             LoadSettings();
             LoadSettings();
             StartSplashForm();
             StartSplashForm();
 
 
@@ -399,8 +353,7 @@ namespace Optimizer
             Application.Run(_MainForm);
             Application.Run(_MainForm);
         }
         }
 
 
-        private static void StartSplashForm()
-        {
+        private static void StartSplashForm() {
             _SplashForm = new SplashForm();
             _SplashForm = new SplashForm();
             var splashThread = new Thread(new ThreadStart(
             var splashThread = new Thread(new ThreadStart(
                 () => Application.Run(_SplashForm)));
                 () => Application.Run(_SplashForm)));
@@ -409,8 +362,7 @@ namespace Optimizer
             splashThread.Start();
             splashThread.Start();
         }
         }
 
 
-        private static void MainForm_Load(object sender, EventArgs e)
-        {
+        private static void MainForm_Load(object sender, EventArgs e) {
             if (_SplashForm != null && !_SplashForm.Disposing && !_SplashForm.IsDisposed)
             if (_SplashForm != null && !_SplashForm.Disposing && !_SplashForm.IsDisposed)
                 _SplashForm.Invoke(new Action(() => _SplashForm.Close()));
                 _SplashForm.Invoke(new Action(() => _SplashForm.Close()));
 
 
@@ -419,8 +371,7 @@ namespace Optimizer
             _MainForm.TopMost = false;
             _MainForm.TopMost = false;
         }
         }
 
 
-        private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
-        {
+        private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) {
             return EmbeddedAssembly.Get(args.Name);
             return EmbeddedAssembly.Get(args.Name);
         }
         }
     }
     }

文件差异内容过多而无法显示
+ 216 - 432
Optimizer/SilentOps.cs


+ 30 - 60
Optimizer/StartupHelper.cs

@@ -4,10 +4,8 @@ using System.Collections.Generic;
 using System.IO;
 using System.IO;
 using System.Linq;
 using System.Linq;
 
 
-namespace Optimizer
-{
-    internal static class StartupHelper
-    {
+namespace Optimizer {
+    internal static class StartupHelper {
         internal static readonly string LocalMachineRun = "Software\\Microsoft\\Windows\\CurrentVersion\\Run";
         internal static readonly string LocalMachineRun = "Software\\Microsoft\\Windows\\CurrentVersion\\Run";
         internal static readonly string LocalMachineRunOnce = "Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce";
         internal static readonly string LocalMachineRunOnce = "Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce";
         internal static readonly string LocalMachineRunWoW = "Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Run";
         internal static readonly string LocalMachineRunWoW = "Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Run";
@@ -18,65 +16,50 @@ namespace Optimizer
         internal static readonly string LocalMachineStartupFolder = CleanHelper.ProgramData + "\\Microsoft\\Windows\\Start Menu\\Programs\\Startup";
         internal static readonly string LocalMachineStartupFolder = CleanHelper.ProgramData + "\\Microsoft\\Windows\\Start Menu\\Programs\\Startup";
         internal static readonly string CurrentUserStartupFolder = CleanHelper.ProfileAppDataRoaming + "\\Microsoft\\Windows\\Start Menu\\Programs\\Startup";
         internal static readonly string CurrentUserStartupFolder = CleanHelper.ProfileAppDataRoaming + "\\Microsoft\\Windows\\Start Menu\\Programs\\Startup";
 
 
-        private static void GetRegistryStartupItemsHelper(ref List<StartupItem> list, StartupItemLocation location, StartupItemType type)
-        {
+        private static void GetRegistryStartupItemsHelper(ref List<StartupItem> list, StartupItemLocation location, StartupItemType type) {
             string keyPath = string.Empty;
             string keyPath = string.Empty;
             RegistryKey hive = null;
             RegistryKey hive = null;
 
 
-            if (location == StartupItemLocation.HKLM)
-            {
+            if (location == StartupItemLocation.HKLM) {
                 hive = Registry.LocalMachine;
                 hive = Registry.LocalMachine;
 
 
-                if (type == StartupItemType.Run)
-                {
+                if (type == StartupItemType.Run) {
                     keyPath = LocalMachineRun;
                     keyPath = LocalMachineRun;
                 }
                 }
-                else if (type == StartupItemType.RunOnce)
-                {
+                else if (type == StartupItemType.RunOnce) {
                     keyPath = LocalMachineRunOnce;
                     keyPath = LocalMachineRunOnce;
                 }
                 }
             }
             }
-            else if (location == StartupItemLocation.HKLMWoW)
-            {
+            else if (location == StartupItemLocation.HKLMWoW) {
                 hive = Registry.LocalMachine;
                 hive = Registry.LocalMachine;
 
 
-                if (type == StartupItemType.Run)
-                {
+                if (type == StartupItemType.Run) {
                     keyPath = LocalMachineRunWoW;
                     keyPath = LocalMachineRunWoW;
                 }
                 }
-                else if (type == StartupItemType.RunOnce)
-                {
+                else if (type == StartupItemType.RunOnce) {
                     keyPath = LocalMachineRunOnceWow;
                     keyPath = LocalMachineRunOnceWow;
                 }
                 }
             }
             }
-            else if (location == StartupItemLocation.HKCU)
-            {
+            else if (location == StartupItemLocation.HKCU) {
                 hive = Registry.CurrentUser;
                 hive = Registry.CurrentUser;
 
 
-                if (type == StartupItemType.Run)
-                {
+                if (type == StartupItemType.Run) {
                     keyPath = CurrentUserRun;
                     keyPath = CurrentUserRun;
                 }
                 }
-                else if (type == StartupItemType.RunOnce)
-                {
+                else if (type == StartupItemType.RunOnce) {
                     keyPath = CurrentUserRunOnce;
                     keyPath = CurrentUserRunOnce;
                 }
                 }
             }
             }
 
 
-            if (hive != null)
-            {
-                try
-                {
+            if (hive != null) {
+                try {
                     RegistryKey key = hive.OpenSubKey(keyPath, true);
                     RegistryKey key = hive.OpenSubKey(keyPath, true);
 
 
-                    if (key != null)
-                    {
+                    if (key != null) {
                         string[] valueNames = key.GetValueNames();
                         string[] valueNames = key.GetValueNames();
 
 
-                        foreach (string x in valueNames)
-                        {
-                            try
-                            {
+                        foreach (string x in valueNames) {
+                            try {
                                 RegistryStartupItem item = new RegistryStartupItem();
                                 RegistryStartupItem item = new RegistryStartupItem();
                                 item.Name = x;
                                 item.Name = x;
                                 item.FileLocation = key.GetValue(x).ToString();
                                 item.FileLocation = key.GetValue(x).ToString();
@@ -86,26 +69,21 @@ namespace Optimizer
 
 
                                 list.Add(item);
                                 list.Add(item);
                             }
                             }
-                            catch (Exception ex)
-                            {
+                            catch (Exception ex) {
                                 Logger.LogError("Utilities.GetRegistryStartupItemsHelper", ex.Message, ex.StackTrace);
                                 Logger.LogError("Utilities.GetRegistryStartupItemsHelper", ex.Message, ex.StackTrace);
                             }
                             }
                         }
                         }
                     }
                     }
                 }
                 }
-                catch (Exception ex)
-                {
+                catch (Exception ex) {
                     Logger.LogError("Utilities.GetRegistryStartupItemsHelper", ex.Message, ex.StackTrace);
                     Logger.LogError("Utilities.GetRegistryStartupItemsHelper", ex.Message, ex.StackTrace);
                 }
                 }
             }
             }
         }
         }
 
 
-        private static void GetFolderStartupItemsHelper(ref List<StartupItem> list, IEnumerable<string> files, IEnumerable<string> shortcuts, StartupItemLocation folderOrigin)
-        {
-            foreach (string file in files)
-            {
-                try
-                {
+        private static void GetFolderStartupItemsHelper(ref List<StartupItem> list, IEnumerable<string> files, IEnumerable<string> shortcuts, StartupItemLocation folderOrigin) {
+            foreach (string file in files) {
+                try {
                     FolderStartupItem item = new FolderStartupItem();
                     FolderStartupItem item = new FolderStartupItem();
                     item.Name = Path.GetFileNameWithoutExtension(file);
                     item.Name = Path.GetFileNameWithoutExtension(file);
                     item.FileLocation = file;
                     item.FileLocation = file;
@@ -114,16 +92,13 @@ namespace Optimizer
 
 
                     list.Add(item);
                     list.Add(item);
                 }
                 }
-                catch (Exception ex)
-                {
+                catch (Exception ex) {
                     Logger.LogError("Utilities.GetFolderStartupItemsHelper", ex.Message, ex.StackTrace);
                     Logger.LogError("Utilities.GetFolderStartupItemsHelper", ex.Message, ex.StackTrace);
                 }
                 }
             }
             }
 
 
-            foreach (string shortcut in shortcuts)
-            {
-                try
-                {
+            foreach (string shortcut in shortcuts) {
+                try {
                     FolderStartupItem item = new FolderStartupItem();
                     FolderStartupItem item = new FolderStartupItem();
                     item.Name = Path.GetFileNameWithoutExtension(shortcut);
                     item.Name = Path.GetFileNameWithoutExtension(shortcut);
                     item.FileLocation = Utilities.GetShortcutTargetFile(shortcut);
                     item.FileLocation = Utilities.GetShortcutTargetFile(shortcut);
@@ -132,15 +107,13 @@ namespace Optimizer
 
 
                     list.Add(item);
                     list.Add(item);
                 }
                 }
-                catch (Exception ex)
-                {
+                catch (Exception ex) {
                     Logger.LogError("Utilities.GetFolderStartupItemsHelper", ex.Message, ex.StackTrace);
                     Logger.LogError("Utilities.GetFolderStartupItemsHelper", ex.Message, ex.StackTrace);
                 }
                 }
             }
             }
         }
         }
 
 
-        internal static List<StartupItem> GetStartupItems()
-        {
+        internal static List<StartupItem> GetStartupItems() {
             List<StartupItem> startupItems = new List<StartupItem>();
             List<StartupItem> startupItems = new List<StartupItem>();
 
 
             GetRegistryStartupItemsHelper(ref startupItems, StartupItemLocation.HKLM, StartupItemType.Run);
             GetRegistryStartupItemsHelper(ref startupItems, StartupItemLocation.HKLM, StartupItemType.Run);
@@ -149,14 +122,12 @@ namespace Optimizer
             GetRegistryStartupItemsHelper(ref startupItems, StartupItemLocation.HKCU, StartupItemType.Run);
             GetRegistryStartupItemsHelper(ref startupItems, StartupItemLocation.HKCU, StartupItemType.Run);
             GetRegistryStartupItemsHelper(ref startupItems, StartupItemLocation.HKCU, StartupItemType.RunOnce);
             GetRegistryStartupItemsHelper(ref startupItems, StartupItemLocation.HKCU, StartupItemType.RunOnce);
 
 
-            if (Environment.Is64BitOperatingSystem)
-            {
+            if (Environment.Is64BitOperatingSystem) {
                 GetRegistryStartupItemsHelper(ref startupItems, StartupItemLocation.HKLMWoW, StartupItemType.Run);
                 GetRegistryStartupItemsHelper(ref startupItems, StartupItemLocation.HKLMWoW, StartupItemType.Run);
                 GetRegistryStartupItemsHelper(ref startupItems, StartupItemLocation.HKLMWoW, StartupItemType.RunOnce);
                 GetRegistryStartupItemsHelper(ref startupItems, StartupItemLocation.HKLMWoW, StartupItemType.RunOnce);
             }
             }
 
 
-            if (Directory.Exists(CurrentUserStartupFolder))
-            {
+            if (Directory.Exists(CurrentUserStartupFolder)) {
                 IEnumerable<string> currentUserFiles = Directory.EnumerateFiles(CurrentUserStartupFolder, "*.*", SearchOption.AllDirectories)
                 IEnumerable<string> currentUserFiles = Directory.EnumerateFiles(CurrentUserStartupFolder, "*.*", SearchOption.AllDirectories)
                     .Where(s => s.EndsWith(".exe") || s.EndsWith(".bat") || s.EndsWith(".cmd"));
                     .Where(s => s.EndsWith(".exe") || s.EndsWith(".bat") || s.EndsWith(".cmd"));
 
 
@@ -165,8 +136,7 @@ namespace Optimizer
                 GetFolderStartupItemsHelper(ref startupItems, currentUserFiles, currentUserShortcuts, StartupItemLocation.CUStartupFolder);
                 GetFolderStartupItemsHelper(ref startupItems, currentUserFiles, currentUserShortcuts, StartupItemLocation.CUStartupFolder);
             }
             }
 
 
-            if (Directory.Exists(LocalMachineStartupFolder))
-            {
+            if (Directory.Exists(LocalMachineStartupFolder)) {
                 IEnumerable<string> localMachineFiles = Directory.EnumerateFiles(LocalMachineStartupFolder, "*.*", SearchOption.AllDirectories)
                 IEnumerable<string> localMachineFiles = Directory.EnumerateFiles(LocalMachineStartupFolder, "*.*", SearchOption.AllDirectories)
                     .Where(s => s.EndsWith(".exe") || s.EndsWith(".bat") || s.EndsWith(".cmd"));
                     .Where(s => s.EndsWith(".exe") || s.EndsWith(".bat") || s.EndsWith(".cmd"));
 
 

+ 12 - 24
Optimizer/TokenPrivilegeHelper.cs

@@ -2,15 +2,12 @@
 using System.Runtime.InteropServices;
 using System.Runtime.InteropServices;
 using System.Security;
 using System.Security;
 
 
-namespace Optimizer
-{
+namespace Optimizer {
     /*
     /*
      *  Allows clients to obtain a Windows token privilege for a well-defined scope simply by "using" an instance of this class.
      *  Allows clients to obtain a Windows token privilege for a well-defined scope simply by "using" an instance of this class.
      */
      */
-    sealed class TokenPrivilegeHelper : IDisposable
-    {
-        private enum PrivilegeAction : uint
-        {
+    sealed class TokenPrivilegeHelper : IDisposable {
+        private enum PrivilegeAction : uint {
             Disable = 0x0,
             Disable = 0x0,
             Enable = 0x2
             Enable = 0x2
         }
         }
@@ -21,29 +18,25 @@ namespace Optimizer
 
 
         private readonly string privilegeName;
         private readonly string privilegeName;
 
 
-        private TokenPrivilegeHelper(string privilegeName)
-        {
+        private TokenPrivilegeHelper(string privilegeName) {
             this.privilegeName = privilegeName;
             this.privilegeName = privilegeName;
             Apply(PrivilegeAction.Enable);
             Apply(PrivilegeAction.Enable);
         }
         }
 
 
-        private void Apply(PrivilegeAction action)
-        {
+        private void Apply(PrivilegeAction action) {
             OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, out IntPtr tokenHandle);
             OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, out IntPtr tokenHandle);
             LookupPrivilegeValue(null, privilegeName, out Luid luid);
             LookupPrivilegeValue(null, privilegeName, out Luid luid);
             var tokenPrivilege = new TokenPrivileges(luid, (uint)action);
             var tokenPrivilege = new TokenPrivileges(luid, (uint)action);
             UpdateTokenPrivileges(tokenHandle, tokenPrivilege);
             UpdateTokenPrivileges(tokenHandle, tokenPrivilege);
         }
         }
 
 
-        private void UpdateTokenPrivileges(IntPtr tokenHandle, TokenPrivileges privilegeInfo)
-        {
+        private void UpdateTokenPrivileges(IntPtr tokenHandle, TokenPrivileges privilegeInfo) {
             bool successful = AdjustTokenPrivileges(tokenHandle, false, ref privilegeInfo, 0, IntPtr.Zero, IntPtr.Zero);
             bool successful = AdjustTokenPrivileges(tokenHandle, false, ref privilegeInfo, 0, IntPtr.Zero, IntPtr.Zero);
             if (!successful || Marshal.GetLastWin32Error() == ERROR_NOT_ALL_ASSIGNED)
             if (!successful || Marshal.GetLastWin32Error() == ERROR_NOT_ALL_ASSIGNED)
                 throw new SecurityException($"Can't adjust token privilege {privilegeName}");
                 throw new SecurityException($"Can't adjust token privilege {privilegeName}");
         }
         }
 
 
-        public void Dispose()
-        {
+        public void Dispose() {
             Apply(PrivilegeAction.Disable);
             Apply(PrivilegeAction.Disable);
         }
         }
 
 
@@ -51,11 +44,9 @@ namespace Optimizer
         private const int ERROR_NOT_ALL_ASSIGNED = 1300;
         private const int ERROR_NOT_ALL_ASSIGNED = 1300;
 
 
         [StructLayout(LayoutKind.Sequential)]
         [StructLayout(LayoutKind.Sequential)]
-        private struct TokenPrivileges
-        {
+        private struct TokenPrivileges {
             // We can use this struct only with one privilege since CLR doesn't support marshalling dynamic-sized arrays
             // We can use this struct only with one privilege since CLR doesn't support marshalling dynamic-sized arrays
-            public TokenPrivileges(Luid luid, uint attributes)
-            {
+            public TokenPrivileges(Luid luid, uint attributes) {
                 Count = 1;
                 Count = 1;
                 Privileges = new[] {
                 Privileges = new[] {
                     new LuidAndAttributes(luid, attributes)
                     new LuidAndAttributes(luid, attributes)
@@ -68,10 +59,8 @@ namespace Optimizer
         }
         }
 
 
         [StructLayout(LayoutKind.Sequential)]
         [StructLayout(LayoutKind.Sequential)]
-        private readonly struct LuidAndAttributes
-        {
-            public LuidAndAttributes(Luid luid, uint attributes)
-            {
+        private readonly struct LuidAndAttributes {
+            public LuidAndAttributes(Luid luid, uint attributes) {
                 Luid = luid;
                 Luid = luid;
                 Attributes = attributes;
                 Attributes = attributes;
             }
             }
@@ -81,8 +70,7 @@ namespace Optimizer
         }
         }
 
 
         [StructLayout(LayoutKind.Sequential)]
         [StructLayout(LayoutKind.Sequential)]
-        private readonly struct Luid
-        {
+        private readonly struct Luid {
             private readonly uint LowPart;
             private readonly uint LowPart;
             private readonly int HighPart;
             private readonly int HighPart;
         }
         }

+ 15 - 31
Optimizer/UWPHelper.cs

@@ -1,49 +1,37 @@
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
 using System.Collections.ObjectModel;
-using System.Linq;
 using System.Management.Automation;
 using System.Management.Automation;
 
 
-namespace Optimizer
-{
-    internal static class UWPHelper
-    {
-        internal static List<KeyValuePair<string, string>> GetUWPApps(bool showAll)
-        {
+namespace Optimizer {
+    internal static class UWPHelper {
+        internal static List<KeyValuePair<string, string>> GetUWPApps(bool showAll) {
             List<KeyValuePair<string, string>> modernApps = new List<KeyValuePair<string, string>>();
             List<KeyValuePair<string, string>> modernApps = new List<KeyValuePair<string, string>>();
-            if (Utilities.CurrentWindowsVersion == WindowsVersion.Windows8)
-            {
+            if (Utilities.CurrentWindowsVersion == WindowsVersion.Windows8) {
                 showAll = true;
                 showAll = true;
             }
             }
 
 
-            using (PowerShell script = PowerShell.Create())
-            {
-                if (showAll)
-                {
+            using (PowerShell script = PowerShell.Create()) {
+                if (showAll) {
                     script.AddScript("Get-AppxPackage | Select Name,InstallLocation");
                     script.AddScript("Get-AppxPackage | Select Name,InstallLocation");
                 }
                 }
-                else
-                {
+                else {
                     script.AddScript(@"Get-AppxPackage | Where {$_.NonRemovable -like ""False""} | Select  Name,InstallLocation");
                     script.AddScript(@"Get-AppxPackage | Where {$_.NonRemovable -like ""False""} | Select  Name,InstallLocation");
                 }
                 }
 
 
                 string[] tmp;
                 string[] tmp;
                 Collection<PSObject> psResult;
                 Collection<PSObject> psResult;
-                try
-                {
+                try {
                     psResult = script.Invoke();
                     psResult = script.Invoke();
                 }
                 }
-                catch
-                {
+                catch {
                     return modernApps;
                     return modernApps;
                 }
                 }
 
 
                 if (psResult == null) return modernApps;
                 if (psResult == null) return modernApps;
 
 
-                foreach (PSObject x in psResult)
-                {
+                foreach (PSObject x in psResult) {
                     tmp = x.ToString().Replace("@", string.Empty).Replace("{", string.Empty).Replace("}", string.Empty).Replace("Name=", string.Empty).Replace("InstallLocation=", string.Empty).Trim().Split(';');
                     tmp = x.ToString().Replace("@", string.Empty).Replace("{", string.Empty).Replace("}", string.Empty).Replace("Name=", string.Empty).Replace("InstallLocation=", string.Empty).Trim().Split(';');
-                    if (!modernApps.Exists(i => i.Key == tmp[0]))
-                    {
+                    if (!modernApps.Exists(i => i.Key == tmp[0])) {
                         modernApps.Add(new KeyValuePair<string, string>(tmp[0], tmp[1]));
                         modernApps.Add(new KeyValuePair<string, string>(tmp[0], tmp[1]));
                     }
                     }
                 }
                 }
@@ -52,10 +40,8 @@ namespace Optimizer
             return modernApps;
             return modernApps;
         }
         }
 
 
-        internal static bool UninstallUWPApp(string appName)
-        {
-            using (PowerShell script = PowerShell.Create())
-            {
+        internal static bool UninstallUWPApp(string appName) {
+            using (PowerShell script = PowerShell.Create()) {
                 script.AddScript(string.Format("Get-AppxPackage -AllUsers '{0}' | Remove-AppxPackage", appName));
                 script.AddScript(string.Format("Get-AppxPackage -AllUsers '{0}' | Remove-AppxPackage", appName));
                 script.Invoke();
                 script.Invoke();
                 return script.Streams.Error.Count > 0;
                 return script.Streams.Error.Count > 0;
@@ -65,12 +51,10 @@ namespace Optimizer
             }
             }
         }
         }
 
 
-        internal static bool RestoreAllUWPApps()
-        {
+        internal static bool RestoreAllUWPApps() {
             string cmd = "Get-AppxPackage -AllUsers | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register \"$($_.InstallLocation)\\AppXManifest.xml\"}";
             string cmd = "Get-AppxPackage -AllUsers | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register \"$($_.InstallLocation)\\AppXManifest.xml\"}";
 
 
-            using (PowerShell script = PowerShell.Create())
-            {
+            using (PowerShell script = PowerShell.Create()) {
                 script.AddScript(cmd);
                 script.AddScript(cmd);
                 script.Invoke();
                 script.Invoke();
                 return script.Streams.Error.Count > 0;
                 return script.Streams.Error.Count > 0;

+ 157 - 315
Optimizer/Utilities.cs

@@ -4,7 +4,6 @@ using System.Collections.Generic;
 using System.Diagnostics;
 using System.Diagnostics;
 using System.Drawing;
 using System.Drawing;
 using System.IO;
 using System.IO;
-using System.Linq;
 using System.Reflection;
 using System.Reflection;
 using System.Security.AccessControl;
 using System.Security.AccessControl;
 using System.Security.Principal;
 using System.Security.Principal;
@@ -13,10 +12,8 @@ using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using System.Windows.Forms;
 using System.Windows.Forms;
 
 
-namespace Optimizer
-{
-    internal static class Utilities
-    {
+namespace Optimizer {
+    internal static class Utilities {
         // DEPRECATED
         // DEPRECATED
         //internal readonly static string DefaultEdgeDownloadFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Downloads");
         //internal readonly static string DefaultEdgeDownloadFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Downloads");
 
 
@@ -27,24 +24,19 @@ namespace Optimizer
 
 
         internal delegate void SetControlPropertyThreadSafeDelegate(Control control, string propertyName, object propertyValue);
         internal delegate void SetControlPropertyThreadSafeDelegate(Control control, string propertyName, object propertyValue);
 
 
-        internal static void SetControlPropertyThreadSafe(Control control, string propertyName, object propertyValue)
-        {
-            if (control.InvokeRequired)
-            {
+        internal static void SetControlPropertyThreadSafe(Control control, string propertyName, object propertyValue) {
+            if (control.InvokeRequired) {
                 control.Invoke(new SetControlPropertyThreadSafeDelegate(SetControlPropertyThreadSafe), new object[] { control, propertyName, propertyValue });
                 control.Invoke(new SetControlPropertyThreadSafeDelegate(SetControlPropertyThreadSafe), new object[] { control, propertyName, propertyValue });
             }
             }
-            else
-            {
+            else {
                 control.GetType().InvokeMember(propertyName, BindingFlags.SetProperty, null, control, new object[] { propertyValue });
                 control.GetType().InvokeMember(propertyName, BindingFlags.SetProperty, null, control, new object[] { propertyValue });
             }
             }
         }
         }
 
 
-        internal static IEnumerable<Control> GetSelfAndChildrenRecursive(Control parent)
-        {
+        internal static IEnumerable<Control> GetSelfAndChildrenRecursive(Control parent) {
             List<Control> controls = new List<Control>();
             List<Control> controls = new List<Control>();
 
 
-            foreach (Control child in parent.Controls)
-            {
+            foreach (Control child in parent.Controls) {
                 controls.AddRange(GetSelfAndChildrenRecursive(child));
                 controls.AddRange(GetSelfAndChildrenRecursive(child));
             }
             }
 
 
@@ -52,8 +44,7 @@ namespace Optimizer
             return controls;
             return controls;
         }
         }
 
 
-        internal static Color ToGrayScale(this Color originalColor)
-        {
+        internal static Color ToGrayScale(this Color originalColor) {
             if (originalColor.Equals(Color.Transparent))
             if (originalColor.Equals(Color.Transparent))
                 return originalColor;
                 return originalColor;
 
 
@@ -61,63 +52,49 @@ namespace Optimizer
             return Color.FromArgb(grayScale, grayScale, grayScale);
             return Color.FromArgb(grayScale, grayScale, grayScale);
         }
         }
 
 
-        internal static string GetWindowsDetails()
-        {
+        internal static string GetWindowsDetails() {
             string bitness = Environment.Is64BitOperatingSystem ? "64-bit" : "32-bit";
             string bitness = Environment.Is64BitOperatingSystem ? "64-bit" : "32-bit";
-            if (CurrentWindowsVersion == WindowsVersion.Windows10 || CurrentWindowsVersion == WindowsVersion.Windows11)
-            {
+            if (CurrentWindowsVersion == WindowsVersion.Windows10 || CurrentWindowsVersion == WindowsVersion.Windows11) {
                 return string.Format("{0} - {1} ({2})", GetOS(), GetWindows10Build(), bitness);
                 return string.Format("{0} - {1} ({2})", GetOS(), GetWindows10Build(), bitness);
             }
             }
-            else
-            {
+            else {
                 return string.Format("{0} - ({1})", GetOS(), bitness);
                 return string.Format("{0} - ({1})", GetOS(), bitness);
             }
             }
         }
         }
 
 
-        internal static string GetWindows10Build()
-        {
+        internal static string GetWindows10Build() {
             return (string)Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", "DisplayVersion", "");
             return (string)Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", "DisplayVersion", "");
         }
         }
 
 
-        internal static string GetOS()
-        {
+        internal static string GetOS() {
             productName = (string)Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", "ProductName", "");
             productName = (string)Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", "ProductName", "");
 
 
-            if (productName.Contains("Windows 7"))
-            {
+            if (productName.Contains("Windows 7")) {
                 CurrentWindowsVersion = WindowsVersion.Windows7;
                 CurrentWindowsVersion = WindowsVersion.Windows7;
             }
             }
-            if ((productName.Contains("Windows 8")) || (productName.Contains("Windows 8.1")))
-            {
+            if ((productName.Contains("Windows 8")) || (productName.Contains("Windows 8.1"))) {
                 CurrentWindowsVersion = WindowsVersion.Windows8;
                 CurrentWindowsVersion = WindowsVersion.Windows8;
             }
             }
-            if (productName.Contains("Windows 10"))
-            {
+            if (productName.Contains("Windows 10")) {
                 buildNumber = (string)Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", "CurrentBuild", "");
                 buildNumber = (string)Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", "CurrentBuild", "");
 
 
-                if (Convert.ToInt32(buildNumber) >= 22000)
-                {
+                if (Convert.ToInt32(buildNumber) >= 22000) {
                     productName = productName.Replace("Windows 10", "Windows 11");
                     productName = productName.Replace("Windows 10", "Windows 11");
                     CurrentWindowsVersion = WindowsVersion.Windows11;
                     CurrentWindowsVersion = WindowsVersion.Windows11;
                 }
                 }
-                else
-                {
+                else {
                     CurrentWindowsVersion = WindowsVersion.Windows10;
                     CurrentWindowsVersion = WindowsVersion.Windows10;
                 }
                 }
             }
             }
 
 
-            if (Program.UNSAFE_MODE)
-            {
-                if (productName.Contains("Windows Server 2008"))
-                {
+            if (Program.UNSAFE_MODE) {
+                if (productName.Contains("Windows Server 2008")) {
                     CurrentWindowsVersion = WindowsVersion.Windows7;
                     CurrentWindowsVersion = WindowsVersion.Windows7;
                 }
                 }
-                if (productName.Contains("Windows Server 2012"))
-                {
+                if (productName.Contains("Windows Server 2012")) {
                     CurrentWindowsVersion = WindowsVersion.Windows8;
                     CurrentWindowsVersion = WindowsVersion.Windows8;
                 }
                 }
-                if (productName.Contains("Windows Server 2016") || productName.Contains("Windows Server 2019") || productName.Contains("Windows Server 2022"))
-                {
+                if (productName.Contains("Windows Server 2016") || productName.Contains("Windows Server 2019") || productName.Contains("Windows Server 2022")) {
                     CurrentWindowsVersion = WindowsVersion.Windows10;
                     CurrentWindowsVersion = WindowsVersion.Windows10;
                 }
                 }
             }
             }
@@ -125,38 +102,31 @@ namespace Optimizer
             return productName;
             return productName;
         }
         }
 
 
-        internal static string GetBitness()
-        {
+        internal static string GetBitness() {
             string bitness;
             string bitness;
 
 
-            if (Environment.Is64BitOperatingSystem)
-            {
+            if (Environment.Is64BitOperatingSystem) {
                 bitness = "You are working with 64-bit";
                 bitness = "You are working with 64-bit";
             }
             }
-            else
-            {
+            else {
                 bitness = "You are working with 32-bit";
                 bitness = "You are working with 32-bit";
             }
             }
 
 
             return bitness;
             return bitness;
         }
         }
 
 
-        internal static bool IsAdmin()
-        {
+        internal static bool IsAdmin() {
             return new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator);
             return new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator);
         }
         }
 
 
-        internal static bool IsCompatible()
-        {
+        internal static bool IsCompatible() {
             bool legit;
             bool legit;
             string os = GetOS();
             string os = GetOS();
 
 
-            if ((os.Contains("XP")) || (os.Contains("Vista")) || os.Contains("Server 2003"))
-            {
+            if ((os.Contains("XP")) || (os.Contains("Vista")) || os.Contains("Server 2003")) {
                 legit = false;
                 legit = false;
             }
             }
-            else
-            {
+            else {
                 legit = true;
                 legit = true;
             }
             }
             return legit;
             return legit;
@@ -186,12 +156,9 @@ namespace Optimizer
         //    Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Edge", "DownloadDirectory", path, RegistryValueKind.String);
         //    Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Edge", "DownloadDirectory", path, RegistryValueKind.String);
         //}
         //}
 
 
-        internal static void RunBatchFile(string batchFile)
-        {
-            try
-            {
-                using (Process p = new Process())
-                {
+        internal static void RunBatchFile(string batchFile) {
+            try {
+                using (Process p = new Process()) {
                     p.StartInfo.CreateNoWindow = true;
                     p.StartInfo.CreateNoWindow = true;
                     p.StartInfo.FileName = batchFile;
                     p.StartInfo.FileName = batchFile;
                     p.StartInfo.UseShellExecute = false;
                     p.StartInfo.UseShellExecute = false;
@@ -201,19 +168,16 @@ namespace Optimizer
                     p.Close();
                     p.Close();
                 }
                 }
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("Utilities.RunBatchFile", ex.Message, ex.StackTrace);
                 Logger.LogError("Utilities.RunBatchFile", ex.Message, ex.StackTrace);
             }
             }
         }
         }
 
 
-        internal static void ImportRegistryScript(string scriptFile)
-        {
+        internal static void ImportRegistryScript(string scriptFile) {
             string path = "\"" + scriptFile + "\"";
             string path = "\"" + scriptFile + "\"";
 
 
             Process p = new Process();
             Process p = new Process();
-            try
-            {
+            try {
                 p.StartInfo.FileName = "regedit.exe";
                 p.StartInfo.FileName = "regedit.exe";
                 p.StartInfo.UseShellExecute = false;
                 p.StartInfo.UseShellExecute = false;
 
 
@@ -221,171 +185,135 @@ namespace Optimizer
 
 
                 p.WaitForExit();
                 p.WaitForExit();
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 p.Dispose();
                 p.Dispose();
                 Logger.LogError("Utilities.ImportRegistryScript", ex.Message, ex.StackTrace);
                 Logger.LogError("Utilities.ImportRegistryScript", ex.Message, ex.StackTrace);
             }
             }
-            finally
-            {
+            finally {
                 p.Dispose();
                 p.Dispose();
             }
             }
         }
         }
 
 
-        internal static void Reboot()
-        {
+        internal static void Reboot() {
             OptionsHelper.SaveSettings();
             OptionsHelper.SaveSettings();
             Process.Start("shutdown.exe", "/r /t 0");
             Process.Start("shutdown.exe", "/r /t 0");
         }
         }
 
 
-        internal static void DisableHibernation()
-        {
+        internal static void DisableHibernation() {
             Utilities.RunCommand("powercfg -h off");
             Utilities.RunCommand("powercfg -h off");
             Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power", "HibernateEnabled", "0", RegistryValueKind.DWord);
             Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power", "HibernateEnabled", "0", RegistryValueKind.DWord);
         }
         }
 
 
-        internal static void EnableHibernation()
-        {
+        internal static void EnableHibernation() {
             Utilities.TryDeleteRegistryValue(true, @"SYSTEM\CurrentControlSet\Control\Power", "HibernateEnabled");
             Utilities.TryDeleteRegistryValue(true, @"SYSTEM\CurrentControlSet\Control\Power", "HibernateEnabled");
             Utilities.RunCommand("powercfg -h on");
             Utilities.RunCommand("powercfg -h on");
         }
         }
 
 
-        internal static void ActivateMainForm()
-        {
+        internal static void ActivateMainForm() {
             Program._MainForm.Activate();
             Program._MainForm.Activate();
         }
         }
 
 
-        internal static bool ServiceExists(string serviceName)
-        {
+        internal static bool ServiceExists(string serviceName) {
             return Array.Exists(ServiceController.GetServices(), (serviceController => serviceController.ServiceName.Equals(serviceName)));
             return Array.Exists(ServiceController.GetServices(), (serviceController => serviceController.ServiceName.Equals(serviceName)));
         }
         }
 
 
-        internal static void StopService(string serviceName)
-        {
-            if (ServiceExists(serviceName))
-            {
+        internal static void StopService(string serviceName) {
+            if (ServiceExists(serviceName)) {
                 ServiceController sc = new ServiceController(serviceName);
                 ServiceController sc = new ServiceController(serviceName);
-                if (sc.CanStop)
-                {
+                if (sc.CanStop) {
                     sc.Stop();
                     sc.Stop();
                 }
                 }
             }
             }
         }
         }
 
 
-        internal static void StartService(string serviceName)
-        {
-            if (ServiceExists(serviceName))
-            {
+        internal static void StartService(string serviceName) {
+            if (ServiceExists(serviceName)) {
                 ServiceController sc = new ServiceController(serviceName);
                 ServiceController sc = new ServiceController(serviceName);
 
 
-                try
-                {
+                try {
                     sc.Start();
                     sc.Start();
                 }
                 }
-                catch (Exception ex)
-                {
+                catch (Exception ex) {
                     Logger.LogError("Utilities.StartService", ex.Message, ex.StackTrace);
                     Logger.LogError("Utilities.StartService", ex.Message, ex.StackTrace);
                 }
                 }
             }
             }
         }
         }
 
 
-        internal static void EnableFirewall()
-        {
+        internal static void EnableFirewall() {
             RunCommand("netsh advfirewall set currentprofile state on");
             RunCommand("netsh advfirewall set currentprofile state on");
         }
         }
 
 
-        internal static void EnableCommandPrompt()
-        {
-            using (RegistryKey key = Registry.CurrentUser.CreateSubKey("Software\\Policies\\Microsoft\\Windows\\System"))
-            {
+        internal static void EnableCommandPrompt() {
+            using (RegistryKey key = Registry.CurrentUser.CreateSubKey("Software\\Policies\\Microsoft\\Windows\\System")) {
                 key.SetValue("DisableCMD", 0, RegistryValueKind.DWord);
                 key.SetValue("DisableCMD", 0, RegistryValueKind.DWord);
             }
             }
         }
         }
 
 
-        internal static void EnableControlPanel()
-        {
-            using (RegistryKey key = Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer"))
-            {
+        internal static void EnableControlPanel() {
+            using (RegistryKey key = Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer")) {
                 key.SetValue("NoControlPanel", 0, RegistryValueKind.DWord);
                 key.SetValue("NoControlPanel", 0, RegistryValueKind.DWord);
             }
             }
         }
         }
 
 
-        internal static void EnableFolderOptions()
-        {
-            using (RegistryKey key = Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer"))
-            {
+        internal static void EnableFolderOptions() {
+            using (RegistryKey key = Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer")) {
                 key.SetValue("NoFolderOptions", 0, RegistryValueKind.DWord);
                 key.SetValue("NoFolderOptions", 0, RegistryValueKind.DWord);
             }
             }
         }
         }
 
 
-        internal static void EnableRunDialog()
-        {
-            using (RegistryKey key = Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer"))
-            {
+        internal static void EnableRunDialog() {
+            using (RegistryKey key = Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer")) {
                 key.SetValue("NoRun", 0, RegistryValueKind.DWord);
                 key.SetValue("NoRun", 0, RegistryValueKind.DWord);
             }
             }
         }
         }
 
 
-        internal static void EnableContextMenu()
-        {
-            using (RegistryKey key = Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer"))
-            {
+        internal static void EnableContextMenu() {
+            using (RegistryKey key = Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer")) {
                 key.SetValue("NoViewContextMenu", 0, RegistryValueKind.DWord);
                 key.SetValue("NoViewContextMenu", 0, RegistryValueKind.DWord);
             }
             }
         }
         }
 
 
-        internal static void EnableTaskManager()
-        {
-            using (RegistryKey key = Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System"))
-            {
+        internal static void EnableTaskManager() {
+            using (RegistryKey key = Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System")) {
                 key.SetValue("DisableTaskMgr", 0, RegistryValueKind.DWord);
                 key.SetValue("DisableTaskMgr", 0, RegistryValueKind.DWord);
             }
             }
         }
         }
 
 
-        internal static void EnableRegistryEditor()
-        {
-            using (RegistryKey key = Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System"))
-            {
+        internal static void EnableRegistryEditor() {
+            using (RegistryKey key = Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System")) {
                 key.SetValue("DisableRegistryTools", 0, RegistryValueKind.DWord);
                 key.SetValue("DisableRegistryTools", 0, RegistryValueKind.DWord);
             }
             }
         }
         }
 
 
-        internal static void RunCommand(string command)
-        {
+        internal static void RunCommand(string command) {
             if (string.IsNullOrEmpty(command)) return;
             if (string.IsNullOrEmpty(command)) return;
 
 
-            using (Process p = new Process())
-            {
+            using (Process p = new Process()) {
                 p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                 p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                 p.StartInfo.FileName = "cmd.exe";
                 p.StartInfo.FileName = "cmd.exe";
                 p.StartInfo.Arguments = "/C " + command;
                 p.StartInfo.Arguments = "/C " + command;
                 p.StartInfo.CreateNoWindow = true;
                 p.StartInfo.CreateNoWindow = true;
 
 
-                try
-                {
+                try {
                     p.Start();
                     p.Start();
                     p.WaitForExit();
                     p.WaitForExit();
                     p.Close();
                     p.Close();
                 }
                 }
-                catch (Exception ex)
-                {
+                catch (Exception ex) {
                     Logger.LogError("Utilities.RunCommand", ex.Message, ex.StackTrace);
                     Logger.LogError("Utilities.RunCommand", ex.Message, ex.StackTrace);
                 }
                 }
             }
             }
         }
         }
 
 
-        internal static void FindFile(string fileName)
-        {
+        internal static void FindFile(string fileName) {
             if (File.Exists(fileName)) Process.Start("explorer.exe", $"/select, \"{fileName}\"");
             if (File.Exists(fileName)) Process.Start("explorer.exe", $"/select, \"{fileName}\"");
         }
         }
 
 
-        internal static void FindFolder(string folder)
-        {
+        internal static void FindFolder(string folder) {
             if (Directory.Exists(folder)) RunCommand($"explorer.exe \"{folder}\"");
             if (Directory.Exists(folder)) RunCommand($"explorer.exe \"{folder}\"");
         }
         }
 
 
-        internal static string GetShortcutTargetFile(string shortcutFilename)
-        {
+        internal static string GetShortcutTargetFile(string shortcutFilename) {
             string pathOnly = Path.GetDirectoryName(shortcutFilename);
             string pathOnly = Path.GetDirectoryName(shortcutFilename);
             string filenameOnly = Path.GetFileName(shortcutFilename);
             string filenameOnly = Path.GetFileName(shortcutFilename);
 
 
@@ -393,8 +321,7 @@ namespace Optimizer
             Shell32.Folder folder = shell.NameSpace(pathOnly);
             Shell32.Folder folder = shell.NameSpace(pathOnly);
             Shell32.FolderItem folderItem = folder.ParseName(filenameOnly);
             Shell32.FolderItem folderItem = folder.ParseName(filenameOnly);
 
 
-            if (folderItem != null)
-            {
+            if (folderItem != null) {
                 Shell32.ShellLinkObject link = (Shell32.ShellLinkObject)folderItem.GetLink;
                 Shell32.ShellLinkObject link = (Shell32.ShellLinkObject)folderItem.GetLink;
                 return link.Path;
                 return link.Path;
             }
             }
@@ -402,22 +329,17 @@ namespace Optimizer
             return string.Empty;
             return string.Empty;
         }
         }
 
 
-        internal static void RestartExplorer()
-        {
+        internal static void RestartExplorer() {
             const string explorer = "explorer.exe";
             const string explorer = "explorer.exe";
             string explorerPath = string.Format("{0}\\{1}", Environment.GetEnvironmentVariable("WINDIR"), explorer);
             string explorerPath = string.Format("{0}\\{1}", Environment.GetEnvironmentVariable("WINDIR"), explorer);
 
 
-            foreach (Process process in Process.GetProcesses())
-            {
-                try
-                {
-                    if (string.Compare(process.MainModule.FileName, explorerPath, StringComparison.OrdinalIgnoreCase) == 0)
-                    {
+            foreach (Process process in Process.GetProcesses()) {
+                try {
+                    if (string.Compare(process.MainModule.FileName, explorerPath, StringComparison.OrdinalIgnoreCase) == 0) {
                         process.Kill();
                         process.Kill();
                     }
                     }
                 }
                 }
-                catch (Exception ex)
-                {
+                catch (Exception ex) {
                     Logger.LogError("Utilities.RestartExplorer", ex.Message, ex.StackTrace);
                     Logger.LogError("Utilities.RestartExplorer", ex.Message, ex.StackTrace);
                 }
                 }
             }
             }
@@ -426,36 +348,27 @@ namespace Optimizer
             Process.Start(explorer);
             Process.Start(explorer);
         }
         }
 
 
-        internal static void FindKeyInRegistry(string key)
-        {
-            try
-            {
+        internal static void FindKeyInRegistry(string key) {
+            try {
                 Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit", "LastKey", key);
                 Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit", "LastKey", key);
                 Process.Start("regedit");
                 Process.Start("regedit");
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("Utilities.FindKeyInRegistry", ex.Message, ex.StackTrace);
                 Logger.LogError("Utilities.FindKeyInRegistry", ex.Message, ex.StackTrace);
             }
             }
         }
         }
 
 
-        internal static void Repair(bool withoutRestart = false)
-        {
-            try
-            {
+        internal static void Repair(bool withoutRestart = false) {
+            try {
                 Directory.Delete(CoreHelper.CoreFolder, true);
                 Directory.Delete(CoreHelper.CoreFolder, true);
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("Utilities.ResetConfiguration", ex.Message, ex.StackTrace);
                 Logger.LogError("Utilities.ResetConfiguration", ex.Message, ex.StackTrace);
             }
             }
-            finally
-            {
-                if (!withoutRestart)
-                {
+            finally {
+                if (!withoutRestart) {
                     // BYPASS SINGLE-INSTANCE MECHANISM
                     // BYPASS SINGLE-INSTANCE MECHANISM
-                    if (Program.MUTEX != null)
-                    {
+                    if (Program.MUTEX != null) {
                         Program.MUTEX.ReleaseMutex();
                         Program.MUTEX.ReleaseMutex();
                         Program.MUTEX.Dispose();
                         Program.MUTEX.Dispose();
                         Program.MUTEX = null;
                         Program.MUTEX = null;
@@ -466,8 +379,7 @@ namespace Optimizer
             }
             }
         }
         }
 
 
-        internal static Task RunAsync(this Process process)
-        {
+        internal static Task RunAsync(this Process process) {
             var tcs = new TaskCompletionSource<object>();
             var tcs = new TaskCompletionSource<object>();
             process.EnableRaisingEvents = true;
             process.EnableRaisingEvents = true;
             process.Exited += (s, e) => tcs.TrySetResult(null);
             process.Exited += (s, e) => tcs.TrySetResult(null);
@@ -476,50 +388,39 @@ namespace Optimizer
             return tcs.Task;
             return tcs.Task;
         }
         }
 
 
-        internal static string SanitizeFileFolderName(string fileName)
-        {
+        internal static string SanitizeFileFolderName(string fileName) {
             char[] invalids = Path.GetInvalidFileNameChars();
             char[] invalids = Path.GetInvalidFileNameChars();
             return string.Join("_", fileName.Split(invalids, StringSplitOptions.RemoveEmptyEntries)).TrimEnd('.');
             return string.Join("_", fileName.Split(invalids, StringSplitOptions.RemoveEmptyEntries)).TrimEnd('.');
         }
         }
 
 
         // attempt to enable Local Group Policy Editor on Windows 10 Home editions
         // attempt to enable Local Group Policy Editor on Windows 10 Home editions
-        internal static void EnableGPEDitor()
-        {
+        internal static void EnableGPEDitor() {
             Utilities.RunBatchFile(CoreHelper.ScriptsFolder + "GPEditEnablerInHome.bat");
             Utilities.RunBatchFile(CoreHelper.ScriptsFolder + "GPEditEnablerInHome.bat");
         }
         }
 
 
-        internal static void TryDeleteRegistryValue(bool localMachine, string path, string valueName)
-        {
-            try
-            {
+        internal static void TryDeleteRegistryValue(bool localMachine, string path, string valueName) {
+            try {
                 if (localMachine) Registry.LocalMachine.OpenSubKey(path, true).DeleteValue(valueName, false);
                 if (localMachine) Registry.LocalMachine.OpenSubKey(path, true).DeleteValue(valueName, false);
                 if (!localMachine) Registry.CurrentUser.OpenSubKey(path, true).DeleteValue(valueName, false);
                 if (!localMachine) Registry.CurrentUser.OpenSubKey(path, true).DeleteValue(valueName, false);
             }
             }
             catch { }
             catch { }
         }
         }
 
 
-        internal static void TryDeleteRegistryValueDefaultUsers(string path, string valueName)
-        {
-            try
-            {
+        internal static void TryDeleteRegistryValueDefaultUsers(string path, string valueName) {
+            try {
                 Registry.Users.OpenSubKey(path, true).DeleteValue(valueName, false);
                 Registry.Users.OpenSubKey(path, true).DeleteValue(valueName, false);
             }
             }
             catch { }
             catch { }
         }
         }
 
 
-        internal static void DisableProtectedService(string serviceName)
-        {
-            using (TokenPrivilegeHelper.TakeOwnership)
-            {
-                using (RegistryKey allServicesKey = Registry.LocalMachine.OpenSubKeyWritable(@"SYSTEM\CurrentControlSet\Services"))
-                {
+        internal static void DisableProtectedService(string serviceName) {
+            using (TokenPrivilegeHelper.TakeOwnership) {
+                using (RegistryKey allServicesKey = Registry.LocalMachine.OpenSubKeyWritable(@"SYSTEM\CurrentControlSet\Services")) {
                     allServicesKey.GrantFullControlOnSubKey(serviceName);
                     allServicesKey.GrantFullControlOnSubKey(serviceName);
-                    using (RegistryKey serviceKey = allServicesKey.OpenSubKeyWritable(serviceName))
-                    {
+                    using (RegistryKey serviceKey = allServicesKey.OpenSubKeyWritable(serviceName)) {
                         if (serviceKey == null) return;
                         if (serviceKey == null) return;
 
 
-                        foreach (string subkeyName in serviceKey.GetSubKeyNames())
-                        {
+                        foreach (string subkeyName in serviceKey.GetSubKeyNames()) {
                             serviceKey.TakeOwnershipOnSubKey(subkeyName);
                             serviceKey.TakeOwnershipOnSubKey(subkeyName);
                             serviceKey.GrantFullControlOnSubKey(subkeyName);
                             serviceKey.GrantFullControlOnSubKey(subkeyName);
                         }
                         }
@@ -554,19 +455,14 @@ namespace Optimizer
         //    }
         //    }
         //}
         //}
 
 
-        internal static void EnableProtectedService(string serviceName)
-        {
-            using (TokenPrivilegeHelper.TakeOwnership)
-            {
-                using (RegistryKey allServicesKey = Registry.LocalMachine.OpenSubKeyWritable(@"SYSTEM\CurrentControlSet\Services"))
-                {
+        internal static void EnableProtectedService(string serviceName) {
+            using (TokenPrivilegeHelper.TakeOwnership) {
+                using (RegistryKey allServicesKey = Registry.LocalMachine.OpenSubKeyWritable(@"SYSTEM\CurrentControlSet\Services")) {
                     allServicesKey.GrantFullControlOnSubKey(serviceName);
                     allServicesKey.GrantFullControlOnSubKey(serviceName);
-                    using (RegistryKey serviceKey = allServicesKey.OpenSubKeyWritable(serviceName))
-                    {
+                    using (RegistryKey serviceKey = allServicesKey.OpenSubKeyWritable(serviceName)) {
                         if (serviceKey == null) return;
                         if (serviceKey == null) return;
 
 
-                        foreach (string subkeyName in serviceKey.GetSubKeyNames())
-                        {
+                        foreach (string subkeyName in serviceKey.GetSubKeyNames()) {
                             serviceKey.TakeOwnershipOnSubKey(subkeyName);
                             serviceKey.TakeOwnershipOnSubKey(subkeyName);
                             serviceKey.GrantFullControlOnSubKey(subkeyName);
                             serviceKey.GrantFullControlOnSubKey(subkeyName);
                         }
                         }
@@ -576,8 +472,7 @@ namespace Optimizer
             }
             }
         }
         }
 
 
-        public static RegistryKey OpenSubKeyWritable(this RegistryKey registryKey, string subkeyName, RegistryRights? rights = null)
-        {
+        public static RegistryKey OpenSubKeyWritable(this RegistryKey registryKey, string subkeyName, RegistryRights? rights = null) {
             RegistryKey subKey;
             RegistryKey subKey;
 
 
             if (rights == null)
             if (rights == null)
@@ -585,8 +480,7 @@ namespace Optimizer
             else
             else
                 subKey = registryKey.OpenSubKey(subkeyName, RegistryKeyPermissionCheck.ReadWriteSubTree, rights.Value);
                 subKey = registryKey.OpenSubKey(subkeyName, RegistryKeyPermissionCheck.ReadWriteSubTree, rights.Value);
 
 
-            if (subKey == null)
-            {
+            if (subKey == null) {
                 Logger.LogError("Utilities.OpenSubKeyWritable", $"Subkey {subkeyName} not found.", "-");
                 Logger.LogError("Utilities.OpenSubKeyWritable", $"Subkey {subkeyName} not found.", "-");
             }
             }
 
 
@@ -596,12 +490,10 @@ namespace Optimizer
         internal static SecurityIdentifier RetrieveCurrentUserIdentifier()
         internal static SecurityIdentifier RetrieveCurrentUserIdentifier()
             => WindowsIdentity.GetCurrent().User ?? throw new Exception("Unable to retrieve current user SID.");
             => WindowsIdentity.GetCurrent().User ?? throw new Exception("Unable to retrieve current user SID.");
 
 
-        internal static void GrantFullControlOnSubKey(this RegistryKey registryKey, string subkeyName)
-        {
+        internal static void GrantFullControlOnSubKey(this RegistryKey registryKey, string subkeyName) {
             using (RegistryKey subKey = registryKey.OpenSubKeyWritable(subkeyName,
             using (RegistryKey subKey = registryKey.OpenSubKeyWritable(subkeyName,
                 RegistryRights.TakeOwnership | RegistryRights.ChangePermissions
                 RegistryRights.TakeOwnership | RegistryRights.ChangePermissions
-            ))
-            {
+            )) {
                 RegistrySecurity accessRules = subKey.GetAccessControl();
                 RegistrySecurity accessRules = subKey.GetAccessControl();
                 SecurityIdentifier currentUser = RetrieveCurrentUserIdentifier();
                 SecurityIdentifier currentUser = RetrieveCurrentUserIdentifier();
                 accessRules.SetOwner(currentUser);
                 accessRules.SetOwner(currentUser);
@@ -618,29 +510,23 @@ namespace Optimizer
             }
             }
         }
         }
 
 
-        internal static void TakeOwnershipOnSubKey(this RegistryKey registryKey, string subkeyName)
-        {
-            using (RegistryKey subKey = registryKey.OpenSubKeyWritable(subkeyName, RegistryRights.TakeOwnership))
-            {
+        internal static void TakeOwnershipOnSubKey(this RegistryKey registryKey, string subkeyName) {
+            using (RegistryKey subKey = registryKey.OpenSubKeyWritable(subkeyName, RegistryRights.TakeOwnership)) {
                 RegistrySecurity accessRules = subKey.GetAccessControl();
                 RegistrySecurity accessRules = subKey.GetAccessControl();
                 accessRules.SetOwner(RetrieveCurrentUserIdentifier());
                 accessRules.SetOwner(RetrieveCurrentUserIdentifier());
                 subKey.SetAccessControl(accessRules);
                 subKey.SetAccessControl(accessRules);
             }
             }
         }
         }
 
 
-        internal static string GetNETFramework()
-        {
+        internal static string GetNETFramework() {
             string subkey = @"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\";
             string subkey = @"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\";
             int netRelease;
             int netRelease;
 
 
-            using (RegistryKey ndpKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey(subkey))
-            {
-                if (ndpKey != null && ndpKey.GetValue("Release") != null)
-                {
+            using (RegistryKey ndpKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey(subkey)) {
+                if (ndpKey != null && ndpKey.GetValue("Release") != null) {
                     netRelease = (int)ndpKey.GetValue("Release");
                     netRelease = (int)ndpKey.GetValue("Release");
                 }
                 }
-                else
-                {
+                else {
                     return "4.0";
                     return "4.0";
                 }
                 }
             }
             }
@@ -669,130 +555,101 @@ namespace Optimizer
             return "4.0";
             return "4.0";
         }
         }
 
 
-        internal static void SearchWith(string term, bool ddg)
-        {
-            try
-            {
+        internal static void SearchWith(string term, bool ddg) {
+            try {
                 if (ddg) Process.Start(string.Format("https://duckduckgo.com/?q={0}", term));
                 if (ddg) Process.Start(string.Format("https://duckduckgo.com/?q={0}", term));
                 if (!ddg) Process.Start(string.Format("https://www.google.com/search?q={0}", term));
                 if (!ddg) Process.Start(string.Format("https://www.google.com/search?q={0}", term));
             }
             }
             catch { }
             catch { }
         }
         }
 
 
-        internal static void EnableLoginVerbose()
-        {
-            try
-            {
+        internal static void EnableLoginVerbose() {
+            try {
                 Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System", "verbosestatus", 1, RegistryValueKind.DWord);
                 Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System", "verbosestatus", 1, RegistryValueKind.DWord);
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("Utilities.EnableLoginVerbose", ex.Message, ex.StackTrace);
                 Logger.LogError("Utilities.EnableLoginVerbose", ex.Message, ex.StackTrace);
             }
             }
         }
         }
 
 
-        internal static void DisableLoginVerbose()
-        {
+        internal static void DisableLoginVerbose() {
             Utilities.TryDeleteRegistryValue(true, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System", "verbosestatus");
             Utilities.TryDeleteRegistryValue(true, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System", "verbosestatus");
         }
         }
 
 
         // [!!!]
         // [!!!]
-        internal static void UnlockAllCores()
-        {
-            try
-            {
+        internal static void UnlockAllCores() {
+            try {
                 Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Power\PowerSettings\54533251-82be-4824-96c1-47b60b740d00\0cc5b647-c1df-4637-891a-dec35c318583", "ValueMax", 0, RegistryValueKind.DWord);
                 Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Power\PowerSettings\54533251-82be-4824-96c1-47b60b740d00\0cc5b647-c1df-4637-891a-dec35c318583", "ValueMax", 0, RegistryValueKind.DWord);
                 Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Power\PowerSettings\54533251-82be-4824-96c1-47b60b740d00\0cc5b647-c1df-4637-891a-dec35c318583", "ValueMin", 0, RegistryValueKind.DWord);
                 Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Power\PowerSettings\54533251-82be-4824-96c1-47b60b740d00\0cc5b647-c1df-4637-891a-dec35c318583", "ValueMin", 0, RegistryValueKind.DWord);
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("Utilities.UnlockAllCores", ex.Message, ex.StackTrace);
                 Logger.LogError("Utilities.UnlockAllCores", ex.Message, ex.StackTrace);
             }
             }
         }
         }
 
 
         // value = RAM in GB * 1024 * 1024
         // value = RAM in GB * 1024 * 1024
-        internal static void DisableSvcHostProcessSplitting(int ramInGb)
-        {
-            try
-            {
+        internal static void DisableSvcHostProcessSplitting(int ramInGb) {
+            try {
                 ramInGb = ramInGb * 1024 * 1024;
                 ramInGb = ramInGb * 1024 * 1024;
                 Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control", "SvcHostSplitThresholdInKB", ramInGb, RegistryValueKind.DWord);
                 Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control", "SvcHostSplitThresholdInKB", ramInGb, RegistryValueKind.DWord);
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("Utilities.DisableSvcHostProcessSplitting", ex.Message, ex.StackTrace);
                 Logger.LogError("Utilities.DisableSvcHostProcessSplitting", ex.Message, ex.StackTrace);
             }
             }
         }
         }
 
 
         // reset the value to default
         // reset the value to default
-        internal static void EnableSvcHostProcessSplitting()
-        {
-            try
-            {
+        internal static void EnableSvcHostProcessSplitting() {
+            try {
                 Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control", "SvcHostSplitThresholdInKB", 380000, RegistryValueKind.DWord);
                 Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control", "SvcHostSplitThresholdInKB", 380000, RegistryValueKind.DWord);
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("Utilities.EnableSvcHostProcessSplitting", ex.Message, ex.StackTrace);
                 Logger.LogError("Utilities.EnableSvcHostProcessSplitting", ex.Message, ex.StackTrace);
             }
             }
         }
         }
 
 
-        internal static void DisableHPET()
-        {
+        internal static void DisableHPET() {
             Utilities.RunCommand("bcdedit /deletevalue useplatformclock");
             Utilities.RunCommand("bcdedit /deletevalue useplatformclock");
             Thread.Sleep(500);
             Thread.Sleep(500);
             Utilities.RunCommand("bcdedit /set disabledynamictick yes");
             Utilities.RunCommand("bcdedit /set disabledynamictick yes");
         }
         }
 
 
-        internal static void EnableHPET()
-        {
+        internal static void EnableHPET() {
             Utilities.RunCommand("bcdedit /set useplatformclock true");
             Utilities.RunCommand("bcdedit /set useplatformclock true");
             Thread.Sleep(500);
             Thread.Sleep(500);
             Utilities.RunCommand("bcdedit /set disabledynamictick no");
             Utilities.RunCommand("bcdedit /set disabledynamictick no");
         }
         }
 
 
-        internal static void RegisterAutoStart()
-        {
-            try
-            {
-                using (RegistryKey k = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true))
-                {
+        internal static void RegisterAutoStart() {
+            try {
+                using (RegistryKey k = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true)) {
                     k.SetValue("Optimizer", Assembly.GetEntryAssembly().Location);
                     k.SetValue("Optimizer", Assembly.GetEntryAssembly().Location);
                 }
                 }
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("Utilities.AddToStartup", ex.Message, ex.StackTrace);
                 Logger.LogError("Utilities.AddToStartup", ex.Message, ex.StackTrace);
             }
             }
         }
         }
 
 
-        internal static void UnregisterAutoStart()
-        {
-            try
-            {
-                using (RegistryKey k = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true))
-                {
+        internal static void UnregisterAutoStart() {
+            try {
+                using (RegistryKey k = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true)) {
                     k.DeleteValue("Optimizer", false);
                     k.DeleteValue("Optimizer", false);
                 }
                 }
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("Utilities.DeleteFromStartup", ex.Message, ex.StackTrace);
                 Logger.LogError("Utilities.DeleteFromStartup", ex.Message, ex.StackTrace);
             }
             }
         }
         }
 
 
-        internal static void AllowProcessToRun(string pName)
-        {
-            try
-            {
-                using (RegistryKey ifeo = Registry.LocalMachine.OpenSubKeyWritable(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion", RegistryRights.FullControl))
-                {
+        internal static void AllowProcessToRun(string pName) {
+            try {
+                using (RegistryKey ifeo = Registry.LocalMachine.OpenSubKeyWritable(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion", RegistryRights.FullControl)) {
                     if (ifeo == null) return;
                     if (ifeo == null) return;
 
 
                     ifeo.GrantFullControlOnSubKey("Image File Execution Options");
                     ifeo.GrantFullControlOnSubKey("Image File Execution Options");
 
 
-                    using (RegistryKey k = ifeo.OpenSubKeyWritable("Image File Execution Options", RegistryRights.FullControl))
-                    {
+                    using (RegistryKey k = ifeo.OpenSubKeyWritable("Image File Execution Options", RegistryRights.FullControl)) {
                         if (k == null) return;
                         if (k == null) return;
 
 
                         k.GrantFullControlOnSubKey(pName);
                         k.GrantFullControlOnSubKey(pName);
@@ -800,31 +657,25 @@ namespace Optimizer
                     }
                     }
                 }
                 }
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("Utilities.AllowProcessToRun", ex.Message, ex.StackTrace);
                 Logger.LogError("Utilities.AllowProcessToRun", ex.Message, ex.StackTrace);
             }
             }
         }
         }
 
 
-        internal static void PreventProcessFromRunning(string pName)
-        {
-            try
-            {
-                using (RegistryKey ifeo = Registry.LocalMachine.OpenSubKeyWritable(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion", RegistryRights.FullControl))
-                {
+        internal static void PreventProcessFromRunning(string pName) {
+            try {
+                using (RegistryKey ifeo = Registry.LocalMachine.OpenSubKeyWritable(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion", RegistryRights.FullControl)) {
                     if (ifeo == null) return;
                     if (ifeo == null) return;
 
 
                     ifeo.GrantFullControlOnSubKey("Image File Execution Options");
                     ifeo.GrantFullControlOnSubKey("Image File Execution Options");
 
 
-                    using (RegistryKey k = ifeo.OpenSubKeyWritable("Image File Execution Options", RegistryRights.FullControl))
-                    {
+                    using (RegistryKey k = ifeo.OpenSubKeyWritable("Image File Execution Options", RegistryRights.FullControl)) {
                         if (k == null) return;
                         if (k == null) return;
 
 
                         k.CreateSubKey(pName);
                         k.CreateSubKey(pName);
                         k.GrantFullControlOnSubKey(pName);
                         k.GrantFullControlOnSubKey(pName);
 
 
-                        using (RegistryKey f = k.OpenSubKeyWritable(pName, RegistryRights.FullControl))
-                        {
+                        using (RegistryKey f = k.OpenSubKeyWritable(pName, RegistryRights.FullControl)) {
                             if (f == null) return;
                             if (f == null) return;
 
 
                             f.SetValue("Debugger", @"%windir%\System32\taskkill.exe");
                             f.SetValue("Debugger", @"%windir%\System32\taskkill.exe");
@@ -832,27 +683,22 @@ namespace Optimizer
                     }
                     }
                 }
                 }
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("Utilities.PreventProcessFromRunning", ex.Message, ex.StackTrace);
                 Logger.LogError("Utilities.PreventProcessFromRunning", ex.Message, ex.StackTrace);
             }
             }
         }
         }
 
 
-        internal static string GetUserDownloadsFolder()
-        {
-            try
-            {
+        internal static string GetUserDownloadsFolder() {
+            try {
                 return Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", "{374DE290-123F-4565-9164-39C4925E467B}", string.Empty).ToString();
                 return Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", "{374DE290-123F-4565-9164-39C4925E467B}", string.Empty).ToString();
             }
             }
-            catch (Exception ex)
-            {
+            catch (Exception ex) {
                 Logger.LogError("Utilities.GetUserDownloadsFolder", ex.Message, ex.StackTrace);
                 Logger.LogError("Utilities.GetUserDownloadsFolder", ex.Message, ex.StackTrace);
                 return string.Empty;
                 return string.Empty;
             }
             }
         }
         }
 
 
-        internal static void ReinforceCurrentTweaks()
-        {
+        internal static void ReinforceCurrentTweaks() {
             SilentConfig silentConfig = new SilentConfig();
             SilentConfig silentConfig = new SilentConfig();
             Tweaks silentConfigTweaks = new Tweaks();
             Tweaks silentConfigTweaks = new Tweaks();
             silentConfig.Tweaks = silentConfigTweaks;
             silentConfig.Tweaks = silentConfigTweaks;
@@ -927,22 +773,18 @@ namespace Optimizer
 
 
             SilentOps.CurrentSilentConfig = silentConfig;
             SilentOps.CurrentSilentConfig = silentConfig;
 
 
-            if (CurrentWindowsVersion == WindowsVersion.Windows7)
-            {
+            if (CurrentWindowsVersion == WindowsVersion.Windows7) {
                 SilentOps.ProcessTweaksGeneral();
                 SilentOps.ProcessTweaksGeneral();
             }
             }
-            if (CurrentWindowsVersion == WindowsVersion.Windows8)
-            {
+            if (CurrentWindowsVersion == WindowsVersion.Windows8) {
                 SilentOps.ProcessTweaksGeneral();
                 SilentOps.ProcessTweaksGeneral();
                 SilentOps.ProcessTweaksWindows8();
                 SilentOps.ProcessTweaksWindows8();
             }
             }
-            if (CurrentWindowsVersion == WindowsVersion.Windows10)
-            {
+            if (CurrentWindowsVersion == WindowsVersion.Windows10) {
                 SilentOps.ProcessTweaksGeneral();
                 SilentOps.ProcessTweaksGeneral();
                 SilentOps.ProcessTweaksWindows10();
                 SilentOps.ProcessTweaksWindows10();
             }
             }
-            if (CurrentWindowsVersion == WindowsVersion.Windows11)
-            {
+            if (CurrentWindowsVersion == WindowsVersion.Windows11) {
                 SilentOps.ProcessTweaksGeneral();
                 SilentOps.ProcessTweaksGeneral();
                 SilentOps.ProcessTweaksWindows10();
                 SilentOps.ProcessTweaksWindows10();
                 SilentOps.ProcessTweaksWindows11();
                 SilentOps.ProcessTweaksWindows11();

+ 5 - 5
README.md

@@ -3,7 +3,7 @@
 </p>
 </p>
 
 
 <p align="center">
 <p align="center">
-	<a href="https://github.com/hellzerg/optimizer/releases/download/16.3/Optimizer-16.3.exe" target="_blank">
+	<a href="https://github.com/hellzerg/optimizer/releases/download/16.4/Optimizer-16.4.exe" target="_blank">
 		<img src="https://raw.githubusercontent.com/hellzerg/optimizer/master/download-button.png">
 		<img src="https://raw.githubusercontent.com/hellzerg/optimizer/master/download-button.png">
 		<br>
 		<br>
 		<img src="https://raw.githubusercontent.com/hellzerg/optimizer/master/flags.png">
 		<img src="https://raw.githubusercontent.com/hellzerg/optimizer/master/flags.png">
@@ -25,9 +25,9 @@ Welcome to Optimizer, an advanced configuration utility designed to enhance your
 - Disable unnecessary Windows services
 - Disable unnecessary Windows services
 - Turn off Windows telemetry, Cortana, and more
 - Turn off Windows telemetry, Cortana, and more
 - Disable Office telemetry (works with Office 2016 or newer)
 - Disable Office telemetry (works with Office 2016 or newer)
-- Stop automatic Windows 10 updates
+- Stop automatic Windows 10/11 updates
 - Download multiple useful apps quickly
 - Download multiple useful apps quickly
-- Disable CoPilot AI in Windows 11 and Edge
+- Disable CoPilot AI in Windows 11
 - Uninstall UWP apps
 - Uninstall UWP apps
 - Clean system drive and browser profiles
 - Clean system drive and browser profiles
 - Fix common registry issues
 - Fix common registry issues
@@ -105,8 +105,8 @@ Learn about our security measures in the [Security Policy](https://github.com/he
 <h2> 📊 Details</h2> 
 <h2> 📊 Details</h2> 
 </center>
 </center>
 
 
-- Latest version: 16.3 (Released: December 22, 2023)
-- SHA256: A70EECA600155EFB57A52BB29493B5CD33409F475B9293AF38677B26EBB9F79B
+- Latest version: 16.4 (Released: December 29, 2023)
+- SHA256: F4775567CA9941B4FB3224D97B0741AE669EEDFCB0D8B3C71106B21BDB1AEE28
 
 
 <center>
 <center>
 <h2> ☕ Buy me a delicious espresso</h2>
 <h2> ☕ Buy me a delicious espresso</h2>

+ 1 - 1
version.txt

@@ -1 +1 @@
-16.3
+16.4

部分文件因为文件数量过多而无法显示