MainForm.cs 65 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using Microsoft.Win32;
  11. using System.IO;
  12. using System.Threading;
  13. using System.Reflection;
  14. using System.Diagnostics;
  15. using System.Collections.Specialized;
  16. using System.Text.RegularExpressions;
  17. using System.Net;
  18. using Newtonsoft.Json;
  19. namespace Optimizer
  20. {
  21. public partial class MainForm : Form
  22. {
  23. ListViewColumnSorter _columnSorter;
  24. List<StartupItem> _startUpItems = new List<StartupItem>();
  25. List<string> _hostsEntries = new List<string>();
  26. List<string> _customCommands = new List<string>();
  27. List<string> _desktopItems = new List<string>();
  28. List<string> _modernApps = new List<string>();
  29. DesktopItemType _desktopItemType = DesktopItemType.Program;
  30. DesktopTypePosition _desktopItemPosition = DesktopTypePosition.Top;
  31. readonly string _latestVersionLink = "https://raw.githubusercontent.com/hellzerg/optimizer/master/version.txt";
  32. readonly string _changelogLink = "https://github.com/hellzerg/optimizer/blob/master/CHANGELOG.md";
  33. readonly string _noNewVersionMessage = "You already have the latest version!";
  34. readonly string _betaVersionMessage = "You are using an experimental version!";
  35. readonly string _blockedIP = "0.0.0.0";
  36. readonly string _restartMessage = "Restart to apply changes?";
  37. readonly string _removeStartupItemsMessage = "Are you sure you want to delete all startup items?";
  38. readonly string _removeHostsEntriesMessage = "Are you sure you want to delete all hosts entries?";
  39. readonly string _removeDesktopItemsMessage = "Are you sure you want to delete all desktop items?";
  40. readonly string _removeModernAppsMessage = "Are you sure you want to uninstall the following app(s)?";
  41. readonly string _errorModernAppsMessage = "The following app(s) couldn't be uninstalled:\n";
  42. readonly string _resetMessage = "Are you sure you want to reset configuration?\n\nThis will reset all your preferences, including any icons you extracted or downloaded using Integrator, but will not touch anything on your computer!";
  43. private string NewVersionMessage(string latestVersion)
  44. {
  45. return string.Format("There is a new version available!\n\nLatest version: {0}\nCurrent version: {1}\n\nDo you want to download it now?", latestVersion, Program.GetCurrentVersionTostring());
  46. }
  47. private string NewDownloadLink(string latestVersion)
  48. {
  49. return string.Format("https://github.com/hellzerg/optimizer/releases/download/{0}/Optimizer-{0}.exe", latestVersion);
  50. }
  51. private void CheckForUpdate()
  52. {
  53. WebClient client = new WebClient
  54. {
  55. Encoding = Encoding.UTF8
  56. };
  57. string latestVersion = string.Empty;
  58. try
  59. {
  60. latestVersion = client.DownloadString(_latestVersionLink);
  61. }
  62. catch (Exception ex)
  63. {
  64. MessageBox.Show(ex.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
  65. }
  66. if (!string.IsNullOrEmpty(latestVersion))
  67. {
  68. if (float.Parse(latestVersion) > Program.GetCurrentVersion())
  69. {
  70. if (MessageBox.Show(NewVersionMessage(latestVersion), "Update available", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  71. {
  72. // PATCHING PROCESS
  73. try
  74. {
  75. Assembly currentAssembly = Assembly.GetEntryAssembly();
  76. if (currentAssembly == null)
  77. {
  78. currentAssembly = Assembly.GetCallingAssembly();
  79. }
  80. string appFolder = Path.GetDirectoryName(currentAssembly.Location);
  81. string appName = Path.GetFileNameWithoutExtension(currentAssembly.Location);
  82. string appExtension = Path.GetExtension(currentAssembly.Location);
  83. string archiveFile = Path.Combine(appFolder, appName + "_old" + appExtension);
  84. string appFile = Path.Combine(appFolder, appName + appExtension);
  85. string tempFile = Path.Combine(appFolder, appName + "_tmp" + appExtension);
  86. // DOWNLOAD NEW VERSION
  87. client.DownloadFile(NewDownloadLink(latestVersion), tempFile);
  88. // DELETE PREVIOUS BACK-UP
  89. if (File.Exists(archiveFile))
  90. {
  91. File.Delete(archiveFile);
  92. }
  93. // MAKE BACK-UP
  94. File.Move(appFile, archiveFile);
  95. // PATCH
  96. File.Move(tempFile, appFile);
  97. Application.Restart();
  98. }
  99. catch (Exception ex)
  100. {
  101. MessageBox.Show(ex.Message);
  102. }
  103. }
  104. }
  105. else if (float.Parse(latestVersion) == Program.GetCurrentVersion())
  106. {
  107. MessageBox.Show(_noNewVersionMessage, "No update available", MessageBoxButtons.OK, MessageBoxIcon.Information);
  108. }
  109. else
  110. {
  111. MessageBox.Show(_betaVersionMessage, "No update available", MessageBoxButtons.OK, MessageBoxIcon.Information);
  112. }
  113. }
  114. }
  115. private void EnableToggleEvents()
  116. {
  117. toggleSwitch12.Click += new EventHandler(toggleSwitch12_Click);
  118. toggleSwitch11.Click += new EventHandler(toggleSwitch11_Click);
  119. toggleSwitch10.Click += new EventHandler(toggleSwitch10_Click);
  120. toggleSwitch9.Click += new EventHandler(toggleSwitch9_Click);
  121. toggleSwitch8.Click += new EventHandler(toggleSwitch8_Click);
  122. toggleSwitch7.Click += new EventHandler(toggleSwitch7_Click);
  123. toggleSwitch6.Click += new EventHandler(toggleSwitch6_Click);
  124. toggleSwitch5.Click += new EventHandler(toggleSwitch5_Click);
  125. toggleSwitch4.Click += new EventHandler(toggleSwitch4_Click);
  126. toggleSwitch1.Click += new EventHandler(toggleSwitch1_Click);
  127. toggleSwitch3.Click += new EventHandler(toggleSwitch3_Click);
  128. toggleSwitch2.Click += new EventHandler(toggleSwitch2_Click);
  129. toggleSwitch27.Click += new EventHandler(toggleSwitch27_Click);
  130. toggleSwitch28.Click += new EventHandler(toggleSwitch28_Click);
  131. toggleSwitch29.Click += new EventHandler(toggleSwitch29_Click);
  132. toggleSwitch30.Click += new EventHandler(toggleSwitch30_Click);
  133. toggleSwitch22.Click += new EventHandler(toggleSwitch22_Click);
  134. toggleSwitch20.Click += new EventHandler(toggleSwitch20_Click);
  135. toggleSwitch21.Click += new EventHandler(toggleSwitch21_Click);
  136. toggleSwitch23.Click += new EventHandler(toggleSwitch23_Click);
  137. toggleSwitch24.Click += new EventHandler(toggleSwitch24_Click);
  138. toggleSwitch25.Click += new EventHandler(toggleSwitch25_Click);
  139. toggleSwitch26.Click += new EventHandler(toggleSwitch26_Click);
  140. toggleSwitch17.Click += new EventHandler(toggleSwitch17_Click);
  141. toggleSwitch16.Click += new EventHandler(toggleSwitch16_Click);
  142. toggleSwitch15.Click += new EventHandler(toggleSwitch15_Click);
  143. toggleSwitch14.Click += new EventHandler(toggleSwitch14_Click);
  144. toggleSwitch13.Click += new EventHandler(toggleSwitch13_Click);
  145. toggleSwitch31.Click += new EventHandler(toggleSwitch31_Click);
  146. toggleSwitch18.Click += new EventHandler(toggleSwitch18_Click);
  147. toggleSwitch19.Click += new EventHandler(toggleSwitch19_Click);
  148. toggleSwitch32.Click += new EventHandler(toggleSwitch32_Click);
  149. toggleSwitch33.Click += new EventHandler(ToggleSwitch33_Click);
  150. toggleSwitch34.Click += new EventHandler(ToggleSwitch34_Click);
  151. toggleSwitch35.Click += new EventHandler(ToggleSwitch35_Click);
  152. toggleSwitch36.Click += new EventHandler(ToggleSwitch36_Click);
  153. }
  154. private void ToggleSwitch36_Click(object sender, EventArgs e)
  155. {
  156. if (!toggleSwitch36.Checked)
  157. {
  158. Optimize.DisableSmartScreen();
  159. }
  160. else
  161. {
  162. Optimize.EnableSmartScreen();
  163. }
  164. Options.CurrentOptions.DisableSmartScreen = !toggleSwitch36.Checked;
  165. }
  166. private void ToggleSwitch35_Click(object sender, EventArgs e)
  167. {
  168. if (!toggleSwitch35.Checked)
  169. {
  170. Optimize.DisableForcedFeatureUpdates();
  171. }
  172. else
  173. {
  174. Optimize.EnableForcedFeatureUpdates();
  175. }
  176. Options.CurrentOptions.DisableFeatureUpdates = !toggleSwitch35.Checked;
  177. }
  178. private void ToggleSwitch34_Click(object sender, EventArgs e)
  179. {
  180. if (!toggleSwitch34.Checked)
  181. {
  182. Optimize.DisableInsiderService();
  183. }
  184. else
  185. {
  186. Optimize.EnableInsiderService();
  187. }
  188. Options.CurrentOptions.DisableInsiderService = !toggleSwitch34.Checked;
  189. }
  190. private void ToggleSwitch33_Click(object sender, EventArgs e)
  191. {
  192. if (!toggleSwitch33.Checked)
  193. {
  194. Optimize.DisableFaxService();
  195. }
  196. else
  197. {
  198. Optimize.EnableFaxService();
  199. }
  200. Options.CurrentOptions.DisableFaxService = !toggleSwitch33.Checked;
  201. }
  202. private void LoadSettings()
  203. {
  204. switch (Options.CurrentOptions.Color)
  205. {
  206. case Theme.Caramel:
  207. radioCaramel.Checked = true;
  208. break;
  209. case Theme.Lime:
  210. radioLime.Checked = true;
  211. break;
  212. case Theme.Magma:
  213. radioMagma.Checked = true;
  214. break;
  215. case Theme.Minimal:
  216. radioMinimal.Checked = true;
  217. break;
  218. case Theme.Ocean:
  219. radioOcean.Checked = true;
  220. break;
  221. case Theme.Zerg:
  222. radioZerg.Checked = true;
  223. break;
  224. }
  225. }
  226. public MainForm()
  227. {
  228. InitializeComponent();
  229. EnableToggleEvents();
  230. CheckForIllegalCrossThreadCalls = false;
  231. Options.ApplyTheme(this);
  232. ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
  233. if (Utilities.CurrentWindowsVersion == WindowsVersion.Unsupported)
  234. {
  235. tabCollection.TabPages.Remove(universalTab);
  236. tabCollection.TabPages.Remove(windowsVIIITab);
  237. tabCollection.TabPages.Remove(windowsXTab);
  238. tabCollection.TabPages.Remove(modernAppsTab);
  239. }
  240. if (Utilities.CurrentWindowsVersion == WindowsVersion.Windows7)
  241. {
  242. LoadUniversalToggleStates();
  243. tabCollection.TabPages.Remove(windowsVIIITab);
  244. tabCollection.TabPages.Remove(windowsXTab);
  245. tabCollection.TabPages.Remove(modernAppsTab);
  246. }
  247. if (Utilities.CurrentWindowsVersion == WindowsVersion.Windows8)
  248. {
  249. LoadUniversalToggleStates();
  250. LoadWindowsVIIIToggleStates();
  251. tabCollection.TabPages.Remove(windowsXTab);
  252. GetModernApps();
  253. }
  254. if (Utilities.CurrentWindowsVersion == WindowsVersion.Windows10)
  255. {
  256. LoadUniversalToggleStates();
  257. LoadWindowsXToggleStates();
  258. tabCollection.TabPages.Remove(windowsVIIITab);
  259. GetModernApps();
  260. }
  261. _columnSorter = new ListViewColumnSorter();
  262. listStartupItems.ListViewItemSorter = _columnSorter;
  263. integratorTimer.Start();
  264. runDialogTime.Start();
  265. GetStartupItems();
  266. GetHostsEntries();
  267. GetDesktopItems();
  268. GetCustomCommands();
  269. LoadSettings();
  270. radioProgram.Checked = true;
  271. radioTop.Checked = true;
  272. txtVersion.Text = "Version: " + Program.GetCurrentVersionTostring();
  273. Program.MainForm = this;
  274. txtOS.Text = "Microsoft " + Utilities.GetOS();
  275. txtBitness.Text = Utilities.GetBitness();
  276. }
  277. private void CleanPC()
  278. {
  279. try
  280. {
  281. if (checkTemp.Checked)
  282. {
  283. CleanHelper.CleanTemporaries();
  284. }
  285. if (checkUTorrent.Checked)
  286. {
  287. CleanHelper.CleanUTorrent();
  288. }
  289. if (checkFileZilla.Checked)
  290. {
  291. CleanHelper.CleanFileZilla();
  292. }
  293. if (checkMiniDumps.Checked)
  294. {
  295. CleanHelper.CleanMiniDumps();
  296. }
  297. if (checkPrefetch.Checked)
  298. {
  299. CleanHelper.CleanPrefetch();
  300. }
  301. if (checkMediaCache.Checked)
  302. {
  303. CleanHelper.CleanMediaPlayersCache();
  304. }
  305. if (checkLogs.Checked)
  306. {
  307. CleanHelper.CleanLogs();
  308. }
  309. if (checkErrorReports.Checked)
  310. {
  311. CleanHelper.CleanErrorReports();
  312. }
  313. if (checkBin.Checked)
  314. {
  315. CleanHelper.EmptyRecycleBin();
  316. }
  317. }
  318. catch { }
  319. finally
  320. {
  321. CleaningAnimation(false);
  322. }
  323. }
  324. private void CleaningAnimation(bool start)
  325. {
  326. if (start)
  327. {
  328. Utilities.SetControlPropertyThreadSafe(cleaningpanel, "Visible", true);
  329. Utilities.SetControlPropertyThreadSafe(progress2, "Visible", true);
  330. Utilities.SetControlPropertyThreadSafe(progress2, "Style", ProgressBarStyle.Marquee);
  331. Utilities.SetControlPropertyThreadSafe(progress2, "MarqueeAnimationSpeed", 1);
  332. Utilities.SetControlPropertyThreadSafe(label4, "Visible", true);
  333. Utilities.SetControlPropertyThreadSafe(button20, "Enabled", false);
  334. Utilities.SetControlPropertyThreadSafe(panel1, "Enabled", false);
  335. }
  336. else
  337. {
  338. Utilities.SetControlPropertyThreadSafe(cleaningpanel, "Visible", false);
  339. Utilities.SetControlPropertyThreadSafe(progress2, "Visible", false);
  340. Utilities.SetControlPropertyThreadSafe(progress2, "Value", 0);
  341. Utilities.SetControlPropertyThreadSafe(progress2, "Style", ProgressBarStyle.Blocks);
  342. Utilities.SetControlPropertyThreadSafe(progress2, "MarqueeAnimationSpeed", 1);
  343. Utilities.SetControlPropertyThreadSafe(label4, "Visible", false);
  344. Utilities.SetControlPropertyThreadSafe(button20, "Enabled", true);
  345. Utilities.SetControlPropertyThreadSafe(panel1, "Enabled", true);
  346. }
  347. }
  348. private bool FixRegistry()
  349. {
  350. bool changeDetected = false;
  351. try
  352. {
  353. if (checkFirewall.Checked)
  354. {
  355. Utilities.EnableFirewall();
  356. changeDetected = true;
  357. }
  358. if (checkCommandPrompt.Checked)
  359. {
  360. Utilities.EnableCommandPrompt();
  361. changeDetected = true;
  362. }
  363. if (checkControlPanel.Checked)
  364. {
  365. Utilities.EnableControlPanel();
  366. changeDetected = true;
  367. }
  368. if (checkFolderOptions.Checked)
  369. {
  370. Utilities.EnableFolderOptions();
  371. changeDetected = true;
  372. }
  373. if (checkRunDialog.Checked)
  374. {
  375. Utilities.EnableRunDialog();
  376. changeDetected = true;
  377. }
  378. if (checkContextMenu.Checked)
  379. {
  380. Utilities.EnableContextMenu();
  381. changeDetected = true;
  382. }
  383. if (checkTaskManager.Checked)
  384. {
  385. Utilities.EnableTaskManager();
  386. changeDetected = true;
  387. }
  388. if (checkRegistryEditor.Checked)
  389. {
  390. Utilities.EnableRegistryEditor();
  391. changeDetected = true;
  392. }
  393. }
  394. catch { }
  395. return changeDetected;
  396. }
  397. private void LoadUniversalToggleStates()
  398. {
  399. toggleSwitch1.Checked = Options.CurrentOptions.EnablePerformanceTweaks;
  400. toggleSwitch2.Checked = Options.CurrentOptions.DisableNetworkThrottling;
  401. toggleSwitch3.Checked = Options.CurrentOptions.DisableWindowsDefender;
  402. toggleSwitch4.Checked = Options.CurrentOptions.DisableSystemRestore;
  403. toggleSwitch5.Checked = Options.CurrentOptions.DisablePrintService;
  404. toggleSwitch6.Checked = Options.CurrentOptions.DisableMediaPlayerSharing;
  405. toggleSwitch7.Checked = Options.CurrentOptions.BlockSkypeAds;
  406. toggleSwitch8.Checked = Options.CurrentOptions.DisableErrorReporting;
  407. toggleSwitch9.Checked = Options.CurrentOptions.DisableHomeGroup;
  408. toggleSwitch10.Checked = Options.CurrentOptions.DisableSuperfetch;
  409. toggleSwitch11.Checked = Options.CurrentOptions.DisableTelemetryTasks;
  410. toggleSwitch12.Checked = Options.CurrentOptions.DisableOffice2016Telemetry;
  411. toggleSwitch32.Checked = Options.CurrentOptions.DisableCompatibilityAssistant;
  412. toggleSwitch33.Checked = Options.CurrentOptions.DisableFaxService;
  413. toggleSwitch36.Checked = Options.CurrentOptions.DisableSmartScreen;
  414. }
  415. private void LoadWindowsVIIIToggleStates()
  416. {
  417. toggleSwitch31.Checked = Options.CurrentOptions.DisableOneDrive;
  418. }
  419. private void LoadWindowsXToggleStates()
  420. {
  421. toggleSwitch13.Checked = Options.CurrentOptions.EnableLegacyVolumeSlider;
  422. toggleSwitch14.Checked = Options.CurrentOptions.UninstallOneDrive;
  423. toggleSwitch15.Checked = Options.CurrentOptions.DisableGameBar;
  424. toggleSwitch16.Checked = Options.CurrentOptions.DisableCortana;
  425. toggleSwitch17.Checked = Options.CurrentOptions.DisableXboxLive;
  426. toggleSwitch18.Checked = Options.CurrentOptions.DisableQuickAccessHistory;
  427. toggleSwitch19.Checked = Options.CurrentOptions.EnableTaskbarColor;
  428. toggleSwitch20.Checked = Options.CurrentOptions.DisableSensorServices;
  429. toggleSwitch21.Checked = Options.CurrentOptions.DisablePrivacyOptions;
  430. toggleSwitch22.Checked = Options.CurrentOptions.DisableSilentAppInstall;
  431. toggleSwitch23.Checked = Options.CurrentOptions.DisableTelemetryServices;
  432. toggleSwitch24.Checked = Options.CurrentOptions.DisableAutomaticUpdates;
  433. toggleSwitch25.Checked = Options.CurrentOptions.DisableMyPeople;
  434. toggleSwitch26.Checked = Options.CurrentOptions.DisableStartMenuAds;
  435. toggleSwitch27.Checked = Options.CurrentOptions.EnableDarkTheme;
  436. toggleSwitch28.Checked = Options.CurrentOptions.DisableSpellingTyping;
  437. toggleSwitch29.Checked = Options.CurrentOptions.DisableWindowsInk;
  438. toggleSwitch30.Checked = Options.CurrentOptions.ExcludeDrivers;
  439. toggleSwitch34.Checked = Options.CurrentOptions.DisableInsiderService;
  440. toggleSwitch35.Checked = Options.CurrentOptions.DisableFeatureUpdates;
  441. }
  442. private void Main_Load(object sender, EventArgs e)
  443. {
  444. }
  445. private void GetDesktopItems()
  446. {
  447. _desktopItems = Integrator.GetDesktopItems();
  448. listDesktopItems.Items.Clear();
  449. for (int i = 0; i < _desktopItems.Count; i++)
  450. {
  451. if (!string.IsNullOrEmpty(_desktopItems[i]))
  452. {
  453. listDesktopItems.Items.Add(_desktopItems[i]);
  454. }
  455. }
  456. }
  457. private void GetHostsEntries()
  458. {
  459. _hostsEntries = HostsHelper.GetHostsEntries();
  460. listHostEntries.Items.Clear();
  461. for (int i = 0; i < _hostsEntries.Count; i++)
  462. {
  463. if (!string.IsNullOrEmpty(_hostsEntries[i]))
  464. {
  465. listHostEntries.Items.Add(_hostsEntries[i]);
  466. }
  467. }
  468. chkReadOnly.Checked = HostsHelper.GetReadOnly();
  469. button47.Enabled = !chkReadOnly.Checked;
  470. button46.Enabled = !chkReadOnly.Checked;
  471. button42.Enabled = !chkReadOnly.Checked;
  472. button41.Enabled = !chkReadOnly.Checked;
  473. linkLabel4.Enabled = !chkReadOnly.Checked;
  474. chkBlock.Enabled = !chkReadOnly.Checked;
  475. txtDomain.Enabled = !chkReadOnly.Checked;
  476. txtIP.Enabled = !chkReadOnly.Checked;
  477. }
  478. private void GetStartupItems()
  479. {
  480. _startUpItems = Utilities.GetStartupItems();
  481. listStartupItems.Items.Clear();
  482. for (int i = 0; i < _startUpItems.Count; i++)
  483. {
  484. ListViewItem list = new ListViewItem(_startUpItems[i].Name);
  485. list.SubItems.Add(_startUpItems[i].FileLocation);
  486. list.SubItems.Add(_startUpItems[i].ToString());
  487. listStartupItems.Items.Add(list);
  488. }
  489. }
  490. private void GetModernApps()
  491. {
  492. button74.Enabled = false;
  493. button75.Enabled = false;
  494. listModernApps.Enabled = false;
  495. listModernApps.Items.Clear();
  496. _modernApps = Utilities.GetModernApps();
  497. foreach (string x in _modernApps)
  498. {
  499. listModernApps.Items.Add(x);
  500. }
  501. button74.Enabled = true;
  502. button75.Enabled = true;
  503. listModernApps.Enabled = true;
  504. }
  505. private async void UninstallModernApps()
  506. {
  507. string selectedApps = string.Empty;
  508. if (listModernApps.CheckedItems.Count > 0)
  509. {
  510. foreach (string x in listModernApps.CheckedItems)
  511. {
  512. if (string.IsNullOrEmpty(selectedApps))
  513. {
  514. selectedApps = x;
  515. }
  516. else
  517. {
  518. selectedApps += Environment.NewLine + x;
  519. }
  520. }
  521. if (MessageBox.Show(_removeModernAppsMessage + "\n\n" + selectedApps, "Optimizer", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  522. {
  523. button74.Enabled = false;
  524. button75.Enabled = false;
  525. listModernApps.Enabled = false;
  526. bool errorOccured = false;
  527. string failedApps = string.Empty;
  528. foreach (string app in listModernApps.CheckedItems)
  529. {
  530. await Task.Run(() => errorOccured = Utilities.UninstallModernApp(app));
  531. if (errorOccured)
  532. {
  533. failedApps += Environment.NewLine + app;
  534. }
  535. }
  536. if (!string.IsNullOrEmpty(failedApps))
  537. {
  538. MessageBox.Show(_errorModernAppsMessage + failedApps, "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
  539. }
  540. GetModernApps();
  541. }
  542. }
  543. }
  544. private void GetCustomCommands()
  545. {
  546. _customCommands = Integrator.GetCustomCommands();
  547. listCustomCommands.Items.Clear();
  548. foreach (string s in _customCommands)
  549. {
  550. listCustomCommands.Items.Add(s);
  551. }
  552. }
  553. private void Main_FormClosing(object sender, EventArgs e)
  554. {
  555. Options.SaveSettings();
  556. }
  557. private void button39_Click(object sender, EventArgs e)
  558. {
  559. HelperForm f = new HelperForm(this, MessageType.Restart, _restartMessage);
  560. f.ShowDialog();
  561. }
  562. private void button43_Click(object sender, EventArgs e)
  563. {
  564. HelperForm f = new HelperForm(this, MessageType.Restart, _restartMessage);
  565. f.ShowDialog();
  566. }
  567. private void button44_Click(object sender, EventArgs e)
  568. {
  569. HelperForm f = new HelperForm(this, MessageType.Restart, _restartMessage);
  570. f.ShowDialog();
  571. }
  572. private void button45_Click(object sender, EventArgs e)
  573. {
  574. HelperForm f = new HelperForm(this, MessageType.Restart, _restartMessage);
  575. f.ShowDialog();
  576. }
  577. private void button18_Click(object sender, EventArgs e)
  578. {
  579. EdgeForm f = new EdgeForm();
  580. f.ShowDialog();
  581. }
  582. private void checkSelectAll_CheckedChanged(object sender, EventArgs e)
  583. {
  584. checkTemp.Checked = checkSelectAll.Checked;
  585. checkUTorrent.Checked = checkSelectAll.Checked;
  586. checkFileZilla.Checked = checkSelectAll.Checked;
  587. checkMiniDumps.Checked = checkSelectAll.Checked;
  588. checkPrefetch.Checked = checkSelectAll.Checked;
  589. checkMediaCache.Checked = checkSelectAll.Checked;
  590. checkLogs.Checked = checkSelectAll.Checked;
  591. checkBin.Checked = checkSelectAll.Checked;
  592. checkErrorReports.Checked = checkSelectAll.Checked;
  593. }
  594. private void button20_Click(object sender, EventArgs e)
  595. {
  596. CleaningAnimation(true);
  597. Task t = new Task(() => CleanPC());
  598. t.Start();
  599. }
  600. private void button32_Click(object sender, EventArgs e)
  601. {
  602. if (listStartupItems.SelectedItems.Count == 1)
  603. {
  604. _startUpItems[listStartupItems.SelectedIndices[0]].Remove();
  605. GetStartupItems();
  606. }
  607. }
  608. internal void RemoveAllStartupItems()
  609. {
  610. foreach (ListViewItem i in listStartupItems.Items)
  611. {
  612. _startUpItems[i.Index].Remove();
  613. }
  614. GetStartupItems();
  615. }
  616. private void button22_Click(object sender, EventArgs e)
  617. {
  618. if (listStartupItems.Items.Count > 0)
  619. {
  620. HelperForm r = new HelperForm(this, MessageType.Startup, _removeStartupItemsMessage);
  621. r.ShowDialog(this);
  622. }
  623. }
  624. private void button31_Click(object sender, EventArgs e)
  625. {
  626. if (listStartupItems.SelectedItems.Count == 1)
  627. {
  628. _startUpItems[listStartupItems.SelectedIndices[0]].LocateFile();
  629. }
  630. }
  631. private void checkEnableAll_CheckedChanged(object sender, EventArgs e)
  632. {
  633. checkTaskManager.Checked = checkEnableAll.Checked;
  634. checkCommandPrompt.Checked = checkEnableAll.Checked;
  635. checkControlPanel.Checked = checkEnableAll.Checked;
  636. checkFolderOptions.Checked = checkEnableAll.Checked;
  637. checkRunDialog.Checked = checkEnableAll.Checked;
  638. checkContextMenu.Checked = checkEnableAll.Checked;
  639. checkFirewall.Checked = checkEnableAll.Checked;
  640. checkRegistryEditor.Checked = checkEnableAll.Checked;
  641. }
  642. private void button33_Click(object sender, EventArgs e)
  643. {
  644. bool flag = FixRegistry();
  645. if (flag)
  646. {
  647. panel2.Enabled = false;
  648. button33.Enabled = false;
  649. if (checkRestartExplorer.Checked)
  650. {
  651. Utilities.RestartExplorer();
  652. }
  653. panel2.Enabled = true;
  654. button33.Enabled = true;
  655. }
  656. }
  657. private void pictureBox1_Click(object sender, EventArgs e)
  658. {
  659. AboutForm f = new AboutForm();
  660. f.ShowDialog(this);
  661. }
  662. private void button37_Click(object sender, EventArgs e)
  663. {
  664. GetStartupItems();
  665. }
  666. private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  667. {
  668. HostsHelper.LocateHosts();
  669. }
  670. private void linkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  671. {
  672. HostsEditorForm f = new HostsEditorForm();
  673. f.ShowDialog(this);
  674. GetHostsEntries();
  675. }
  676. private void linkLabel4_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  677. {
  678. HostsHelper.RestoreDefaultHosts();
  679. GetHostsEntries();
  680. }
  681. private void button47_Click(object sender, EventArgs e)
  682. {
  683. if ((txtIP.Text != string.Empty) && (txtDomain.Text != string.Empty))
  684. {
  685. string ip = txtIP.Text.Trim();
  686. string domain = txtDomain.Text.Trim();
  687. string recommendedDomain = string.Empty;
  688. if (!domain.StartsWith("www."))
  689. {
  690. recommendedDomain = "www." + domain;
  691. }
  692. else
  693. {
  694. recommendedDomain = domain.Replace("www.", string.Empty);
  695. }
  696. HostsHelper.AddEntry(HostsHelper.SanitizeEntry(ip) + " " + HostsHelper.SanitizeEntry(domain));
  697. if (!string.IsNullOrEmpty(recommendedDomain))
  698. {
  699. HostsHelper.AddEntry(HostsHelper.SanitizeEntry(ip) + " " + HostsHelper.SanitizeEntry(recommendedDomain));
  700. }
  701. GetHostsEntries();
  702. txtIP.Clear();
  703. txtDomain.Clear();
  704. chkBlock.Checked = false;
  705. }
  706. }
  707. private void button41_Click(object sender, EventArgs e)
  708. {
  709. GetHostsEntries();
  710. }
  711. private void button42_Click(object sender, EventArgs e)
  712. {
  713. if (listHostEntries.SelectedItems.Count == 1)
  714. {
  715. HostsHelper.RemoveEntry(listHostEntries.SelectedItem.ToString().Replace(" : ", " "));
  716. GetHostsEntries();
  717. }
  718. }
  719. private void button46_Click(object sender, EventArgs e)
  720. {
  721. if (listHostEntries.Items.Count > 0)
  722. {
  723. HelperForm r = new HelperForm(this, MessageType.Hosts, _removeHostsEntriesMessage);
  724. r.ShowDialog(this);
  725. }
  726. }
  727. internal void RemoveAllHostsEntries()
  728. {
  729. List<string> collection = new List<string>();
  730. foreach (string item in listHostEntries.Items)
  731. {
  732. collection.Add(item.Replace(" : ", " "));
  733. }
  734. HostsHelper.RemoveAllEntries(collection);
  735. GetHostsEntries();
  736. }
  737. private void aio_SelectedIndexChanged(object sender, EventArgs e)
  738. {
  739. if (tabCollection.SelectedTab == hostsEditorTab)
  740. {
  741. txtIP.Focus();
  742. }
  743. }
  744. private void button48_Click(object sender, EventArgs e)
  745. {
  746. defineCommandDialog.ShowDialog();
  747. }
  748. private void button50_Click(object sender, EventArgs e)
  749. {
  750. if ((txtRunFile.Text != string.Empty) && (txtRunKeyword.Text != string.Empty))
  751. {
  752. Integrator.CreateCustomCommand(txtRunFile.Text, txtRunKeyword.Text);
  753. txtRunFile.Clear();
  754. txtRunKeyword.Clear();
  755. GetCustomCommands();
  756. }
  757. }
  758. private void DefineCmd_FileOk(object sender, CancelEventArgs e)
  759. {
  760. txtRunFile.Text = defineCommandDialog.FileName;
  761. txtRunKeyword.Text = Path.GetFileNameWithoutExtension(txtRunFile.Text).ToLower();
  762. }
  763. private void button58_Click(object sender, EventArgs e)
  764. {
  765. InfoForm r = new InfoForm(Integrator.powerinfo);
  766. r.ShowDialog(this);
  767. }
  768. private void button56_Click(object sender, EventArgs e)
  769. {
  770. InfoForm r = new InfoForm(Integrator.systemtoolsinfo);
  771. r.ShowDialog(this);
  772. }
  773. private void button52_Click(object sender, EventArgs e)
  774. {
  775. InfoForm r = new InfoForm(Integrator.windowsappsinfo);
  776. r.ShowDialog(this);
  777. }
  778. private void button49_Click(object sender, EventArgs e)
  779. {
  780. InfoForm r = new InfoForm(Integrator.systemshortcutsinfo);
  781. r.ShowDialog(this);
  782. }
  783. private void button55_Click(object sender, EventArgs e)
  784. {
  785. InfoForm r = new InfoForm(Integrator.desktopshortcutsinfo);
  786. r.ShowDialog(this);
  787. }
  788. private void button59_Click(object sender, EventArgs e)
  789. {
  790. Utilities.ImportRegistryScript(Required.ReadyMadeMenusFolder + "\\PowerMenu.reg");
  791. GetDesktopItems();
  792. }
  793. private void button53_Click(object sender, EventArgs e)
  794. {
  795. Utilities.ImportRegistryScript(Required.ReadyMadeMenusFolder + "\\SystemTools.reg");
  796. GetDesktopItems();
  797. }
  798. private void button54_Click(object sender, EventArgs e)
  799. {
  800. Utilities.ImportRegistryScript(Required.ReadyMadeMenusFolder + "\\WindowsApps.reg");
  801. GetDesktopItems();
  802. }
  803. private void button51_Click(object sender, EventArgs e)
  804. {
  805. Utilities.ImportRegistryScript(Required.ReadyMadeMenusFolder + "\\SystemShortcuts.reg");
  806. GetDesktopItems();
  807. }
  808. private void button57_Click(object sender, EventArgs e)
  809. {
  810. Utilities.ImportRegistryScript(Required.ReadyMadeMenusFolder + "\\DesktopShortcuts.reg");
  811. GetDesktopItems();
  812. }
  813. private void button60_Click(object sender, EventArgs e)
  814. {
  815. GetDesktopItems();
  816. }
  817. private void button61_Click(object sender, EventArgs e)
  818. {
  819. if (listDesktopItems.SelectedItems.Count == 1)
  820. {
  821. Integrator.RemoveItem(listDesktopItems.SelectedItem.ToString());
  822. GetDesktopItems();
  823. }
  824. }
  825. internal void RemoveAllDesktopItems()
  826. {
  827. List<string> collection = new List<string>();
  828. foreach (string item in listDesktopItems.Items)
  829. {
  830. collection.Add(item);
  831. }
  832. Integrator.RemoveAllItems(collection);
  833. GetDesktopItems();
  834. }
  835. private void button62_Click(object sender, EventArgs e)
  836. {
  837. if (listDesktopItems.Items.Count > 0)
  838. {
  839. HelperForm r = new HelperForm(this, MessageType.Integrator, _removeDesktopItemsMessage);
  840. r.ShowDialog(this);
  841. }
  842. }
  843. private void radioProgram_CheckedChanged(object sender, EventArgs e)
  844. {
  845. if (radioProgram.Checked)
  846. {
  847. btnBrowseItem.Enabled = true;
  848. txtItem.Clear();
  849. checkDefaultIcon.Checked = true;
  850. txtIcon.Enabled = false;
  851. btnBrowseIcon.Enabled = false;
  852. itemtoaddgroup.Text = "Program to add:";
  853. checkDefaultIcon.Visible = true;
  854. checkDefaultIcon.Text = "Use program's icon";
  855. txtItemName.Clear();
  856. txtItem.ReadOnly = true;
  857. txtIcon.ReadOnly = true;
  858. _desktopItemType = DesktopItemType.Program;
  859. }
  860. }
  861. private void radioFolder_CheckedChanged(object sender, EventArgs e)
  862. {
  863. if (radioFolder.Checked)
  864. {
  865. checkDefaultIcon.Checked = true;
  866. btnBrowseItem.Enabled = true;
  867. txtItem.Clear();
  868. itemtoaddgroup.Text = "Folder to add:";
  869. checkDefaultIcon.Text = "Use default folder icon";
  870. txtItemName.Clear();
  871. txtItem.ReadOnly = true;
  872. txtIcon.ReadOnly = true;
  873. _desktopItemType = DesktopItemType.Folder;
  874. }
  875. }
  876. private void radioLink_CheckedChanged(object sender, EventArgs e)
  877. {
  878. if (radioLink.Checked)
  879. {
  880. checkDefaultIcon.Checked = true;
  881. checkDefaultIcon.Text = "Download website icon (favicon)";
  882. btnBrowseItem.Enabled = false;
  883. itemtoaddgroup.Text = "Web address to add:";
  884. checkDefaultIcon.Visible = true;
  885. txtItem.Text = "http://";
  886. txtItemName.Clear();
  887. txtItem.ReadOnly = false;
  888. txtIcon.ReadOnly = true;
  889. _desktopItemType = DesktopItemType.Link;
  890. }
  891. }
  892. private void radioFile_CheckedChanged(object sender, EventArgs e)
  893. {
  894. if (radioFile.Checked)
  895. {
  896. checkDefaultIcon.Checked = true;
  897. checkDefaultIcon.Text = "No icon";
  898. btnBrowseItem.Enabled = true;
  899. itemtoaddgroup.Text = "File to add:";
  900. checkDefaultIcon.Visible = true;
  901. txtItem.Clear();
  902. txtItemName.Clear();
  903. txtItem.ReadOnly = true;
  904. txtIcon.ReadOnly = true;
  905. _desktopItemType = DesktopItemType.File;
  906. }
  907. }
  908. private void radioCommand_CheckedChanged(object sender, EventArgs e)
  909. {
  910. if (radioCommand.Checked)
  911. {
  912. btnBrowseItem.Enabled = false;
  913. txtItem.Clear();
  914. checkDefaultIcon.Checked = true;
  915. txtIcon.Enabled = false;
  916. btnBrowseIcon.Enabled = false;
  917. itemtoaddgroup.Text = "Command to add:";
  918. checkDefaultIcon.Visible = true;
  919. checkDefaultIcon.Text = "No icon";
  920. txtItemName.Clear();
  921. txtItem.ReadOnly = false;
  922. txtIcon.ReadOnly = true;
  923. _desktopItemType = DesktopItemType.Command;
  924. }
  925. }
  926. private void checkDefaultIcon_CheckedChanged(object sender, EventArgs e)
  927. {
  928. if (checkDefaultIcon.Checked)
  929. {
  930. txtIcon.Clear();
  931. txtIcon.Enabled = false;
  932. btnBrowseIcon.Enabled = false;
  933. }
  934. else
  935. {
  936. txtIcon.Clear();
  937. txtIcon.Enabled = true;
  938. btnBrowseIcon.Enabled = true;
  939. }
  940. }
  941. private void btnBrowseItem_Click(object sender, EventArgs e)
  942. {
  943. switch (_desktopItemType)
  944. {
  945. case DesktopItemType.Program:
  946. defineProgramDialog.ShowDialog();
  947. break;
  948. case DesktopItemType.Folder:
  949. defineFolderDialog.ShowDialog();
  950. txtItem.Text = defineFolderDialog.SelectedPath;
  951. int i = defineFolderDialog.SelectedPath.LastIndexOf("\\");
  952. txtItemName.Text = defineFolderDialog.SelectedPath.Remove(0, i + 1);
  953. break;
  954. case DesktopItemType.File:
  955. defineFileDialog.ShowDialog();
  956. break;
  957. }
  958. }
  959. private void DefineProgramDialog_FileOk(object sender, CancelEventArgs e)
  960. {
  961. txtItem.Text = defineProgramDialog.FileName;
  962. txtItemName.Text = defineProgramDialog.SafeFileName.Replace(".exe", string.Empty);
  963. }
  964. private void DefineFileDialog_FileOk(object sender, CancelEventArgs e)
  965. {
  966. txtItem.Text = defineFileDialog.FileName;
  967. txtItemName.Text = defineFileDialog.SafeFileName;
  968. }
  969. private void btnBrowseIcon_Click(object sender, EventArgs e)
  970. {
  971. switch (_desktopItemType)
  972. {
  973. case DesktopItemType.Program:
  974. DefineProgramIconDialog.ShowDialog();
  975. break;
  976. case DesktopItemType.Folder:
  977. DefineFolderIconDialog.ShowDialog();
  978. break;
  979. case DesktopItemType.Link:
  980. DefineURLIconDialog.ShowDialog();
  981. break;
  982. case DesktopItemType.File:
  983. DefineFileIconDialog.ShowDialog();
  984. break;
  985. case DesktopItemType.Command:
  986. DefineCommandIconDialog.ShowDialog();
  987. break;
  988. }
  989. }
  990. private void DefineProgramIconDialog_FileOk(object sender, CancelEventArgs e)
  991. {
  992. txtIcon.Text = DefineProgramIconDialog.FileName;
  993. if (txtIcon.Text.Contains(".exe"))
  994. {
  995. string iconpath = Integrator.ExtractIconFromExecutable(txtItemName.Text, DefineProgramIconDialog.FileName);
  996. txtIcon.Text = iconpath;
  997. }
  998. }
  999. private void DefineFolderIconDialog_FileOk(object sender, CancelEventArgs e)
  1000. {
  1001. txtIcon.Text = DefineFolderIconDialog.FileName;
  1002. if (txtIcon.Text.Contains(".exe"))
  1003. {
  1004. string iconpath = Integrator.ExtractIconFromExecutable(txtItemName.Text, DefineFolderIconDialog.FileName);
  1005. txtIcon.Text = iconpath;
  1006. }
  1007. }
  1008. private void DefineURLIconDialog_FileOk(object sender, CancelEventArgs e)
  1009. {
  1010. txtIcon.Text = DefineURLIconDialog.FileName;
  1011. if (txtIcon.Text.Contains(".exe"))
  1012. {
  1013. string iconpath = Integrator.ExtractIconFromExecutable(txtItemName.Text, DefineURLIconDialog.FileName);
  1014. txtIcon.Text = iconpath;
  1015. }
  1016. }
  1017. private void DefineFileIconDialog_FileOk(object sender, CancelEventArgs e)
  1018. {
  1019. txtIcon.Text = DefineFileIconDialog.FileName;
  1020. if (txtIcon.Text.Contains(".exe"))
  1021. {
  1022. string iconpath = Integrator.ExtractIconFromExecutable(txtItemName.Text, DefineFileIconDialog.FileName);
  1023. txtIcon.Text = iconpath;
  1024. }
  1025. }
  1026. private void DefineCommandIconDialog_FileOk(object sender, CancelEventArgs e)
  1027. {
  1028. txtIcon.Text = DefineCommandIconDialog.FileName;
  1029. if (txtIcon.Text.Contains(".exe"))
  1030. {
  1031. string iconpath = Integrator.ExtractIconFromExecutable(txtItemName.Text, DefineCommandIconDialog.FileName);
  1032. txtIcon.Text = iconpath;
  1033. }
  1034. }
  1035. private void btnAddItem_Click(object sender, EventArgs e)
  1036. {
  1037. string icon = string.Empty;
  1038. switch (_desktopItemType)
  1039. {
  1040. case DesktopItemType.Program:
  1041. if (checkDefaultIcon.Checked)
  1042. {
  1043. icon = txtItem.Text;
  1044. }
  1045. else
  1046. {
  1047. icon = txtIcon.Text;
  1048. }
  1049. Integrator.AddItem(txtItemName.Text, txtItem.Text, icon, _desktopItemPosition, checkShift.Checked, DesktopItemType.Program);
  1050. break;
  1051. case DesktopItemType.Folder:
  1052. if (checkDefaultIcon.Checked)
  1053. {
  1054. icon = Integrator.FolderDefaultIcon;
  1055. }
  1056. else
  1057. {
  1058. icon = txtIcon.Text;
  1059. }
  1060. Integrator.AddItem(txtItemName.Text, txtItem.Text, icon, _desktopItemPosition, checkShift.Checked, DesktopItemType.Folder);
  1061. break;
  1062. case DesktopItemType.Link:
  1063. if (checkDefaultIcon.Checked)
  1064. {
  1065. icon = Integrator.DownloadFavicon(txtItem.Text, txtItemName.Text);
  1066. }
  1067. else
  1068. {
  1069. icon = txtIcon.Text;
  1070. }
  1071. Integrator.AddItem(txtItemName.Text, txtItem.Text, icon, _desktopItemPosition, checkShift.Checked, DesktopItemType.Link);
  1072. break;
  1073. case DesktopItemType.File:
  1074. if (!checkDefaultIcon.Checked)
  1075. {
  1076. icon = txtIcon.Text;
  1077. }
  1078. Integrator.AddItem(txtItemName.Text, txtItem.Text, icon, _desktopItemPosition, checkShift.Checked, DesktopItemType.File);
  1079. break;
  1080. case DesktopItemType.Command:
  1081. if (!checkDefaultIcon.Checked)
  1082. {
  1083. icon = txtIcon.Text;
  1084. }
  1085. Integrator.AddItem(txtItemName.Text, txtItem.Text, icon, _desktopItemPosition, checkShift.Checked, DesktopItemType.Command);
  1086. break;
  1087. }
  1088. GetDesktopItems();
  1089. ResetIntegratorForm();
  1090. }
  1091. private void integratorTimer_Tick(object sender, EventArgs e)
  1092. {
  1093. if ((txtItem.Text != "") && (txtItemName.Text != "") && (txtIcon.Text != "") && (!checkDefaultIcon.Checked))
  1094. {
  1095. btnAddItem.Enabled = true;
  1096. }
  1097. else if ((txtItem.Text != "") && (txtItemName.Text != "") && (checkDefaultIcon.Checked))
  1098. {
  1099. btnAddItem.Enabled = true;
  1100. }
  1101. else
  1102. {
  1103. btnAddItem.Enabled = false;
  1104. }
  1105. }
  1106. private void runDialogTimer_Tick(object sender, EventArgs e)
  1107. {
  1108. if ((txtRunFile.Text != "") && (txtRunKeyword.Text != ""))
  1109. {
  1110. btnCreateCustomCommand.Enabled = true;
  1111. }
  1112. else
  1113. {
  1114. btnCreateCustomCommand.Enabled = false;
  1115. }
  1116. }
  1117. private void radioTop_CheckedChanged(object sender, EventArgs e)
  1118. {
  1119. if (radioTop.Checked)
  1120. {
  1121. _desktopItemPosition = DesktopTypePosition.Top;
  1122. }
  1123. }
  1124. private void radioMiddle_CheckedChanged(object sender, EventArgs e)
  1125. {
  1126. if (radioMiddle.Checked)
  1127. {
  1128. _desktopItemPosition = DesktopTypePosition.Middle;
  1129. }
  1130. }
  1131. private void radioBottom_CheckedChanged(object sender, EventArgs e)
  1132. {
  1133. if (radioBottom.Checked)
  1134. {
  1135. _desktopItemPosition = DesktopTypePosition.Bottom;
  1136. }
  1137. }
  1138. private void ResetIntegratorForm()
  1139. {
  1140. txtItem.Clear();
  1141. txtIcon.Clear();
  1142. checkDefaultIcon.Checked = true;
  1143. txtItemName.Clear();
  1144. if (radioLink.Checked)
  1145. {
  1146. txtItem.Text = "http://";
  1147. }
  1148. }
  1149. private void radioOcean_CheckedChanged(object sender, EventArgs e)
  1150. {
  1151. Options.CurrentOptions.Color = Theme.Ocean;
  1152. Options.ApplyTheme(this);
  1153. }
  1154. private void radioMagma_CheckedChanged(object sender, EventArgs e)
  1155. {
  1156. Options.CurrentOptions.Color = Theme.Magma;
  1157. Options.ApplyTheme(this);
  1158. }
  1159. private void radioZerg_CheckedChanged(object sender, EventArgs e)
  1160. {
  1161. Options.CurrentOptions.Color = Theme.Zerg;
  1162. Options.ApplyTheme(this);
  1163. }
  1164. private void radioMinimal_CheckedChanged(object sender, EventArgs e)
  1165. {
  1166. Options.CurrentOptions.Color = Theme.Minimal;
  1167. Options.ApplyTheme(this);
  1168. }
  1169. private void radioCaramel_CheckedChanged(object sender, EventArgs e)
  1170. {
  1171. Options.CurrentOptions.Color = Theme.Caramel;
  1172. Options.ApplyTheme(this);
  1173. }
  1174. private void radioLime_CheckedChanged(object sender, EventArgs e)
  1175. {
  1176. Options.CurrentOptions.Color = Theme.Lime;
  1177. Options.ApplyTheme(this);
  1178. }
  1179. private void button64_Click(object sender, EventArgs e)
  1180. {
  1181. if (listStartupItems.SelectedItems.Count == 1)
  1182. {
  1183. _startUpItems[listStartupItems.SelectedIndices[0]].LocateKey();
  1184. }
  1185. }
  1186. private void button66_Click(object sender, EventArgs e)
  1187. {
  1188. Integrator.TakeOwnership(false);
  1189. }
  1190. private void button65_Click(object sender, EventArgs e)
  1191. {
  1192. Integrator.TakeOwnership(true);
  1193. }
  1194. private void listStartupItems_ColumnClick(object sender, ColumnClickEventArgs e)
  1195. {
  1196. if (e.Column == _columnSorter.CurrentColumn)
  1197. {
  1198. if (_columnSorter.SortOrder == SortOrder.Ascending)
  1199. {
  1200. _columnSorter.SortOrder = SortOrder.Descending;
  1201. }
  1202. else
  1203. {
  1204. _columnSorter.SortOrder = SortOrder.Ascending;
  1205. }
  1206. }
  1207. else
  1208. {
  1209. _columnSorter.CurrentColumn = e.Column;
  1210. _columnSorter.SortOrder = SortOrder.Ascending;
  1211. }
  1212. listStartupItems.Sort();
  1213. }
  1214. private void chkBlock_CheckedChanged(object sender, EventArgs e)
  1215. {
  1216. if (chkBlock.Checked)
  1217. {
  1218. txtIP.Text = _blockedIP;
  1219. txtIP.Enabled = false;
  1220. }
  1221. else
  1222. {
  1223. txtIP.Clear();
  1224. txtIP.Enabled = true;
  1225. }
  1226. }
  1227. private void button8_Click(object sender, EventArgs e)
  1228. {
  1229. GetCustomCommands();
  1230. }
  1231. private void button26_Click(object sender, EventArgs e)
  1232. {
  1233. if (listCustomCommands.SelectedItems.Count == 1)
  1234. {
  1235. Integrator.DeleteCustomCommand(listCustomCommands.SelectedItem.ToString());
  1236. GetCustomCommands();
  1237. }
  1238. }
  1239. private void button75_Click(object sender, EventArgs e)
  1240. {
  1241. GetModernApps();
  1242. }
  1243. private void button74_Click(object sender, EventArgs e)
  1244. {
  1245. UninstallModernApps();
  1246. }
  1247. private void chkSelectAllModernApps_CheckedChanged(object sender, EventArgs e)
  1248. {
  1249. for (int i = 0; i < listModernApps.Items.Count; i++)
  1250. {
  1251. listModernApps.SetItemChecked(i, chkSelectAllModernApps.Checked);
  1252. }
  1253. }
  1254. private void btnResetConfig_Click(object sender, EventArgs e)
  1255. {
  1256. if (MessageBox.Show(_resetMessage, "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  1257. {
  1258. Utilities.ResetConfiguration();
  1259. }
  1260. }
  1261. private void toggleSwitch1_Click(object sender, EventArgs e)
  1262. {
  1263. if (!toggleSwitch1.Checked)
  1264. {
  1265. Optimize.EnablePerformanceTweaks();
  1266. }
  1267. else
  1268. {
  1269. Optimize.DisablePerformanceTweaks();
  1270. }
  1271. Options.CurrentOptions.EnablePerformanceTweaks = !toggleSwitch1.Checked;
  1272. }
  1273. private void toggleSwitch2_Click(object sender, EventArgs e)
  1274. {
  1275. if (!toggleSwitch2.Checked)
  1276. {
  1277. Optimize.DisableNetworkThrottling();
  1278. }
  1279. else
  1280. {
  1281. Optimize.EnableNetworkThrottling();
  1282. }
  1283. Options.CurrentOptions.DisableNetworkThrottling = !toggleSwitch2.Checked;
  1284. }
  1285. private void toggleSwitch3_Click(object sender, EventArgs e)
  1286. {
  1287. if (!toggleSwitch3.Checked)
  1288. {
  1289. Optimize.DisableDefender();
  1290. }
  1291. else
  1292. {
  1293. Optimize.EnableDefender();
  1294. }
  1295. Options.CurrentOptions.DisableWindowsDefender = !toggleSwitch3.Checked;
  1296. }
  1297. private void toggleSwitch4_Click(object sender, EventArgs e)
  1298. {
  1299. if (!toggleSwitch4.Checked)
  1300. {
  1301. Optimize.DisableSystemRestore();
  1302. }
  1303. else
  1304. {
  1305. Optimize.EnableSystemRestore();
  1306. }
  1307. Options.CurrentOptions.DisableSystemRestore = !toggleSwitch4.Checked;
  1308. }
  1309. private void toggleSwitch5_Click(object sender, EventArgs e)
  1310. {
  1311. if (!toggleSwitch5.Checked)
  1312. {
  1313. Optimize.DisablePrintService();
  1314. }
  1315. else
  1316. {
  1317. Optimize.EnablePrintService();
  1318. }
  1319. Options.CurrentOptions.DisablePrintService = !toggleSwitch5.Checked;
  1320. }
  1321. private void toggleSwitch6_Click(object sender, EventArgs e)
  1322. {
  1323. if (!toggleSwitch6.Checked)
  1324. {
  1325. Optimize.DisableMediaPlayerSharing();
  1326. }
  1327. else
  1328. {
  1329. Optimize.EnableMediaPlayerSharing();
  1330. }
  1331. Options.CurrentOptions.DisableMediaPlayerSharing = !toggleSwitch6.Checked;
  1332. }
  1333. private void toggleSwitch7_Click(object sender, EventArgs e)
  1334. {
  1335. if (!toggleSwitch7.Checked)
  1336. {
  1337. Optimize.DisableSkypeAds();
  1338. }
  1339. else
  1340. {
  1341. Optimize.EnableSkypeAds();
  1342. }
  1343. Options.CurrentOptions.BlockSkypeAds = !toggleSwitch7.Checked;
  1344. }
  1345. private void toggleSwitch8_Click(object sender, EventArgs e)
  1346. {
  1347. if (!toggleSwitch8.Checked)
  1348. {
  1349. Optimize.DisableErrorReporting();
  1350. }
  1351. else
  1352. {
  1353. Optimize.EnableErrorReporting();
  1354. }
  1355. Options.CurrentOptions.DisableErrorReporting = !toggleSwitch8.Checked;
  1356. }
  1357. private void toggleSwitch9_Click(object sender, EventArgs e)
  1358. {
  1359. if (!toggleSwitch9.Checked)
  1360. {
  1361. Optimize.DisableHomeGroup();
  1362. }
  1363. else
  1364. {
  1365. Optimize.EnableHomeGroup();
  1366. }
  1367. Options.CurrentOptions.DisableHomeGroup = !toggleSwitch9.Checked;
  1368. }
  1369. private void toggleSwitch10_Click(object sender, EventArgs e)
  1370. {
  1371. if (!toggleSwitch10.Checked)
  1372. {
  1373. Optimize.DisableSuperfetch();
  1374. }
  1375. else
  1376. {
  1377. Optimize.EnableSuperfetch();
  1378. }
  1379. Options.CurrentOptions.DisableSuperfetch = !toggleSwitch10.Checked;
  1380. }
  1381. private void toggleSwitch11_Click(object sender, EventArgs e)
  1382. {
  1383. if (!toggleSwitch11.Checked)
  1384. {
  1385. Optimize.DisableTelemetryTasks();
  1386. }
  1387. else
  1388. {
  1389. Optimize.EnableTelemetryTasks();
  1390. }
  1391. Options.CurrentOptions.DisableTelemetryTasks = !toggleSwitch11.Checked;
  1392. }
  1393. private void toggleSwitch12_Click(object sender, EventArgs e)
  1394. {
  1395. if (!toggleSwitch12.Checked)
  1396. {
  1397. Optimize.DisableOffice2016Telemetry();
  1398. }
  1399. else
  1400. {
  1401. Optimize.EnableOffice2016Telemetry();
  1402. }
  1403. Options.CurrentOptions.DisableOffice2016Telemetry = !toggleSwitch12.Checked;
  1404. }
  1405. private void toggleSwitch13_Click(object sender, EventArgs e)
  1406. {
  1407. if (!toggleSwitch13.Checked)
  1408. {
  1409. Optimize.EnableLegacyVolumeSlider();
  1410. }
  1411. else
  1412. {
  1413. Optimize.DisableLegacyVolumeSlider();
  1414. }
  1415. Options.CurrentOptions.EnableLegacyVolumeSlider = !toggleSwitch13.Checked;
  1416. }
  1417. private void toggleSwitch19_Click(object sender, EventArgs e)
  1418. {
  1419. if (!toggleSwitch19.Checked)
  1420. {
  1421. Optimize.EnableTaskbarColor();
  1422. }
  1423. else
  1424. {
  1425. Optimize.DisableTaskbarColor();
  1426. }
  1427. Options.CurrentOptions.EnableTaskbarColor = !toggleSwitch19.Checked;
  1428. }
  1429. private void toggleSwitch18_Click(object sender, EventArgs e)
  1430. {
  1431. if (!toggleSwitch18.Checked)
  1432. {
  1433. Optimize.DisableQuickAccessHistory();
  1434. }
  1435. else
  1436. {
  1437. Optimize.EnableQuickAccessHistory();
  1438. }
  1439. Options.CurrentOptions.DisableQuickAccessHistory = !toggleSwitch18.Checked;
  1440. }
  1441. private void toggleSwitch26_Click(object sender, EventArgs e)
  1442. {
  1443. if (!toggleSwitch26.Checked)
  1444. {
  1445. Optimize.DisableStartMenuAds();
  1446. }
  1447. else
  1448. {
  1449. Optimize.EnableStartMenuAds();
  1450. }
  1451. Options.CurrentOptions.DisableStartMenuAds = !toggleSwitch26.Checked;
  1452. }
  1453. private void toggleSwitch27_Click(object sender, EventArgs e)
  1454. {
  1455. if (!toggleSwitch27.Checked)
  1456. {
  1457. Optimize.EnableDarkTheme();
  1458. }
  1459. else
  1460. {
  1461. Optimize.EnableLightTheme();
  1462. }
  1463. Options.CurrentOptions.EnableDarkTheme = !toggleSwitch27.Checked;
  1464. }
  1465. private void toggleSwitch14_Click(object sender, EventArgs e)
  1466. {
  1467. if (!toggleSwitch14.Checked)
  1468. {
  1469. Task t = new Task(() => Optimize.UninstallOneDrive());
  1470. t.Start();
  1471. }
  1472. else
  1473. {
  1474. Task t = new Task(() => Optimize.InstallOneDrive());
  1475. t.Start();
  1476. }
  1477. Options.CurrentOptions.UninstallOneDrive = !toggleSwitch14.Checked;
  1478. }
  1479. private void toggleSwitch25_Click(object sender, EventArgs e)
  1480. {
  1481. if (!toggleSwitch25.Checked)
  1482. {
  1483. Optimize.DisableMyPeople();
  1484. }
  1485. else
  1486. {
  1487. Optimize.EnableMyPeople();
  1488. }
  1489. Options.CurrentOptions.DisableMyPeople = !toggleSwitch25.Checked;
  1490. }
  1491. private void toggleSwitch24_Click(object sender, EventArgs e)
  1492. {
  1493. if (!toggleSwitch24.Checked)
  1494. {
  1495. Optimize.DisableAutomaticUpdates();
  1496. }
  1497. else
  1498. {
  1499. Optimize.EnableAutomaticUpdates();
  1500. }
  1501. Options.CurrentOptions.DisableAutomaticUpdates = !toggleSwitch24.Checked;
  1502. }
  1503. private void toggleSwitch30_Click(object sender, EventArgs e)
  1504. {
  1505. if (!toggleSwitch30.Checked)
  1506. {
  1507. Optimize.ExcludeDrivers();
  1508. }
  1509. else
  1510. {
  1511. Optimize.IncludeDrivers();
  1512. }
  1513. Options.CurrentOptions.ExcludeDrivers = !toggleSwitch30.Checked;
  1514. }
  1515. private void toggleSwitch23_Click(object sender, EventArgs e)
  1516. {
  1517. if (!toggleSwitch23.Checked)
  1518. {
  1519. Optimize.DisableTelemetryServices();
  1520. }
  1521. else
  1522. {
  1523. Optimize.EnableTelemetryServices();
  1524. }
  1525. Options.CurrentOptions.DisableTelemetryServices = !toggleSwitch23.Checked;
  1526. }
  1527. private void toggleSwitch21_Click(object sender, EventArgs e)
  1528. {
  1529. if (!toggleSwitch21.Checked)
  1530. {
  1531. Optimize.DisablePrivacyOptions();
  1532. }
  1533. else
  1534. {
  1535. Optimize.EnablePrivacyOptions();
  1536. }
  1537. Options.CurrentOptions.DisablePrivacyOptions = !toggleSwitch21.Checked;
  1538. }
  1539. private void toggleSwitch22_Click(object sender, EventArgs e)
  1540. {
  1541. if (!toggleSwitch22.Checked)
  1542. {
  1543. Optimize.DisableSilentAppInstall();
  1544. }
  1545. else
  1546. {
  1547. Optimize.EnableSilentAppInstall();
  1548. }
  1549. Options.CurrentOptions.DisableSilentAppInstall = !toggleSwitch22.Checked;
  1550. }
  1551. private void toggleSwitch16_Click(object sender, EventArgs e)
  1552. {
  1553. if (!toggleSwitch16.Checked)
  1554. {
  1555. Optimize.DisableCortana();
  1556. }
  1557. else
  1558. {
  1559. Optimize.EnableCortana();
  1560. }
  1561. Options.CurrentOptions.DisableCortana = !toggleSwitch16.Checked;
  1562. }
  1563. private void toggleSwitch20_Click(object sender, EventArgs e)
  1564. {
  1565. if (!toggleSwitch20.Checked)
  1566. {
  1567. Optimize.DisableSensorServices();
  1568. }
  1569. else
  1570. {
  1571. Optimize.EnableSensorServices();
  1572. }
  1573. Options.CurrentOptions.DisableSensorServices = !toggleSwitch20.Checked;
  1574. }
  1575. private void toggleSwitch29_Click(object sender, EventArgs e)
  1576. {
  1577. if (!toggleSwitch29.Checked)
  1578. {
  1579. Optimize.DisableWindowsInk();
  1580. }
  1581. else
  1582. {
  1583. Optimize.EnableWindowsInk();
  1584. }
  1585. Options.CurrentOptions.DisableWindowsInk = !toggleSwitch29.Checked;
  1586. }
  1587. private void toggleSwitch28_Click(object sender, EventArgs e)
  1588. {
  1589. if (!toggleSwitch28.Checked)
  1590. {
  1591. Optimize.DisableSpellingAndTypingFeatures();
  1592. }
  1593. else
  1594. {
  1595. Optimize.EnableSpellingAndTypingFeatures();
  1596. }
  1597. Options.CurrentOptions.DisableSpellingTyping = !toggleSwitch28.Checked;
  1598. }
  1599. private void toggleSwitch17_Click(object sender, EventArgs e)
  1600. {
  1601. if (!toggleSwitch17.Checked)
  1602. {
  1603. Optimize.DisableXboxLive();
  1604. }
  1605. else
  1606. {
  1607. Optimize.EnableXboxLive();
  1608. }
  1609. Options.CurrentOptions.DisableXboxLive = !toggleSwitch17.Checked;
  1610. }
  1611. private void toggleSwitch15_Click(object sender, EventArgs e)
  1612. {
  1613. if (!toggleSwitch15.Checked)
  1614. {
  1615. Optimize.DisableGameBar();
  1616. }
  1617. else
  1618. {
  1619. Optimize.EnableGameBar();
  1620. }
  1621. Options.CurrentOptions.DisableGameBar = !toggleSwitch15.Checked;
  1622. }
  1623. private void toggleSwitch31_Click(object sender, EventArgs e)
  1624. {
  1625. if (!toggleSwitch31.Checked)
  1626. {
  1627. Optimize.DisableOneDrive();
  1628. }
  1629. else
  1630. {
  1631. Optimize.EnableOneDrive();
  1632. }
  1633. Options.CurrentOptions.DisableOneDrive = !toggleSwitch31.Checked;
  1634. }
  1635. private void toggleSwitch32_Click(object sender, EventArgs e)
  1636. {
  1637. if (!toggleSwitch32.Checked)
  1638. {
  1639. Optimize.DisableCompatibilityAssistant();
  1640. }
  1641. else
  1642. {
  1643. Optimize.EnableCompatibilityAssistant();
  1644. }
  1645. Options.CurrentOptions.DisableCompatibilityAssistant = !toggleSwitch32.Checked;
  1646. }
  1647. private void btnUpdate_Click(object sender, EventArgs e)
  1648. {
  1649. CheckForUpdate();
  1650. }
  1651. private void btnChangelog_Click(object sender, EventArgs e)
  1652. {
  1653. try
  1654. {
  1655. Process.Start(_changelogLink);
  1656. }
  1657. catch (Exception ex)
  1658. {
  1659. MessageBox.Show(ex.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1660. }
  1661. }
  1662. private void chkReadOnly_CheckedChanged(object sender, EventArgs e)
  1663. {
  1664. HostsHelper.ReadOnly(chkReadOnly.Checked);
  1665. button47.Enabled = !chkReadOnly.Checked;
  1666. button46.Enabled = !chkReadOnly.Checked;
  1667. button42.Enabled = !chkReadOnly.Checked;
  1668. button41.Enabled = !chkReadOnly.Checked;
  1669. linkLabel4.Enabled = !chkReadOnly.Checked;
  1670. chkBlock.Enabled = !chkReadOnly.Checked;
  1671. txtDomain.Enabled = !chkReadOnly.Checked;
  1672. txtIP.Enabled = !chkReadOnly.Checked;
  1673. txtIP.Focus();
  1674. }
  1675. }
  1676. }