Bläddra i källkod

Upcoming changes for version 3.7

hellzerg 7 år sedan
förälder
incheckning
94d4097842

+ 14 - 1
Optimizer/Enums.cs

@@ -45,7 +45,6 @@ namespace Optimizer
     internal enum MessageType
     {
         Error,
-        Optimize,
         Startup,
         Restart,
         Hosts,
@@ -84,4 +83,18 @@ namespace Optimizer
         SHERB_NOPROGRESSUI = 0x00000001,
         SHERB_NOSOUND = 0x00000004
     }
+
+    public enum ToggleSwitchAlignment
+    {
+        Near,
+        Center,
+        Far
+    }
+
+    public enum ToggleSwitchButtonAlignment
+    {
+        Left,
+        Center,
+        Right
+    }
 }

+ 9 - 48
Optimizer/HelperForm.Designer.cs

@@ -31,17 +31,15 @@
             this.lblMessage = new System.Windows.Forms.Label();
             this.btnYes = new System.Windows.Forms.Button();
             this.btnNo = new System.Windows.Forms.Button();
-            this.chkPrint = new System.Windows.Forms.CheckBox();
-            this.chkSensors = new System.Windows.Forms.CheckBox();
             this.SuspendLayout();
             // 
             // lblMessage
             // 
             this.lblMessage.Font = new System.Drawing.Font("Segoe UI Semibold", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(161)));
-            this.lblMessage.Location = new System.Drawing.Point(10, 7);
+            this.lblMessage.Location = new System.Drawing.Point(12, 9);
             this.lblMessage.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
             this.lblMessage.Name = "lblMessage";
-            this.lblMessage.Size = new System.Drawing.Size(432, 69);
+            this.lblMessage.Size = new System.Drawing.Size(540, 86);
             this.lblMessage.TabIndex = 0;
             this.lblMessage.Text = "Restart to apply changes?";
             // 
@@ -55,10 +53,10 @@
             this.btnYes.FlatAppearance.MouseOverBackColor = System.Drawing.Color.RoyalBlue;
             this.btnYes.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
             this.btnYes.ForeColor = System.Drawing.Color.White;
-            this.btnYes.Location = new System.Drawing.Point(358, 128);
+            this.btnYes.Location = new System.Drawing.Point(448, 160);
             this.btnYes.Margin = new System.Windows.Forms.Padding(2);
             this.btnYes.Name = "btnYes";
-            this.btnYes.Size = new System.Drawing.Size(96, 31);
+            this.btnYes.Size = new System.Drawing.Size(120, 39);
             this.btnYes.TabIndex = 31;
             this.btnYes.Tag = "themeable";
             this.btnYes.Text = "Yes";
@@ -75,65 +73,31 @@
             this.btnNo.FlatAppearance.MouseOverBackColor = System.Drawing.Color.RoyalBlue;
             this.btnNo.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
             this.btnNo.ForeColor = System.Drawing.Color.White;
-            this.btnNo.Location = new System.Drawing.Point(257, 128);
+            this.btnNo.Location = new System.Drawing.Point(321, 160);
             this.btnNo.Margin = new System.Windows.Forms.Padding(2);
             this.btnNo.Name = "btnNo";
-            this.btnNo.Size = new System.Drawing.Size(96, 31);
+            this.btnNo.Size = new System.Drawing.Size(120, 39);
             this.btnNo.TabIndex = 32;
             this.btnNo.Tag = "themeable";
             this.btnNo.Text = "No";
             this.btnNo.UseVisualStyleBackColor = false;
             this.btnNo.Click += new System.EventHandler(this.btnNo_Click);
             // 
-            // chkPrint
-            // 
-            this.chkPrint.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
-            this.chkPrint.AutoSize = true;
-            this.chkPrint.Checked = true;
-            this.chkPrint.CheckState = System.Windows.Forms.CheckState.Checked;
-            this.chkPrint.Font = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(161)));
-            this.chkPrint.Location = new System.Drawing.Point(10, 117);
-            this.chkPrint.Margin = new System.Windows.Forms.Padding(2);
-            this.chkPrint.Name = "chkPrint";
-            this.chkPrint.Size = new System.Drawing.Size(211, 19);
-            this.chkPrint.TabIndex = 33;
-            this.chkPrint.Text = "I use Print Service, do not disable it";
-            this.chkPrint.UseVisualStyleBackColor = true;
-            this.chkPrint.Visible = false;
-            // 
-            // chkSensors
-            // 
-            this.chkSensors.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
-            this.chkSensors.AutoSize = true;
-            this.chkSensors.Checked = true;
-            this.chkSensors.CheckState = System.Windows.Forms.CheckState.Checked;
-            this.chkSensors.Font = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(161)));
-            this.chkSensors.Location = new System.Drawing.Point(10, 140);
-            this.chkSensors.Margin = new System.Windows.Forms.Padding(2);
-            this.chkSensors.Name = "chkSensors";
-            this.chkSensors.Size = new System.Drawing.Size(226, 19);
-            this.chkSensors.TabIndex = 34;
-            this.chkSensors.Text = "This is a tablet, do not disable Sensors";
-            this.chkSensors.UseVisualStyleBackColor = true;
-            this.chkSensors.Visible = false;
-            // 
             // HelperForm
             // 
             this.AcceptButton = this.btnYes;
-            this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
+            this.AutoScaleDimensions = new System.Drawing.SizeF(120F, 120F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
             this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20)))));
             this.CancelButton = this.btnNo;
-            this.ClientSize = new System.Drawing.Size(463, 169);
-            this.Controls.Add(this.chkSensors);
-            this.Controls.Add(this.chkPrint);
+            this.ClientSize = new System.Drawing.Size(579, 211);
             this.Controls.Add(this.btnNo);
             this.Controls.Add(this.btnYes);
             this.Controls.Add(this.lblMessage);
             this.Font = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(161)));
             this.ForeColor = System.Drawing.Color.White;
             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
-            this.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3);
+            this.Margin = new System.Windows.Forms.Padding(2, 4, 2, 4);
             this.MaximizeBox = false;
             this.MinimizeBox = false;
             this.Name = "HelperForm";
@@ -142,7 +106,6 @@
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
             this.Load += new System.EventHandler(this.Messager_Load);
             this.ResumeLayout(false);
-            this.PerformLayout();
 
         }
 
@@ -151,7 +114,5 @@
         private System.Windows.Forms.Label lblMessage;
         private System.Windows.Forms.Button btnYes;
         private System.Windows.Forms.Button btnNo;
-        private System.Windows.Forms.CheckBox chkPrint;
-        private System.Windows.Forms.CheckBox chkSensors;
     }
 }

+ 0 - 14
Optimizer/HelperForm.cs

@@ -21,13 +21,6 @@ namespace Optimizer
             {
                 this.Close();
             }
-            if (_type == MessageType.Optimize)
-            {
-                OptimizeForm f = new OptimizeForm(!chkPrint.Checked, !chkSensors.Checked);
-                f.ShowDialog();
-                f.BringToFront();
-                this.Close();
-            }
             if (_type == MessageType.Startup)
             {
                 _main.RemoveAllStartupItems();
@@ -66,13 +59,6 @@ namespace Optimizer
                 this.CancelButton = btnNo;
                 this.CancelButton = btnYes;
             }
-            if (_type == MessageType.Optimize)
-            {
-                chkPrint.Checked = true;
-                chkPrint.Visible = true;
-                chkSensors.Checked = true;
-                chkSensors.Visible = true;
-            }
         }
 
         private void btnNo_Click(object sender, EventArgs e)

+ 10 - 10
Optimizer/Integrator.cs

@@ -135,10 +135,10 @@ namespace Optimizer
                 Icon ico = Icon.ExtractAssociatedIcon(fileName);
 
                 Clipboard.SetImage(ico.ToBitmap());
-                Clipboard.GetImage().Save(Required.ExtractedIcons + "\\" + itemName + ".ico", ImageFormat.Bmp);
+                Clipboard.GetImage().Save(Required.ExtractedIconsFolder + itemName + ".ico", ImageFormat.Bmp);
                 Clipboard.Clear();
 
-                iconPath = Required.ExtractedIcons + "\\" + itemName + ".ico";
+                iconPath = Required.ExtractedIconsFolder + itemName + ".ico";
             }
 
             return iconPath;
@@ -153,9 +153,9 @@ namespace Optimizer
                 Uri url = new Uri(link);
                 if (url.HostNameType == UriHostNameType.Dns)
                 {
-                    Image.FromStream(((HttpWebResponse)WebRequest.Create("http://" + url.Host + "/favicon.ico").GetResponse()).GetResponseStream()).Save(Required.FavIcons + name + ".ico", ImageFormat.Bmp);
+                    Image.FromStream(((HttpWebResponse)WebRequest.Create("http://" + url.Host + "/favicon.ico").GetResponse()).GetResponseStream()).Save(Required.FavIconsFolder + name + ".ico", ImageFormat.Bmp);
 
-                    favicon = Required.FavIcons + name + ".ico";
+                    favicon = Required.FavIconsFolder + name + ".ico";
                 }
             }
             catch { }
@@ -212,30 +212,30 @@ namespace Optimizer
 
         internal static void TakeOwnership(bool remove)
         {
-            if (!File.Exists(Required.ReadyMadeMenus + "\\InstallTakeOwnership.reg"))
+            if (!File.Exists(Required.ReadyMadeMenusFolder + "InstallTakeOwnership.reg"))
             {
                 try
                 {
-                    File.WriteAllText(Required.ReadyMadeMenus + "\\InstallTakeOwnership.reg", Properties.Resources.InstallTakeOwnership);
+                    File.WriteAllText(Required.ReadyMadeMenusFolder + "InstallTakeOwnership.reg", Properties.Resources.InstallTakeOwnership);
                 }
                 catch { }
             }
-            if (!File.Exists(Required.ReadyMadeMenus + "\\RemoveTakeOwnership.reg"))
+            if (!File.Exists(Required.ReadyMadeMenusFolder + "RemoveTakeOwnership.reg"))
             {
                 try
                 {
-                    File.WriteAllText(Required.ReadyMadeMenus + "\\RemoveTakeOwnership.reg", Properties.Resources.RemoveTakeOwnership);
+                    File.WriteAllText(Required.ReadyMadeMenusFolder + "RemoveTakeOwnership.reg", Properties.Resources.RemoveTakeOwnership);
                 }
                 catch { }
             }
             
             if (!remove)
             {
-                Utilities.ImportRegistryScript(Required.ReadyMadeMenus + "\\InstallTakeOwnership.reg");
+                Utilities.ImportRegistryScript(Required.ReadyMadeMenusFolder + "InstallTakeOwnership.reg");
             }
             else
             {
-                Utilities.ImportRegistryScript(Required.ReadyMadeMenus + "\\RemoveTakeOwnership.reg");
+                Utilities.ImportRegistryScript(Required.ReadyMadeMenusFolder + "RemoveTakeOwnership.reg");
             }
         }
     }

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 470 - 501
Optimizer/MainForm.Designer.cs


+ 529 - 292
Optimizer/MainForm.cs

@@ -40,9 +40,42 @@ namespace Optimizer
         readonly string _removeDesktopItemsMessage = "Are you sure you want to delete all desktop items?";
         readonly string _removeModernAppsMessage = "Are you sure you want to uninstall the following app(s)?";
         readonly string _errorModernAppsMessage = "The following app(s) couldn't be uninstalled:\n";
-        readonly string _applyAllWindows7Message = "This will apply every option in Universal and Windows 7 tabs. Continue?";
-        readonly string _applyAllWindows8Message = "This will apply every option in Universal and Windows 8.1 tabs. Continue?";
-        readonly string _applyAllWindows10Message = "This will apply every option in Universal and Windows 10 tabs. Continue?";
+        readonly string _resetMessage = "Are you sure you want to reset configuration?\n\nThis will delete all your preferences, including any icons you extracted or downloaded using Integrator.";
+
+        private void EnableToggleEvents()
+        {
+            toggleSwitch12.Click += new EventHandler(toggleSwitch12_Click);
+            toggleSwitch11.Click += new EventHandler(toggleSwitch11_Click);
+            toggleSwitch10.Click += new EventHandler(toggleSwitch10_Click);
+            toggleSwitch9.Click += new EventHandler(toggleSwitch9_Click);
+            toggleSwitch8.Click += new EventHandler(toggleSwitch8_Click);
+            toggleSwitch7.Click += new EventHandler(toggleSwitch7_Click);
+            toggleSwitch6.Click += new EventHandler(toggleSwitch6_Click);
+            toggleSwitch5.Click += new EventHandler(toggleSwitch5_Click);
+            toggleSwitch4.Click += new EventHandler(toggleSwitch4_Click);
+            toggleSwitch1.Click += new EventHandler(toggleSwitch1_Click);
+            toggleSwitch3.Click += new EventHandler(toggleSwitch3_Click);
+            toggleSwitch2.Click += new EventHandler(toggleSwitch2_Click);
+            toggleSwitch27.Click += new EventHandler(toggleSwitch27_Click);
+            toggleSwitch28.Click += new EventHandler(toggleSwitch28_Click);
+            toggleSwitch29.Click += new EventHandler(toggleSwitch29_Click);
+            toggleSwitch30.Click += new EventHandler(toggleSwitch30_Click);
+            toggleSwitch22.Click += new EventHandler(toggleSwitch22_Click);
+            toggleSwitch20.Click += new EventHandler(toggleSwitch20_Click);
+            toggleSwitch21.Click += new EventHandler(toggleSwitch21_Click);
+            toggleSwitch23.Click += new EventHandler(toggleSwitch23_Click);
+            toggleSwitch24.Click += new EventHandler(toggleSwitch24_Click);
+            toggleSwitch25.Click += new EventHandler(toggleSwitch25_Click);
+            toggleSwitch26.Click += new EventHandler(toggleSwitch26_Click);
+            toggleSwitch17.Click += new EventHandler(toggleSwitch17_Click);
+            toggleSwitch16.Click += new EventHandler(toggleSwitch16_Click);
+            toggleSwitch15.Click += new EventHandler(toggleSwitch15_Click);
+            toggleSwitch14.Click += new EventHandler(toggleSwitch14_Click);
+            toggleSwitch13.Click += new EventHandler(toggleSwitch13_Click);
+            toggleSwitch31.Click += new EventHandler(toggleSwitch31_Click);
+            toggleSwitch18.Click += new EventHandler(toggleSwitch18_Click);
+            toggleSwitch19.Click += new EventHandler(toggleSwitch19_Click);
+        }
 
         private void LoadSettings()
         {
@@ -72,34 +105,63 @@ namespace Optimizer
         public MainForm()
         {
             InitializeComponent();
+            EnableToggleEvents();
+
+            CheckForIllegalCrossThreadCalls = false;
             Options.ApplyTheme(this);
 
-            _columnSorter = new ListViewColumnSorter();
-            listStartupItems.ListViewItemSorter = _columnSorter;
-        }
+            if (Utilities.CurrentWindowsVersion == WindowsVersion.Unsupported)
+            {
+                tabCollection.TabPages.Remove(universalTab);
+                tabCollection.TabPages.Remove(windowsVIIITab);
+                tabCollection.TabPages.Remove(windowsXTab);
+                tabCollection.TabPages.Remove(modernAppsTab);
+            }
 
-        private void ApplyAll()
-        {
-            if (Utilities.CurrentWindowsVersion != WindowsVersion.Unsupported)
+            if (Utilities.CurrentWindowsVersion == WindowsVersion.Windows7)
             {
-                string message = string.Empty;
+                LoadUniversalToggleStates();
+                tabCollection.TabPages.Remove(windowsVIIITab);
+                tabCollection.TabPages.Remove(windowsXTab);
+                tabCollection.TabPages.Remove(modernAppsTab);
+            }
 
-                if (Utilities.CurrentWindowsVersion == WindowsVersion.Windows7)
-                {
-                    message = _applyAllWindows7Message;
-                }
-                if (Utilities.CurrentWindowsVersion == WindowsVersion.Windows8)
-                {
-                    message = _applyAllWindows8Message;
-                }
-                if (Utilities.CurrentWindowsVersion == WindowsVersion.Windows10)
-                {
-                    message = _applyAllWindows10Message;
-                }
+            if (Utilities.CurrentWindowsVersion == WindowsVersion.Windows8)
+            {
+                LoadUniversalToggleStates();
+                LoadWindowsVIIIToggleStates();
+                tabCollection.TabPages.Remove(windowsXTab);
+            }
 
-                HelperForm r = new HelperForm(this, MessageType.Optimize, message);
-                r.ShowDialog(this);
+            if (Utilities.CurrentWindowsVersion == WindowsVersion.Windows10)
+            {
+                LoadUniversalToggleStates();
+                LoadWindowsXToggleStates();
+                tabCollection.TabPages.Remove(windowsVIIITab);
             }
+
+            _columnSorter = new ListViewColumnSorter();
+            listStartupItems.ListViewItemSorter = _columnSorter;
+
+            integratorTimer.Start();
+            runDialogTime.Start();
+
+            GetStartupItems();
+            GetHostsEntries();
+            GetDesktopItems();
+            GetCustomCommands();
+            GetModernApps();
+
+            LoadSettings();
+
+            radioProgram.Checked = true;
+            radioTop.Checked = true;
+
+            txtVersion.Text = "Version: " + Program.GetCurrentVersion();
+            Program.MainForm = this;
+
+            txtOS.Text = "Microsoft " + Utilities.GetOS();
+            txtBitness.Text = Utilities.GetBitness();
         }
 
         private void CleanPC()
@@ -152,7 +214,7 @@ namespace Optimizer
 
         private void CleaningAnimation(bool start)
         {
-            if (start == true)
+            if (start)
             {
                 Utilities.SetControlPropertyThreadSafe(cleaningpanel, "Visible", true);
                 Utilities.SetControlPropertyThreadSafe(progress2, "Visible", true);
@@ -227,57 +289,52 @@ namespace Optimizer
             return changeDetected;
         }
 
-        private void Main_Load(object sender, EventArgs e)
+        private void LoadUniversalToggleStates()
         {
-            CheckForIllegalCrossThreadCalls = false;
-            
-            integratorTimer.Start();
-            runDialogTime.Start();
-
-            GetStartupItems();
-            GetHostsEntries();
-            GetDesktopItems();
-            GetCustomCommands();
-            GetModernApps();
+            toggleSwitch1.Checked = Options.CurrentOptions.EnablePerformanceTweaks;
+            toggleSwitch2.Checked = Options.CurrentOptions.DisableNetworkThrottling;
+            toggleSwitch3.Checked = Options.CurrentOptions.DisableWindowsDefender;
+            toggleSwitch4.Checked = Options.CurrentOptions.DisableSystemRestore;
+            toggleSwitch5.Checked = Options.CurrentOptions.DisablePrintService;
+            toggleSwitch6.Checked = Options.CurrentOptions.DisableMediaPlayerSharing;
+            toggleSwitch7.Checked = Options.CurrentOptions.BlockSkypeAds;
+            toggleSwitch8.Checked = Options.CurrentOptions.DisableErrorReporting;
+            toggleSwitch9.Checked = Options.CurrentOptions.DisableHomeGroup;
+            toggleSwitch10.Checked = Options.CurrentOptions.DisableSuperfetch;
+            toggleSwitch11.Checked = Options.CurrentOptions.DisableTelemetryTasks;
+            toggleSwitch12.Checked = Options.CurrentOptions.DisableOffice2016Telemetry;
+        }
 
-            LoadSettings();
+        private void LoadWindowsVIIIToggleStates()
+        {
+            toggleSwitch31.Checked = Options.CurrentOptions.DisableOneDrive;
+        }
 
-            radioProgram.Checked = true;
-            radioTop.Checked = true;
+        private void LoadWindowsXToggleStates()
+        {
+            toggleSwitch13.Checked = Options.CurrentOptions.EnableLegacyVolumeSlider;
+            toggleSwitch14.Checked = Options.CurrentOptions.UninstallOneDrive;
+            toggleSwitch15.Checked = Options.CurrentOptions.DisableGameBar;
+            toggleSwitch16.Checked = Options.CurrentOptions.DisableCortana;
+            toggleSwitch17.Checked = Options.CurrentOptions.DisableXboxLive;
+            toggleSwitch18.Checked = Options.CurrentOptions.DisableQuickAccessHistory;
+            toggleSwitch19.Checked = Options.CurrentOptions.EnableTaskbarColor;
+            toggleSwitch20.Checked = Options.CurrentOptions.DisableSensorServices;
+            toggleSwitch21.Checked = Options.CurrentOptions.DisablePrivacyOptions;
+            toggleSwitch22.Checked = Options.CurrentOptions.DisableSilentAppInstall;
+            toggleSwitch23.Checked = Options.CurrentOptions.DisableTelemetryServices;
+            toggleSwitch24.Checked = Options.CurrentOptions.DisableAutomaticUpdates;
+            toggleSwitch25.Checked = Options.CurrentOptions.DisableMyPeople;
+            toggleSwitch26.Checked = Options.CurrentOptions.DisableStartMenuAds;
+            toggleSwitch27.Checked = Options.CurrentOptions.EnableDarkTheme;
+            toggleSwitch28.Checked = Options.CurrentOptions.DisableSpellingTyping;
+            toggleSwitch29.Checked = Options.CurrentOptions.DisableWindowsInk;
+            toggleSwitch30.Checked = Options.CurrentOptions.ExcludeDrivers;
+        }
 
-            txtVersion.Text = "Version: " + Program.GetCurrentVersion();
-            Program.MainForm = this;
-            
-            txtOS.Text = "Microsoft " + Utilities.GetOS();
-            txtBitness.Text = Utilities.GetBitness();   
+        private void Main_Load(object sender, EventArgs e)
+        {
             
-            if (Utilities.CurrentWindowsVersion == WindowsVersion.Unsupported)
-            {
-                tabCollection.TabPages.Remove(universalTab);
-                tabCollection.TabPages.Remove(windowsVIITab);
-                tabCollection.TabPages.Remove(windowsVIIITab);
-                tabCollection.TabPages.Remove(windowsXTab);
-                tabCollection.TabPages.Remove(modernAppsTab);
-            }   
-
-            if (Utilities.CurrentWindowsVersion == WindowsVersion.Windows7)
-            {
-                tabCollection.TabPages.Remove(windowsVIIITab);
-                tabCollection.TabPages.Remove(windowsXTab);
-                tabCollection.TabPages.Remove(modernAppsTab);
-            }
-
-            if (Utilities.CurrentWindowsVersion == WindowsVersion.Windows8)
-            {
-                tabCollection.TabPages.Remove(windowsVIITab);
-                tabCollection.TabPages.Remove(windowsXTab);
-            }
-
-            if (Utilities.CurrentWindowsVersion == WindowsVersion.Windows10)
-            {
-                tabCollection.TabPages.Remove(windowsVIITab);
-                tabCollection.TabPages.Remove(windowsVIIITab);
-            }
         }
 
         private void GetDesktopItems()
@@ -429,179 +486,12 @@ namespace Optimizer
             f.ShowDialog();
         }
 
-        private void button3_Click(object sender, EventArgs e)
-        {
-            Optimize.PerformanceTweaks();
-            button3.Enabled = false;
-        }
-
-        private void button2_Click(object sender, EventArgs e)
-        {
-            Optimize.DisableNetworkThrottling();
-            button2.Enabled = false;
-        }
-
-        private void button1_Click(object sender, EventArgs e)
-        {
-            Task t = new Task(() => Optimize.DisableDefender());
-            t.Start();
-            button1.Enabled = false;
-        }
-
-        private void button17_Click(object sender, EventArgs e)
-        {
-            Task t = new Task(() => Optimize.DisableSystemRestore());
-            t.Start();
-            button17.Enabled = false;
-        }
-
-        private void button16_Click(object sender, EventArgs e)
-        {
-            Optimize.DisableErrorReporting();
-            button16.Enabled = false;
-        }
-
-        private void button13_Click(object sender, EventArgs e)
-        {
-            Optimize.DisableHomeGroup();
-            button13.Enabled = false;
-        }
-
-        private void button14_Click(object sender, EventArgs e)
-        {
-            Optimize.DisableSuperfetch();
-            button14.Enabled = false;
-        }
-
-        private void button15_Click(object sender, EventArgs e)
-        {
-            Optimize.DisablePrintSpooler();
-            button15.Enabled = false;
-        }
-
-        private void button10_Click(object sender, EventArgs e)
-        {
-            Optimize.BlockSkypeAds();
-            button10.Enabled = false;
-        }
-
-        private void button9_Click(object sender, EventArgs e)
-        {
-            Optimize.RestoreLegacyVolumeSlider();
-            button9.Enabled = false;
-        }
-
-        private void button29_Click(object sender, EventArgs e)
-        {
-            Task t = new Task(() => Optimize.UninstallOneDrive());
-            t.Start();
-            Utilities.ActivateMainForm();
-            button29.Enabled = false;
-        }
-
-        private void button24_Click(object sender, EventArgs e)
-        {
-            Optimize.DisableCortana();
-            button24.Enabled = false;
-        }
-
-        private void button21_Click(object sender, EventArgs e)
-        {
-            Task t = new Task(() => Optimize.DisableXboxLive());
-            t.Start();
-            button21.Enabled = false;
-        }
-
         private void button18_Click(object sender, EventArgs e)
         {
             EdgeForm f = new EdgeForm();
             f.ShowDialog();
         }
 
-        private void button28_Click(object sender, EventArgs e)
-        {
-            Optimize.DisableAutomaticUpdates();
-            button28.Enabled = false;
-        }
-
-        private void button27_Click(object sender, EventArgs e)
-        {
-            Optimize.DisableDiagnosticsTracking();
-            button27.Enabled = false;
-        }
-
-        private void button25_Click(object sender, EventArgs e)
-        {
-            Optimize.DisableWAPPush();
-            button25.Enabled = false;
-        }
-
-        private void button23_Click(object sender, EventArgs e)
-        {
-            Optimize.DisableDataTelemetry();
-            button23.Enabled = false;
-        }
-
-        private void button30_Click(object sender, EventArgs e)
-        {
-            Optimize.DisableSensorServices();
-            button30.Enabled = false;
-        }
-
-        private void button36_Click(object sender, EventArgs e)
-        {
-            Optimize.DisableOneDrive();
-            button36.Enabled = false;
-        }
-
-        private void button35_Click(object sender, EventArgs e)
-        {
-            Optimize.RemoveWindows10Icon();
-            button35.Enabled = false;
-        }
-
-        private void button38_Click(object sender, EventArgs e)
-        {
-            Optimize.RemoveWindows10Icon();
-            button38.Enabled = false;
-        }
-
-        private void button4_Click(object sender, EventArgs e)
-        {
-            Task t = new Task(() => Optimize.DisableTelemetryTasks());
-            t.Start();
-            Utilities.ActivateMainForm();
-            button4.Enabled = false;
-        }
-
-        private void button5_Click(object sender, EventArgs e)
-        {
-            Task t = new Task(() => Optimize.DisableOfficeTelemetryTasks());
-            t.Start();
-            Utilities.ActivateMainForm();
-            button5.Enabled = false;
-        }
-
-        private void button6_Click(object sender, EventArgs e)
-        {
-            ApplyAll();
-        }
-
-        private void button11_Click(object sender, EventArgs e)
-        {
-            ApplyAll();
-        }
-
-        private void button12_Click(object sender, EventArgs e)
-        {
-            ApplyAll();
-        }
-
-        private void button19_Click(object sender, EventArgs e)
-        {
-            ApplyAll();
-        }
-
         private void checkSelectAll_CheckedChanged(object sender, EventArgs e)
         {
             checkTemp.Checked = checkSelectAll.Checked;
@@ -700,12 +590,6 @@ namespace Optimizer
             GetStartupItems();
         }
 
-        private void button40_Click(object sender, EventArgs e)
-        {
-            Optimize.DisablePrivacyOptions();
-            button40.Enabled = false;
-        }
-
         private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
         {
             HostsHelper.LocateHosts();
@@ -857,31 +741,31 @@ namespace Optimizer
 
         private void button59_Click(object sender, EventArgs e)
         {
-            Utilities.ImportRegistryScript(Required.ReadyMadeMenus + "\\PowerMenu.reg");
+            Utilities.ImportRegistryScript(Required.ReadyMadeMenusFolder + "\\PowerMenu.reg");
             GetDesktopItems();
         }
 
         private void button53_Click(object sender, EventArgs e)
         {
-            Utilities.ImportRegistryScript(Required.ReadyMadeMenus + "\\SystemTools.reg");
+            Utilities.ImportRegistryScript(Required.ReadyMadeMenusFolder + "\\SystemTools.reg");
             GetDesktopItems();
         }
 
         private void button54_Click(object sender, EventArgs e)
         {
-            Utilities.ImportRegistryScript(Required.ReadyMadeMenus + "\\WindowsApps.reg");
+            Utilities.ImportRegistryScript(Required.ReadyMadeMenusFolder + "\\WindowsApps.reg");
             GetDesktopItems();
         }
 
         private void button51_Click(object sender, EventArgs e)
         {
-            Utilities.ImportRegistryScript(Required.ReadyMadeMenus + "\\SystemShortcuts.reg");
+            Utilities.ImportRegistryScript(Required.ReadyMadeMenusFolder + "\\SystemShortcuts.reg");
             GetDesktopItems();
         }
 
         private void button57_Click(object sender, EventArgs e)
         {
-            Utilities.ImportRegistryScript(Required.ReadyMadeMenus + "\\DesktopShortcuts.reg");
+            Utilities.ImportRegistryScript(Required.ReadyMadeMenusFolder + "\\DesktopShortcuts.reg");
             GetDesktopItems();
         }
 
@@ -1303,12 +1187,6 @@ namespace Optimizer
             Options.ApplyTheme(this);
         }
 
-        private void button63_Click(object sender, EventArgs e)
-        {
-            Optimize.DisableGameBar();
-            button63.Enabled = false;
-        }
-
         private void button64_Click(object sender, EventArgs e)
         {
             if (listStartupItems.SelectedItems.Count == 1)
@@ -1363,12 +1241,6 @@ namespace Optimizer
             }
         }
 
