Browse Source

Code cleanup

deadmoon 5 years ago
parent
commit
af80ca5c71

+ 0 - 7
Optimizer/AboutForm.cs

@@ -1,11 +1,4 @@
 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;
 using System.Diagnostics;
 

+ 6 - 15
Optimizer/CleanHelper.cs

@@ -1,15 +1,6 @@
 using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 using System.IO;
 using System.Runtime.InteropServices;
-using Microsoft.Win32;
-using System.Text.RegularExpressions;
-using System.Windows.Forms;
-using System.Diagnostics;
 
 namespace Optimizer
 {
@@ -65,12 +56,12 @@ namespace Optimizer
         {
             EmptyFolder(TempFolder);
         }
-       
+
         internal static void CleanUTorrent()
         {
             EmptyFolder(UTorrentCache);
         }
-      
+
         internal static void CleanFileZilla()
         {
             try
@@ -84,7 +75,7 @@ namespace Optimizer
         {
             EmptyFolder(OSDriveWindows + "\\Minidump");
         }
-       
+
         internal static void CleanErrorReports()
         {
             EmptyFolder(ProfileAppDataLocal + "\\Microsoft\\Windows\\WER\\ReportArchive");
@@ -96,12 +87,12 @@ namespace Optimizer
             EmptyFolder(ProgramData + "\\Microsoft\\Windows\\WER\\Temp");
             EmptyFolder(ProgramData + "\\Microsoft\\Windows\\WER\\ERC");
         }
-      
+
         internal static void CleanPrefetch()
         {
             EmptyFolder(OSDriveWindows + "\\Prefetch");
         }
-       
+
         internal static void CleanMediaPlayersCache()
         {
             EmptyFolder(ProfileAppDataLocal + "\\Microsoft\\Media Player");
@@ -114,7 +105,7 @@ namespace Optimizer
             }
             catch { }
         }
-     
+
         internal static void CleanLogs()
         {
             EmptyFolder(System32Folder + "\\LogFiles");

+ 0 - 8
Optimizer/EdgeForm.cs

@@ -1,12 +1,4 @@
 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;
 using System.IO;
 
 namespace Optimizer

+ 1 - 7
Optimizer/Enums.cs

@@ -1,10 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Optimizer
+namespace Optimizer
 {
     internal enum LogType
     {

+ 0 - 8
Optimizer/HelperForm.cs

@@ -1,12 +1,4 @@
 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
 {

+ 0 - 7
Optimizer/HostsEditorForm.cs

@@ -1,11 +1,4 @@
 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

+ 0 - 3
Optimizer/HostsHelper.cs

@@ -1,10 +1,7 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 using System.IO;
-using System.Windows.Forms;
 using System.Text.RegularExpressions;
 
 namespace Optimizer

+ 1 - 8
Optimizer/InfoForm.cs

@@ -1,11 +1,4 @@
 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
@@ -16,7 +9,7 @@ namespace Optimizer
         {
             InitializeComponent();
             Options.ApplyTheme(this);
-            
+
             txtInfo.Text = info;
         }
 

+ 3 - 6
Optimizer/Integrator.cs

@@ -1,10 +1,7 @@
 using System;
 using System.Collections.Generic;
-using System.Linq;
-using System.Text;
 using System.IO;
 using Microsoft.Win32;
-using System.Threading.Tasks;
 using System.Windows.Forms;
 using System.Drawing;
 using System.Net;
@@ -41,7 +38,7 @@ namespace Optimizer
             }
 
             string key = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" + keyword;
-            
+
             Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" + keyword);
             Registry.SetValue(key, "", file);
             Registry.SetValue(key, "Path", file.Substring(0, file.LastIndexOf("\\")));
@@ -72,7 +69,7 @@ namespace Optimizer
             using (RegistryKey key = Registry.ClassesRoot.OpenSubKey(@"DesktopBackground\Shell\" + itemName, true))
             {
                 key.CreateSubKey("command", RegistryKeyPermissionCheck.Default);
-            }        
+            }
         }
 
         internal static List<string> GetDesktopItems()
@@ -228,7 +225,7 @@ namespace Optimizer
                 }
                 catch { }
             }
-            
+
             if (!remove)
             {
                 Utilities.ImportRegistryScript(Required.ReadyMadeMenusFolder + "InstallTakeOwnership.reg");

+ 0 - 4
Optimizer/ListViewColumnSorter.cs

@@ -1,10 +1,6 @@
 using System;
 using System.Collections;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
 using System.Windows.Forms;
-using System.Threading.Tasks;
 
 namespace Optimizer
 {

+ 8 - 16
Optimizer/MainForm.cs

@@ -1,21 +1,13 @@
 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;
-using Microsoft.Win32;
 using System.IO;
-using System.Threading;
 using System.Reflection;
 using System.Diagnostics;
-using System.Collections.Specialized;
-using System.Text.RegularExpressions;
 using System.Net;
-using Newtonsoft.Json;
 
 namespace Optimizer
 {
@@ -535,7 +527,7 @@ namespace Optimizer
 
         private void Main_Load(object sender, EventArgs e)
         {
-            
+
         }
 
         private void GetDesktopItems()
@@ -556,7 +548,7 @@ namespace Optimizer
         {
             _hostsEntries = HostsHelper.GetHostsEntries();
             listHostEntries.Items.Clear();
-           
+
             for (int i = 0; i < _hostsEntries.Count; i++)
             {
                 if (!string.IsNullOrEmpty(_hostsEntries[i]))
@@ -749,7 +741,7 @@ namespace Optimizer
             {
                 HelperForm r = new HelperForm(this, MessageType.Startup, _removeStartupItemsMessage);
                 r.ShowDialog(this);
-            } 
+            }
         }
 
         private void button31_Click(object sender, EventArgs e)
@@ -838,7 +830,7 @@ namespace Optimizer
                 }
 
                 HostsHelper.AddEntry(HostsHelper.SanitizeEntry(ip) + " " + HostsHelper.SanitizeEntry(domain));
-                
+
                 if (!string.IsNullOrEmpty(recommendedDomain))
                 {
                     HostsHelper.AddEntry(HostsHelper.SanitizeEntry(ip) + " " + HostsHelper.SanitizeEntry(recommendedDomain));
@@ -918,7 +910,7 @@ namespace Optimizer
         private void DefineCmd_FileOk(object sender, CancelEventArgs e)
         {
             txtRunFile.Text = defineCommandDialog.FileName;
-            txtRunKeyword.Text = Path.GetFileNameWithoutExtension(txtRunFile.Text).ToLower();            
+            txtRunKeyword.Text = Path.GetFileNameWithoutExtension(txtRunFile.Text).ToLower();
         }
 
         private void button58_Click(object sender, EventArgs e)
@@ -1272,7 +1264,7 @@ namespace Optimizer
                     }
 
                     Integrator.AddItem(txtItemName.Text, txtItem.Text, icon, _desktopItemPosition, checkShift.Checked, DesktopItemType.Link);
-                    
+
                     break;
                 case DesktopItemType.File:
                     if (!checkDefaultIcon.Checked)
@@ -1281,7 +1273,7 @@ namespace Optimizer
                     }
 
                     Integrator.AddItem(txtItemName.Text, txtItem.Text, icon, _desktopItemPosition, checkShift.Checked, DesktopItemType.File);
-                    
+
                     break;
                 case DesktopItemType.Command:
                     if (!checkDefaultIcon.Checked)
@@ -1290,7 +1282,7 @@ namespace Optimizer
                     }
 
                     Integrator.AddItem(txtItemName.Text, txtItem.Text, icon, _desktopItemPosition, checkShift.Checked, DesktopItemType.Command);
-                    
+
                     break;
             }
 

+ 5 - 15
Optimizer/Optimize.cs

@@ -1,19 +1,7 @@
 using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 using System.Diagnostics;
-using System.Windows.Forms;
 using System.IO;
-using System.Collections.ObjectModel;
-using System.ServiceProcess;
-using System.Runtime.InteropServices;
-using System.Management.Automation;
 using Microsoft.Win32;
-using System.Management.Automation.Runspaces;
-using System.Security.AccessControl;
-using System.Security.Principal;
 using Microsoft.VisualBasic.FileIO;
 
 namespace Optimizer
@@ -258,11 +246,11 @@ namespace Optimizer
                     p.StartInfo.FileName = "vssadmin";
                     p.StartInfo.Arguments = "delete shadows /for=c: /all /quiet";
                     p.StartInfo.UseShellExecute = false;
-                    
+
                     p.Start();
                     p.WaitForExit();
                     p.Close();
-                }     
+                }
             }
             catch //(Exception ex)
             {
@@ -506,7 +494,7 @@ namespace Optimizer
         {
             Utilities.StopService("SensrSvc");
             Utilities.StopService("SensorService");
-            
+
             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);
         }