-        private void button7_Click(object sender, EventArgs e)
-        {
-            Optimize.DisableQuickAccess();
-            button7.Enabled = false;
-        }
-
         private void button8_Click(object sender, EventArgs e)
         {
             GetCustomCommands();
@@ -1383,70 +1255,435 @@ namespace Optimizer
             }
         }
 
-        private void button34_Click(object sender, EventArgs e)
+        private void button75_Click(object sender, EventArgs e)
+        {
+            GetModernApps();
+        }
+
+        private void button74_Click(object sender, EventArgs e)
+        {
+            UninstallModernApps();
+        }
+
+        private void chkSelectAllModernApps_CheckedChanged(object sender, EventArgs e)
+        {
+            for (int i = 0; i < listModernApps.Items.Count; i++)
+            {
+                listModernApps.SetItemChecked(i, chkSelectAllModernApps.Checked);
+            }
+        }
+
+        private void btnResetConfig_Click(object sender, EventArgs e)
+        {
+            if (MessageBox.Show(_resetMessage, "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
+            {
+                Utilities.ResetConfiguration();
+            }
+        }
+
+        private void toggleSwitch1_Click(object sender, EventArgs e)
         {
-            Optimize.DisableMediaPlayerSharing();
-            button34.Enabled = false;
+            if (!toggleSwitch1.Checked)
+            {
+                Optimize.EnablePerformanceTweaks();
+            }
+            else
+            {
+                Optimize.DisablePerformanceTweaks();
+            }
+            Options.CurrentOptions.EnablePerformanceTweaks = !toggleSwitch1.Checked;
         }
 
-        private void button68_Click(object sender, EventArgs e)
+        private void toggleSwitch2_Click(object sender, EventArgs e)
         {
-            Optimize.DisableStartMenuAds();
-            button68.Enabled = false;
+            if (!toggleSwitch2.Checked)
+            {
+                Optimize.DisableNetworkThrottling();
+            }
+            else
+            {
+                Optimize.EnableNetworkThrottling();
+            }
+            Options.CurrentOptions.DisableNetworkThrottling = !toggleSwitch2.Checked;
         }
 
-        private void button67_Click(object sender, EventArgs e)
+        private void toggleSwitch3_Click(object sender, EventArgs e)
         {
-            Optimize.DisableSilentAppInstall();
-            button67.Enabled = false;
+            if (!toggleSwitch3.Checked)
+            {
+                Optimize.DisableDefender();
+            }
+            else
+            {
+                Optimize.EnableDefender();
+            }
+            Options.CurrentOptions.DisableWindowsDefender = !toggleSwitch3.Checked;
         }
 
-        private void button69_Click(object sender, EventArgs e)
+        private void toggleSwitch4_Click(object sender, EventArgs e)
         {
-            Optimize.DisableMyPeople();
-            button69.Enabled = false;
+            if (!toggleSwitch4.Checked)
+            {
+                Optimize.DisableSystemRestore();
+            }
+            else
+            {
+                Optimize.EnableSystemRestore();
+            }
+            Options.CurrentOptions.DisableSystemRestore = !toggleSwitch4.Checked;
         }
 
-        private void button70_Click(object sender, EventArgs e)
+        private void toggleSwitch5_Click(object sender, EventArgs e)
         {
-            Optimize.ExcludeDrivers();
-            button70.Enabled = false;
+            if (!toggleSwitch5.Checked)
+            {
+                Optimize.DisablePrintService();
+            }
+            else
+            {
+                Optimize.EnablePrintService();
+            }
+            Options.CurrentOptions.DisablePrintService = !toggleSwitch5.Checked;
         }
 
-        private void button71_Click(object sender, EventArgs e)
+        private void toggleSwitch6_Click(object sender, EventArgs e)
         {
-            Optimize.DisableWindowsInk();
-            button71.Enabled = false;
+            if (!toggleSwitch6.Checked)
+            {
+                Optimize.DisableMediaPlayerSharing();
+            }
+            else
+            {
+                Optimize.EnableMediaPlayerSharing();
+            }
+            Options.CurrentOptions.DisableMediaPlayerSharing = !toggleSwitch6.Checked;
         }
 
-        private void button72_Click(object sender, EventArgs e)
+        private void toggleSwitch7_Click(object sender, EventArgs e)
         {
-            Optimize.DisableSpellingAndTypingFeatures();
-            button72.Enabled = false;
+            if (!toggleSwitch7.Checked)
+            {
+                Optimize.DisableSkypeAds();
+            }
+            else
+            {
+                Optimize.EnableSkypeAds();
+            }
+            Options.CurrentOptions.BlockSkypeAds = !toggleSwitch7.Checked;
         }
 
-        private void button73_Click(object sender, EventArgs e)
+        private void toggleSwitch8_Click(object sender, EventArgs e)
         {
-            Optimize.RestoreTaskbarColor();
-            button73.Enabled = false;
+            if (!toggleSwitch8.Checked)
+            {
+                Optimize.DisableErrorReporting();
+            }
+            else
+            {
+                Optimize.EnableErrorReporting();
+            }
+            Options.CurrentOptions.DisableErrorReporting = !toggleSwitch8.Checked;
         }
 
-        private void button75_Click(object sender, EventArgs e)
+        private void toggleSwitch9_Click(object sender, EventArgs e)
         {
-            GetModernApps();
+            if (!toggleSwitch9.Checked)
+            {
+                Optimize.DisableHomeGroup();
+            }
+            else
+            {
+                Optimize.EnableHomeGroup();
+            }
+            Options.CurrentOptions.DisableHomeGroup = !toggleSwitch9.Checked;
         }
 
-        private void button74_Click(object sender, EventArgs e)
+        private void toggleSwitch10_Click(object sender, EventArgs e)
         {
-            UninstallModernApps();
+            if (!toggleSwitch10.Checked)
+            {
+                Optimize.DisableSuperfetch();
+            }
+            else
+            {
+                Optimize.EnableSuperfetch();
+            }
+            Options.CurrentOptions.DisableSuperfetch = !toggleSwitch10.Checked;
         }
 
-        private void chkSelectAllModernApps_CheckedChanged(object sender, EventArgs e)
+        private void toggleSwitch11_Click(object sender, EventArgs e)
         {
-            for (int i = 0; i < listModernApps.Items.Count; i++)
+            if (!toggleSwitch11.Checked)
             {
-                listModernApps.SetItemChecked(i, chkSelectAllModernApps.Checked);
+                Optimize.DisableTelemetryTasks();
+            }
+            else
+            {
+                Optimize.EnableTelemetryTasks();
+            }
+            Options.CurrentOptions.DisableTelemetryTasks = !toggleSwitch11.Checked;
+        }
+
+        private void toggleSwitch12_Click(object sender, EventArgs e)
+        {
+            if (!toggleSwitch12.Checked)
+            {
+                Optimize.DisableOffice2016Telemetry();
+            }
+            else
+            {
+                Optimize.EnableOffice2016Telemetry();
+            }
+            Options.CurrentOptions.DisableOffice2016Telemetry = !toggleSwitch12.Checked;
+        }
+
+        private void toggleSwitch13_Click(object sender, EventArgs e)
+        {
+            if (!toggleSwitch13.Checked)
+            {
+                Optimize.EnableLegacyVolumeSlider();
+            }
+            else
+            {
+                Optimize.DisableLegacyVolumeSlider();
+            }
+            Options.CurrentOptions.EnableLegacyVolumeSlider = !toggleSwitch13.Checked;
+        }
+
+        private void toggleSwitch19_Click(object sender, EventArgs e)
+        {
+            if (!toggleSwitch19.Checked)
+            {
+                Optimize.EnableTaskbarColor();
+            }
+            else
+            {
+                Optimize.DisableTaskbarColor();
+            }
+            Options.CurrentOptions.EnableTaskbarColor = !toggleSwitch19.Checked;
+        }
+
+        private void toggleSwitch18_Click(object sender, EventArgs e)
+        {
+            if (!toggleSwitch18.Checked)
+            {
+                Optimize.DisableQuickAccessHistory();
+            }
+            else
+            {
+                Optimize.EnableQuickAccessHistory();
+            }
+            Options.CurrentOptions.DisableQuickAccessHistory = !toggleSwitch18.Checked;
+        }
+
+        private void toggleSwitch26_Click(object sender, EventArgs e)
+        {
+            if (!toggleSwitch26.Checked)
+            {
+                Optimize.DisableStartMenuAds();
+            }
+            else
+            {
+                Optimize.EnableStartMenuAds();
+            }
+            Options.CurrentOptions.DisableStartMenuAds = !toggleSwitch26.Checked;
+        }
+
+        private void toggleSwitch27_Click(object sender, EventArgs e)
+        {
+            if (!toggleSwitch27.Checked)
+            {
+                Optimize.EnableDarkTheme();
+            }
+            else
+            {
+                Optimize.EnableLightTheme();
+            }
+            Options.CurrentOptions.EnableDarkTheme = !toggleSwitch27.Checked;
+        }
+
+        private void toggleSwitch14_Click(object sender, EventArgs e)
+        {
+            if (!toggleSwitch14.Checked)
+            {
+                Task t = new Task(() => Optimize.UninstallOneDrive());
+                t.Start();
+            }
+            else
+            {
+                Task t = new Task(() => Optimize.InstallOneDrive());
+                t.Start();
+            }
+            Options.CurrentOptions.UninstallOneDrive = !toggleSwitch14.Checked;
+        }
+
+        private void toggleSwitch25_Click(object sender, EventArgs e)
+        {
+            if (!toggleSwitch25.Checked)
+            {
+                Optimize.DisableMyPeople();
+            }
+            else
+            {
+                Optimize.EnableMyPeople();
+            }
+            Options.CurrentOptions.DisableMyPeople = !toggleSwitch25.Checked;
+        }
+
+        private void toggleSwitch24_Click(object sender, EventArgs e)
+        {
+            if (!toggleSwitch24.Checked)
+            {
+                Optimize.DisableAutomaticUpdates();
+            }
+            else
+            {
+                Optimize.EnableAutomaticUpdates();
+            }
+            Options.CurrentOptions.DisableAutomaticUpdates = !toggleSwitch24.Checked;
+        }
+
+        private void toggleSwitch30_Click(object sender, EventArgs e)
+        {
+            if (!toggleSwitch30.Checked)
+            {
+                Optimize.ExcludeDrivers();
+            }
+            else
+            {
+                Optimize.IncludeDrivers();
+            }
+            Options.CurrentOptions.ExcludeDrivers = !toggleSwitch30.Checked;
+        }
+
+        private void toggleSwitch23_Click(object sender, EventArgs e)
+        {
+            if (!toggleSwitch23.Checked)
+            {
+                Optimize.DisableTelemetryServices();
+            }
+            else
+            {
+                Optimize.EnableTelemetryServices();
+            }
+            Options.CurrentOptions.DisableTelemetryServices = !toggleSwitch23.Checked;
+        }
+
+        private void toggleSwitch21_Click(object sender, EventArgs e)
+        {
+            if (!toggleSwitch21.Checked)
+            {
+                Optimize.DisablePrivacyOptions();
+            }
+            else
+            {
+                Optimize.EnablePrivacyOptions();
+            }
+            Options.CurrentOptions.DisablePrivacyOptions = !toggleSwitch21.Checked;
+        }
+
+        private void toggleSwitch22_Click(object sender, EventArgs e)
+        {
+            if (!toggleSwitch22.Checked)
+            {
+                Optimize.DisableSilentAppInstall();
+            }
+            else
+            {
+                Optimize.EnableSilentAppInstall();
+            }
+            Options.CurrentOptions.DisableSilentAppInstall = !toggleSwitch22.Checked;
+        }
+
+        private void toggleSwitch16_Click(object sender, EventArgs e)
+        {
+            if (!toggleSwitch16.Checked)
+            {
+                Optimize.DisableCortana();
+            }
+            else
+            {
+                Optimize.EnableCortana();
+            }
+            Options.CurrentOptions.DisableCortana = !toggleSwitch16.Checked;
+        }
+
+        private void toggleSwitch20_Click(object sender, EventArgs e)
+        {
+            if (!toggleSwitch20.Checked)
+            {
+                Optimize.DisableSensorServices();
+            }
+            else
+            {
+                Optimize.EnableSensorServices();
+            }
+            Options.CurrentOptions.DisableSensorServices = !toggleSwitch20.Checked;
+        }
+
+        private void toggleSwitch29_Click(object sender, EventArgs e)
+        {
+            if (!toggleSwitch29.Checked)
+            {
+                Optimize.DisableWindowsInk();
+            }
+            else
+            {
+                Optimize.EnableWindowsInk();
+            }
+            Options.CurrentOptions.DisableWindowsInk = !toggleSwitch29.Checked;
+        }
+
+        private void toggleSwitch28_Click(object sender, EventArgs e)
+        {
+            if (!toggleSwitch28.Checked)
+            {
+                Optimize.DisableSpellingAndTypingFeatures();
+            }
+            else
+            {
+                Optimize.EnableSpellingAndTypingFeatures();
+            }
+            Options.CurrentOptions.DisableSpellingTyping = !toggleSwitch28.Checked;
+        }
+
+        private void toggleSwitch17_Click(object sender, EventArgs e)
+        {
+            if (!toggleSwitch17.Checked)
+            {
+                Optimize.DisableXboxLive();
+            }
+            else
+            {
+                Optimize.EnableXboxLive();
+            }
+            Options.CurrentOptions.DisableXboxLive = !toggleSwitch17.Checked;
+        }
+
+        private void toggleSwitch15_Click(object sender, EventArgs e)
+        {
+            if (!toggleSwitch15.Checked)
+            {
+                Optimize.DisableGameBar();
+            }
+            else
+            {
+                Optimize.EnableGameBar();
+            }
+            Options.CurrentOptions.DisableGameBar = !toggleSwitch15.Checked;
+        }
+
+        private void toggleSwitch31_Click(object sender, EventArgs e)
+        {
+            if (!toggleSwitch31.Checked)
+            {
+                Optimize.DisableOneDrive();
+            }
+            else
+            {
+                Optimize.EnableOneDrive();
             }
+            Options.CurrentOptions.DisableOneDrive = !toggleSwitch31.Checked;
         }
     }
 }