@@ -813,6 +801,7 @@ namespace Optimizer
             Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager", "PreInstalledAppsEnabled", "0", RegistryValueKind.DWord);
             Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\CloudContent", "DisableWindowsConsumerFeatures", "1", RegistryValueKind.DWord);
             Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager", "OemPreInstalledAppsEnabled", "0", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\WindowsStore", "AutoDownload", "2", RegistryValueKind.DWord);
         }
 
         internal static void EnableSilentAppInstall()
@@ -822,6 +811,7 @@ namespace Optimizer
             Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager", "PreInstalledAppsEnabled", "1", RegistryValueKind.DWord);
             Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\CloudContent", "DisableWindowsConsumerFeatures", "0", RegistryValueKind.DWord);
             Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager", "OemPreInstalledAppsEnabled", "1", RegistryValueKind.DWord);
+            Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\WindowsStore", "AutoDownload", "4", RegistryValueKind.DWord);
         }
 
         internal static void DisableMyPeople()

+ 0 - 3
Optimizer/Options.cs

@@ -1,8 +1,5 @@
 using System;
-using System.Collections.Generic;
 using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 using System.Windows.Forms;
 using System.Drawing;
 using System.IO;

+ 7 - 10
Optimizer/Program.cs

@@ -1,12 +1,6 @@
 using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
 using System.Windows.Forms;
-using System.Security.Principal;
-using Microsoft.Win32;
 using System.IO;
-using System.Security.Cryptography;
 using System.Reflection;
 
 namespace Optimizer
@@ -17,7 +11,7 @@ namespace Optimizer
         /* DO NOT LEAVE THEM EMPTY */
 
         // Enter current version here
-  
+
         internal readonly static float Major = 0;
         internal readonly static float Minor = 0;
 
@@ -34,7 +28,7 @@ namespace Optimizer
         /* END OF VERSION PROPERTIES */
 
         internal static MainForm MainForm;
-        
+
         readonly static string _adminMissingMessage = "Optimizer needs to be run as administrator!\nApp will now close...";
         readonly static string _unsupportedMessage = "Optimizer works in Windows 7 or higher!\nApp will now close...";
 
@@ -75,7 +69,7 @@ namespace Optimizer
                     Options.LoadSettings();
 
                     // checking for silent  config argument
-                    if (switches.Length ==1)
+                    if (switches.Length == 1)
                     {
                         string arg = switches[0].Trim();
 
@@ -91,18 +85,21 @@ namespace Optimizer
                                     {
                                         SilentOps.ProcessSilentConfigGeneral();
                                         SilentOps.SilentUpdateOptionsGeneral();
+                                        Options.SaveSettings();
                                     }
                                     else if (SilentOps.CurrentSilentConfig.WindowsVersion == 8 && Utilities.CurrentWindowsVersion == WindowsVersion.Windows8)
                                     {
                                         SilentOps.ProcessSilentConfigGeneral();
                                         SilentOps.ProcessSilentConfigWindows8();
                                         SilentOps.SilentUpdateOptions8();
+                                        Options.SaveSettings();
                                     }
                                     else if (SilentOps.CurrentSilentConfig.WindowsVersion == 10 && Utilities.CurrentWindowsVersion == WindowsVersion.Windows10)
                                     {
                                         SilentOps.ProcessSilentConfigGeneral();
                                         SilentOps.ProcessSilentConfigWindows10();
                                         SilentOps.SilentUpdateOptions10();
+                                        Options.SaveSettings();
                                     }
                                     else
                                     {
@@ -140,7 +137,7 @@ namespace Optimizer
 
                     Application.Exit();
                 }
-            }            
+            }
         }
 
         private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)

+ 0 - 1
Optimizer/Properties/AssemblyInfo.cs

@@ -1,5 +1,4 @@
 using System.Reflection;
-using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 
 // General Information about an assembly is controlled through the following 

+ 1 - 8
Optimizer/Required.cs

@@ -1,11 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Drawing;
-using System.IO;
-using System.Windows.Forms;
+using System.IO;
 
 namespace Optimizer
 {

+ 0 - 4
Optimizer/SilentConfig.cs

@@ -1,8 +1,4 @@
 using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 
 namespace Optimizer
 {

+ 1 - 5
Optimizer/SilentOps.cs

@@ -1,8 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using System.Threading.Tasks;
 using Newtonsoft.Json;
 using System.IO;
 

+ 1 - 8
Optimizer/StartupItem.cs

@@ -1,12 +1,5 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Microsoft.Win32;
+using Microsoft.Win32;
 using System.IO;
-using System.Text.RegularExpressions;
-using System.Windows.Forms;
 
 namespace Optimizer
 {

+ 1 - 5
Optimizer/ToggleSwitch/ImageHelper.cs

@@ -1,16 +1,12 @@
 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 = 
+        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},

+ 1 - 3
Optimizer/Utilities.cs

@@ -4,8 +4,6 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Reflection;
 using System.Security.Principal;
-using System.Text;
-using System.Threading.Tasks;
 using System.Windows.Forms;
 using System.IO;
 using System.Diagnostics;
@@ -275,7 +273,7 @@ namespace Optimizer
             if (hive != null)
             {
                 RegistryKey key = hive.OpenSubKey(keyPath, true);
-                
+
                 if (key != null)
                 {
                     string[] valueNames = key.GetValueNames();