+ 1 - 1
Optimizer/MainForm.resx

@@ -182,7 +182,7 @@ any application only by typing your desired keyword.</value>
     <value>860, 58</value>
   </metadata>
   <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>86</value>
+    <value>25</value>
   </metadata>
   <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
     <value>

+ 458 - 54
Optimizer/Optimize.cs

@@ -20,28 +20,47 @@ namespace Optimizer
 {
     public static class Optimize
     {
-        readonly static string CompatTelRunnerFile = Path.GetPathRoot(Environment.SystemDirectory) + @"Windows\System32\CompatTelRunner.exe";
-        readonly static string CompatTelRunnerFileOff = "CompatTelRunner.exe.OFF";
+        readonly static string CompatTelRunnerFile = Path.Combine(Path.GetPathRoot(Environment.SystemDirectory), @"Windows\System32\CompatTelRunner.exe");
+
+        readonly static string CompatTelRunnerFileOff = Path.Combine(Path.GetPathRoot(Environment.SystemDirectory), @"Windows\System32\CompatTelRunner.exe.OFF");
+
+        readonly static string CompatTelRunnerFileName = "CompatTelRunner.exe";
+        readonly static string CompatTelRunnerFileNameOff = "CompatTelRunner.exe.OFF";
 
         internal static void DisableTelemetryRunner()
         {
             try
             {
+                if (File.Exists(CompatTelRunnerFileOff)) File.Delete(CompatTelRunnerFileOff);
+
                 if (File.Exists(CompatTelRunnerFile))
                 {
                     Utilities.RunCommand(string.Format("takeown /F {0}", CompatTelRunnerFile));
                     Utilities.RunCommand(string.Format("icacls \"{0}\" /grant administrators:F", CompatTelRunnerFile));
 
-                    FileSystem.RenameFile(CompatTelRunnerFile, CompatTelRunnerFileOff);
+                    FileSystem.RenameFile(CompatTelRunnerFile, CompatTelRunnerFileNameOff);
+                }
+            }
+            catch { }
+        }
+
+        internal static void EnableTelemetryRunner()
+        {
+            try
+            {
+                if (File.Exists(CompatTelRunnerFileOff))
+                {
+                    FileSystem.RenameFile(CompatTelRunnerFileOff, CompatTelRunnerFileName);
                 }
             }
             catch { }
         }
 
-        internal static void PerformanceTweaks()
+        internal static void EnablePerformanceTweaks()
         {
             Registry.SetValue("HKEY_CLASSES_ROOT\\AllFilesystemObjects\\shellex\\ContextMenuHandlers\\Copy To", "", "{C2FBB630-2971-11D1-A18C-00C04FD75D13}");
             Registry.SetValue("HKEY_CLASSES_ROOT\\AllFilesystemObjects\\shellex\\ContextMenuHandlers\\Move To", "", "{C2FBB631-2971-11D1-A18C-00C04FD75D13}");
+
             Registry.SetValue("HKEY_CURRENT_USER\\Control Panel\\Desktop", "AutoEndTasks", "1");
             Registry.SetValue("HKEY_CURRENT_USER\\Control Panel\\Desktop", "HungAppTimeout", "1000");
             Registry.SetValue("HKEY_CURRENT_USER\\Control Panel\\Desktop", "MenuShowDelay", "8");
@@ -68,24 +87,113 @@ namespace Optimizer
             Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Games", "Priority", 6, RegistryValueKind.DWord);
         }
 
+        internal static void DisablePerformanceTweaks()
+        {
+            try
+            {
+                Registry.ClassesRoot.DeleteSubKeyTree(@"AllFilesystemObjects\\shellex\\ContextMenuHandlers\\Copy To", false);
+                Registry.ClassesRoot.DeleteSubKeyTree(@"AllFilesystemObjects\\shellex\\ContextMenuHandlers\\Move To", false);
+
+                Registry.CurrentUser.OpenSubKey(@"Control Panel\Desktop", true).DeleteValue("AutoEndTasks", false);
+                Registry.CurrentUser.OpenSubKey(@"Control Panel\Desktop", true).DeleteValue("HungAppTimeout", false);
+                Registry.CurrentUser.OpenSubKey(@"Control Panel\Desktop", true).DeleteValue("WaitToKillAppTimeout", false);
+                Registry.CurrentUser.OpenSubKey(@"Control Panel\Desktop", true).DeleteValue("LowLevelHooksTimeout", false);
+
+                Registry.SetValue("HKEY_CURRENT_USER\\Control Panel\\Desktop", "MenuShowDelay", "400");
+                Registry.SetValue("HKEY_CURRENT_USER\\Control Panel\\Mouse", "MouseHoverTime", "400");
+
+                Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Policies\Explorer", true).DeleteValue("NoLowDiskSpaceChecks", false);
+                Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Policies\Explorer", true).DeleteValue("LinkResolveIgnoreLinkInfo", false);
+                Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Policies\Explorer", true).DeleteValue("NoResolveSearch", false);
+                Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Policies\Explorer", true).DeleteValue("NoResolveTrack", false);
+                Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Policies\Explorer", true).DeleteValue("NoInternetOpenWith", false);
+
+                Registry.SetValue("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control", "WaitToKillServiceTimeout", "5000");
+
+                Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DiagTrack", "Start", "2", RegistryValueKind.DWord);
+                Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\diagnosticshub.standardcollector.service", "Start", "2", RegistryValueKind.DWord);
+                Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\dmwappushservice", "Start", "2", RegistryValueKind.DWord);
+
+                Utilities.StartService("DiagTrack");
+                Utilities.StartService("diagnosticshub.standardcollector.service");
+                Utilities.StartService("dmwappushservice");
+
+                Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile", true).DeleteValue("SystemResponsiveness", false);
+                Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Games", true).DeleteValue("GPU Priority", false);
+                Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Games", true).DeleteValue("Priority", false);
+            }
+            catch { }
+        }
+
+        internal static void DisableTelemetryServices()
+        {
+            Utilities.StopService("DiagTrack");
+            Utilities.StopService("diagnosticshub.standardcollector.service");
+            Utilities.StopService("dmwappushservice");
+            Utilities.StopService("DcpSvc");
+
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DiagTrack", "Start", "4", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\diagnosticshub.standardcollector.service", "Start", "4", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\dmwappushservice", "Start", "4", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DcpSvc", "Start", "4", RegistryValueKind.DWord);
+        }
+
+        internal static void EnableTelemetryServices()
+        {
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DiagTrack", "Start", "2", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\diagnosticshub.standardcollector.service", "Start", "2", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\dmwappushservice", "Start", "2", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DcpSvc", "Start", "2", RegistryValueKind.DWord);
+
+            Utilities.StartService("DiagTrack");
+            Utilities.StartService("diagnosticshub.standardcollector.service");
+            Utilities.StartService("dmwappushservice");
+            Utilities.StartService("DcpSvc");
+        }
+
         internal static void DisableMediaPlayerSharing()
         {
             Utilities.StopService("WMPNetworkSvc");
             Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WMPNetworkSvc", "Start", "4", RegistryValueKind.DWord);
         }
 
+        internal static void EnableMediaPlayerSharing()
+        {
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WMPNetworkSvc", "Start", "2", RegistryValueKind.DWord);
+            Utilities.StartService("WMPNetworkSvc");
+        }
+
         internal static void DisableNetworkThrottling()
         {
             Int32 tempInt = Convert.ToInt32("ffffffff", 16);
             Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Multimedia\\SystemProfile", "NetworkThrottlingIndex", tempInt, RegistryValueKind.DWord);
         }
 
-        internal static void BlockSkypeAds()
+        internal static void EnableNetworkThrottling()
+        {
+            try
+            {
+                Registry.LocalMachine.OpenSubKey(@"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Multimedia\\SystemProfile", true).DeleteValue("NetworkThrottlingIndex", false);
+            }
+            catch { }
+        }
+
+        internal static void DisableSkypeAds()
         {
             Registry.SetValue("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Domains\\skype.com\\apps", "https", "00000004", RegistryValueKind.DWord);
             Registry.SetValue("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Domains\\skype.com\\apps", "http", "00000004", RegistryValueKind.DWord);
         }
 
+        internal static void EnableSkypeAds()
+        {
+            try
+            {
+                Registry.CurrentUser.OpenSubKey(@"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Domains\\skype.com\\apps", true).DeleteValue("http", false);
+                Registry.CurrentUser.OpenSubKey(@"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Domains\\skype.com\\apps", true).DeleteValue("https", false);
+            }
+            catch { }
+        }
+
         internal static void DisableHomeGroup()
         {
             Utilities.StopService("HomeGroupListener");
@@ -95,13 +203,22 @@ namespace Optimizer
             Registry.SetValue("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\HomeGroupProvider", "Start", "4", RegistryValueKind.DWord);
         }
 
-        internal static void DisablePrintSpooler()
+        internal static void EnableHomeGroup()
+        {
+            Registry.SetValue("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\HomeGroupListener", "Start", "2", RegistryValueKind.DWord);
+            Registry.SetValue("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\HomeGroupProvider", "Start", "2", RegistryValueKind.DWord);
+
+            Utilities.StartService("HomeGroupListener");
+            Utilities.StartService("HomeGroupProvider");
+        }
+
+        internal static void DisablePrintService()
         {
             Utilities.StopService("Spooler");
             Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Spooler", "Start", "3", RegistryValueKind.DWord);
         }
 
-        internal static void EnablePrintSpooler()
+        internal static void EnablePrintService()
         {
             Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Spooler", "Start", "2", RegistryValueKind.DWord);
             Utilities.StartService("Spooler");
@@ -113,6 +230,12 @@ namespace Optimizer
             Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SysMain", "Start", "4", RegistryValueKind.DWord);
         }
 
+        internal static void EnableSuperfetch()
+        {
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SysMain", "Start", "2", RegistryValueKind.DWord);
+            Utilities.StartService("SysMain");
+        }
+
         internal static void DisableSystemRestore()
         {
             try
@@ -139,6 +262,13 @@ namespace Optimizer
             Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\SystemRestore", "DisableConfig", "00000001", RegistryValueKind.DWord);
         }
 
+        internal static void EnableSystemRestore()
+        {
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\SystemRestore", "DisableConfig", "00000000", RegistryValueKind.DWord);
+
+            Utilities.StartService("VSS");
+        }
+
         internal static void DisableDefender()
         {
             Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender", "DisableAntiSpyware", "1", RegistryValueKind.DWord);
@@ -158,71 +288,114 @@ namespace Optimizer
             Utilities.RunCommand("regsvr32 /u /s \"C:\\Program Files\\Windows Defender\\shellext.dll\"");
         }
 
+        internal static void EnableDefender()
+        {
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender", "DisableAntiSpyware", "0", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows Defender\Spynet", "SpyNetReporting", "1", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows Defender\Spynet", "SubmitSamplesConsent", "1", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\MRT", "DontReportInfectionInformation", "0", RegistryValueKind.DWord);
+        }
+
         internal static void DisableErrorReporting()
         {
             Utilities.StopService("WerSvc");
             Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WerSvc", "Start", "4", RegistryValueKind.DWord);
         }
 
-        internal static void DisableTransparency()
+        internal static void EnableErrorReporting()
         {
-            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize", "EnableTransparency", "00000000", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WerSvc", "Start", "2", RegistryValueKind.DWord);
+            Utilities.StartService("WerSvc");
         }
 
+        // not used
+
+        //internal static void DisableTransparency()
+        //{
+        //    Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize", "EnableTransparency", "00000000", RegistryValueKind.DWord);
+        //}
+
+        //internal static void EnableTransparency()
+        //{
+        //    Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize", "EnableTransparency", "00000001", RegistryValueKind.DWord);
+        //}
+
         internal static void EnableDarkTheme()
         {
             Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize", "AppsUseLightTheme", "00000000", RegistryValueKind.DWord);
         }
 
-        internal static void RestoreLegacyVolumeSlider()
+        internal static void EnableLightTheme()
+        {
+            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize", "AppsUseLightTheme", "00000001", RegistryValueKind.DWord);
+        }
+
+        internal static void EnableLegacyVolumeSlider()
         {
             Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\MTCUVC", "EnableMtcUvc", "00000000", RegistryValueKind.DWord);
         }
 
-        internal static void RestoreTaskbarColor()
+        internal static void DisableLegacyVolumeSlider()
         {
-            // enable title bar color
-            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\DWM", "ColorPrevalence", "00000001", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\MTCUVC", "EnableMtcUvc", "00000001", RegistryValueKind.DWord);
+        }
 
-            // disable task bar, start menu and action center color
+        internal static void EnableTaskbarColor()
+        {
+            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\DWM", "ColorPrevalence", "00000001", RegistryValueKind.DWord);
             Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize", "ColorPrevalence", "00000000", RegistryValueKind.DWord);
         }
 
+        internal static void DisableTaskbarColor()
+        {
+            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\DWM", "ColorPrevalence", "00000000", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize", "ColorPrevalence", "00000001", RegistryValueKind.DWord);
+        }
+
         internal static void UninstallOneDrive()
         {
-            Utilities.RunBatchFile(Required.RequiredFolder + "\\OneDrive_Uninstaller.cmd");
+            Utilities.RunBatchFile(Required.ScriptsFolder + "OneDrive_Uninstaller.cmd");
             Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\OneDrive", "DisableFileSyncNGSC", "1", RegistryValueKind.DWord);
         }
 
+        internal static void InstallOneDrive()
+        {
+            try
+            {
+                Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\OneDrive", "DisableFileSyncNGSC", "0", RegistryValueKind.DWord);
+
+                string oneDriveInstaller;
+                if (Environment.Is64BitOperatingSystem)
+                {
+                    oneDriveInstaller = Path.Combine(Path.GetPathRoot(Environment.SystemDirectory), "Windows\\SysWOW64\\OneDriveSetup.exe");
+                }
+                else
+                {
+                    oneDriveInstaller = Path.Combine(Path.GetPathRoot(Environment.SystemDirectory), "Windows\\System32\\OneDriveSetup.exe");
+                }
+                Process.Start(oneDriveInstaller);
+            }
+            catch { }
+        }
+
         internal static void DisableCortana()
         {
             Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Windows Search", "AllowCortana", "0", RegistryValueKind.DWord);
             Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Windows Search", "DisableWebSearch", "1", RegistryValueKind.DWord);
             Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Windows Search", "ConnectedSearchUseWeb", "0", RegistryValueKind.DWord);
-        }
 
-        internal static void DisableDataTelemetry()
-        {
-            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\DataCollection", "AllowTelemetry", "0", RegistryValueKind.DWord);
-            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\WMI\AutoLogger\AutoLogger-Diagtrack-Listener", "Start", "0", RegistryValueKind.DWord);
-            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\WMI\AutoLogger\AutoLogger-Diagtrack-Listener", "Start", "0", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Search", "HistoryViewEnabled", "0", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Search", "DeviceHistoryEnabled", "0", RegistryValueKind.DWord);
         }
 
-        internal static void DisableDiagnosticsTracking()
+        internal static void EnableCortana()
         {
-            Utilities.StopService("DiagTrack");
-            Utilities.StopService("diagnosticshub.standardcollector.service");
-            Utilities.StopService("dmwappushservice");
-
-            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DiagTrack", "Start", "4", RegistryValueKind.DWord);
-            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\diagnosticshub.standardcollector.service", "Start", "4", RegistryValueKind.DWord);
-            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\dmwappushservice", "Start", "4", RegistryValueKind.DWord);
-        }
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Windows Search", "AllowCortana", "1", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Windows Search", "DisableWebSearch", "0", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Windows Search", "ConnectedSearchUseWeb", "1", RegistryValueKind.DWord);
 
-        internal static void DisableWAPPush()
-        {
-            Utilities.StopService("dmwappushservice");
-            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\dmwappushservice", "Start", "4", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Search", "HistoryViewEnabled", "1", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Search", "DeviceHistoryEnabled", "1", RegistryValueKind.DWord);
         }
 
         internal static void DisableXboxLive()
@@ -239,7 +412,27 @@ namespace Optimizer
             Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\XboxGipSvc", "Start", "4", RegistryValueKind.DWord);
             Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\xbgm", "Start", "4", RegistryValueKind.DWord);
 
-            Utilities.RunBatchFile(Required.RequiredFolder + "\\DisableXboxTasks.bat");
+            Utilities.RunBatchFile(Required.ScriptsFolder + "DisableXboxTasks.bat");
+        }
+
+        internal static void EnableXboxLive()
+        {
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\XboxNetApiSvc", "Start", "2", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\XblAuthManager", "Start", "2", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\XblGameSave", "Start", "2", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\XboxGipSvc", "Start", "2", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\xbgm", "Start", "2", RegistryValueKind.DWord);
+
+            try
+            {
+                if (!File.Exists(Required.ScriptsFolder + "EnableXboxTasks.bat"))
+                {
+                    File.WriteAllText(Required.ScriptsFolder + "EnableXboxTasks.bat", Properties.Resources.EnableXboxTasks);
+                }
+            }
+            catch { }
+
+            Utilities.RunBatchFile(Required.ScriptsFolder + "EnableXboxTasks.bat");
         }
 
         internal static void DisableAutomaticUpdates()
@@ -249,37 +442,48 @@ namespace Optimizer
             Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config", "DODownloadMode", "0", RegistryValueKind.DWord);
         }
 
-        internal static void RemoveWindows10Icon()
+        internal static void EnableAutomaticUpdates()
         {
-            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\GWX", "DisableGWX", "00000001", RegistryValueKind.DWord);
-            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate", "DisableOSUpgrade", "00000001", RegistryValueKind.DWord);
-            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\OSUpgrade", "AllowOSUpgrade", "00000000", RegistryValueKind.DWord);
-            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\OSUpgrade", "ReservationsAllowed", "00000000", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU", "AUOptions", "5", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU", "NoAutoRebootWithLoggedOnUsers", "0", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config", "DODownloadMode", "1", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU", "NoAutoUpdate", "0", RegistryValueKind.DWord);
         }
 
+        // no longer useful
+
+        //internal static void RemoveWindows10Icon()
+        //{
+        //    Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\GWX", "DisableGWX", "00000001", RegistryValueKind.DWord);
+        //    Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate", "DisableOSUpgrade", "00000001", RegistryValueKind.DWord);
+        //    Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\OSUpgrade", "AllowOSUpgrade", "00000000", RegistryValueKind.DWord);
+        //    Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\OSUpgrade", "ReservationsAllowed", "00000000", RegistryValueKind.DWord);
+        //}
+
         internal static void DisableOneDrive()
         {
             Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\OneDrive", "DisableFileSyncNGSC", "1", RegistryValueKind.DWord);
         }
 
+        internal static void EnableOneDrive()
+        {
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\OneDrive", "DisableFileSyncNGSC", "0", RegistryValueKind.DWord);
+        }
+
         internal static void EnableSensorServices()
         {
-            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DcpSvc", "Start", "2", RegistryValueKind.DWord);
             Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SensrSvc", "Start", "2", RegistryValueKind.DWord);
             Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SensorService", "Start", "2", RegistryValueKind.DWord);
 
-            Utilities.StartService("DcpSvc");
             Utilities.StartService("SensrSvc");
             Utilities.StartService("SensorService");
         }
 
         internal static void DisableSensorServices()
         {
-            Utilities.StopService("DcpSvc");
             Utilities.StopService("SensrSvc");
             Utilities.StopService("SensorService");
-
-            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DcpSvc", "Start", "4", RegistryValueKind.DWord);
+            
             Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SensrSvc", "Start", "4", RegistryValueKind.DWord);
             Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SensorService", "Start", "4", RegistryValueKind.DWord);
         }
@@ -287,13 +491,49 @@ namespace Optimizer
         internal static void DisableTelemetryTasks()
         {
             DisableTelemetryRunner();
-            Utilities.RunBatchFile(Required.RequiredFolder + "\\DisableTelemetryTasks.bat");
+            Utilities.RunBatchFile(Required.ScriptsFolder + "DisableTelemetryTasks.bat");
+        }
+
+        internal static void EnableTelemetryTasks()
+        {
+            EnableTelemetryRunner();
+
+            try
+            {
+                if (!File.Exists(Required.ScriptsFolder + "EnableTelemetryTasks.bat"))
+                {
+                    File.WriteAllText(Required.ScriptsFolder + "EnableTelemetryTasks.bat", Properties.Resources.EnableTelemetryTasks);
+                }
+            }
+            catch { }
+
+            Utilities.RunBatchFile(Required.ScriptsFolder + "EnableTelemetryTasks.bat");
+        }
+
+        internal static void DisableOffice2016Telemetry()
+        {
+            Utilities.RunBatchFile(Required.ScriptsFolder + "DisableOfficeTelemetryTasks.bat");
+            Utilities.ImportRegistryScript(Required.ScriptsFolder + "DisableOfficeTelemetryTasks.reg");
         }
 
-        internal static void DisableOfficeTelemetryTasks()
+        internal static void EnableOffice2016Telemetry()
         {
-            Utilities.RunBatchFile(Required.RequiredFolder + "\\DisableOfficeTelemetryTasks.bat");
-            Utilities.ImportRegistryScript(Required.RequiredFolder + "\\DisableOfficeTelemetryTasks.reg");
+            try
+            {
+                if (!File.Exists(Required.ScriptsFolder + "EnableOfficeTelemetryTasks.reg"))
+                {
+                    File.WriteAllText(Required.ScriptsFolder + "EnableOfficeTelemetryTasks.reg", Properties.Resources.EnableOfficeTelemetry);
+                }
+
+                if (!File.Exists(Required.ScriptsFolder + "EnableOfficeTelemetryTasks.bat"))
+                {
+                    File.WriteAllText(Required.ScriptsFolder + "EnableOfficeTelemetryTasks.bat", Properties.Resources.EnableOfficeTelemetryTasks);
+                }
+            }
+            catch { }
+
+            Utilities.RunBatchFile(Required.ScriptsFolder + "EnableOfficeTelemetryTasks.bat");
+            Utilities.ImportRegistryScript(Required.ScriptsFolder + "EnableOfficeTelemetryTasks.reg");
         }
 
         internal static void DisablePrivacyOptions()
@@ -356,12 +596,14 @@ namespace Optimizer
 
             // Other devices
             Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy", "LetAppsSyncWithDevices", "2", RegistryValueKind.DWord);
-            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\LooselyCoupled", "Value", "0", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\LooselyCoupled", "Value", "Deny", RegistryValueKind.String);
 
             // Feedback & diagnostics
             Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Siuf\Rules", "PeriodInNanoSeconds", "0", RegistryValueKind.DWord);
             Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Siuf\Rules", "NumberOfSIUFInPeriod", "0", RegistryValueKind.DWord);
             Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\DataCollection", "AllowTelemetry", "0", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\WMI\AutoLogger\AutoLogger-Diagtrack-Listener", "Start", "0", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\WMI\AutoLogger\AutoLogger-Diagtrack-Listener", "Start", "0", RegistryValueKind.DWord);
 
             // App diagnostics
             Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{2297E4E2-5DBE-466D-A12B-0F8286F0D9CA}", "Value", "Deny", RegistryValueKind.String);
@@ -371,6 +613,7 @@ namespace Optimizer
 
             // Hotspot 2.0
             Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WcmSvc\Tethering", "Hotspot2SignUp", "1", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WlanSvc\AnqpCache", "OsuRegistrationStatus", "0", RegistryValueKind.DWord);
 
             // Mobile Hotspot remote startup
             Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WcmSvc\Tethering", "RemoteStartupDisabled", "1", RegistryValueKind.DWord);
@@ -379,31 +622,141 @@ namespace Optimizer
             Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Connect", "AllowProjectionToPC", "0", RegistryValueKind.DWord);
         }
 
+        internal static void EnablePrivacyOptions()
+        {
+            // Turn off KMS Client Online AVS Validation
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows NT\CurrentVersion\Software Protection Platform", "NoGenTicket", "0", RegistryValueKind.DWord);
+
+            // General
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo", "Enabled", "1", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\AppHost\EnableWebContentEvaluation", "Enabled", "1", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_CURRENT_USER\Control Panel\International\User Profile", "HttpAcceptLanguageOptOut", "0", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SmartGlass", "UserAuthPolicy", "1", RegistryValueKind.DWord);
+
+            // Location
+            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{E6AD100E-5F4E-44CD-BE0F-2265D88D14F5}", "Value", "Allow", RegistryValueKind.String);
+            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{BFA794E4-F964-4FDB-90F6-51056BFE4B44}", "Value", "Allow", RegistryValueKind.String);
+            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Sensor\Permissions\{BFA794E4-F964-4FDB-90F6-51056BFE4B44}", "SensorPermissionState", "1", RegistryValueKind.DWord);
+
+            // Camera
+            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{E5323777-F976-4f5b-9B55-B94699C46E44}", "Value", "Allow", RegistryValueKind.String);
+
+            // Microphone
+            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{2EEF81BE-33FA-4800-9670-1CD474972C3F}", "Value", "Allow", RegistryValueKind.String);
+
+            // Notifications
+            Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{52079E78-A92B-413F-B213-E8FE35712E72}", "Value", "Allow", RegistryValueKind.String);
+
+            // Speech, inking & typing
+            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Personalization\Settings", "AcceptedPrivacyPolicy", "1", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\SettingSync\Groups\Language", "Enabled", "1", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\InputPersonalization", "RestrictImplicitTextCollection", "0", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\InputPersonalization", "RestrictImplicitInkCollection", "0", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore", "HarvestContacts", "1", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Input\TIPC", "Enabled", "1", RegistryValueKind.DWord);
+
+            // Account info
+            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{C1D23ACC-752B-43E5-8448-8D0E519CD6D6}", "Value", "Allow", RegistryValueKind.String);
+
+            // Contacts
+            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{7D7E8402-7C54-4821-A34E-AEEFD62DED93}", "Value", "Allow", RegistryValueKind.String);
+
+            // Calendar
+            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{D89823BA-7180-4B81-B50C-7E471E6121A3}", "Value", "Allow", RegistryValueKind.String);
+
+            // Call history
+            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{8BC668CF-7728-45BD-93F8-CF2B3B41D7AB}", "Value", "Allow", RegistryValueKind.String);
+
+            // Email
+            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{9231CB4C-BF57-4AF3-8C55-FDA7BFCC04C5}", "Value", "Allow", RegistryValueKind.String);
+
+            // Tasks
+            Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{E390DF20-07DF-446D-B962-F5C953062741}", "Value", "Allow", RegistryValueKind.String);
+
+            // Messaging
+            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{21157C1F-2651-4CC1-90CA-1F28B02263F6}", "Value", "Allow", RegistryValueKind.String);
+            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{992AFA70-6F47-4148-B3E9-3003349C1548}", "Value", "Allow", RegistryValueKind.String);
+
+            // Radios
+            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{A8804298-2D5F-42E3-9531-9C8C39EB29CE}", "Value", "Allow", RegistryValueKind.String);
+
+            // Other devices
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy", "LetAppsSyncWithDevices", "0", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\LooselyCoupled", "Value", "Allow", RegistryValueKind.String);
+
+            // Feedback & diagnostics
+            try
+            {
+                Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Siuf\Rules", true).DeleteValue("PeriodInNanoSeconds", false);
+                Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Siuf\Rules", true).DeleteValue("NumberOfSIUFInPeriod", false);
+            }
+            catch { }
+
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\DataCollection", "AllowTelemetry", "1", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\WMI\AutoLogger\AutoLogger-Diagtrack-Listener", "Start", "1", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\WMI\AutoLogger\AutoLogger-Diagtrack-Listener", "Start", "1", RegistryValueKind.DWord);
+
+            // App diagnostics
+            Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{2297E4E2-5DBE-466D-A12B-0F8286F0D9CA}", "Value", "Allow", RegistryValueKind.String);
+
+            // Wi-Fi Sense
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\config", "AutoConnectAllowedOEM", "1", RegistryValueKind.DWord);
+
+            // Hotspot 2.0
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WcmSvc\Tethering", "Hotspot2SignUp", "0", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WlanSvc\AnqpCache", "OsuRegistrationStatus", "1", RegistryValueKind.DWord);
+
+            // Mobile Hotspot remote startup
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WcmSvc\Tethering", "RemoteStartupDisabled", "0", RegistryValueKind.DWord);
+
+            // Projecting to this PC
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Connect", "AllowProjectionToPC", "1", RegistryValueKind.DWord);
+        }
+
         internal static void DisableGameBar()
         {
             Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\GameDVR", "AppCaptureEnabled", "0", RegistryValueKind.DWord);
             Registry.SetValue(@"HKEY_CURRENT_USER\System\GameConfigStore", "GameDVR_Enabled", "0", RegistryValueKind.DWord);
         }
 
-        internal static void DisableQuickAccess()
+        internal static void EnableGameBar()
+        {
+            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\GameDVR", "AppCaptureEnabled", "1", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_CURRENT_USER\System\GameConfigStore", "GameDVR_Enabled", "1", RegistryValueKind.DWord);
+        }
+
+        internal static void DisableQuickAccessHistory()
         {
-            // Hide Sync Provider ads
             Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "ShowSyncProviderNotifications", "0", RegistryValueKind.DWord);
 
-            // Disable Quick Access history
             using (RegistryKey k = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Explorer", true))
             {
                 k.SetValue("ShowFrequent", 0, RegistryValueKind.DWord);
                 k.SetValue("ShowRecent", 0, RegistryValueKind.DWord);
             }
 
-            // File Explorer opens 'This PC' by default
             using (RegistryKey k = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", true))
             {
                 k.SetValue("LaunchTo", 1, RegistryValueKind.DWord);
             }
         }
 
+        internal static void EnableQuickAccessHistory()
+        {
+            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "ShowSyncProviderNotifications", "1", RegistryValueKind.DWord);
+
+            using (RegistryKey k = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Explorer", true))
+            {
+                k.SetValue("ShowFrequent", 1, RegistryValueKind.DWord);
+                k.SetValue("ShowRecent", 1, RegistryValueKind.DWord);
+            }
+
+            using (RegistryKey k = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", true))
+            {
+                k.SetValue("LaunchTo", 2, RegistryValueKind.DWord);
+            }
+        }
+
         internal static void DisableStartMenuAds()
         {
             Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager", "SystemPaneSuggestionsEnabled", "0", RegistryValueKind.DWord);
@@ -417,6 +770,19 @@ namespace Optimizer
             Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager", "FeatureManagementEnabled", "0", RegistryValueKind.DWord);
         }
 
+        internal static void EnableStartMenuAds()
+        {
+            Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager", "SystemPaneSuggestionsEnabled", "1", RegistryValueKind.DWord);
+
+            Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager", "SubscribedContent-338388Enabled", "1", RegistryValueKind.DWord);
+
+            Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager", "SubscribedContentEnabled", "1", RegistryValueKind.DWord);
+
+            Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager", "SoftLandingEnabled", "1", RegistryValueKind.DWord);
+
+            Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager", "FeatureManagementEnabled", "1", RegistryValueKind.DWord);
+        }
+
         internal static void DisableSilentAppInstall()
         {
             Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager", "SilentInstalledAppsEnabled", "0", RegistryValueKind.DWord);
@@ -426,22 +792,47 @@ namespace Optimizer
             Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager", "OemPreInstalledAppsEnabled", "0", RegistryValueKind.DWord);
         }
 
+        internal static void EnableSilentAppInstall()
+        {
+            Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager", "SilentInstalledAppsEnabled", "1", RegistryValueKind.DWord);
+
+            Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager", "PreInstalledAppsEnabled", "1", RegistryValueKind.DWord);
+
+            Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager", "OemPreInstalledAppsEnabled", "1", RegistryValueKind.DWord);
+        }
+
         internal static void DisableMyPeople()
         {
             Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People", "PeopleBand", "0", RegistryValueKind.DWord);
         }
 
+        internal static void EnableMyPeople()
+        {
+            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People", "PeopleBand", "1", RegistryValueKind.DWord);
+        }
+
         internal static void ExcludeDrivers()
         {
             Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate", "ExcludeWUDriversInQualityUpdate", "1", RegistryValueKind.DWord);
         }
 
+        internal static void IncludeDrivers()
+        {
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate", "ExcludeWUDriversInQualityUpdate", "0", RegistryValueKind.DWord);
+        }
+
         internal static void DisableWindowsInk()
         {
             Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\WindowsInkWorkspace", "AllowWindowsInkWorkspace", "0", RegistryValueKind.DWord);
             Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\WindowsInkWorkspace", "AllowSuggestedAppsInWindowsInkWorkspace", "0", RegistryValueKind.DWord);
         }
 
+        internal static void EnableWindowsInk()
+        {
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\WindowsInkWorkspace", "AllowWindowsInkWorkspace", "1", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\WindowsInkWorkspace", "AllowSuggestedAppsInWindowsInkWorkspace", "1", RegistryValueKind.DWord);
+        }
+
         internal static void DisableSpellingAndTypingFeatures()
         {
             // Spelling
@@ -454,5 +845,18 @@ namespace Optimizer
             Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\TabletTip\1.7", "EnablePredictionSpaceInsertion", "0", RegistryValueKind.DWord);
             Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\TabletTip\1.7", "EnableTextPrediction", "0", RegistryValueKind.DWord);
         }
+
+        internal static void EnableSpellingAndTypingFeatures()
+        {
+            // Spelling
+            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\TabletTip\1.7", "EnableAutocorrection", "1", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\TabletTip\1.7", "EnableSpellchecking", "1", RegistryValueKind.DWord);
+
+            // Typing
+            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\TabletTip\1.7", "EnableDoubleTapSpace", "1", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\TabletTip\1.7", "EnableInkingWithTouch", "1", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\TabletTip\1.7", "EnablePredictionSpaceInsertion", "1", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\TabletTip\1.7", "EnableTextPrediction", "1", RegistryValueKind.DWord);
+        }
     }
 }

+ 0 - 96
Optimizer/OptimizeForm.Designer.cs

@@ -1,96 +0,0 @@
-namespace Optimizer
-{
-    partial class OptimizeForm
-    {
-        /// <summary>
-        /// Required designer variable.
-        /// </summary>
-        private System.ComponentModel.IContainer components = null;
-
-        /// <summary>
-        /// Clean up any resources being used.
-        /// </summary>
-        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
-        protected override void Dispose(bool disposing)
-        {
-            if (disposing && (components != null))
-            {
-                components.Dispose();
-            }
-            base.Dispose(disposing);
-        }
-
-        #region Windows Form Designer generated code
-
-        /// <summary>
-        /// Required method for Designer support - do not modify
-        /// the contents of this method with the code editor.
-        /// </summary>
-        private void InitializeComponent()
-        {
-            this.components = new System.ComponentModel.Container();
-            this.label1 = new System.Windows.Forms.Label();
-            this.label2 = new System.Windows.Forms.Label();
-            this.dotTimer = new System.Windows.Forms.Timer(this.components);
-            this.SuspendLayout();
-            // 
-            // label1
-            // 
-            this.label1.AutoSize = true;
-            this.label1.Font = new System.Drawing.Font("Segoe UI Semibold", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(161)));
-            this.label1.ForeColor = System.Drawing.Color.White;
-            this.label1.Location = new System.Drawing.Point(39, 18);
-            this.label1.Name = "label1";
-            this.label1.Size = new System.Drawing.Size(259, 35);
-            this.label1.TabIndex = 0;
-            this.label1.Tag = "themeable";
-            this.label1.Text = "Applying, please wait";
-            // 
-            // label2
-            // 
-            this.label2.AutoSize = true;
-            this.label2.Font = new System.Drawing.Font("Segoe UI Semibold", 19F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(161)));
-            this.label2.ForeColor = System.Drawing.Color.White;
-            this.label2.Location = new System.Drawing.Point(147, 53);
-            this.label2.Name = "label2";
-            this.label2.Size = new System.Drawing.Size(44, 45);
-            this.label2.TabIndex = 1;
-            this.label2.Text = "...";
-            // 
-            // dotTimer
-            // 
-            this.dotTimer.Interval = 500;
-            this.dotTimer.Tick += new System.EventHandler(this.dotTimer_Tick);
-            // 
-            // OptimizeForm
-            // 
-            this.AutoScaleDimensions = new System.Drawing.SizeF(120F, 120F);
-            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
-            this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20)))));
-            this.ClientSize = new System.Drawing.Size(336, 111);
-            this.ControlBox = false;
-            this.Controls.Add(this.label2);
-            this.Controls.Add(this.label1);
-            this.Font = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(161)));
-            this.ForeColor = System.Drawing.Color.White;
-            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
-            this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
-            this.MaximizeBox = false;
-            this.MinimizeBox = false;
-            this.Name = "OptimizeForm";
-            this.ShowIcon = false;
-            this.ShowInTaskbar = false;
-            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
-            this.Load += new System.EventHandler(this.Helper_Load);
-            this.ResumeLayout(false);
-            this.PerformLayout();
-
-        }
-
-        #endregion
-
-        private System.Windows.Forms.Label label1;
-        private System.Windows.Forms.Label label2;
-        private System.Windows.Forms.Timer dotTimer;
-    }
-}

+ 0 - 146
Optimizer/OptimizeForm.cs

@@ -1,146 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-
-namespace Optimizer
-{
-    public partial class OptimizeForm : Form
-    {
-        bool _disablePrintServices = false;
-        bool _disableSensorServices = false;
-
-        public OptimizeForm(bool disablePrintServices, bool disableSensorServices)
-        {
-            InitializeComponent();
-
-            _disablePrintServices = disablePrintServices;
-            _disableSensorServices = disableSensorServices;
-        }
-
-        private void ApplyAll()
-        {
-            if (Utilities.CurrentWindowsVersion != WindowsVersion.Unsupported)
-            {
-                try
-                {
-                    // universal
-                    Optimize.PerformanceTweaks();
-                    Optimize.DisableNetworkThrottling();
-                    Optimize.DisableDefender();
-                    Optimize.DisableSystemRestore();
-
-                    if (_disablePrintServices)
-                    {
-                        Optimize.DisablePrintSpooler();
-                    }
-                    else
-                    {
-                        Optimize.EnablePrintSpooler();
-                    }
-
-                    Optimize.DisableMediaPlayerSharing();
-                    Optimize.BlockSkypeAds();
-                    Optimize.DisableErrorReporting();
-                    Optimize.DisableHomeGroup();
-                    Optimize.DisableSuperfetch();
-                    Optimize.DisableTelemetryTasks();
-                    Optimize.DisableOfficeTelemetryTasks();
-
-                    // Windows-specific
-
-                    // Windows 7
-                    if ((Utilities.CurrentWindowsVersion == WindowsVersion.Windows7))
-                    {
-                        Optimize.RemoveWindows10Icon();
-                    }
-
-                    // Windows 8 / 8.1
-                    if ((Utilities.CurrentWindowsVersion == WindowsVersion.Windows8))
-                    {
-                        Optimize.RemoveWindows10Icon();
-                        Optimize.DisableOneDrive();
-                    }
-
-                    // Windows 10
-                    if ((Utilities.CurrentWindowsVersion == WindowsVersion.Windows10))
-                    {
-                        Optimize.RestoreLegacyVolumeSlider();
-                        Optimize.DisableCortana();
-                        Optimize.DisableXboxLive();
-                        Optimize.DisableAutomaticUpdates();
-                        Optimize.DisableDiagnosticsTracking();
-                        Optimize.DisableWAPPush();
-                        Optimize.DisableDataTelemetry();
-
-                        if (_disableSensorServices)
-                        {
-                            Optimize.DisableSensorServices();
-                        }
-                        else
-                        {
-                            Optimize.EnableSensorServices();
-                        }
-
-                        Optimize.UninstallOneDrive();
-                        Optimize.DisablePrivacyOptions();
-                        Optimize.DisableGameBar();
-                        Optimize.DisableQuickAccess();
-                        Optimize.DisableStartMenuAds();
-                        Optimize.DisableSilentAppInstall();
-                        Optimize.DisableMyPeople();
-                        Optimize.ExcludeDrivers();
-                        Optimize.DisableWindowsInk();
-                        Optimize.DisableSpellingAndTypingFeatures();
-                        Optimize.RestoreTaskbarColor();
-                    }
-                }
-                catch //(Exception error)
-                {
-                    //MessageBox.Show(error.Message);
-                }
-                finally
-                {
-                    this.Close();
-                }
-            }
-
-            this.Close();
-        }
-
-        private void Helper_Load(object sender, EventArgs e)
-        {
-            CheckForIllegalCrossThreadCalls = false;
-            Options.ApplyTheme(this);
-
-            dotTimer.Start();
-
-            Task t = new Task(() => ApplyAll());
-            t.Start();
-        }
-
-        private void dotTimer_Tick(object sender, EventArgs e)
-        {
-            switch (label2.Text)
-            {
-                case "":
-                    label2.Text = ".";
-                    break;
-                case ".":
-                    label2.Text = "..";
-                    break;
-                case "..":
-                    label2.Text = "...";
-                    break;
-                case "...":
-                    label2.Text = "";
-                    break;
-            }
-        }
-    }
-}

+ 0 - 123
Optimizer/OptimizeForm.resx

@@ -1,123 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<root>
-  <!-- 
-    Microsoft ResX Schema 
-    
-    Version 2.0
-    
-    The primary goals of this format is to allow a simple XML format 
-    that is mostly human readable. The generation and parsing of the 
-    various data types are done through the TypeConverter classes 
-    associated with the data types.
-    
-    Example:
-    
-    ... ado.net/XML headers & schema ...
-    <resheader name="resmimetype">text/microsoft-resx</resheader>
-    <resheader name="version">2.0</resheader>
-    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
-    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
-    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
-    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
-    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
-        <value>[base64 mime encoded serialized .NET Framework object]</value>
-    </data>
-    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
-        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
-        <comment>This is a comment</comment>
-    </data>
-                
-    There are any number of "resheader" rows that contain simple 
-    name/value pairs.
-    
-    Each data row contains a name, and value. The row also contains a 
-    type or mimetype. Type corresponds to a .NET class that support 
-    text/value conversion through the TypeConverter architecture. 
-    Classes that don't support this are serialized and stored with the 
-    mimetype set.
-    
-    The mimetype is used for serialized objects, and tells the 
-    ResXResourceReader how to depersist the object. This is currently not 
-    extensible. For a given mimetype the value must be set accordingly:
-    
-    Note - application/x-microsoft.net.object.binary.base64 is the format 
-    that the ResXResourceWriter will generate, however the reader can 
-    read any of the formats listed below.
-    
-    mimetype: application/x-microsoft.net.object.binary.base64
-    value   : The object must be serialized with 
-            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
-            : and then encoded with base64 encoding.
-    
-    mimetype: application/x-microsoft.net.object.soap.base64
-    value   : The object must be serialized with 
-            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
-            : and then encoded with base64 encoding.
-
-    mimetype: application/x-microsoft.net.object.bytearray.base64
-    value   : The object must be serialized into a byte array 
-            : using a System.ComponentModel.TypeConverter
-            : and then encoded with base64 encoding.
-    -->
-  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
-    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
-    <xsd:element name="root" msdata:IsDataSet="true">
-      <xsd:complexType>
-        <xsd:choice maxOccurs="unbounded">
-          <xsd:element name="metadata">
-            <xsd:complexType>
-              <xsd:sequence>
-                <xsd:element name="value" type="xsd:string" minOccurs="0" />
-              </xsd:sequence>
-              <xsd:attribute name="name" use="required" type="xsd:string" />
-              <xsd:attribute name="type" type="xsd:string" />
-              <xsd:attribute name="mimetype" type="xsd:string" />
-              <xsd:attribute ref="xml:space" />
-            </xsd:complexType>
-          </xsd:element>
-          <xsd:element name="assembly">
-            <xsd:complexType>
-              <xsd:attribute name="alias" type="xsd:string" />
-              <xsd:attribute name="name" type="xsd:string" />
-            </xsd:complexType>
-          </xsd:element>
-          <xsd:element name="data">
-            <xsd:complexType>
-              <xsd:sequence>
-                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
-                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
-              </xsd:sequence>
-              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
-              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
-              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
-              <xsd:attribute ref="xml:space" />
-            </xsd:complexType>
-          </xsd:element>
-          <xsd:element name="resheader">
-            <xsd:complexType>
-              <xsd:sequence>
-                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
-              </xsd:sequence>
-              <xsd:attribute name="name" type="xsd:string" use="required" />
-            </xsd:complexType>
-          </xsd:element>
-        </xsd:choice>
-      </xsd:complexType>
-    </xsd:element>
-  </xsd:schema>
-  <resheader name="resmimetype">
-    <value>text/microsoft-resx</value>
-  </resheader>
-  <resheader name="version">
-    <value>2.0</value>
-  </resheader>
-  <resheader name="reader">
-    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
-  </resheader>
-  <resheader name="writer">
-    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
-  </resheader>
-  <metadata name="dotTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>17, 17</value>
-  </metadata>
-</root>

+ 10 - 9
Optimizer/Optimizer.csproj

@@ -107,12 +107,6 @@
     </Compile>
     <Compile Include="Integrator.cs" />
     <Compile Include="ListViewColumnSorter.cs" />
-    <Compile Include="OptimizeForm.cs">
-      <SubType>Form</SubType>
-    </Compile>
-    <Compile Include="OptimizeForm.Designer.cs">
-      <DependentUpon>OptimizeForm.cs</DependentUpon>
-    </Compile>
     <Compile Include="MainForm.cs">
       <SubType>Form</SubType>
     </Compile>
@@ -131,6 +125,12 @@
     </Compile>
     <Compile Include="Required.cs" />
     <Compile Include="StartupItem.cs" />
+    <Compile Include="ToggleSwitch\ImageHelper.cs" />
+    <Compile Include="ToggleSwitch\ToggleSwitch.cs">
+      <SubType>Component</SubType>
+    </Compile>
+    <Compile Include="ToggleSwitch\ToggleSwitchRenderer.cs" />
+    <Compile Include="ToggleSwitch\ToggleSwitchRendererBase.cs" />
     <Compile Include="Utilities.cs" />
     <EmbeddedResource Include="AboutForm.resx">
       <DependentUpon>AboutForm.cs</DependentUpon>
@@ -144,9 +144,6 @@
     <EmbeddedResource Include="InfoForm.resx">
       <DependentUpon>InfoForm.cs</DependentUpon>
     </EmbeddedResource>
-    <EmbeddedResource Include="OptimizeForm.resx">
-      <DependentUpon>OptimizeForm.cs</DependentUpon>
-    </EmbeddedResource>
     <EmbeddedResource Include="MainForm.resx">
       <DependentUpon>MainForm.cs</DependentUpon>
     </EmbeddedResource>
@@ -177,6 +174,10 @@
     </Compile>
     <None Include="Resources\DesktopShortcuts.reg" />
     <None Include="Resources\DisableOfficeTelemetry.reg" />
+    <None Include="Resources\EnableOfficeTelemetry.reg" />
+    <None Include="Resources\EnableOfficeTelemetryTasks.bat" />
+    <None Include="Resources\EnableTelemetryTasks.bat" />
+    <None Include="Resources\EnableXboxTasks.bat" />
     <None Include="Resources\hosts" />
     <None Include="Resources\InstallTakeOwnership.reg" />
     <None Include="Resources\PowerMenu.reg" />

+ 84 - 17
Optimizer/Options.cs

@@ -13,6 +13,40 @@ namespace Optimizer
     public class SettingsJson
     {
         public Theme Color { get; set; }
+
+        public bool EnablePerformanceTweaks { get; set; }
+        public bool DisableNetworkThrottling { get; set; }
+        public bool DisableWindowsDefender { get; set; }
+        public bool DisableSystemRestore { get; set; }
+        public bool DisablePrintService { get; set; }
+        public bool DisableMediaPlayerSharing { get; set; }
+        public bool BlockSkypeAds { get; set; }
+        public bool DisableErrorReporting { get; set; }
+        public bool DisableHomeGroup { get; set; }
+        public bool DisableSuperfetch { get; set; }
+        public bool DisableTelemetryTasks { get; set; }
+        public bool DisableOffice2016Telemetry { get; set; }
+
+        public bool EnableLegacyVolumeSlider { get; set; }
+        public bool EnableTaskbarColor { get; set; }
+        public bool DisableQuickAccessHistory { get; set; }
+        public bool DisableStartMenuAds { get; set; }
+        public bool EnableDarkTheme { get; set; }
+        public bool UninstallOneDrive { get; set; }
+        public bool DisableMyPeople { get; set; }
+        public bool DisableAutomaticUpdates { get; set; }
+        public bool ExcludeDrivers { get; set; }
+        public bool DisableTelemetryServices { get; set; }
+        public bool DisablePrivacyOptions { get; set; }
+        public bool DisableSilentAppInstall { get; set; }
+        public bool DisableCortana { get; set; }
+        public bool DisableSensorServices { get; set; }
+        public bool DisableWindowsInk { get; set; }
+        public bool DisableSpellingTyping { get; set; }
+        public bool DisableXboxLive { get; set; }
+        public bool DisableGameBar { get; set; }
+
+        public bool DisableOneDrive { get; set; }
     }
 
     internal static class Options
@@ -22,9 +56,6 @@ namespace Optimizer
 
         internal static SettingsJson CurrentOptions = new SettingsJson();
 
-        // use this to determine if changes have been made
-        static SettingsJson _flag = new SettingsJson();
-
         internal static void ApplyTheme(Form f)
         {
             switch (CurrentOptions.Color)
@@ -57,6 +88,13 @@ namespace Optimizer
             Utilities.GetSelfAndChildrenRecursive(f).OfType<Button>().ToList().ForEach(b => b.FlatAppearance.MouseDownBackColor = c2);
             Utilities.GetSelfAndChildrenRecursive(f).OfType<Button>().ToList().ForEach(b => b.FlatAppearance.MouseOverBackColor = c2);
 
+            foreach (ToggleSwitch tmp in Utilities.GetSelfAndChildrenRecursive(f).OfType<ToggleSwitch>().ToList())
+            {
+                if ((string)tmp.Tag == _themeFlag)
+                {
+                    tmp.SetRenderer(new ToggleSwitchRenderer());
+                }
+            }
             foreach (Label tmp in Utilities.GetSelfAndChildrenRecursive(f).OfType<Label>().ToList())
             {
                 if ((string)tmp.Tag == _themeFlag)
@@ -86,18 +124,16 @@ namespace Optimizer
         {
             if (File.Exists(SettingsFile))
             {
-                // compare with flag to determine if changes have been made
-                if (_flag.Color != CurrentOptions.Color)
+                File.Delete(SettingsFile);
+
+                using (FileStream fs = File.Open(SettingsFile, FileMode.OpenOrCreate))
+                using (StreamWriter sw = new StreamWriter(fs))
+                using (JsonWriter jw = new JsonTextWriter(sw))
                 {
-                    using (FileStream fs = File.Open(SettingsFile, FileMode.OpenOrCreate))
-                    using (StreamWriter sw = new StreamWriter(fs))
-                    using (JsonWriter jw = new JsonTextWriter(sw))
-                    {
-                        jw.Formatting = Formatting.Indented;
-
-                        JsonSerializer serializer = new JsonSerializer();
-                        serializer.Serialize(jw, CurrentOptions);
-                    }
+                    jw.Formatting = Formatting.Indented;
+
+                    JsonSerializer serializer = new JsonSerializer();
+                    serializer.Serialize(jw, CurrentOptions);
                 }
             }
         }
@@ -108,6 +144,40 @@ namespace Optimizer
             {
                 CurrentOptions.Color = Theme.Zerg;
 
+                CurrentOptions.EnablePerformanceTweaks = false;
+                CurrentOptions.DisableNetworkThrottling = false;
+                CurrentOptions.DisableWindowsDefender = false;
+                CurrentOptions.DisableSystemRestore = false;
+                CurrentOptions.DisablePrintService = false;
+                CurrentOptions.DisableMediaPlayerSharing = false;
+                CurrentOptions.BlockSkypeAds = false;
+                CurrentOptions.DisableErrorReporting = false;
+                CurrentOptions.DisableHomeGroup = false;
+                CurrentOptions.DisableSuperfetch = false;
+                CurrentOptions.DisableTelemetryTasks = false;
+                CurrentOptions.DisableOffice2016Telemetry = false;
+
+                CurrentOptions.EnableLegacyVolumeSlider = false;
+                CurrentOptions.EnableTaskbarColor = false;
+                CurrentOptions.DisableQuickAccessHistory = false;
+                CurrentOptions.DisableStartMenuAds = false;
+                CurrentOptions.EnableDarkTheme = false;
+                CurrentOptions.UninstallOneDrive = false;
+                CurrentOptions.DisableMyPeople = false;
+                CurrentOptions.DisableAutomaticUpdates = false;
+                CurrentOptions.ExcludeDrivers = false;
+                CurrentOptions.DisableTelemetryServices = false;
+                CurrentOptions.DisablePrivacyOptions = false;
+                CurrentOptions.DisableSilentAppInstall = false;
+                CurrentOptions.DisableCortana = false;
+                CurrentOptions.DisableSensorServices = false;
+                CurrentOptions.DisableWindowsInk = false;
+                CurrentOptions.DisableSpellingTyping = false;
+                CurrentOptions.DisableXboxLive = false;
+                CurrentOptions.DisableGameBar = false;
+
+                CurrentOptions.DisableOneDrive = false;
+
                 using (FileStream fs = File.Open(SettingsFile, FileMode.CreateNew))
                 using (StreamWriter sw = new StreamWriter(fs))
                 using (JsonWriter jw = new JsonTextWriter(sw))
@@ -121,9 +191,6 @@ namespace Optimizer
             else
             {
                 CurrentOptions = JsonConvert.DeserializeObject<SettingsJson>(File.ReadAllText(SettingsFile));
-
-                // initialize flag
-                _flag.Color = CurrentOptions.Color;
             }
         }
     }

+ 1 - 1
Optimizer/Program.cs

@@ -18,7 +18,7 @@ namespace Optimizer
 
         // Enter current version here
         internal readonly static float Major = 3;
-        internal readonly static float Minor = 6;
+        internal readonly static float Minor = 7;
 
         internal static string GetCurrentVersion()
         {

+ 68 - 4
Optimizer/Properties/Resources.Designer.cs

@@ -19,7 +19,7 @@ namespace Optimizer.Properties {
     // class via a tool like ResGen or Visual Studio.
     // To add or remove a member, edit your .ResX file then rerun ResGen
     // with the /str option, or rebuild your VS project.
-    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
     internal class Resources {
@@ -121,10 +121,10 @@ namespace Optimizer.Properties {
         /// <summary>
         ///   Looks up a localized string similar to schtasks /end /tn &quot;\Microsoft\Windows\Customer Experience Improvement Program\Consolidator&quot;
         ///schtasks /change /tn &quot;\Microsoft\Windows\Customer Experience Improvement Program\Consolidator&quot; /disable
+        ///schtasks /end /tn &quot;\Microsoft\Windows\Customer Experience Improvement Program\BthSQM&quot;
+        ///schtasks /change /tn &quot;\Microsoft\Windows\Customer Experience Improvement Program\BthSQM&quot; /disable
         ///schtasks /end /tn &quot;\Microsoft\Windows\Customer Experience Improvement Program\KernelCeipTask&quot;
-        ///schtasks /change /tn &quot;\Microsoft\Windows\Customer Experience Improvement Program\KernelCeipTask&quot; /disable
-        ///schtasks /end /tn &quot;\Microsoft\Windows\Customer Experience Improvement Program\UsbCeip&quot;
-        ///schtasks /change /tn &quot;\M [rest of string was truncated]&quot;;.
+        ///schtasks /change /tn &quot;\Microsoft\ [rest of string was truncated]&quot;;.
         /// </summary>
         internal static string DisableTelemetryTasks {
             get {
@@ -145,6 +145,70 @@ namespace Optimizer.Properties {
             }
         }
         
+        /// <summary>
+        ///   Looks up a localized string similar to Windows Registry Editor Version 5.00
+        ///
+        ///[HKEY_CURRENT_USER\Software\Policies\microsoft\office\16.0\osm\preventedapplications]
+        ///&quot;accesssolution&quot;=-
+        ///&quot;olksolution&quot;=-
+        ///&quot;onenotesolution&quot;=-
+        ///&quot;pptsolution&quot;=-
+        ///&quot;projectsolution&quot;=-
+        ///&quot;publishersolution&quot;=-
+        ///&quot;visiosolution&quot;=-
+        ///&quot;wdsolution&quot;=-
+        ///&quot;xlsolution&quot;=-
+        /// 
+        ///[HKEY_CURRENT_USER\Software\Policies\microsoft\office\16.0\osm\preventedsolutiontypes]
+        ///&quot;agave&quot;=-
+        ///&quot;appaddins&quot;=-
+        ///&quot;comaddins&quot;=-
+        ///&quot;documentfiles&quot;=-
+        ///&quot;templatefiles&quot;=-
+        ///.
+        /// </summary>
+        internal static string EnableOfficeTelemetry {
+            get {
+                return ResourceManager.GetString("EnableOfficeTelemetry", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to schtasks /change /tn &quot;\Microsoft\Office\OfficeTelemetryAgentFallBack2016&quot; /enable
+        ///schtasks /change /tn &quot;\Microsoft\Office\OfficeTelemetryAgentLogOn2016&quot; /enable
+        ///.
+        /// </summary>
+        internal static string EnableOfficeTelemetryTasks {
+            get {
+                return ResourceManager.GetString("EnableOfficeTelemetryTasks", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to schtasks /change /tn &quot;\Microsoft\Windows\Customer Experience Improvement Program\Consolidator&quot; /enable
+        ///schtasks /change /tn &quot;\Microsoft\Windows\Customer Experience Improvement Program\BthSQM&quot; /enable
+        ///schtasks /change /tn &quot;\Microsoft\Windows\Customer Experience Improvement Program\KernelCeipTask&quot; /enable
+        ///schtasks /change /tn &quot;\Microsoft\Windows\Customer Experience Improvement Program\UsbCeip&quot; /enable
+        ///schtasks /change /tn &quot;\Microsoft\Windows\Customer Experience Improvement Program\Uploader&quot; /enable
+        ///schta [rest of string was truncated]&quot;;.
+        /// </summary>
+        internal static string EnableTelemetryTasks {
+            get {
+                return ResourceManager.GetString("EnableTelemetryTasks", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to schtasks /change /tn &quot;\Microsoft\XblGameSave\XblGameSaveTask&quot; /enable
+        ///schtasks /change /tn &quot;\Microsoft\XblGameSave\XblGameSaveTaskLogon&quot; /enable
+        ///.
+        /// </summary>
+        internal static string EnableXboxTasks {
+            get {
+                return ResourceManager.GetString("EnableXboxTasks", resourceCulture);
+            }
+        }
+        
         /// <summary>
         ///   Looks up a localized resource of type System.Byte[].
         /// </summary>

+ 23 - 11
Optimizer/Properties/Resources.resx

@@ -119,13 +119,13 @@
   </resheader>
   <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
   <data name="DisableOfficeTelemetryTasks" type="System.Resources.ResXFileRef, System.Windows.Forms">
-    <value>..\Resources\DisableOfficeTelemetryTasks.bat;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;windows-1253</value>
+    <value>..\Resources\DisableOfficeTelemetryTasks.bat;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
   </data>
   <data name="DisableTelemetryTasks" type="System.Resources.ResXFileRef, System.Windows.Forms">
-    <value>..\Resources\DisableTelemetryTasks.bat;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;windows-1253</value>
+    <value>..\Resources\DisableTelemetryTasks.bat;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
   </data>
   <data name="DisableXboxTasks" type="System.Resources.ResXFileRef, System.Windows.Forms">
-    <value>..\Resources\DisableXboxTasks.bat;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
+    <value>..\Resources\DisableXboxTasks.bat;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
   </data>
   <data name="OneDrive_Uninstaller" type="System.Resources.ResXFileRef, System.Windows.Forms">
     <value>..\Resources\OneDrive_Uninstaller.bin;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
@@ -134,27 +134,39 @@
     <value>..\Resources\hosts;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </data>
   <data name="DesktopShortcuts" type="System.Resources.ResXFileRef, System.Windows.Forms">
-    <value>..\Resources\DesktopShortcuts.reg;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16</value>
+    <value>..\Resources\DesktopShortcuts.reg;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
   </data>
   <data name="PowerMenu" type="System.Resources.ResXFileRef, System.Windows.Forms">
-    <value>..\Resources\PowerMenu.reg;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16</value>
+    <value>..\Resources\PowerMenu.reg;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
   </data>
   <data name="SystemShortcuts" type="System.Resources.ResXFileRef, System.Windows.Forms">
-    <value>..\Resources\SystemShortcuts.reg;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16</value>
+    <value>..\Resources\SystemShortcuts.reg;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
   </data>
   <data name="SystemTools" type="System.Resources.ResXFileRef, System.Windows.Forms">
-    <value>..\Resources\SystemTools.reg;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16</value>
+    <value>..\Resources\SystemTools.reg;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
   </data>
   <data name="WindowsApps" type="System.Resources.ResXFileRef, System.Windows.Forms">
-    <value>..\Resources\WindowsApps.reg;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16</value>
+    <value>..\Resources\WindowsApps.reg;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
   </data>
   <data name="DisableOfficeTelemetry" type="System.Resources.ResXFileRef, System.Windows.Forms">
-    <value>..\Resources\DisableOfficeTelemetry.reg;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
+    <value>..\Resources\DisableOfficeTelemetry.reg;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
   </data>
   <data name="InstallTakeOwnership" type="System.Resources.ResXFileRef, System.Windows.Forms">
-    <value>..\Resources\InstallTakeOwnership.reg;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
+    <value>..\Resources\InstallTakeOwnership.reg;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
   </data>
   <data name="RemoveTakeOwnership" type="System.Resources.ResXFileRef, System.Windows.Forms">
-    <value>..\Resources\RemoveTakeOwnership.reg;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16</value>
+    <value>..\Resources\RemoveTakeOwnership.reg;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
+  </data>
+  <data name="EnableTelemetryTasks" type="System.Resources.ResXFileRef, System.Windows.Forms">
+    <value>..\Resources\EnableTelemetryTasks.bat;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
+  </data>
+  <data name="EnableOfficeTelemetry" type="System.Resources.ResXFileRef, System.Windows.Forms">
+    <value>..\Resources\EnableOfficeTelemetry.reg;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
+  </data>
+  <data name="EnableOfficeTelemetryTasks" type="System.Resources.ResXFileRef, System.Windows.Forms">
+    <value>..\Resources\EnableOfficeTelemetryTasks.bat;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
+  </data>
+  <data name="EnableXboxTasks" type="System.Resources.ResXFileRef, System.Windows.Forms">
+    <value>..\Resources\EnableXboxTasks.bat;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
   </data>
 </root>

+ 44 - 24
Optimizer/Required.cs

@@ -12,10 +12,10 @@ namespace Optimizer
     internal static class Required
     {
         internal readonly static string CoreFolder = CleanHelper.ProgramData + "\\Optimizer\\";
-        internal readonly static string ReadyMadeMenus = CleanHelper.ProgramData + "\\Optimizer\\ReadyMadeMenus\\";
-        internal readonly static string RequiredFolder = CleanHelper.ProgramData + "\\Optimizer\\Required\\";
-        internal readonly static string ExtractedIcons = CleanHelper.ProgramData + "\\Optimizer\\ExtractedIcons\\";
-        internal readonly static string FavIcons = CleanHelper.ProgramData + "\\Optimizer\\FavIcons\\";
+        internal readonly static string ReadyMadeMenusFolder = CleanHelper.ProgramData + "\\Optimizer\\ReadyMadeMenus\\";
+        internal readonly static string ScriptsFolder = CleanHelper.ProgramData + "\\Optimizer\\Required\\";
+        internal readonly static string ExtractedIconsFolder = CleanHelper.ProgramData + "\\Optimizer\\ExtractedIcons\\";
+        internal readonly static string FavIconsFolder = CleanHelper.ProgramData + "\\Optimizer\\FavIcons\\";
 
         internal static void Deploy()
         {
@@ -23,82 +23,102 @@ namespace Optimizer
             {
                 Directory.CreateDirectory(CoreFolder);
             }
-            if (!Directory.Exists(ReadyMadeMenus))
+            if (!Directory.Exists(ReadyMadeMenusFolder))
             {
-                Directory.CreateDirectory(ReadyMadeMenus);
+                Directory.CreateDirectory(ReadyMadeMenusFolder);
             }
-            if (!Directory.Exists(RequiredFolder))
+            if (!Directory.Exists(ScriptsFolder))
             {
-                Directory.CreateDirectory(RequiredFolder);
+                Directory.CreateDirectory(ScriptsFolder);
             }
-            if (!Directory.Exists(ExtractedIcons))
+            if (!Directory.Exists(ExtractedIconsFolder))
             {
-                Directory.CreateDirectory(ExtractedIcons);
+                Directory.CreateDirectory(ExtractedIconsFolder);
             }
-            if (!Directory.Exists(FavIcons))
+            if (!Directory.Exists(FavIconsFolder))
             {
-                Directory.CreateDirectory(FavIcons);
+                Directory.CreateDirectory(FavIconsFolder);
             }
 
             try
             {
-                File.WriteAllText(ReadyMadeMenus + "\\DesktopShortcuts.reg", Properties.Resources.DesktopShortcuts);
+                File.WriteAllText(ReadyMadeMenusFolder + "DesktopShortcuts.reg", Properties.Resources.DesktopShortcuts);
             }
             catch { }
             try
             {
-                File.WriteAllText(ReadyMadeMenus + "\\SystemShortcuts.reg", Properties.Resources.SystemShortcuts);
+                File.WriteAllText(ReadyMadeMenusFolder + "SystemShortcuts.reg", Properties.Resources.SystemShortcuts);
             }
             catch { }
             try
             {
-                File.WriteAllText(ReadyMadeMenus + "\\PowerMenu.reg", Properties.Resources.PowerMenu);
+                File.WriteAllText(ReadyMadeMenusFolder + "PowerMenu.reg", Properties.Resources.PowerMenu);
             }
             catch { }
             try
             {
-                File.WriteAllText(ReadyMadeMenus + "\\SystemTools.reg", Properties.Resources.SystemTools);
+                File.WriteAllText(ReadyMadeMenusFolder + "SystemTools.reg", Properties.Resources.SystemTools);
             }
             catch { }
             try
             {
-                File.WriteAllText(ReadyMadeMenus + "\\WindowsApps.reg", Properties.Resources.WindowsApps);
+                File.WriteAllText(ReadyMadeMenusFolder + "WindowsApps.reg", Properties.Resources.WindowsApps);
             }
             catch { }
 
             try
             {
-                File.WriteAllText(RequiredFolder + "\\DisableOfficeTelemetryTasks.bat", Properties.Resources.DisableOfficeTelemetryTasks);
+                File.WriteAllText(ScriptsFolder + "DisableOfficeTelemetryTasks.bat", Properties.Resources.DisableOfficeTelemetryTasks);
             }
             catch { }
             try
             {
-                File.WriteAllText(RequiredFolder + "\\DisableOfficeTelemetryTasks.reg", Properties.Resources.DisableOfficeTelemetry);
+                File.WriteAllText(ScriptsFolder + "DisableOfficeTelemetryTasks.reg", Properties.Resources.DisableOfficeTelemetry);
             }
             catch { }
             try
             {
-                File.WriteAllText(RequiredFolder + "\\DisableTelemetryTasks.bat", Properties.Resources.DisableTelemetryTasks);
+                File.WriteAllText(ScriptsFolder + "EnableOfficeTelemetryTasks.bat", Properties.Resources.EnableOfficeTelemetryTasks);
             }
             catch { }
             try
             {
-                File.WriteAllText(RequiredFolder + "\\DisableXboxTasks.bat", Properties.Resources.DisableXboxTasks);
+                File.WriteAllText(ScriptsFolder + "EnableOfficeTelemetryTasks.reg", Properties.Resources.EnableOfficeTelemetry);
             }
             catch { }
             try
             {
-                File.WriteAllBytes(RequiredFolder + "\\OneDrive_Uninstaller.cmd", Properties.Resources.OneDrive_Uninstaller);
+                File.WriteAllText(ScriptsFolder + "DisableTelemetryTasks.bat", Properties.Resources.DisableTelemetryTasks);
             }
             catch { }
             try
             {
-                File.WriteAllText(ReadyMadeMenus + "\\InstallTakeOwnership.reg", Properties.Resources.InstallTakeOwnership);
+                File.WriteAllText(ScriptsFolder + "EnableTelemetryTasks.bat", Properties.Resources.EnableTelemetryTasks);
             }
             catch { }
             try
             {
-                File.WriteAllText(ReadyMadeMenus + "\\RemoveTakeOwnership.reg", Properties.Resources.RemoveTakeOwnership);
+                File.WriteAllText(ScriptsFolder + "DisableXboxTasks.bat", Properties.Resources.DisableXboxTasks);
+            }
+            catch { }
+            try
+            {
+                File.WriteAllText(ScriptsFolder + "EnableXboxTasks.bat", Properties.Resources.EnableXboxTasks);
+            }
+            catch { }
+            try
+            {
+                File.WriteAllBytes(ScriptsFolder + "OneDrive_Uninstaller.cmd", Properties.Resources.OneDrive_Uninstaller);
+            }
+            catch { }
+            try
+            {
+                File.WriteAllText(ReadyMadeMenusFolder + "InstallTakeOwnership.reg", Properties.Resources.InstallTakeOwnership);
+            }
+            catch { }
+            try
+            {
+                File.WriteAllText(ReadyMadeMenusFolder + "RemoveTakeOwnership.reg", Properties.Resources.RemoveTakeOwnership);
             }
             catch { }
         }

+ 19 - 0
Optimizer/Resources/EnableOfficeTelemetry.reg

@@ -0,0 +1,19 @@
+Windows Registry Editor Version 5.00
+
+[HKEY_CURRENT_USER\Software\Policies\microsoft\office\16.0\osm\preventedapplications]
+"accesssolution"=-
+"olksolution"=-
+"onenotesolution"=-
+"pptsolution"=-
+"projectsolution"=-
+"publishersolution"=-
+"visiosolution"=-
+"wdsolution"=-
+"xlsolution"=-
+ 
+[HKEY_CURRENT_USER\Software\Policies\microsoft\office\16.0\osm\preventedsolutiontypes]
+"agave"=-
+"appaddins"=-
+"comaddins"=-
+"documentfiles"=-
+"templatefiles"=-

+ 2 - 0
Optimizer/Resources/EnableOfficeTelemetryTasks.bat

@@ -0,0 +1,2 @@
+schtasks /change /tn "\Microsoft\Office\OfficeTelemetryAgentFallBack2016" /enable
+schtasks /change /tn "\Microsoft\Office\OfficeTelemetryAgentLogOn2016" /enable

+ 24 - 0
Optimizer/Resources/EnableTelemetryTasks.bat

@@ -0,0 +1,24 @@
+schtasks /change /tn "\Microsoft\Windows\Customer Experience Improvement Program\Consolidator" /enable
+schtasks /change /tn "\Microsoft\Windows\Customer Experience Improvement Program\BthSQM" /enable
+schtasks /change /tn "\Microsoft\Windows\Customer Experience Improvement Program\KernelCeipTask" /enable
+schtasks /change /tn "\Microsoft\Windows\Customer Experience Improvement Program\UsbCeip" /enable
+schtasks /change /tn "\Microsoft\Windows\Customer Experience Improvement Program\Uploader" /enable
+schtasks /change /tn "\Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser" /enable
+schtasks /change /tn "\Microsoft\Windows\Application Experience\ProgramDataUpdater" /enable
+schtasks /change /tn "\Microsoft\Windows\Application Experience\StartupAppTask" /enable"
+schtasks /change /tn "\Microsoft\Windows\DiskDiagnostic\Microsoft-Windows-DiskDiagnosticDataCollector" /enable
+schtasks /change /tn "\Microsoft\Windows\DiskDiagnostic\Microsoft-Windows-DiskDiagnosticResolver" /enable
+schtasks /change /tn "\Microsoft\Windows\Power Efficiency Diagnostics\AnalyzeSystem" /enable
+schtasks /change /tn "\Microsoft\Windows\Shell\FamilySafetyMonitor" /enable
+schtasks /change /tn "\Microsoft\Windows\Shell\FamilySafetyRefresh" /enable
+schtasks /change /tn "\Microsoft\Windows\Shell\FamilySafetyUpload" /enable
+schtasks /change /tn "\Microsoft\Windows\Autochk\Proxy" /enable
+schtasks /change /tn "\Microsoft\Windows\Maintenance\WinSAT" /enable
+schtasks /change /tn "\Microsoft\Windows\Application Experience\AitAgent" /enable
+schtasks /change /tn "\Microsoft\Windows\Windows Error Reporting\QueueReporting" /enable
+schtasks /change /tn "\Microsoft\Windows\CloudExperienceHost\CreateObjectTask" /enable
+schtasks /change /tn "\Microsoft\Windows\DiskFootprint\Diagnostics" /enable
+schtasks /change /tn "\Microsoft\Windows\FileHistory\File History (maintenance mode)" /enable
+schtasks /change /tn "\Microsoft\Windows\PI\Sqm-Tasks" /enable
+schtasks /change /tn "\Microsoft\Windows\NetTrace\GatherNetworkInfo" /enable
+schtasks /change /tn "\Microsoft\Windows\AppID\SmartScreenSpecific" /enable

+ 2 - 0
Optimizer/Resources/EnableXboxTasks.bat

@@ -0,0 +1,2 @@
+schtasks /change /tn "\Microsoft\XblGameSave\XblGameSaveTask" /enable
+schtasks /change /tn "\Microsoft\XblGameSave\XblGameSaveTaskLogon" /enable

+ 56 - 0
Optimizer/ToggleSwitch/ImageHelper.cs

@@ -0,0 +1,56 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Drawing.Imaging;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Optimizer
+{
+    public static class ImageHelper
+    {
+        private static float[][] _colorMatrixElements = {
+                                            new float[] {(float)0.299, (float)0.299, (float)0.299, 0, 0},
+                                            new float[] {(float)0.587, (float)0.587, (float)0.587, 0, 0},
+                                            new float[] {(float)0.114, (float)0.114, (float)0.114, 0, 0},
+                                            new float[] {0,  0,  0,  1, 0},
+                                            new float[] {0, 0, 0, 0, 1}
+                                        };
+
+        private static ColorMatrix _grayscaleColorMatrix = new ColorMatrix(_colorMatrixElements);
+
+        public static ImageAttributes GetGrayscaleAttributes()
+        {
+            ImageAttributes attr = new ImageAttributes();
+            attr.SetColorMatrix(_grayscaleColorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
+            return attr;
+        }
+
+        public static Size RescaleImageToFit(Size imageSize, Size canvasSize)
+        {
+            //Code "borrowed" from http://stackoverflow.com/questions/1940581/c-sharp-image-resizing-to-different-size-while-preserving-aspect-ratio
+            // and the Math.Min improvement from http://stackoverflow.com/questions/6501797/resize-image-proportionally-with-maxheight-and-maxwidth-constraints
+
+            // Figure out the ratio
+            double ratioX = (double)canvasSize.Width / (double)imageSize.Width;
+            double ratioY = (double)canvasSize.Height / (double)imageSize.Height;
+
+            // use whichever multiplier is smaller
+            double ratio = Math.Min(ratioX, ratioY);
+
+            // now we can get the new height and width
+            int newHeight = Convert.ToInt32(imageSize.Height * ratio);
+            int newWidth = Convert.ToInt32(imageSize.Width * ratio);
+
+            Size resizedSize = new Size(newWidth, newHeight);
+
+            if (resizedSize.Width > canvasSize.Width || resizedSize.Height > canvasSize.Height)
+            {
+                throw new Exception("ImageHelper.RescaleImageToFit - Resize failed!");
+            }
+
+            return resizedSize;
+        }
+    }
+}

+ 1033 - 0
Optimizer/ToggleSwitch/ToggleSwitch.cs

@@ -0,0 +1,1033 @@
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Windows.Forms;
+
+namespace Optimizer
+{
+    [DefaultValue("Checked"), DefaultEvent("CheckedChanged"), ToolboxBitmap(typeof(CheckBox))]
+    internal class ToggleSwitch : Control
+    {
+        public delegate void CheckedChangedDelegate(Object sender, EventArgs e);
+        [Description("Raised when the ToggleSwitch has changed state")]
+        public event CheckedChangedDelegate CheckedChanged;
+
+        private readonly Timer _animationTimer = new Timer();
+        private ToggleSwitchRendererBase _renderer;
+
+        private bool _checked = false;
+        private bool _moving = false;
+        private bool _animating = false;
+        private bool _animationResult = false;
+        private int _animationTarget = 0;
+        private bool _useAnimation = true;
+        private int _animationInterval = 1;
+        private int _animationStep = 10;
+        private bool _allowUserChange = true;
+
+        private bool _isLeftFieldHovered = false;
+        private bool _isButtonHovered = false;
+        private bool _isRightFieldHovered = false;
+        private bool _isLeftFieldPressed = false;
+        private bool _isButtonPressed = false;
+        private bool _isRightFieldPressed = false;
+
+        private int _buttonValue = 0;
+        private int _savedButtonValue = 0;
+        private int _xOffset = 0;
+        private int _xValue = 0;
+        private int _thresholdPercentage = 50;
+        private bool _grayWhenDisabled = true;
+        private bool _toggleOnButtonClick = true;
+        private bool _toggleOnSideClick = true;
+
+        private MouseEventArgs _lastMouseEventArgs = null;
+
+        private bool _buttonScaleImage;
+        private ToggleSwitchButtonAlignment _buttonAlignment = ToggleSwitchButtonAlignment.Center;
+        private Image _buttonImage = null;
+
+        private Color _offForeColor = Color.Black;
+        private Font _offFont;
+        private Image _offSideImage = null;
+        private bool _offSideScaleImage;
+        private ToggleSwitchAlignment _offSideAlignment = ToggleSwitchAlignment.Center;
+        private Image _offButtonImage = null;
+        private bool _offButtonScaleImage;
+        private ToggleSwitchButtonAlignment _offButtonAlignment = ToggleSwitchButtonAlignment.Center;
+
+        private string _onText = "";
+        private Color _onForeColor = Color.Black;
+        private Font _onFont;
+        private Image _onSideImage = null;
+        private bool _onSideScaleImage;
+        private ToggleSwitchAlignment _onSideAlignment = ToggleSwitchAlignment.Center;
+        private Image _onButtonImage = null;
+        private bool _onButtonScaleImage;
+        private ToggleSwitchButtonAlignment _onButtonAlignment = ToggleSwitchButtonAlignment.Center;
+
+        public ToggleSwitch()
+        {
+            SetStyle(ControlStyles.ResizeRedraw |
+                        ControlStyles.SupportsTransparentBackColor |
+                        ControlStyles.AllPaintingInWmPaint |
+                        ControlStyles.UserPaint |
+                        ControlStyles.OptimizedDoubleBuffer |
+                        ControlStyles.DoubleBuffer, true);
+
+            OnFont = base.Font;
+            OffFont = base.Font;
+
+            SetRenderer(new ToggleSwitchRenderer());
+
+            _animationTimer.Enabled = false;
+            _animationTimer.Interval = _animationInterval;
+            _animationTimer.Tick += AnimationTimer_Tick;
+        }
+
+        public void SetRenderer(ToggleSwitchRendererBase renderer)
+        {
+            renderer.SetToggleSwitch(this);
+            _renderer = renderer;
+
+            if (_renderer != null) Refresh();
+        }
+
+        [Bindable(true)]
+        [DefaultValue(false)]
+        [Category("Data")]
+        [Description("Gets or sets the Checked value of the ToggleSwitch")]
+        public bool Checked
+        {
+            get { return _checked; }
+            set
+            {
+                if (value != _checked)
+                {
+                    while (_animating)
+                    {
+                        Application.DoEvents();
+                    }
+
+                    if (value == true)
+                    {
+                        int buttonWidth = _renderer.GetButtonWidth();
+                        _animationTarget = Width - buttonWidth;
+                        BeginAnimation(true);
+                    }
+                    else
+                    {
+                        _animationTarget = 0;
+                        BeginAnimation(false);
+                    }
+                }
+            }
+        }
+
+        [Bindable(true)]
+        [DefaultValue(true)]
+        [Category("Behavior")]
+        [Description("Gets or sets whether the user can change the value of the button or not")]
+        public bool AllowUserChange
+        {
+            get { return _allowUserChange; }
+            set { _allowUserChange = value; }
+        }
+
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string CheckedString
+        {
+            get
+            {
+                return Checked ? (string.IsNullOrEmpty(OnText) ? "ON" : OnText) : (string.IsNullOrEmpty(OnText) ? "OFF" : OnText);
+            }
+        }
+
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public Rectangle ButtonRectangle
+        {
+            get
+            {
+                return _renderer.GetButtonRectangle();
+            }
+        }
+
+        [Bindable(false)]
+        [DefaultValue(true)]
+        [Category("Appearance")]
+        [Description("Gets or sets if the ToggleSwitch should be grayed out when disabled")]
+        public bool GrayWhenDisabled
+        {
+            get { return _grayWhenDisabled; }
+            set
+            {
+                if (value != _grayWhenDisabled)
+                {
+                    _grayWhenDisabled = value;
+
+                    if (!Enabled)
+                        Refresh();
+                }
+            }
+        }
+
+        [Bindable(false)]
+        [DefaultValue(true)]
+        [Category("Behavior")]
+        [Description("Gets or sets if the ToggleSwitch should toggle when the button is clicked")]
+        public bool ToggleOnButtonClick
+        {
+            get { return _toggleOnButtonClick; }
+            set { _toggleOnButtonClick = value; }
+        }
+
+        [Bindable(false)]
+        [DefaultValue(true)]
+        [Category("Behavior")]
+        [Description("Gets or sets if the ToggleSwitch should toggle when the track besides the button is clicked")]
+        public bool ToggleOnSideClick
+        {
+            get { return _toggleOnSideClick; }
+            set { _toggleOnSideClick = value; }
+        }
+
+        [Bindable(false)]
+        [DefaultValue(50)]
+        [Category("Behavior")]
+        [Description("Gets or sets how much the button need to be on the other side (in peercept) before it snaps")]
+        public int ThresholdPercentage
+        {
+            get { return _thresholdPercentage; }
+            set { _thresholdPercentage = value; }
+        }
+
+        [Bindable(false)]
+        [DefaultValue(typeof(Color), "Black")]
+        [Category("Appearance")]
+        [Description("Gets or sets the forecolor of the text when Checked=false")]
+        public Color OffForeColor
+        {
+            get { return _offForeColor; }
+            set
+            {
+                if (value != _offForeColor)
+                {
+                    _offForeColor = value;
+                    Refresh();
+                }
+            }
+        }
+
+        [Bindable(false)]
+        [DefaultValue(typeof(Font), "Microsoft Sans Serif, 8.25pt")]
+        [Category("Appearance")]
+        [Description("Gets or sets the font of the text when Checked=false")]
+        public Font OffFont
+        {
+            get { return _offFont; }
+            set
+            {
+                if (!value.Equals(_offFont))
+                {
+                    _offFont = value;
+                    Refresh();
+                }
+            }
+        }
+
+        [Bindable(false)]
+        [DefaultValue(null)]
+        [Category("Appearance")]
+        [Description("Gets or sets the side image when Checked=false - Note: Settings the OffSideImage overrules the OffText property. Only the image will be shown")]
+        public Image OffSideImage
+        {
+            get { return _offSideImage; }
+            set
+            {
+                if (value != _offSideImage)
+                {
+                    _offSideImage = value;
+                    Refresh();
+                }
+            }
+        }
+
+        [Bindable(false)]
+        [DefaultValue(false)]
+        [Category("Behavior")]
+        [Description("Gets or sets whether the side image visible when Checked=false should be scaled to fit")]
+        public bool OffSideScaleImageToFit
+        {
+            get { return _offSideScaleImage; }
+            set
+            {
+                if (value != _offSideScaleImage)
+                {
+                    _offSideScaleImage = value;
+                    Refresh();
+                }
+            }
+        }
+
+        [Bindable(false)]
+        [DefaultValue(typeof(ToggleSwitchAlignment), "Center")]
+        [Category("Appearance")]
+        [Description("Gets or sets how the text or side image visible when Checked=false should be aligned")]
+        public ToggleSwitchAlignment OffSideAlignment
+        {
+            get { return _offSideAlignment; }
+            set
+            {
+                if (value != _offSideAlignment)
+                {
+                    _offSideAlignment = value;
+                    Refresh();
+                }
+            }
+        }
+
+        [Bindable(false)]
+        [DefaultValue(null)]
+        [Category("Appearance")]
+        [Description("Gets or sets the button image when Checked=false and ButtonImage is not set")]
+        public Image OffButtonImage
+        {
+            get { return _offButtonImage; }
+            set
+            {
+                if (value != _offButtonImage)
+                {
+                    _offButtonImage = value;
+                    Refresh();
+                }
+            }
+        }
+
+        [Bindable(false)]
+        [DefaultValue(false)]
+        [Category("Behavior")]
+        [Description("Gets or sets whether the button image visible when Checked=false should be scaled to fit")]
+        public bool OffButtonScaleImageToFit
+        {
+            get { return _offButtonScaleImage; }
+            set
+            {
+                if (value != _offButtonScaleImage)
+                {
+                    _offButtonScaleImage = value;
+                    Refresh();
+                }
+            }
+        }
+
+        [Bindable(false)]
+        [DefaultValue(typeof(ToggleSwitchButtonAlignment), "Center")]
+        [Category("Appearance")]
+        [Description("Gets or sets how the button image visible when Checked=false should be aligned")]
+        public ToggleSwitchButtonAlignment OffButtonAlignment
+        {
+            get { return _offButtonAlignment; }
+            set
+            {
+                if (value != _offButtonAlignment)
+                {
+                    _offButtonAlignment = value;
+                    Refresh();
+                }
+            }
+        }
+
+        [Bindable(false)]
+        [DefaultValue(typeof(Color), "Black")]
+        [Category("Appearance")]
+        [Description("Gets or sets the forecolor of the text when Checked=true")]
+        public Color OnForeColor
+        {
+            get { return _onForeColor; }
+            set
+            {
+                if (value != _onForeColor)
+                {
+                    _onForeColor = value;
+                    Refresh();
+                }
+            }
+        }
+
+        [Bindable(false)]
+        [DefaultValue(typeof(Font), "Microsoft Sans Serif, 8,25pt")]
+        [Category("Appearance")]
+        [Description("Gets or sets the font of the text when Checked=true")]
+        public Font OnFont
+        {
+            get { return _onFont; }
+            set
+            {
+                if (!value.Equals(_onFont))
+                {
+                    _onFont = value;
+                    Refresh();
+                }
+            }
+        }
+
+        [Bindable(false)]
+        [DefaultValue("")]
+        [Category("Appearance")]
+        [Description("On-button text")]
+        public string OnText
+        {
+            get { return _onText; }
+            set
+            {
+                if (value != _onText)
+                {
+                    _onText = value;
+                    Refresh();
+                }
+            }
+        }
+
+        [Bindable(false)]
+        [DefaultValue(null)]
+        [Category("Appearance")]
+        [Description("Gets or sets the side image visible when Checked=true - Note: Settings the OnSideImage overrules the OnText property. Only the image will be shown.")]
+        public Image OnSideImage
+        {
+            get { return _onSideImage; }
+            set
+            {
+                if (value != _onSideImage)
+                {
+                    _onSideImage = value;
+                    Refresh();
+                }
+            }
+        }
+
+        [Bindable(false)]
+        [DefaultValue(false)]
+        [Category("Behavior")]
+        [Description("Gets or sets whether the side image visible when Checked=true should be scaled to fit")]
+        public bool OnSideScaleImageToFit
+        {
+            get { return _onSideScaleImage; }
+            set
+            {
+                if (value != _onSideScaleImage)
+                {
+                    _onSideScaleImage = value;
+                    Refresh();
+                }
+            }
+        }
+
+        [Bindable(false)]
+        [DefaultValue(null)]
+        [Category("Appearance")]
+        [Description("Gets or sets the button image")]
+        public Image ButtonImage
+        {
+            get { return _buttonImage; }
+            set
+            {
+                if (value != _buttonImage)
+                {
+                    _buttonImage = value;
+                    Refresh();
+                }
+            }
+        }
+
+        [Bindable(false)]
+        [DefaultValue(false)]
+        [Category("Behavior")]
+        [Description("Gets or sets whether the button image should be scaled to fit")]
+        public bool ButtonScaleImageToFit
+        {
+            get { return _buttonScaleImage; }
+            set
+            {
+                if (value != _buttonScaleImage)
+                {
+                    _buttonScaleImage = value;
+                    Refresh();
+                }
+            }
+        }
+
+        [Bindable(false)]
+        [DefaultValue(typeof(ToggleSwitchButtonAlignment), "Center")]
+        [Category("Appearance")]
+        [Description("Gets or sets how the button image should be aligned")]
+        public ToggleSwitchButtonAlignment ButtonAlignment
+        {
+            get { return _buttonAlignment; }
+            set
+            {
+                if (value != _buttonAlignment)
+                {
+                    _buttonAlignment = value;
+                    Refresh();
+                }
+            }
+        }
+
+        [Bindable(false)]
+        [DefaultValue(typeof(ToggleSwitchAlignment), "Center")]
+        [Category("Appearance")]
+        [Description("Gets or sets how the text or side image visible when Checked=true should be aligned")]
+        public ToggleSwitchAlignment OnSideAlignment
+        {
+            get { return _onSideAlignment; }
+            set
+            {
+                if (value != _onSideAlignment)
+                {
+                    _onSideAlignment = value;
+                    Refresh();
+                }
+            }
+        }
+
+        [Bindable(false)]
+        [DefaultValue(null)]
+        [Category("Appearance")]
+        [Description("Gets or sets the button image visible when Checked=true and ButtonImage is not set")]
+        public Image OnButtonImage
+        {
+            get { return _onButtonImage; }
+            set
+            {
+                if (value != _onButtonImage)
+                {
+                    _onButtonImage = value;
+                    Refresh();
+                }
+            }
+        }
+
+        [Bindable(false)]
+        [DefaultValue(false)]
+        [Category("Behavior")]
+        [Description("Gets or sets whether the button image visible when Checked=true should be scaled to fit")]
+        public bool OnButtonScaleImageToFit
+        {
+            get { return _onButtonScaleImage; }
+            set
+            {
+                if (value != _onButtonScaleImage)
+                {
+                    _onButtonScaleImage = value;
+                    Refresh();
+                }
+            }
+        }
+
+        [Bindable(false)]
+        [DefaultValue(typeof(ToggleSwitchButtonAlignment), "Center")]
+        [Category("Appearance")]
+        [Description("Gets or sets how the button image visible when Checked=true should be aligned")]
+        public ToggleSwitchButtonAlignment OnButtonAlignment
+        {
+            get { return _onButtonAlignment; }
+            set
+            {
+                if (value != _onButtonAlignment)
+                {
+                    _onButtonAlignment = value;
+                    Refresh();
+                }
+            }
+        }
+
+        [Bindable(false)]
+        [DefaultValue(true)]
+        [Category("Behavior")]
+        [Description("Gets or sets whether the toggle change should be animated or not")]
+        public bool UseAnimation
+        {
+            get { return _useAnimation; }
+            set { _useAnimation = value; }
+        }
+
+        [Bindable(false)]
+        [DefaultValue(1)]
+        [Category("Behavior")]
+        [Description("Gets or sets the interval in ms between animation frames")]
+        public int AnimationInterval
+        {
+            get { return _animationInterval; }
+            set
+            {
+                if (value <= 0)
+                {
+                    throw new ArgumentOutOfRangeException("AnimationInterval must larger than zero!");
+                }
+
+                _animationInterval = value;
+            }
+        }
+
+        [Bindable(false)]
+        [DefaultValue(10)]
+        [Category("Behavior")]
+        [Description("Gets or sets the step in pixes the button shouldbe moved between each animation interval")]
+        public int AnimationStep
+        {
+            get { return _animationStep; }
+            set
+            {
+                if (value <= 0)
+                {
+                    throw new ArgumentOutOfRangeException("AnimationStep must larger than zero!");
+                }
+
+                _animationStep = value;
+            }
+        }
+
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public new string Text
+        {
+            get { return ""; }
+            set { base.Text = ""; }
+        }
+
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public new Color ForeColor
+        {
+            get { return Color.Black; }
+            set { base.ForeColor = Color.Black; }
+        }
+
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public new Font Font
+        {
+            get { return base.Font; }
+            set { base.Font = new Font(base.Font, FontStyle.Regular); }
+        }
+
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        internal bool IsButtonHovered
+        {
+            get { return _isButtonHovered && !_isButtonPressed; }
+        }
+
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        internal bool IsButtonPressed
+        {
+            get { return _isButtonPressed; }
+        }
+
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        internal bool IsLeftSideHovered
+        {
+            get { return _isLeftFieldHovered && !_isLeftFieldPressed; }
+        }
+
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        internal bool IsLeftSidePressed
+        {
+            get { return _isLeftFieldPressed; }
+        }
+
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        internal bool IsRightSideHovered
+        {
+            get { return _isRightFieldHovered && !_isRightFieldPressed; }
+        }
+
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        internal bool IsRightSidePressed
+        {
+            get { return _isRightFieldPressed; }
+        }
+
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        internal int ButtonValue
+        {
+            get
+            {
+                if (_animating || _moving)
+                    return _buttonValue;
+                else if (_checked)
+                    return Width - _renderer.GetButtonWidth();
+                else
+                    return 0;
+            }
+            set
+            {
+                if (value != _buttonValue)
+                {
+                    _buttonValue = value;
+                    Refresh();
+                }
+            }
+        }
+
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        internal bool IsButtonOnLeftSide
+        {
+            get { return (ButtonValue <= 0); }
+        }
+
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        internal bool IsButtonOnRightSide
+        {
+            get { return (ButtonValue >= (Width - _renderer.GetButtonWidth())); }
+        }
+
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        internal bool IsButtonMovingLeft
+        {
+            get { return (_animating && !IsButtonOnLeftSide && _animationResult == false); }
+        }
+
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        internal bool IsButtonMovingRight
+        {
+            get { return (_animating && !IsButtonOnRightSide && _animationResult == true); }
+        }
+
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        internal bool AnimationResult
+        {
+            get { return _animationResult; }
+        }
+
+        protected override Size DefaultSize
+        {
+            get { return new Size(50, 19); }
+        }
+
+        protected override void OnPaintBackground(PaintEventArgs pevent)
+        {
+            pevent.Graphics.ResetClip();
+
+            base.OnPaintBackground(pevent);
+
+            if (_renderer != null)
+                _renderer.RenderBackground(pevent);
+        }
+        protected override void OnPaint(PaintEventArgs e)
+        {
+            e.Graphics.ResetClip();
+
+            base.OnPaint(e);
+
+            if (_renderer != null)
+                _renderer.RenderControl(e);
+        }
+
+        protected override void OnMouseMove(MouseEventArgs e)
+        {
+            _lastMouseEventArgs = e;
+
+            int buttonWidth = _renderer.GetButtonWidth();
+            Rectangle buttonRectangle = _renderer.GetButtonRectangle(buttonWidth);
+
+            if (_moving)
+            {
+                int val = _xValue + (e.Location.X - _xOffset);
+
+                if (val < 0)
+                    val = 0;
+
+                if (val > Width - buttonWidth)
+                    val = Width - buttonWidth;
+
+                ButtonValue = val;
+                Refresh();
+                return;
+            }
+
+            if (buttonRectangle.Contains(e.Location))
+            {
+                _isButtonHovered = true;
+                _isLeftFieldHovered = false;
+                _isRightFieldHovered = false;
+            }
+            else
+            {
+                if (e.Location.X > buttonRectangle.X + buttonRectangle.Width)
+                {
+                    _isButtonHovered = false;
+                    _isLeftFieldHovered = false;
+                    _isRightFieldHovered = true;
+                }
+                else if (e.Location.X < buttonRectangle.X)
+                {
+                    _isButtonHovered = false;
+                    _isLeftFieldHovered = true;
+                    _isRightFieldHovered = false;
+                }
+            }
+
+            Refresh();
+        }
+
+        protected override void OnMouseDown(MouseEventArgs e)
+        {
+            if (_animating || !AllowUserChange)
+                return;
+
+            int buttonWidth = _renderer.GetButtonWidth();
+            Rectangle buttonRectangle = _renderer.GetButtonRectangle(buttonWidth);
+
+            _savedButtonValue = ButtonValue;
+
+            if (buttonRectangle.Contains(e.Location))
+            {
+                _isButtonPressed = true;
+                _isLeftFieldPressed = false;
+                _isRightFieldPressed = false;
+
+                _moving = true;
+                _xOffset = e.Location.X;
+                _buttonValue = buttonRectangle.X;
+                _xValue = ButtonValue;
+            }
+            else
+            {
+                if (e.Location.X > buttonRectangle.X + buttonRectangle.Width)
+                {
+                    _isButtonPressed = false;
+                    _isLeftFieldPressed = false;
+                    _isRightFieldPressed = true;
+                }
+                else if (e.Location.X < buttonRectangle.X)
+                {
+                    _isButtonPressed = false;
+                    _isLeftFieldPressed = true;
+                    _isRightFieldPressed = false;
+                }
+            }
+
+            Refresh();
+        }
+
+        protected override void OnMouseUp(MouseEventArgs e)
+        {
+            if (_animating || !AllowUserChange)
+                return;
+
+            int buttonWidth = _renderer.GetButtonWidth();
+
+            bool wasLeftSidePressed = IsLeftSidePressed;
+            bool wasRightSidePressed = IsRightSidePressed;
+
+            _isButtonPressed = false;
+            _isLeftFieldPressed = false;
+            _isRightFieldPressed = false;
+
+            if (_moving)
+            {
+                int percentage = (int)((100 * (double)ButtonValue) / ((double)Width - (double)buttonWidth));
+
+                if (_checked)
+                {
+                    if (percentage <= (100 - _thresholdPercentage))
+                    {
+                        _animationTarget = 0;
+                        BeginAnimation(false);
+                    }
+                    else if (ToggleOnButtonClick && _savedButtonValue == ButtonValue)
+                    {
+                        _animationTarget = 0;
+                        BeginAnimation(false);
+                    }
+                    else
+                    {
+                        _animationTarget = Width - buttonWidth;
+                        BeginAnimation(true);
+                    }
+                }
+                else
+                {
+                    if (percentage >= _thresholdPercentage)
+                    {
+                        _animationTarget = Width - buttonWidth;
+                        BeginAnimation(true);
+                    }
+                    else if (ToggleOnButtonClick && _savedButtonValue == ButtonValue)
+                    {
+                        _animationTarget = Width - buttonWidth;
+                        BeginAnimation(true);
+                    }
+                    else
+                    {
+                        _animationTarget = 0;
+                        BeginAnimation(false);
+                    }
+                }
+
+                _moving = false;
+                return;
+            }
+
+            if (IsButtonOnRightSide)
+            {
+                _buttonValue = Width - buttonWidth;
+                _animationTarget = 0;
+            }
+            else
+            {
+                _buttonValue = 0;
+                _animationTarget = Width - buttonWidth;
+            }
+
+            if (wasLeftSidePressed && ToggleOnSideClick)
+            {
+                SetValueInternal(false);
+            }
+            else if (wasRightSidePressed && ToggleOnSideClick)
+            {
+                SetValueInternal(true);
+            }
+
+            Refresh();
+        }
+
+        protected override void OnMouseLeave(EventArgs e)
+        {
+            _isButtonHovered = false;
+            _isLeftFieldHovered = false;
+            _isRightFieldHovered = false;
+            _isButtonPressed = false;
+            _isLeftFieldPressed = false;
+            _isRightFieldPressed = false;
+
+            Refresh();
+        }
+
+        protected override void OnEnabledChanged(EventArgs e)
+        {
+            base.OnEnabledChanged(e);
+            Refresh();
+        }
+
+        protected override void OnRegionChanged(EventArgs e)
+        {
+            base.OnRegionChanged(e);
+            Refresh();
+        }
+
+        protected override void OnSizeChanged(EventArgs e)
+        {
+            if (_animationTarget > 0)
+            {
+                int buttonWidth = _renderer.GetButtonWidth();
+                _animationTarget = Width - buttonWidth;
+            }
+
+            base.OnSizeChanged(e);
+        }
+
+        private void SetValueInternal(bool checkedValue)
+        {
+            if (checkedValue == _checked)
+                return;
+
+            while (_animating)
+            {
+                Application.DoEvents();
+            }
+
+            BeginAnimation(checkedValue);
+        }
+
+        private void BeginAnimation(bool checkedValue)
+        {
+            _animating = true;
+            _animationResult = checkedValue;
+
+            if (_animationTimer != null && _useAnimation)
+            {
+                _animationTimer.Interval = _animationInterval;
+                _animationTimer.Enabled = true;
+            }
+            else
+            {
+                AnimationComplete();
+            }
+        }
+
+        private void AnimationTimer_Tick(object sender, EventArgs e)
+        {
+            _animationTimer.Enabled = false;
+
+            bool animationDone = false;
+            int newButtonValue;
+
+            if (IsButtonMovingRight)
+            {
+                newButtonValue = ButtonValue + _animationStep;
+
+                if (newButtonValue > _animationTarget)
+                    newButtonValue = _animationTarget;
+
+                ButtonValue = newButtonValue;
+
+                animationDone = ButtonValue >= _animationTarget;
+            }
+            else
+            {
+                newButtonValue = ButtonValue - _animationStep;
+
+                if (newButtonValue < _animationTarget)
+                    newButtonValue = _animationTarget;
+
+                ButtonValue = newButtonValue;
+
+                animationDone = ButtonValue <= _animationTarget;
+            }
+
+            if (animationDone)
+                AnimationComplete();
+            else
+                _animationTimer.Enabled = true;
+        }
+
+        private void AnimationComplete()
+        {
+            _animating = false;
+            _moving = false;
+            _checked = _animationResult;
+
+            _isButtonHovered = false;
+            _isButtonPressed = false;
+            _isLeftFieldHovered = false;
+            _isLeftFieldPressed = false;
+            _isRightFieldHovered = false;
+            _isRightFieldPressed = false;
+
+            Refresh();
+
+            if (CheckedChanged != null)
+                CheckedChanged(this, new EventArgs());
+
+            if (_lastMouseEventArgs != null)
+                OnMouseMove(_lastMouseEventArgs);
+
+            _lastMouseEventArgs = null;
+        }
+    }
+}

+ 338 - 0
Optimizer/ToggleSwitch/ToggleSwitchRenderer.cs

@@ -0,0 +1,338 @@
+using System.Drawing;
+
+namespace Optimizer
+{
+    internal class ToggleSwitchRenderer : ToggleSwitchRendererBase
+    {
+        public Color BackColor { get; set; }
+        public Color LeftSideColor { get; set; }
+        public Color LeftSideColorHovered { get; set; }
+        public Color LeftSideColorPressed { get; set; }
+        public Color RightSideColor { get; set; }
+        public Color RightSideColorHovered { get; set; }
+        public Color RightSideColorPressed { get; set; }
+        public Color BorderColor { get; set; }
+        public Color ButtonColor { get; set; }
+        public Color ButtonColorHovered { get; set; }
+        public Color ButtonColorPressed { get; set; }
+
+        public ToggleSwitchRenderer()
+        {
+            switch (Options.CurrentOptions.Color)
+            {
+                case Theme.Caramel:
+                    LeftSideColor = Color.DarkOrange;
+                    LeftSideColorHovered = Color.DarkOrange;
+                    LeftSideColorPressed = Color.DarkOrange;
+                    break;
+                case Theme.Ocean:
+                    LeftSideColor = Color.DodgerBlue;
+                    LeftSideColorHovered = Color.DodgerBlue;
+                    LeftSideColorPressed = Color.DodgerBlue;
+                    break;
+                case Theme.Lime:
+                    LeftSideColor = Color.LimeGreen;
+                    LeftSideColorHovered = Color.LimeGreen;
+                    LeftSideColorPressed = Color.LimeGreen;
+                    break;
+                case Theme.Magma:
+                    LeftSideColor = Color.Tomato;
+                    LeftSideColorHovered = Color.Tomato;
+                    LeftSideColorPressed = Color.Tomato;
+                    break;
+                case Theme.Minimal:
+                    LeftSideColor = Color.Gray;
+                    LeftSideColorHovered = Color.Gray;
+                    LeftSideColorPressed = Color.Gray;
+                    break;
+                case Theme.Zerg:
+                    LeftSideColor = Color.MediumOrchid;
+                    LeftSideColorHovered = Color.MediumOrchid;
+                    LeftSideColorPressed = Color.MediumOrchid;
+                    break;
+            }
+
+            BorderColor = Color.FromArgb(20, 20, 20);
+            BackColor = Color.White;
+            RightSideColor = Color.FromArgb(40, 40, 40);
+            RightSideColorHovered = Color.FromArgb(40, 40, 40);
+            RightSideColorPressed = Color.FromArgb(40, 40, 40);
+            ButtonColor = Color.White;
+            ButtonColorHovered = Color.WhiteSmoke;
+            ButtonColorPressed = Color.WhiteSmoke;
+        }
+
+        public override void RenderBorder(Graphics g, Rectangle borderRectangle)
+        {
+            Color borderColor = !ToggleSwitch.Enabled && ToggleSwitch.GrayWhenDisabled ? BorderColor.ToGrayScale() : BorderColor;
+
+            g.SetClip(borderRectangle);
+
+            using (Pen borderPen = new Pen(borderColor))
+            {
+                g.DrawRectangle(borderPen, borderRectangle.X, borderRectangle.Y, borderRectangle.Width - 1, borderRectangle.Height - 1);
+            }
+
+            g.ResetClip();
+        }
+
+        public override void RenderLeftToggleField(Graphics g, Rectangle leftRectangle, int totalToggleFieldWidth)
+        {
+            Rectangle adjustedLeftRect = new Rectangle(leftRectangle.X + 2, 2, leftRectangle.Width - 2, leftRectangle.Height - 4);
+
+            if (adjustedLeftRect.Width > 0)
+            {
+                Color leftColor = LeftSideColor;
+
+                if (ToggleSwitch.IsLeftSidePressed)
+                    leftColor = LeftSideColorPressed;
+                else if (ToggleSwitch.IsLeftSideHovered)
+                    leftColor = LeftSideColorHovered;
+
+                if (!ToggleSwitch.Enabled && ToggleSwitch.GrayWhenDisabled)
+                    leftColor = leftColor.ToGrayScale();
+
+                g.SetClip(adjustedLeftRect);
+
+                using (Brush leftBrush = new SolidBrush(leftColor))
+                {
+                    g.FillRectangle(leftBrush, adjustedLeftRect);
+                }
+
+                if (ToggleSwitch.OnSideImage != null || !string.IsNullOrEmpty(ToggleSwitch.OnText))
+                {
+                    RectangleF fullRectangle = new RectangleF(leftRectangle.X + 2 - (totalToggleFieldWidth - leftRectangle.Width), 2, totalToggleFieldWidth - 2, ToggleSwitch.Height - 4);
+
+                    g.IntersectClip(fullRectangle);
+
+                    if (ToggleSwitch.OnSideImage != null)
+                    {
+                        Size imageSize = ToggleSwitch.OnSideImage.Size;
+                        Rectangle imageRectangle;
+
+                        int imageXPos = (int)fullRectangle.X;
+
+                        if (ToggleSwitch.OnSideScaleImageToFit)
+                        {
+                            Size canvasSize = new Size((int)fullRectangle.Width, (int)fullRectangle.Height);
+                            Size resizedImageSize = ImageHelper.RescaleImageToFit(imageSize, canvasSize);
+
+                            if (ToggleSwitch.OnSideAlignment == ToggleSwitchAlignment.Center)
+                            {
+                                imageXPos = (int)((float)fullRectangle.X + (((float)fullRectangle.Width - (float)resizedImageSize.Width) / 2));
+                            }
+                            else if (ToggleSwitch.OnSideAlignment == ToggleSwitchAlignment.Near)
+                            {
+                                imageXPos = (int)((float)fullRectangle.X + (float)fullRectangle.Width - (float)resizedImageSize.Width);
+                            }
+
+                            imageRectangle = new Rectangle(imageXPos, (int)((float)fullRectangle.Y + (((float)fullRectangle.Height - (float)resizedImageSize.Height) / 2)), resizedImageSize.Width, resizedImageSize.Height);
+
+                            if (!ToggleSwitch.Enabled && ToggleSwitch.GrayWhenDisabled)
+                                g.DrawImage(ToggleSwitch.OnSideImage, imageRectangle, 0, 0, ToggleSwitch.OnSideImage.Width, ToggleSwitch.OnSideImage.Height, GraphicsUnit.Pixel, ImageHelper.GetGrayscaleAttributes());
+                            else
+                                g.DrawImage(ToggleSwitch.OnSideImage, imageRectangle);
+                        }
+                        else
+                        {
+                            if (ToggleSwitch.OnSideAlignment == ToggleSwitchAlignment.Center)
+                            {
+                                imageXPos = (int)((float)fullRectangle.X + (((float)fullRectangle.Width - (float)imageSize.Width) / 2));
+                            }
+                            else if (ToggleSwitch.OnSideAlignment == ToggleSwitchAlignment.Near)
+                            {
+                                imageXPos = (int)((float)fullRectangle.X + (float)fullRectangle.Width - (float)imageSize.Width);
+                            }
+
+                            imageRectangle = new Rectangle(imageXPos, (int)((float)fullRectangle.Y + (((float)fullRectangle.Height - (float)imageSize.Height) / 2)), imageSize.Width, imageSize.Height);
+
+                            if (!ToggleSwitch.Enabled && ToggleSwitch.GrayWhenDisabled)
+                                g.DrawImage(ToggleSwitch.OnSideImage, imageRectangle, 0, 0, ToggleSwitch.OnSideImage.Width, ToggleSwitch.OnSideImage.Height, GraphicsUnit.Pixel, ImageHelper.GetGrayscaleAttributes());
+                            else
+                                g.DrawImageUnscaled(ToggleSwitch.OnSideImage, imageRectangle);
+                        }
+                    }
+                    else if (!string.IsNullOrEmpty(ToggleSwitch.OnText))
+                    {
+                        SizeF textSize = g.MeasureString(ToggleSwitch.OnText, ToggleSwitch.OnFont);
+
+                        float textXPos = fullRectangle.X;
+
+                        if (ToggleSwitch.OnSideAlignment == ToggleSwitchAlignment.Center)
+                        {
+                            textXPos = (float)fullRectangle.X + (((float)fullRectangle.Width - (float)textSize.Width) / 2);
+                        }
+                        else if (ToggleSwitch.OnSideAlignment == ToggleSwitchAlignment.Near)
+                        {
+                            textXPos = (float)fullRectangle.X + (float)fullRectangle.Width - (float)textSize.Width;
+                        }
+
+                        RectangleF textRectangle = new RectangleF(textXPos, (float)fullRectangle.Y + (((float)fullRectangle.Height - (float)textSize.Height) / 2), textSize.Width, textSize.Height);
+
+                        Color textForeColor = ToggleSwitch.OnForeColor;
+
+                        if (!ToggleSwitch.Enabled && ToggleSwitch.GrayWhenDisabled)
+                            textForeColor = textForeColor.ToGrayScale();
+
+                        using (Brush textBrush = new SolidBrush(textForeColor))
+                        {
+                            g.DrawString(ToggleSwitch.OnText, ToggleSwitch.OnFont, textBrush, textRectangle);
+                        }
+                    }
+                }
+
+                g.ResetClip();
+            }
+        }
+
+        public override void RenderRightToggleField(Graphics g, Rectangle rightRectangle, int totalToggleFieldWidth)
+        {
+            Rectangle adjustedRightRect = new Rectangle(rightRectangle.X, 2, rightRectangle.Width - 2, rightRectangle.Height - 4);
+
+            if (adjustedRightRect.Width > 0)
+            {
+                Color rightColor = RightSideColor;
+
+                if (ToggleSwitch.IsRightSidePressed)
+                    rightColor = RightSideColorPressed;
+                else if (ToggleSwitch.IsRightSideHovered)
+                    rightColor = RightSideColorHovered;
+
+                if (!ToggleSwitch.Enabled && ToggleSwitch.GrayWhenDisabled)
+                    rightColor = rightColor.ToGrayScale();
+
+                g.SetClip(adjustedRightRect);
+
+                using (Brush rightBrush = new SolidBrush(rightColor))
+                {
+                    g.FillRectangle(rightBrush, adjustedRightRect);
+                }
+
+                if (ToggleSwitch.OffSideImage != null || !string.IsNullOrEmpty(ToggleSwitch.OnText))
+                {
+                    RectangleF fullRectangle = new RectangleF(rightRectangle.X, 2, totalToggleFieldWidth - 2, ToggleSwitch.Height - 4);
+
+                    g.IntersectClip(fullRectangle);
+
+                    if (ToggleSwitch.OffSideImage != null)
+                    {
+                        Size imageSize = ToggleSwitch.OffSideImage.Size;
+                        Rectangle imageRectangle;
+
+                        int imageXPos = (int)fullRectangle.X;
+
+                        if (ToggleSwitch.OffSideScaleImageToFit)
+                        {
+                            Size canvasSize = new Size((int)fullRectangle.Width, (int)fullRectangle.Height);
+                            Size resizedImageSize = ImageHelper.RescaleImageToFit(imageSize, canvasSize);
+
+                            if (ToggleSwitch.OffSideAlignment == ToggleSwitchAlignment.Center)
+                            {
+                                imageXPos = (int)((float)fullRectangle.X + (((float)fullRectangle.Width - (float)resizedImageSize.Width) / 2));
+                            }
+                            else if (ToggleSwitch.OffSideAlignment == ToggleSwitchAlignment.Far)
+                            {
+                                imageXPos = (int)((float)fullRectangle.X + (float)fullRectangle.Width - (float)resizedImageSize.Width);
+                            }
+
+                            imageRectangle = new Rectangle(imageXPos, (int)((float)fullRectangle.Y + (((float)fullRectangle.Height - (float)resizedImageSize.Height) / 2)), resizedImageSize.Width, resizedImageSize.Height);
+
+                            if (!ToggleSwitch.Enabled && ToggleSwitch.GrayWhenDisabled)
+                                g.DrawImage(ToggleSwitch.OnSideImage, imageRectangle, 0, 0, ToggleSwitch.OnSideImage.Width, ToggleSwitch.OnSideImage.Height, GraphicsUnit.Pixel, ImageHelper.GetGrayscaleAttributes());
+                            else
+                                g.DrawImage(ToggleSwitch.OnSideImage, imageRectangle);
+                        }
+                        else
+                        {
+                            if (ToggleSwitch.OffSideAlignment == ToggleSwitchAlignment.Center)
+                            {
+                                imageXPos = (int)((float)fullRectangle.X + (((float)fullRectangle.Width - (float)imageSize.Width) / 2));
+                            }
+                            else if (ToggleSwitch.OffSideAlignment == ToggleSwitchAlignment.Far)
+                            {
+                                imageXPos = (int)((float)fullRectangle.X + (float)fullRectangle.Width - (float)imageSize.Width);
+                            }
+
+                            imageRectangle = new Rectangle(imageXPos, (int)((float)fullRectangle.Y + (((float)fullRectangle.Height - (float)imageSize.Height) / 2)), imageSize.Width, imageSize.Height);
+
+                            if (!ToggleSwitch.Enabled && ToggleSwitch.GrayWhenDisabled)
+                                g.DrawImage(ToggleSwitch.OnSideImage, imageRectangle, 0, 0, ToggleSwitch.OnSideImage.Width, ToggleSwitch.OnSideImage.Height, GraphicsUnit.Pixel, ImageHelper.GetGrayscaleAttributes());
+                            else
+                                g.DrawImageUnscaled(ToggleSwitch.OffSideImage, imageRectangle);
+                        }
+                    }
+                    else if (!string.IsNullOrEmpty(ToggleSwitch.OnText))
+                    {
+                        SizeF textSize = g.MeasureString(ToggleSwitch.OnText, ToggleSwitch.OffFont);
+
+                        float textXPos = fullRectangle.X;
+
+                        if (ToggleSwitch.OffSideAlignment == ToggleSwitchAlignment.Center)
+                        {
+                            textXPos = (float)fullRectangle.X + (((float)fullRectangle.Width - (float)textSize.Width) / 2);
+                        }
+                        else if (ToggleSwitch.OffSideAlignment == ToggleSwitchAlignment.Far)
+                        {
+                            textXPos = (float)fullRectangle.X + (float)fullRectangle.Width - (float)textSize.Width;
+                        }
+
+                        RectangleF textRectangle = new RectangleF(textXPos, (float)fullRectangle.Y + (((float)fullRectangle.Height - (float)textSize.Height) / 2), textSize.Width, textSize.Height);
+
+                        Color textForeColor = ToggleSwitch.OffForeColor;
+
+                        if (!ToggleSwitch.Enabled && ToggleSwitch.GrayWhenDisabled)
+                            textForeColor = textForeColor.ToGrayScale();
+
+                        using (Brush textBrush = new SolidBrush(textForeColor))
+                        {
+                            g.DrawString(ToggleSwitch.OnText, ToggleSwitch.OffFont, textBrush, textRectangle);
+                        }
+                    }
+                }
+            }
+        }
+
+        public override void RenderButton(Graphics g, Rectangle buttonRectangle)
+        {
+            Color buttonColor = ButtonColor;
+
+            if (ToggleSwitch.IsButtonPressed)
+            {
+                buttonColor = ButtonColorPressed;
+            }
+            else if (ToggleSwitch.IsButtonHovered)
+            {
+                buttonColor = ButtonColorHovered;
+            }
+
+            if (!ToggleSwitch.Enabled && ToggleSwitch.GrayWhenDisabled)
+                buttonColor = buttonColor.ToGrayScale();
+
+            g.SetClip(buttonRectangle);
+
+            using (Brush backBrush = new SolidBrush(buttonColor))
+            {
+                g.FillRectangle(backBrush, buttonRectangle);
+            }
+
+            g.ResetClip();
+        }
+
+        public override int GetButtonWidth()
+        {
+            return (int)((double)ToggleSwitch.Height / 3 * 2);
+        }
+
+        public override Rectangle GetButtonRectangle()
+        {
+            int buttonWidth = GetButtonWidth();
+            return GetButtonRectangle(buttonWidth);
+        }
+
+        public override Rectangle GetButtonRectangle(int buttonWidth)
+        {
+            Rectangle buttonRect = new Rectangle(ToggleSwitch.ButtonValue, 0, buttonWidth, ToggleSwitch.Height);
+            return buttonRect;
+        }
+    }
+}

+ 81 - 0
Optimizer/ToggleSwitch/ToggleSwitchRendererBase.cs

@@ -0,0 +1,81 @@
+using System.Drawing;
+using System.Windows.Forms;
+
+namespace Optimizer
+{
+    public abstract class ToggleSwitchRendererBase
+    {
+        private ToggleSwitch _toggleSwitch;
+
+        protected ToggleSwitchRendererBase() { }
+
+        internal void SetToggleSwitch(ToggleSwitch toggleSwitch)
+        {
+            _toggleSwitch = toggleSwitch;
+        }
+
+        internal ToggleSwitch ToggleSwitch
+        {
+            get { return _toggleSwitch; }
+        }
+
+        public void RenderBackground(PaintEventArgs e)
+        {
+            if (_toggleSwitch == null) return;
+
+            e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
+
+            Rectangle controlRectangle = new Rectangle(0, 0, _toggleSwitch.Width, _toggleSwitch.Height);
+
+            FillBackground(e.Graphics, controlRectangle);
+            RenderBorder(e.Graphics, controlRectangle);
+        }
+
+        public void RenderControl(PaintEventArgs e)
+        {
+            if (_toggleSwitch == null) return;
+
+            e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
+
+            Rectangle buttonRectangle = GetButtonRectangle();
+            int totalToggleFieldWidth = ToggleSwitch.Width - buttonRectangle.Width;
+
+            if (buttonRectangle.X > 0)
+            {
+                Rectangle leftRectangle = new Rectangle(0, 0, buttonRectangle.X, ToggleSwitch.Height);
+
+                if (leftRectangle.Width > 0)
+                    RenderLeftToggleField(e.Graphics, leftRectangle, totalToggleFieldWidth);
+            }
+
+            if (buttonRectangle.X + buttonRectangle.Width < e.ClipRectangle.Width)
+            {
+                Rectangle rightRectangle = new Rectangle(buttonRectangle.X + buttonRectangle.Width, 0, ToggleSwitch.Width - buttonRectangle.X - buttonRectangle.Width, ToggleSwitch.Height);
+
+                if (rightRectangle.Width > 0)
+                    RenderRightToggleField(e.Graphics, rightRectangle, totalToggleFieldWidth);
+            }
+
+            RenderButton(e.Graphics, buttonRectangle);
+        }
+
+        public void FillBackground(Graphics g, Rectangle controlRectangle)
+        {
+            Color backColor = (!ToggleSwitch.Enabled && ToggleSwitch.GrayWhenDisabled) ? ToggleSwitch.BackColor.ToGrayScale() : ToggleSwitch.BackColor;
+
+            using (Brush backBrush = new SolidBrush(backColor))
+            {
+                g.FillRectangle(backBrush, controlRectangle);
+            }
+        }
+
+        public abstract void RenderBorder(Graphics g, Rectangle borderRectangle);
+        public abstract void RenderLeftToggleField(Graphics g, Rectangle leftRectangle, int totalToggleFieldWidth);
+        public abstract void RenderRightToggleField(Graphics g, Rectangle rightRectangle, int totalToggleFieldWidth);
+        public abstract void RenderButton(Graphics g, Rectangle buttonRectangle);
+
+        public abstract int GetButtonWidth();
+        public abstract Rectangle GetButtonRectangle();
+        public abstract Rectangle GetButtonRectangle(int buttonWidth);
+    }
+}

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 0 - 0
Optimizer/Utilities.cs


Vissa filer visades inte eftersom för många filer har ändrats