MainForm.cs 88 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows.Forms;
  7. using System.IO;
  8. using System.Reflection;
  9. using System.Diagnostics;
  10. using System.Net;
  11. using System.Threading;
  12. using System.Linq;
  13. using System.Drawing;
  14. using Timer = System.Windows.Forms.Timer;
  15. using Newtonsoft.Json;
  16. using System.Net.NetworkInformation;
  17. namespace Optimizer
  18. {
  19. public partial class MainForm : Form
  20. {
  21. ListViewColumnSorter _columnSorter;
  22. List<StartupItem> _startUpItems = new List<StartupItem>();
  23. List<string> _hostsEntries = new List<string>();
  24. List<string> _customCommands = new List<string>();
  25. List<string> _desktopItems = new List<string>();
  26. List<string> _modernApps = new List<string>();
  27. bool _trayMenu = false;
  28. List<PingReply> _pingResults;
  29. string _shodanIP = string.Empty;
  30. PingReply tmpReply;
  31. DesktopItemType _desktopItemType = DesktopItemType.Program;
  32. DesktopTypePosition _desktopItemPosition = DesktopTypePosition.Top;
  33. public List<FeedApp> AppsFromFeed = new List<FeedApp>();
  34. readonly string _feedLink = "https://raw.githubusercontent.com/hellzerg/optimizer/master/feed.json";
  35. readonly string _latestVersionLink = "https://raw.githubusercontent.com/hellzerg/optimizer/master/version.txt";
  36. readonly string _changelogLink = "https://github.com/hellzerg/optimizer/blob/master/CHANGELOG.md";
  37. readonly string _noNewVersionMessage = "You already have the latest version!";
  38. readonly string _betaVersionMessage = "You are using an experimental version!";
  39. readonly string _blockedIP = "0.0.0.0";
  40. readonly string _restartMessage = "Restart to apply changes?";
  41. readonly string _removeStartupItemsMessage = "Are you sure you want to delete all startup items?";
  42. readonly string _removeHostsEntriesMessage = "Are you sure you want to delete all hosts entries?";
  43. readonly string _removeDesktopItemsMessage = "Are you sure you want to delete all desktop items?";
  44. readonly string _removeModernAppsMessage = "Are you sure you want to uninstall the following app(s)?";
  45. readonly string _errorModernAppsMessage = "The following app(s) couldn't be uninstalled:\n";
  46. 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!";
  47. private string NewVersionMessage(string latestVersion)
  48. {
  49. 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());
  50. }
  51. private string NewDownloadLink(string latestVersion)
  52. {
  53. return string.Format("https://github.com/hellzerg/optimizer/releases/download/{0}/Optimizer-{0}.exe", latestVersion);
  54. }
  55. private void CheckForUpdate()
  56. {
  57. WebClient client = new WebClient
  58. {
  59. Encoding = Encoding.UTF8
  60. };
  61. string latestVersion = string.Empty;
  62. try
  63. {
  64. latestVersion = client.DownloadString(_latestVersionLink);
  65. }
  66. catch (Exception ex)
  67. {
  68. ErrorLogger.LogError("MainForm.CheckForUpdate", ex.Message, ex.StackTrace);
  69. MessageBox.Show(ex.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
  70. }
  71. if (!string.IsNullOrEmpty(latestVersion))
  72. {
  73. if (float.Parse(latestVersion) > Program.GetCurrentVersion())
  74. {
  75. if (MessageBox.Show(NewVersionMessage(latestVersion), "Update available", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  76. {
  77. // PATCHING PROCESS
  78. try
  79. {
  80. Assembly currentAssembly = Assembly.GetEntryAssembly();
  81. if (currentAssembly == null)
  82. {
  83. currentAssembly = Assembly.GetCallingAssembly();
  84. }
  85. string appFolder = Path.GetDirectoryName(currentAssembly.Location);
  86. string appName = Path.GetFileNameWithoutExtension(currentAssembly.Location);
  87. string appExtension = Path.GetExtension(currentAssembly.Location);
  88. string archiveFile = Path.Combine(appFolder, appName + "_old" + appExtension);
  89. string appFile = Path.Combine(appFolder, appName + appExtension);
  90. string tempFile = Path.Combine(appFolder, appName + "_tmp" + appExtension);
  91. // DOWNLOAD NEW VERSION
  92. client.DownloadFile(NewDownloadLink(latestVersion), tempFile);
  93. // DELETE PREVIOUS BACK-UP
  94. if (File.Exists(archiveFile))
  95. {
  96. File.Delete(archiveFile);
  97. }
  98. // MAKE BACK-UP
  99. File.Move(appFile, archiveFile);
  100. // PATCH
  101. File.Move(tempFile, appFile);
  102. Application.Restart();
  103. }
  104. catch (Exception ex)
  105. {
  106. ErrorLogger.LogError("MainForm.CheckForUpdate", ex.Message, ex.StackTrace);
  107. MessageBox.Show(ex.Message);
  108. }
  109. }
  110. }
  111. else if (float.Parse(latestVersion) == Program.GetCurrentVersion())
  112. {
  113. MessageBox.Show(_noNewVersionMessage, "No update available", MessageBoxButtons.OK, MessageBoxIcon.Information);
  114. }
  115. else
  116. {
  117. MessageBox.Show(_betaVersionMessage, "BETA channel enabled", MessageBoxButtons.OK, MessageBoxIcon.Information);
  118. }
  119. }
  120. }
  121. private void EnableToggleEvents()
  122. {
  123. toggleSwitch7.Click += new EventHandler(ToggleSwitch7_Click);
  124. toggleSwitch12.Click += new EventHandler(toggleSwitch12_Click);
  125. toggleSwitch11.Click += new EventHandler(toggleSwitch11_Click);
  126. toggleSwitch10.Click += new EventHandler(toggleSwitch10_Click);
  127. toggleSwitch9.Click += new EventHandler(toggleSwitch9_Click);
  128. toggleSwitch8.Click += new EventHandler(toggleSwitch8_Click);
  129. toggleSwitch6.Click += new EventHandler(toggleSwitch6_Click);
  130. toggleSwitch5.Click += new EventHandler(toggleSwitch5_Click);
  131. toggleSwitch4.Click += new EventHandler(toggleSwitch4_Click);
  132. toggleSwitch1.Click += new EventHandler(toggleSwitch1_Click);
  133. toggleSwitch3.Click += new EventHandler(toggleSwitch3_Click);
  134. toggleSwitch2.Click += new EventHandler(toggleSwitch2_Click);
  135. toggleSwitch27.Click += new EventHandler(toggleSwitch27_Click);
  136. toggleSwitch28.Click += new EventHandler(toggleSwitch28_Click);
  137. toggleSwitch29.Click += new EventHandler(toggleSwitch29_Click);
  138. toggleSwitch30.Click += new EventHandler(toggleSwitch30_Click);
  139. toggleSwitch20.Click += new EventHandler(toggleSwitch20_Click);
  140. toggleSwitch21.Click += new EventHandler(toggleSwitch21_Click);
  141. toggleSwitch23.Click += new EventHandler(toggleSwitch23_Click);
  142. toggleSwitch24.Click += new EventHandler(toggleSwitch24_Click);
  143. toggleSwitch25.Click += new EventHandler(toggleSwitch25_Click);
  144. toggleSwitch26.Click += new EventHandler(toggleSwitch26_Click);
  145. toggleSwitch17.Click += new EventHandler(toggleSwitch17_Click);
  146. toggleSwitch16.Click += new EventHandler(toggleSwitch16_Click);
  147. toggleSwitch15.Click += new EventHandler(toggleSwitch15_Click);
  148. toggleSwitch14.Click += new EventHandler(toggleSwitch14_Click);
  149. toggleSwitch13.Click += new EventHandler(toggleSwitch13_Click);
  150. toggleSwitch31.Click += new EventHandler(toggleSwitch31_Click);
  151. toggleSwitch18.Click += new EventHandler(toggleSwitch18_Click);
  152. toggleSwitch19.Click += new EventHandler(toggleSwitch19_Click);
  153. toggleSwitch32.Click += new EventHandler(toggleSwitch32_Click);
  154. toggleSwitch33.Click += new EventHandler(ToggleSwitch33_Click);
  155. toggleSwitch34.Click += new EventHandler(ToggleSwitch34_Click);
  156. toggleSwitch35.Click += new EventHandler(ToggleSwitch35_Click);
  157. toggleSwitch36.Click += new EventHandler(ToggleSwitch36_Click);
  158. toggleSwitch37.Click += new EventHandler(ToggleSwitch37_Click);
  159. toggleSwitch38.Click += new EventHandler(ToggleSwitch38_Click);
  160. toggleSwitch39.Click += new EventHandler(ToggleSwitch39_Click);
  161. toggleSwitch40.Click += new EventHandler(ToggleSwitch40_Click);
  162. }
  163. private void ToggleSwitch7_Click(object sender, EventArgs e)
  164. {
  165. if (!toggleSwitch7.Checked)
  166. {
  167. Optimize.DisableActionCenter();
  168. }
  169. else
  170. {
  171. Optimize.EnableActionCenter();
  172. }
  173. Options.CurrentOptions.DisableActionCenter = !toggleSwitch7.Checked;
  174. }
  175. private void ToggleSwitch40_Click(object sender, EventArgs e)
  176. {
  177. if (!toggleSwitch40.Checked)
  178. {
  179. Optimize.RemoveCastToDevice();
  180. }
  181. else
  182. {
  183. Optimize.AddCastToDevice();
  184. }
  185. Options.CurrentOptions.RemoveCastToDevice = !toggleSwitch40.Checked;
  186. }
  187. private void ToggleSwitch39_Click(object sender, EventArgs e)
  188. {
  189. if (!toggleSwitch39.Checked)
  190. {
  191. Optimize.EnableLongPaths();
  192. }
  193. else
  194. {
  195. Optimize.DisableLongPaths();
  196. }
  197. Options.CurrentOptions.EnableLongPaths = !toggleSwitch39.Checked;
  198. }
  199. private void ToggleSwitch38_Click(object sender, EventArgs e)
  200. {
  201. if (!toggleSwitch38.Checked)
  202. {
  203. Optimize.DisableStickyKeys();
  204. }
  205. else
  206. {
  207. Optimize.EnableStickyKeys();
  208. }
  209. Options.CurrentOptions.DisableStickyKeys = !toggleSwitch38.Checked;
  210. }
  211. private void ToggleSwitch37_Click(object sender, EventArgs e)
  212. {
  213. if (!toggleSwitch37.Checked)
  214. {
  215. Optimize.DisableCloudClipboard();
  216. }
  217. else
  218. {
  219. Optimize.EnableCloudClipboard();
  220. }
  221. Options.CurrentOptions.DisableCloudClipboard = !toggleSwitch37.Checked;
  222. }
  223. private void ToggleSwitch36_Click(object sender, EventArgs e)
  224. {
  225. if (!toggleSwitch36.Checked)
  226. {
  227. Optimize.DisableSmartScreen();
  228. }
  229. else
  230. {
  231. Optimize.EnableSmartScreen();
  232. }
  233. Options.CurrentOptions.DisableSmartScreen = !toggleSwitch36.Checked;
  234. }
  235. private void ToggleSwitch35_Click(object sender, EventArgs e)
  236. {
  237. if (!toggleSwitch35.Checked)
  238. {
  239. Optimize.DisableForcedFeatureUpdates();
  240. }
  241. else
  242. {
  243. Optimize.EnableForcedFeatureUpdates();
  244. }
  245. Options.CurrentOptions.DisableFeatureUpdates = !toggleSwitch35.Checked;
  246. }
  247. private void ToggleSwitch34_Click(object sender, EventArgs e)
  248. {
  249. if (!toggleSwitch34.Checked)
  250. {
  251. Optimize.DisableInsiderService();
  252. }
  253. else
  254. {
  255. Optimize.EnableInsiderService();
  256. }
  257. Options.CurrentOptions.DisableInsiderService = !toggleSwitch34.Checked;
  258. }
  259. private void ToggleSwitch33_Click(object sender, EventArgs e)
  260. {
  261. if (!toggleSwitch33.Checked)
  262. {
  263. Optimize.DisableFaxService();
  264. }
  265. else
  266. {
  267. Optimize.EnableFaxService();
  268. }
  269. Options.CurrentOptions.DisableFaxService = !toggleSwitch33.Checked;
  270. }
  271. private void LoadSettings()
  272. {
  273. switch (Options.CurrentOptions.Color)
  274. {
  275. case Theme.Caramel:
  276. radioCaramel.Checked = true;
  277. break;
  278. case Theme.Lime:
  279. radioLime.Checked = true;
  280. break;
  281. case Theme.Magma:
  282. radioMagma.Checked = true;
  283. break;
  284. case Theme.Minimal:
  285. radioMinimal.Checked = true;
  286. break;
  287. case Theme.Ocean:
  288. radioOcean.Checked = true;
  289. break;
  290. case Theme.Zerg:
  291. radioZerg.Checked = true;
  292. break;
  293. }
  294. }
  295. public MainForm()
  296. {
  297. InitializeComponent();
  298. EnableToggleEvents();
  299. CheckForIllegalCrossThreadCalls = false;
  300. Options.ApplyTheme(this);
  301. _trayMenu = Options.CurrentOptions.EnableTray;
  302. quickAccessToggle.Checked = Options.CurrentOptions.EnableTray;
  303. launcherIcon.Visible = Options.CurrentOptions.EnableTray;
  304. // fix SSL/TLS error when contacting internet
  305. ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
  306. // initial states
  307. chkOnlyRemovable.Checked = true;
  308. checkDefaultIcon.Checked = true;
  309. radioProgram.Checked = true;
  310. radioTop.Checked = true;
  311. c64.Checked = Environment.Is64BitOperatingSystem;
  312. c32.Checked = !Environment.Is64BitOperatingSystem;
  313. if (Utilities.CurrentWindowsVersion == WindowsVersion.Unsupported)
  314. {
  315. tabCollection.TabPages.Remove(universalTab);
  316. tabCollection.TabPages.Remove(windowsVIIITab);
  317. tabCollection.TabPages.Remove(windowsXTab);
  318. tabCollection.TabPages.Remove(modernAppsTab);
  319. }
  320. if (Utilities.CurrentWindowsVersion == WindowsVersion.Windows7)
  321. {
  322. LoadUniversalToggleStates();
  323. tabCollection.TabPages.Remove(windowsVIIITab);
  324. tabCollection.TabPages.Remove(windowsXTab);
  325. tabCollection.TabPages.Remove(modernAppsTab);
  326. }
  327. if (Utilities.CurrentWindowsVersion == WindowsVersion.Windows8)
  328. {
  329. LoadUniversalToggleStates();
  330. LoadWindowsVIIIToggleStates();
  331. tabCollection.TabPages.Remove(windowsXTab);
  332. GetModernApps(false);
  333. }
  334. if (Utilities.CurrentWindowsVersion == WindowsVersion.Windows10)
  335. {
  336. LoadUniversalToggleStates();
  337. LoadWindowsXToggleStates();
  338. tabCollection.TabPages.Remove(windowsVIIITab);
  339. GetModernApps(false);
  340. }
  341. _columnSorter = new ListViewColumnSorter();
  342. listStartupItems.ListViewItemSorter = _columnSorter;
  343. GetStartupItems();
  344. GetHostsEntries();
  345. integratorTimer.Start();
  346. runDialogTime.Start();
  347. GetDesktopItems();
  348. GetCustomCommands();
  349. LoadSettings();
  350. txtVersion.Text = "Version: " + Program.GetCurrentVersionTostring();
  351. Program.MainForm = this;
  352. txtOS.Text = "Microsoft " + Utilities.GetOS();
  353. txtBitness.Text = Utilities.GetBitness();
  354. if (string.IsNullOrEmpty(Options.CurrentOptions.AppsFolder))
  355. {
  356. txtDownloadFolder.Text = Path.Combine(Application.StartupPath, "Optimizer Downloads");
  357. Options.CurrentOptions.AppsFolder = Path.Combine(Application.StartupPath, "Optimizer Downloads");
  358. Directory.CreateDirectory(Options.CurrentOptions.AppsFolder);
  359. Options.SaveSettings();
  360. }
  361. else
  362. {
  363. if (!Directory.Exists(Options.CurrentOptions.AppsFolder))
  364. {
  365. Directory.CreateDirectory(Options.CurrentOptions.AppsFolder);
  366. }
  367. txtDownloadFolder.Text = Options.CurrentOptions.AppsFolder;
  368. }
  369. GetFeed();
  370. GetFootprint();
  371. launcherMenu.Renderer = new ToolStripRendererMaterial();
  372. }
  373. private void GetFootprint()
  374. {
  375. ByteSize footprint = CleanHelper.CheckFootprint();
  376. lblFootprint.Text = footprint.ToString();
  377. }
  378. private void GetFeed()
  379. {
  380. WebClient client = new WebClient
  381. {
  382. Encoding = Encoding.UTF8
  383. };
  384. try
  385. {
  386. string feed = client.DownloadString(_feedLink);
  387. AppsFromFeed = JsonConvert.DeserializeObject<List<FeedApp>>(feed);
  388. // UI handling
  389. panel1.Visible = true;
  390. panel2.Visible = true;
  391. panel3.Visible = true;
  392. panel4.Visible = true;
  393. panel5.Visible = true;
  394. panel6.Visible = true;
  395. label42.Visible = true;
  396. label44.Visible = true;
  397. txtDownloadFolder.Visible = true;
  398. button5.Visible = true;
  399. button6.Visible = true;
  400. btnDownloadApps.Visible = true;
  401. c32.Visible = true;
  402. c64.Visible = true;
  403. cAutoInstall.Visible = true;
  404. linkLabel1.Visible = false;
  405. progressDownloader.Visible = true;
  406. txtDownloadStatus.Visible = true;
  407. //btnGetFeed.Visible = true;
  408. txtFeedError.Visible = false;
  409. }
  410. catch (Exception ex)
  411. {
  412. panel1.Visible = false;
  413. panel2.Visible = false;
  414. panel3.Visible = false;
  415. panel4.Visible = false;
  416. panel5.Visible = false;
  417. panel6.Visible = false;
  418. label42.Visible = false;
  419. label44.Visible = false;
  420. txtDownloadFolder.Visible = false;
  421. button5.Visible = true;
  422. button6.Visible = false;
  423. btnDownloadApps.Visible = false;
  424. c32.Visible = false;
  425. c64.Visible = false;
  426. cAutoInstall.Visible = false;
  427. linkLabel1.Visible = false;
  428. progressDownloader.Visible = false;
  429. txtDownloadStatus.Visible = false;
  430. //btnGetFeed.Visible = true;
  431. txtFeedError.Visible = true;
  432. ErrorLogger.LogError("MainForm.GetFeed", ex.Message, ex.StackTrace);
  433. }
  434. }
  435. private void CleanPC()
  436. {
  437. try
  438. {
  439. if (checkTemp.Checked)
  440. {
  441. CleanHelper.CleanTemporaries();
  442. }
  443. if (checkFileZilla.Checked)
  444. {
  445. CleanHelper.CleanFileZilla();
  446. }
  447. if (checkMiniDumps.Checked)
  448. {
  449. CleanHelper.CleanMiniDumps();
  450. }
  451. if (checkMediaCache.Checked)
  452. {
  453. CleanHelper.CleanMediaPlayersCache();
  454. }
  455. if (checkLogs.Checked)
  456. {
  457. CleanHelper.CleanLogs();
  458. }
  459. if (checkErrorReports.Checked)
  460. {
  461. CleanHelper.CleanErrorReports();
  462. }
  463. if (checkBin.Checked)
  464. {
  465. CleanHelper.EmptyRecycleBin();
  466. }
  467. }
  468. catch (Exception ex)
  469. {
  470. ErrorLogger.LogError("MainForm.CleanPC", ex.Message, ex.StackTrace);
  471. }
  472. finally
  473. {
  474. CleaningAnimation(false);
  475. GetFootprint();
  476. }
  477. }
  478. private void CleaningAnimation(bool start)
  479. {
  480. if (start)
  481. {
  482. Utilities.SetControlPropertyThreadSafe(cleaningpanel, "Visible", true);
  483. Utilities.SetControlPropertyThreadSafe(progress2, "Visible", true);
  484. Utilities.SetControlPropertyThreadSafe(progress2, "Style", ProgressBarStyle.Marquee);
  485. Utilities.SetControlPropertyThreadSafe(progress2, "MarqueeAnimationSpeed", 1);
  486. Utilities.SetControlPropertyThreadSafe(label4, "Visible", true);
  487. Utilities.SetControlPropertyThreadSafe(button20, "Enabled", false);
  488. Utilities.SetControlPropertyThreadSafe(panel1, "Enabled", false);
  489. }
  490. else
  491. {
  492. Utilities.SetControlPropertyThreadSafe(cleaningpanel, "Visible", false);
  493. Utilities.SetControlPropertyThreadSafe(progress2, "Visible", false);
  494. Utilities.SetControlPropertyThreadSafe(progress2, "Value", 0);
  495. Utilities.SetControlPropertyThreadSafe(progress2, "Style", ProgressBarStyle.Blocks);
  496. Utilities.SetControlPropertyThreadSafe(progress2, "MarqueeAnimationSpeed", 1);
  497. Utilities.SetControlPropertyThreadSafe(label4, "Visible", false);
  498. Utilities.SetControlPropertyThreadSafe(button20, "Enabled", true);
  499. Utilities.SetControlPropertyThreadSafe(panel1, "Enabled", true);
  500. }
  501. }
  502. private bool FixRegistry()
  503. {
  504. bool changeDetected = false;
  505. try
  506. {
  507. if (checkFirewall.Checked)
  508. {
  509. Utilities.EnableFirewall();
  510. changeDetected = true;
  511. }
  512. if (checkCommandPrompt.Checked)
  513. {
  514. Utilities.EnableCommandPrompt();
  515. changeDetected = true;
  516. }
  517. if (checkControlPanel.Checked)
  518. {
  519. Utilities.EnableControlPanel();
  520. changeDetected = true;
  521. }
  522. if (checkFolderOptions.Checked)
  523. {
  524. Utilities.EnableFolderOptions();
  525. changeDetected = true;
  526. }
  527. if (checkRunDialog.Checked)
  528. {
  529. Utilities.EnableRunDialog();
  530. changeDetected = true;
  531. }
  532. if (checkContextMenu.Checked)
  533. {
  534. Utilities.EnableContextMenu();
  535. changeDetected = true;
  536. }
  537. if (checkTaskManager.Checked)
  538. {
  539. Utilities.EnableTaskManager();
  540. changeDetected = true;
  541. }
  542. if (checkRegistryEditor.Checked)
  543. {
  544. Utilities.EnableRegistryEditor();
  545. changeDetected = true;
  546. }
  547. }
  548. catch (Exception ex)
  549. {
  550. ErrorLogger.LogError("MainForm.FixRegistry", ex.Message, ex.StackTrace);
  551. }
  552. return changeDetected;
  553. }
  554. private void LoadUniversalToggleStates()
  555. {
  556. toggleSwitch1.Checked = Options.CurrentOptions.EnablePerformanceTweaks;
  557. toggleSwitch2.Checked = Options.CurrentOptions.DisableNetworkThrottling;
  558. toggleSwitch3.Checked = Options.CurrentOptions.DisableWindowsDefender;
  559. toggleSwitch4.Checked = Options.CurrentOptions.DisableSystemRestore;
  560. toggleSwitch5.Checked = Options.CurrentOptions.DisablePrintService;
  561. toggleSwitch6.Checked = Options.CurrentOptions.DisableMediaPlayerSharing;
  562. toggleSwitch8.Checked = Options.CurrentOptions.DisableErrorReporting;
  563. toggleSwitch9.Checked = Options.CurrentOptions.DisableHomeGroup;
  564. toggleSwitch10.Checked = Options.CurrentOptions.DisableSuperfetch;
  565. toggleSwitch11.Checked = Options.CurrentOptions.DisableTelemetryTasks;
  566. toggleSwitch12.Checked = Options.CurrentOptions.DisableOffice2016Telemetry;
  567. toggleSwitch32.Checked = Options.CurrentOptions.DisableCompatibilityAssistant;
  568. toggleSwitch33.Checked = Options.CurrentOptions.DisableFaxService;
  569. toggleSwitch36.Checked = Options.CurrentOptions.DisableSmartScreen;
  570. toggleSwitch38.Checked = Options.CurrentOptions.DisableStickyKeys;
  571. }
  572. private void LoadWindowsVIIIToggleStates()
  573. {
  574. toggleSwitch31.Checked = Options.CurrentOptions.DisableOneDrive;
  575. }
  576. private void LoadWindowsXToggleStates()
  577. {
  578. toggleSwitch13.Checked = Options.CurrentOptions.EnableLegacyVolumeSlider;
  579. toggleSwitch14.Checked = Options.CurrentOptions.UninstallOneDrive;
  580. toggleSwitch15.Checked = Options.CurrentOptions.DisableGameBar;
  581. toggleSwitch16.Checked = Options.CurrentOptions.DisableCortana;
  582. toggleSwitch17.Checked = Options.CurrentOptions.DisableXboxLive;
  583. toggleSwitch18.Checked = Options.CurrentOptions.DisableQuickAccessHistory;
  584. toggleSwitch19.Checked = Options.CurrentOptions.EnableTaskbarColor;
  585. toggleSwitch20.Checked = Options.CurrentOptions.DisableSensorServices;
  586. toggleSwitch21.Checked = Options.CurrentOptions.DisablePrivacyOptions;
  587. toggleSwitch23.Checked = Options.CurrentOptions.DisableTelemetryServices;
  588. toggleSwitch24.Checked = Options.CurrentOptions.DisableAutomaticUpdates;
  589. toggleSwitch25.Checked = Options.CurrentOptions.DisableMyPeople;
  590. toggleSwitch26.Checked = Options.CurrentOptions.DisableStartMenuAds;
  591. toggleSwitch27.Checked = Options.CurrentOptions.EnableDarkTheme;
  592. toggleSwitch28.Checked = Options.CurrentOptions.DisableSpellingTyping;
  593. toggleSwitch29.Checked = Options.CurrentOptions.DisableWindowsInk;
  594. toggleSwitch30.Checked = Options.CurrentOptions.ExcludeDrivers;
  595. toggleSwitch34.Checked = Options.CurrentOptions.DisableInsiderService;
  596. toggleSwitch35.Checked = Options.CurrentOptions.DisableFeatureUpdates;
  597. toggleSwitch37.Checked = Options.CurrentOptions.DisableCloudClipboard;
  598. toggleSwitch39.Checked = Options.CurrentOptions.EnableLongPaths;
  599. toggleSwitch40.Checked = Options.CurrentOptions.RemoveCastToDevice;
  600. toggleSwitch7.Checked = Options.CurrentOptions.DisableActionCenter;
  601. }
  602. private void Main_Load(object sender, EventArgs e)
  603. {
  604. }
  605. private void GetDesktopItems()
  606. {
  607. _desktopItems = Integrator.GetDesktopItems();
  608. listDesktopItems.Items.Clear();
  609. for (int i = 0; i < _desktopItems.Count; i++)
  610. {
  611. if (!string.IsNullOrEmpty(_desktopItems[i]))
  612. {
  613. listDesktopItems.Items.Add(_desktopItems[i]);
  614. }
  615. }
  616. }
  617. private void GetHostsEntries()
  618. {
  619. ((Control)this.hostsEditorTab).Enabled = false;
  620. _hostsEntries = HostsHelper.GetHostsEntries();
  621. listHostEntries.Items.Clear();
  622. listHostEntries.Items.AddRange(_hostsEntries.ToArray());
  623. chkReadOnly.Checked = HostsHelper.GetReadOnly();
  624. button47.Enabled = !chkReadOnly.Checked;
  625. button46.Enabled = !chkReadOnly.Checked;
  626. button42.Enabled = !chkReadOnly.Checked;
  627. button41.Enabled = !chkReadOnly.Checked;
  628. linkLabel4.Enabled = !chkReadOnly.Checked;
  629. chkBlock.Enabled = !chkReadOnly.Checked;
  630. txtDomain.Enabled = !chkReadOnly.Checked;
  631. txtIP.Enabled = !chkReadOnly.Checked;
  632. button1.Enabled = !chkReadOnly.Checked;
  633. button2.Enabled = !chkReadOnly.Checked;
  634. button3.Enabled = !chkReadOnly.Checked;
  635. button4.Enabled = !chkReadOnly.Checked;
  636. ((Control)this.hostsEditorTab).Enabled = true;
  637. }
  638. private void GetStartupItems()
  639. {
  640. _startUpItems = Utilities.GetStartupItems();
  641. listStartupItems.Items.Clear();
  642. for (int i = 0; i < _startUpItems.Count; i++)
  643. {
  644. ListViewItem list = new ListViewItem(_startUpItems[i].Name);
  645. list.SubItems.Add(_startUpItems[i].FileLocation);
  646. list.SubItems.Add(_startUpItems[i].ToString());
  647. listStartupItems.Items.Add(list);
  648. }
  649. }
  650. private void GetModernApps(bool showAll)
  651. {
  652. button74.Enabled = false;
  653. button75.Enabled = false;
  654. listModernApps.Enabled = false;
  655. listModernApps.Items.Clear();
  656. _modernApps = Utilities.GetModernApps(showAll);
  657. foreach (string x in _modernApps)
  658. {
  659. listModernApps.Items.Add(x);
  660. }
  661. button74.Enabled = true;
  662. button75.Enabled = true;
  663. listModernApps.Enabled = true;
  664. }
  665. private async void UninstallModernApps()
  666. {
  667. string selectedApps = string.Empty;
  668. if (listModernApps.CheckedItems.Count > 0)
  669. {
  670. foreach (string x in listModernApps.CheckedItems)
  671. {
  672. if (string.IsNullOrEmpty(selectedApps))
  673. {
  674. selectedApps = x;
  675. }
  676. else
  677. {
  678. selectedApps += Environment.NewLine + x;
  679. }
  680. }
  681. if (MessageBox.Show(_removeModernAppsMessage + "\n\n" + selectedApps, "Optimizer", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  682. {
  683. button74.Enabled = false;
  684. button75.Enabled = false;
  685. listModernApps.Enabled = false;
  686. bool errorOccured = false;
  687. string failedApps = string.Empty;
  688. foreach (string app in listModernApps.CheckedItems)
  689. {
  690. await Task.Run(() => errorOccured = Utilities.UninstallModernApp(app));
  691. if (errorOccured)
  692. {
  693. failedApps += Environment.NewLine + app;
  694. }
  695. }
  696. if (!string.IsNullOrEmpty(failedApps))
  697. {
  698. MessageBox.Show(_errorModernAppsMessage + failedApps, "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
  699. }
  700. GetModernApps(!chkOnlyRemovable.Checked);
  701. }
  702. }
  703. }
  704. private void GetCustomCommands()
  705. {
  706. _customCommands = Integrator.GetCustomCommands();
  707. listCustomCommands.Items.Clear();
  708. foreach (string s in _customCommands)
  709. {
  710. listCustomCommands.Items.Add(s);
  711. }
  712. }
  713. private void Main_FormClosing(object sender, FormClosingEventArgs e)
  714. {
  715. if (_trayMenu)
  716. {
  717. e.Cancel = true;
  718. this.Hide();
  719. }
  720. else
  721. {
  722. Options.CurrentOptions.AppsFolder = txtDownloadFolder.Text;
  723. Options.SaveSettings();
  724. }
  725. }
  726. private void button39_Click(object sender, EventArgs e)
  727. {
  728. HelperForm f = new HelperForm(this, MessageType.Restart, _restartMessage);
  729. f.ShowDialog();
  730. }
  731. private void button43_Click(object sender, EventArgs e)
  732. {
  733. HelperForm f = new HelperForm(this, MessageType.Restart, _restartMessage);
  734. f.ShowDialog();
  735. }
  736. private void button44_Click(object sender, EventArgs e)
  737. {
  738. HelperForm f = new HelperForm(this, MessageType.Restart, _restartMessage);
  739. f.ShowDialog();
  740. }
  741. private void button45_Click(object sender, EventArgs e)
  742. {
  743. HelperForm f = new HelperForm(this, MessageType.Restart, _restartMessage);
  744. f.ShowDialog();
  745. }
  746. private void button18_Click(object sender, EventArgs e)
  747. {
  748. EdgeForm f = new EdgeForm();
  749. f.ShowDialog();
  750. }
  751. private void checkSelectAll_CheckedChanged(object sender, EventArgs e)
  752. {
  753. checkTemp.Checked = checkSelectAll.Checked;
  754. checkFileZilla.Checked = checkSelectAll.Checked;
  755. checkMiniDumps.Checked = checkSelectAll.Checked;
  756. checkMediaCache.Checked = checkSelectAll.Checked;
  757. checkLogs.Checked = checkSelectAll.Checked;
  758. checkBin.Checked = checkSelectAll.Checked;
  759. checkErrorReports.Checked = checkSelectAll.Checked;
  760. }
  761. private void button20_Click(object sender, EventArgs e)
  762. {
  763. CleaningAnimation(true);
  764. Task t = new Task(() => CleanPC());
  765. t.Start();
  766. }
  767. private void button32_Click(object sender, EventArgs e)
  768. {
  769. if (listStartupItems.SelectedItems.Count == 1)
  770. {
  771. _startUpItems[listStartupItems.SelectedIndices[0]].Remove();
  772. GetStartupItems();
  773. }
  774. }
  775. internal void RemoveAllStartupItems()
  776. {
  777. foreach (ListViewItem i in listStartupItems.Items)
  778. {
  779. _startUpItems[i.Index].Remove();
  780. }
  781. GetStartupItems();
  782. }
  783. private void button22_Click(object sender, EventArgs e)
  784. {
  785. if (listStartupItems.Items.Count > 0)
  786. {
  787. HelperForm r = new HelperForm(this, MessageType.Startup, _removeStartupItemsMessage);
  788. r.ShowDialog(this);
  789. }
  790. }
  791. private void button31_Click(object sender, EventArgs e)
  792. {
  793. if (listStartupItems.SelectedItems.Count == 1)
  794. {
  795. _startUpItems[listStartupItems.SelectedIndices[0]].LocateFile();
  796. }
  797. }
  798. private void checkEnableAll_CheckedChanged(object sender, EventArgs e)
  799. {
  800. checkTaskManager.Checked = checkEnableAll.Checked;
  801. checkCommandPrompt.Checked = checkEnableAll.Checked;
  802. checkControlPanel.Checked = checkEnableAll.Checked;
  803. checkFolderOptions.Checked = checkEnableAll.Checked;
  804. checkRunDialog.Checked = checkEnableAll.Checked;
  805. checkContextMenu.Checked = checkEnableAll.Checked;
  806. checkFirewall.Checked = checkEnableAll.Checked;
  807. checkRegistryEditor.Checked = checkEnableAll.Checked;
  808. }
  809. private void button33_Click(object sender, EventArgs e)
  810. {
  811. bool flag = FixRegistry();
  812. if (flag)
  813. {
  814. panel2.Enabled = false;
  815. button33.Enabled = false;
  816. if (checkRestartExplorer.Checked)
  817. {
  818. Utilities.RestartExplorer();
  819. }
  820. panel2.Enabled = true;
  821. button33.Enabled = true;
  822. }
  823. }
  824. private void pictureBox1_Click(object sender, EventArgs e)
  825. {
  826. AboutForm f = new AboutForm();
  827. f.ShowDialog(this);
  828. }
  829. private void button37_Click(object sender, EventArgs e)
  830. {
  831. GetStartupItems();
  832. }
  833. private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  834. {
  835. HostsHelper.LocateHosts();
  836. }
  837. private void linkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  838. {
  839. HostsEditorForm f = new HostsEditorForm();
  840. f.ShowDialog(this);
  841. GetHostsEntries();
  842. }
  843. private void linkLabel4_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  844. {
  845. HostsHelper.RestoreDefaultHosts();
  846. GetHostsEntries();
  847. }
  848. private void button47_Click(object sender, EventArgs e)
  849. {
  850. if ((txtIP.Text != string.Empty) && (txtDomain.Text != string.Empty))
  851. {
  852. string ip = txtIP.Text.Trim();
  853. string domain = txtDomain.Text.Trim();
  854. string recommendedDomain = string.Empty;
  855. if (!domain.StartsWith("www."))
  856. {
  857. recommendedDomain = "www." + domain;
  858. }
  859. else
  860. {
  861. recommendedDomain = domain.Replace("www.", string.Empty);
  862. }
  863. HostsHelper.AddEntry(HostsHelper.SanitizeEntry(ip) + " " + HostsHelper.SanitizeEntry(domain));
  864. if (!string.IsNullOrEmpty(recommendedDomain))
  865. {
  866. HostsHelper.AddEntry(HostsHelper.SanitizeEntry(ip) + " " + HostsHelper.SanitizeEntry(recommendedDomain));
  867. }
  868. GetHostsEntries();
  869. txtIP.Clear();
  870. txtDomain.Clear();
  871. chkBlock.Checked = false;
  872. }
  873. }
  874. private void button41_Click(object sender, EventArgs e)
  875. {
  876. GetHostsEntries();
  877. }
  878. private void button42_Click(object sender, EventArgs e)
  879. {
  880. if (listHostEntries.SelectedItems.Count == 1)
  881. {
  882. HostsHelper.RemoveEntry(listHostEntries.SelectedItem.ToString().Replace(" : ", " "));
  883. GetHostsEntries();
  884. }
  885. }
  886. private void button46_Click(object sender, EventArgs e)
  887. {
  888. if (listHostEntries.Items.Count > 0)
  889. {
  890. HelperForm r = new HelperForm(this, MessageType.Hosts, _removeHostsEntriesMessage);
  891. r.ShowDialog(this);
  892. }
  893. }
  894. internal void RemoveAllHostsEntries()
  895. {
  896. List<string> collection = new List<string>();
  897. foreach (string item in listHostEntries.Items)
  898. {
  899. collection.Add(item.Replace(" : ", " "));
  900. }
  901. HostsHelper.RemoveAllEntries(collection);
  902. GetHostsEntries();
  903. }
  904. private void aio_SelectedIndexChanged(object sender, EventArgs e)
  905. {
  906. if (tabCollection.SelectedTab == hostsEditorTab) txtIP.Focus();
  907. if (tabCollection.SelectedTab == pingerTab) txtPingInput.Focus();
  908. }
  909. private void button48_Click(object sender, EventArgs e)
  910. {
  911. defineCommandDialog.ShowDialog();
  912. }
  913. private void button50_Click(object sender, EventArgs e)
  914. {
  915. if ((txtRunFile.Text != string.Empty) && (txtRunKeyword.Text != string.Empty))
  916. {
  917. Integrator.CreateCustomCommand(txtRunFile.Text, txtRunKeyword.Text);
  918. txtRunFile.Clear();
  919. txtRunKeyword.Clear();
  920. GetCustomCommands();
  921. }
  922. }
  923. private void DefineCmd_FileOk(object sender, CancelEventArgs e)
  924. {
  925. txtRunFile.Text = defineCommandDialog.FileName;
  926. txtRunKeyword.Text = Path.GetFileNameWithoutExtension(txtRunFile.Text).ToLower();
  927. }
  928. private void button58_Click(object sender, EventArgs e)
  929. {
  930. InfoForm r = new InfoForm(Integrator.powerinfo);
  931. r.ShowDialog(this);
  932. }
  933. private void button56_Click(object sender, EventArgs e)
  934. {
  935. InfoForm r = new InfoForm(Integrator.systemtoolsinfo);
  936. r.ShowDialog(this);
  937. }
  938. private void button52_Click(object sender, EventArgs e)
  939. {
  940. InfoForm r = new InfoForm(Integrator.windowsappsinfo);
  941. r.ShowDialog(this);
  942. }
  943. private void button49_Click(object sender, EventArgs e)
  944. {
  945. InfoForm r = new InfoForm(Integrator.systemshortcutsinfo);
  946. r.ShowDialog(this);
  947. }
  948. private void button55_Click(object sender, EventArgs e)
  949. {
  950. InfoForm r = new InfoForm(Integrator.desktopshortcutsinfo);
  951. r.ShowDialog(this);
  952. }
  953. private void button59_Click(object sender, EventArgs e)
  954. {
  955. Utilities.ImportRegistryScript(Required.ReadyMadeMenusFolder + "\\PowerMenu.reg");
  956. GetDesktopItems();
  957. }
  958. private void button53_Click(object sender, EventArgs e)
  959. {
  960. Utilities.ImportRegistryScript(Required.ReadyMadeMenusFolder + "\\SystemTools.reg");
  961. GetDesktopItems();
  962. }
  963. private void button54_Click(object sender, EventArgs e)
  964. {
  965. Utilities.ImportRegistryScript(Required.ReadyMadeMenusFolder + "\\WindowsApps.reg");
  966. GetDesktopItems();
  967. }
  968. private void button51_Click(object sender, EventArgs e)
  969. {
  970. Utilities.ImportRegistryScript(Required.ReadyMadeMenusFolder + "\\SystemShortcuts.reg");
  971. GetDesktopItems();
  972. }
  973. private void button57_Click(object sender, EventArgs e)
  974. {
  975. Utilities.ImportRegistryScript(Required.ReadyMadeMenusFolder + "\\DesktopShortcuts.reg");
  976. GetDesktopItems();
  977. }
  978. private void button60_Click(object sender, EventArgs e)
  979. {
  980. GetDesktopItems();
  981. }
  982. private void button61_Click(object sender, EventArgs e)
  983. {
  984. if (listDesktopItems.SelectedItems.Count == 1)
  985. {
  986. Integrator.RemoveItem(listDesktopItems.SelectedItem.ToString());
  987. GetDesktopItems();
  988. }
  989. }
  990. internal void RemoveAllDesktopItems()
  991. {
  992. List<string> collection = new List<string>();
  993. foreach (string item in listDesktopItems.Items)
  994. {
  995. collection.Add(item);
  996. }
  997. Integrator.RemoveAllItems(collection);
  998. GetDesktopItems();
  999. }
  1000. private void button62_Click(object sender, EventArgs e)
  1001. {
  1002. if (listDesktopItems.Items.Count > 0)
  1003. {
  1004. HelperForm r = new HelperForm(this, MessageType.Integrator, _removeDesktopItemsMessage);
  1005. r.ShowDialog(this);
  1006. }
  1007. }
  1008. private void radioProgram_CheckedChanged(object sender, EventArgs e)
  1009. {
  1010. if (radioProgram.Checked)
  1011. {
  1012. btnBrowseItem.Enabled = true;
  1013. txtItem.Clear();
  1014. checkDefaultIcon.Checked = true;
  1015. txtIcon.Enabled = false;
  1016. btnBrowseIcon.Enabled = false;
  1017. itemtoaddgroup.Text = "Program to add:";
  1018. checkDefaultIcon.Visible = true;
  1019. checkDefaultIcon.Text = "Use program's icon";
  1020. txtItemName.Clear();
  1021. txtItem.ReadOnly = true;
  1022. txtIcon.ReadOnly = true;
  1023. _desktopItemType = DesktopItemType.Program;
  1024. }
  1025. }
  1026. private void radioFolder_CheckedChanged(object sender, EventArgs e)
  1027. {
  1028. if (radioFolder.Checked)
  1029. {
  1030. checkDefaultIcon.Checked = true;
  1031. btnBrowseItem.Enabled = true;
  1032. txtItem.Clear();
  1033. itemtoaddgroup.Text = "Folder to add:";
  1034. checkDefaultIcon.Text = "Use default folder icon";
  1035. txtItemName.Clear();
  1036. txtItem.ReadOnly = true;
  1037. txtIcon.ReadOnly = true;
  1038. _desktopItemType = DesktopItemType.Folder;
  1039. }
  1040. }
  1041. private void radioLink_CheckedChanged(object sender, EventArgs e)
  1042. {
  1043. if (radioLink.Checked)
  1044. {
  1045. checkDefaultIcon.Checked = true;
  1046. checkDefaultIcon.Text = "Download website icon (favicon)";
  1047. btnBrowseItem.Enabled = false;
  1048. itemtoaddgroup.Text = "Web address to add:";
  1049. checkDefaultIcon.Visible = true;
  1050. txtItem.Text = "http://";
  1051. txtItemName.Clear();
  1052. txtItem.ReadOnly = false;
  1053. txtIcon.ReadOnly = true;
  1054. _desktopItemType = DesktopItemType.Link;
  1055. }
  1056. }
  1057. private void radioFile_CheckedChanged(object sender, EventArgs e)
  1058. {
  1059. if (radioFile.Checked)
  1060. {
  1061. checkDefaultIcon.Checked = true;
  1062. checkDefaultIcon.Text = "No icon";
  1063. btnBrowseItem.Enabled = true;
  1064. itemtoaddgroup.Text = "File to add:";
  1065. checkDefaultIcon.Visible = true;
  1066. txtItem.Clear();
  1067. txtItemName.Clear();
  1068. txtItem.ReadOnly = true;
  1069. txtIcon.ReadOnly = true;
  1070. _desktopItemType = DesktopItemType.File;
  1071. }
  1072. }
  1073. private void radioCommand_CheckedChanged(object sender, EventArgs e)
  1074. {
  1075. if (radioCommand.Checked)
  1076. {
  1077. btnBrowseItem.Enabled = false;
  1078. txtItem.Clear();
  1079. checkDefaultIcon.Checked = true;
  1080. txtIcon.Enabled = false;
  1081. btnBrowseIcon.Enabled = false;
  1082. itemtoaddgroup.Text = "Command to add:";
  1083. checkDefaultIcon.Visible = true;
  1084. checkDefaultIcon.Text = "No icon";
  1085. txtItemName.Clear();
  1086. txtItem.ReadOnly = false;
  1087. txtIcon.ReadOnly = true;
  1088. _desktopItemType = DesktopItemType.Command;
  1089. }
  1090. }
  1091. private void checkDefaultIcon_CheckedChanged(object sender, EventArgs e)
  1092. {
  1093. if (checkDefaultIcon.Checked)
  1094. {
  1095. txtIcon.Clear();
  1096. txtIcon.Enabled = false;
  1097. btnBrowseIcon.Enabled = false;
  1098. }
  1099. else
  1100. {
  1101. txtIcon.Clear();
  1102. txtIcon.Enabled = true;
  1103. btnBrowseIcon.Enabled = true;
  1104. }
  1105. }
  1106. private void btnBrowseItem_Click(object sender, EventArgs e)
  1107. {
  1108. switch (_desktopItemType)
  1109. {
  1110. case DesktopItemType.Program:
  1111. defineProgramDialog.ShowDialog();
  1112. break;
  1113. case DesktopItemType.Folder:
  1114. defineFolderDialog.ShowDialog();
  1115. txtItem.Text = defineFolderDialog.SelectedPath;
  1116. int i = defineFolderDialog.SelectedPath.LastIndexOf("\\");
  1117. txtItemName.Text = defineFolderDialog.SelectedPath.Remove(0, i + 1);
  1118. break;
  1119. case DesktopItemType.File:
  1120. defineFileDialog.ShowDialog();
  1121. break;
  1122. }
  1123. }
  1124. private void DefineProgramDialog_FileOk(object sender, CancelEventArgs e)
  1125. {
  1126. txtItem.Text = defineProgramDialog.FileName;
  1127. txtItemName.Text = defineProgramDialog.SafeFileName.Replace(".exe", string.Empty);
  1128. }
  1129. private void DefineFileDialog_FileOk(object sender, CancelEventArgs e)
  1130. {
  1131. txtItem.Text = defineFileDialog.FileName;
  1132. txtItemName.Text = defineFileDialog.SafeFileName;
  1133. }
  1134. private void btnBrowseIcon_Click(object sender, EventArgs e)
  1135. {
  1136. switch (_desktopItemType)
  1137. {
  1138. case DesktopItemType.Program:
  1139. DefineProgramIconDialog.ShowDialog();
  1140. break;
  1141. case DesktopItemType.Folder:
  1142. DefineFolderIconDialog.ShowDialog();
  1143. break;
  1144. case DesktopItemType.Link:
  1145. DefineURLIconDialog.ShowDialog();
  1146. break;
  1147. case DesktopItemType.File:
  1148. DefineFileIconDialog.ShowDialog();
  1149. break;
  1150. case DesktopItemType.Command:
  1151. DefineCommandIconDialog.ShowDialog();
  1152. break;
  1153. }
  1154. }
  1155. private void DefineProgramIconDialog_FileOk(object sender, CancelEventArgs e)
  1156. {
  1157. txtIcon.Text = DefineProgramIconDialog.FileName;
  1158. if (txtIcon.Text.Contains(".exe"))
  1159. {
  1160. string iconpath = Integrator.ExtractIconFromExecutable(txtItemName.Text, DefineProgramIconDialog.FileName);
  1161. txtIcon.Text = iconpath;
  1162. }
  1163. }
  1164. private void DefineFolderIconDialog_FileOk(object sender, CancelEventArgs e)
  1165. {
  1166. txtIcon.Text = DefineFolderIconDialog.FileName;
  1167. if (txtIcon.Text.Contains(".exe"))
  1168. {
  1169. string iconpath = Integrator.ExtractIconFromExecutable(txtItemName.Text, DefineFolderIconDialog.FileName);
  1170. txtIcon.Text = iconpath;
  1171. }
  1172. }
  1173. private void DefineURLIconDialog_FileOk(object sender, CancelEventArgs e)
  1174. {
  1175. txtIcon.Text = DefineURLIconDialog.FileName;
  1176. if (txtIcon.Text.Contains(".exe"))
  1177. {
  1178. string iconpath = Integrator.ExtractIconFromExecutable(txtItemName.Text, DefineURLIconDialog.FileName);
  1179. txtIcon.Text = iconpath;
  1180. }
  1181. }
  1182. private void DefineFileIconDialog_FileOk(object sender, CancelEventArgs e)
  1183. {
  1184. txtIcon.Text = DefineFileIconDialog.FileName;
  1185. if (txtIcon.Text.Contains(".exe"))
  1186. {
  1187. string iconpath = Integrator.ExtractIconFromExecutable(txtItemName.Text, DefineFileIconDialog.FileName);
  1188. txtIcon.Text = iconpath;
  1189. }
  1190. }
  1191. private void DefineCommandIconDialog_FileOk(object sender, CancelEventArgs e)
  1192. {
  1193. txtIcon.Text = DefineCommandIconDialog.FileName;
  1194. if (txtIcon.Text.Contains(".exe"))
  1195. {
  1196. string iconpath = Integrator.ExtractIconFromExecutable(txtItemName.Text, DefineCommandIconDialog.FileName);
  1197. txtIcon.Text = iconpath;
  1198. }
  1199. }
  1200. private void btnAddItem_Click(object sender, EventArgs e)
  1201. {
  1202. string icon = string.Empty;
  1203. switch (_desktopItemType)
  1204. {
  1205. case DesktopItemType.Program:
  1206. if (checkDefaultIcon.Checked)
  1207. {
  1208. icon = txtItem.Text;
  1209. }
  1210. else
  1211. {
  1212. icon = txtIcon.Text;
  1213. }
  1214. Integrator.AddItem(txtItemName.Text, txtItem.Text, icon, _desktopItemPosition, checkShift.Checked, DesktopItemType.Program);
  1215. break;
  1216. case DesktopItemType.Folder:
  1217. if (checkDefaultIcon.Checked)
  1218. {
  1219. icon = Integrator.FolderDefaultIcon;
  1220. }
  1221. else
  1222. {
  1223. icon = txtIcon.Text;
  1224. }
  1225. Integrator.AddItem(txtItemName.Text, txtItem.Text, icon, _desktopItemPosition, checkShift.Checked, DesktopItemType.Folder);
  1226. break;
  1227. case DesktopItemType.Link:
  1228. if (checkDefaultIcon.Checked)
  1229. {
  1230. icon = Integrator.DownloadFavicon(txtItem.Text, txtItemName.Text);
  1231. }
  1232. else
  1233. {
  1234. icon = txtIcon.Text;
  1235. }
  1236. Integrator.AddItem(txtItemName.Text, txtItem.Text, icon, _desktopItemPosition, checkShift.Checked, DesktopItemType.Link);
  1237. break;
  1238. case DesktopItemType.File:
  1239. if (!checkDefaultIcon.Checked)
  1240. {
  1241. icon = txtIcon.Text;
  1242. }
  1243. Integrator.AddItem(txtItemName.Text, txtItem.Text, icon, _desktopItemPosition, checkShift.Checked, DesktopItemType.File);
  1244. break;
  1245. case DesktopItemType.Command:
  1246. if (!checkDefaultIcon.Checked)
  1247. {
  1248. icon = txtIcon.Text;
  1249. }
  1250. Integrator.AddItem(txtItemName.Text, txtItem.Text, icon, _desktopItemPosition, checkShift.Checked, DesktopItemType.Command);
  1251. break;
  1252. }
  1253. GetDesktopItems();
  1254. ResetIntegratorForm();
  1255. }
  1256. private void integratorTimer_Tick(object sender, EventArgs e)
  1257. {
  1258. if ((txtItem.Text != "") && (txtItemName.Text != "") && (txtIcon.Text != "") && (!checkDefaultIcon.Checked))
  1259. {
  1260. btnAddItem.Enabled = true;
  1261. }
  1262. else if ((txtItem.Text != "") && (txtItemName.Text != "") && (checkDefaultIcon.Checked))
  1263. {
  1264. btnAddItem.Enabled = true;
  1265. }
  1266. else
  1267. {
  1268. btnAddItem.Enabled = false;
  1269. }
  1270. }
  1271. private void runDialogTimer_Tick(object sender, EventArgs e)
  1272. {
  1273. if ((txtRunFile.Text != "") && (txtRunKeyword.Text != ""))
  1274. {
  1275. btnCreateCustomCommand.Enabled = true;
  1276. }
  1277. else
  1278. {
  1279. btnCreateCustomCommand.Enabled = false;
  1280. }
  1281. }
  1282. private void radioTop_CheckedChanged(object sender, EventArgs e)
  1283. {
  1284. if (radioTop.Checked)
  1285. {
  1286. _desktopItemPosition = DesktopTypePosition.Top;
  1287. }
  1288. }
  1289. private void radioMiddle_CheckedChanged(object sender, EventArgs e)
  1290. {
  1291. if (radioMiddle.Checked)
  1292. {
  1293. _desktopItemPosition = DesktopTypePosition.Middle;
  1294. }
  1295. }
  1296. private void radioBottom_CheckedChanged(object sender, EventArgs e)
  1297. {
  1298. if (radioBottom.Checked)
  1299. {
  1300. _desktopItemPosition = DesktopTypePosition.Bottom;
  1301. }
  1302. }
  1303. private void ResetIntegratorForm()
  1304. {
  1305. txtItem.Clear();
  1306. txtIcon.Clear();
  1307. checkDefaultIcon.Checked = true;
  1308. txtItemName.Clear();
  1309. if (radioLink.Checked)
  1310. {
  1311. txtItem.Text = "http://";
  1312. }
  1313. }
  1314. private void radioOcean_CheckedChanged(object sender, EventArgs e)
  1315. {
  1316. Options.CurrentOptions.Color = Theme.Ocean;
  1317. Options.ApplyTheme(this);
  1318. }
  1319. private void radioMagma_CheckedChanged(object sender, EventArgs e)
  1320. {
  1321. Options.CurrentOptions.Color = Theme.Magma;
  1322. Options.ApplyTheme(this);
  1323. }
  1324. private void radioZerg_CheckedChanged(object sender, EventArgs e)
  1325. {
  1326. Options.CurrentOptions.Color = Theme.Zerg;
  1327. Options.ApplyTheme(this);
  1328. }
  1329. private void radioMinimal_CheckedChanged(object sender, EventArgs e)
  1330. {
  1331. Options.CurrentOptions.Color = Theme.Minimal;
  1332. Options.ApplyTheme(this);
  1333. }
  1334. private void radioCaramel_CheckedChanged(object sender, EventArgs e)
  1335. {
  1336. Options.CurrentOptions.Color = Theme.Caramel;
  1337. Options.ApplyTheme(this);
  1338. }
  1339. private void radioLime_CheckedChanged(object sender, EventArgs e)
  1340. {
  1341. Options.CurrentOptions.Color = Theme.Lime;
  1342. Options.ApplyTheme(this);
  1343. }
  1344. private void button64_Click(object sender, EventArgs e)
  1345. {
  1346. if (listStartupItems.SelectedItems.Count == 1)
  1347. {
  1348. _startUpItems[listStartupItems.SelectedIndices[0]].LocateKey();
  1349. }
  1350. }
  1351. private void button66_Click(object sender, EventArgs e)
  1352. {
  1353. Integrator.TakeOwnership(false);
  1354. }
  1355. private void button65_Click(object sender, EventArgs e)
  1356. {
  1357. Integrator.TakeOwnership(true);
  1358. }
  1359. private void listStartupItems_ColumnClick(object sender, ColumnClickEventArgs e)
  1360. {
  1361. if (e.Column == _columnSorter.CurrentColumn)
  1362. {
  1363. if (_columnSorter.SortOrder == SortOrder.Ascending)
  1364. {
  1365. _columnSorter.SortOrder = SortOrder.Descending;
  1366. }
  1367. else
  1368. {
  1369. _columnSorter.SortOrder = SortOrder.Ascending;
  1370. }
  1371. }
  1372. else
  1373. {
  1374. _columnSorter.CurrentColumn = e.Column;
  1375. _columnSorter.SortOrder = SortOrder.Ascending;
  1376. }
  1377. listStartupItems.Sort();
  1378. }
  1379. private void chkBlock_CheckedChanged(object sender, EventArgs e)
  1380. {
  1381. if (chkBlock.Checked)
  1382. {
  1383. txtIP.Text = _blockedIP;
  1384. txtIP.Enabled = false;
  1385. }
  1386. else
  1387. {
  1388. txtIP.Clear();
  1389. txtIP.Enabled = true;
  1390. }
  1391. }
  1392. private void button8_Click(object sender, EventArgs e)
  1393. {
  1394. GetCustomCommands();
  1395. }
  1396. private void button26_Click(object sender, EventArgs e)
  1397. {
  1398. if (listCustomCommands.SelectedItems.Count == 1)
  1399. {
  1400. Integrator.DeleteCustomCommand(listCustomCommands.SelectedItem.ToString());
  1401. GetCustomCommands();
  1402. }
  1403. }
  1404. private void button75_Click(object sender, EventArgs e)
  1405. {
  1406. GetModernApps(!chkOnlyRemovable.Checked);
  1407. }
  1408. private void button74_Click(object sender, EventArgs e)
  1409. {
  1410. UninstallModernApps();
  1411. }
  1412. private void chkSelectAllModernApps_CheckedChanged(object sender, EventArgs e)
  1413. {
  1414. for (int i = 0; i < listModernApps.Items.Count; i++)
  1415. {
  1416. listModernApps.SetItemChecked(i, chkSelectAllModernApps.Checked);
  1417. }
  1418. }
  1419. private void btnResetConfig_Click(object sender, EventArgs e)
  1420. {
  1421. if (MessageBox.Show(_resetMessage, "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  1422. {
  1423. Utilities.ResetConfiguration();
  1424. }
  1425. }
  1426. private void toggleSwitch1_Click(object sender, EventArgs e)
  1427. {
  1428. if (!toggleSwitch1.Checked)
  1429. {
  1430. Optimize.EnablePerformanceTweaks();
  1431. }
  1432. else
  1433. {
  1434. Optimize.DisablePerformanceTweaks();
  1435. }
  1436. Options.CurrentOptions.EnablePerformanceTweaks = !toggleSwitch1.Checked;
  1437. }
  1438. private void toggleSwitch2_Click(object sender, EventArgs e)
  1439. {
  1440. if (!toggleSwitch2.Checked)
  1441. {
  1442. Optimize.DisableNetworkThrottling();
  1443. }
  1444. else
  1445. {
  1446. Optimize.EnableNetworkThrottling();
  1447. }
  1448. Options.CurrentOptions.DisableNetworkThrottling = !toggleSwitch2.Checked;
  1449. }
  1450. private void toggleSwitch3_Click(object sender, EventArgs e)
  1451. {
  1452. if (!toggleSwitch3.Checked)
  1453. {
  1454. Optimize.DisableDefender();
  1455. }
  1456. else
  1457. {
  1458. Optimize.EnableDefender();
  1459. }
  1460. Options.CurrentOptions.DisableWindowsDefender = !toggleSwitch3.Checked;
  1461. }
  1462. private void toggleSwitch4_Click(object sender, EventArgs e)
  1463. {
  1464. if (!toggleSwitch4.Checked)
  1465. {
  1466. Optimize.DisableSystemRestore();
  1467. }
  1468. else
  1469. {
  1470. Optimize.EnableSystemRestore();
  1471. }
  1472. Options.CurrentOptions.DisableSystemRestore = !toggleSwitch4.Checked;
  1473. }
  1474. private void toggleSwitch5_Click(object sender, EventArgs e)
  1475. {
  1476. if (!toggleSwitch5.Checked)
  1477. {
  1478. Optimize.DisablePrintService();
  1479. }
  1480. else
  1481. {
  1482. Optimize.EnablePrintService();
  1483. }
  1484. Options.CurrentOptions.DisablePrintService = !toggleSwitch5.Checked;
  1485. }
  1486. private void toggleSwitch6_Click(object sender, EventArgs e)
  1487. {
  1488. if (!toggleSwitch6.Checked)
  1489. {
  1490. Optimize.DisableMediaPlayerSharing();
  1491. }
  1492. else
  1493. {
  1494. Optimize.EnableMediaPlayerSharing();
  1495. }
  1496. Options.CurrentOptions.DisableMediaPlayerSharing = !toggleSwitch6.Checked;
  1497. }
  1498. private void toggleSwitch8_Click(object sender, EventArgs e)
  1499. {
  1500. if (!toggleSwitch8.Checked)
  1501. {
  1502. Optimize.DisableErrorReporting();
  1503. }
  1504. else
  1505. {
  1506. Optimize.EnableErrorReporting();
  1507. }
  1508. Options.CurrentOptions.DisableErrorReporting = !toggleSwitch8.Checked;
  1509. }
  1510. private void toggleSwitch9_Click(object sender, EventArgs e)
  1511. {
  1512. if (!toggleSwitch9.Checked)
  1513. {
  1514. Optimize.DisableHomeGroup();
  1515. }
  1516. else
  1517. {
  1518. Optimize.EnableHomeGroup();
  1519. }
  1520. Options.CurrentOptions.DisableHomeGroup = !toggleSwitch9.Checked;
  1521. }
  1522. private void toggleSwitch10_Click(object sender, EventArgs e)
  1523. {
  1524. if (!toggleSwitch10.Checked)
  1525. {
  1526. Optimize.DisableSuperfetch();
  1527. }
  1528. else
  1529. {
  1530. Optimize.EnableSuperfetch();
  1531. }
  1532. Options.CurrentOptions.DisableSuperfetch = !toggleSwitch10.Checked;
  1533. }
  1534. private void toggleSwitch11_Click(object sender, EventArgs e)
  1535. {
  1536. if (!toggleSwitch11.Checked)
  1537. {
  1538. Optimize.DisableTelemetryTasks();
  1539. }
  1540. else
  1541. {
  1542. Optimize.EnableTelemetryTasks();
  1543. }
  1544. Options.CurrentOptions.DisableTelemetryTasks = !toggleSwitch11.Checked;
  1545. }
  1546. private void toggleSwitch12_Click(object sender, EventArgs e)
  1547. {
  1548. if (!toggleSwitch12.Checked)
  1549. {
  1550. Optimize.DisableOffice2016Telemetry();
  1551. }
  1552. else
  1553. {
  1554. Optimize.EnableOffice2016Telemetry();
  1555. }
  1556. Options.CurrentOptions.DisableOffice2016Telemetry = !toggleSwitch12.Checked;
  1557. }
  1558. private void toggleSwitch13_Click(object sender, EventArgs e)
  1559. {
  1560. if (!toggleSwitch13.Checked)
  1561. {
  1562. Optimize.EnableLegacyVolumeSlider();
  1563. }
  1564. else
  1565. {
  1566. Optimize.DisableLegacyVolumeSlider();
  1567. }
  1568. Options.CurrentOptions.EnableLegacyVolumeSlider = !toggleSwitch13.Checked;
  1569. }
  1570. private void toggleSwitch19_Click(object sender, EventArgs e)
  1571. {
  1572. if (!toggleSwitch19.Checked)
  1573. {
  1574. Optimize.EnableTaskbarColor();
  1575. }
  1576. else
  1577. {
  1578. Optimize.DisableTaskbarColor();
  1579. }
  1580. Options.CurrentOptions.EnableTaskbarColor = !toggleSwitch19.Checked;
  1581. }
  1582. private void toggleSwitch18_Click(object sender, EventArgs e)
  1583. {
  1584. if (!toggleSwitch18.Checked)
  1585. {
  1586. Optimize.DisableQuickAccessHistory();
  1587. }
  1588. else
  1589. {
  1590. Optimize.EnableQuickAccessHistory();
  1591. }
  1592. Options.CurrentOptions.DisableQuickAccessHistory = !toggleSwitch18.Checked;
  1593. }
  1594. private void toggleSwitch26_Click(object sender, EventArgs e)
  1595. {
  1596. if (!toggleSwitch26.Checked)
  1597. {
  1598. Optimize.DisableStartMenuAds();
  1599. }
  1600. else
  1601. {
  1602. Optimize.EnableStartMenuAds();
  1603. }
  1604. Options.CurrentOptions.DisableStartMenuAds = !toggleSwitch26.Checked;
  1605. }
  1606. private void toggleSwitch27_Click(object sender, EventArgs e)
  1607. {
  1608. if (!toggleSwitch27.Checked)
  1609. {
  1610. Optimize.EnableDarkTheme();
  1611. }
  1612. else
  1613. {
  1614. Optimize.EnableLightTheme();
  1615. }
  1616. Options.CurrentOptions.EnableDarkTheme = !toggleSwitch27.Checked;
  1617. }
  1618. private void toggleSwitch14_Click(object sender, EventArgs e)
  1619. {
  1620. if (!toggleSwitch14.Checked)
  1621. {
  1622. Task t = new Task(() => Optimize.UninstallOneDrive());
  1623. t.Start();
  1624. }
  1625. else
  1626. {
  1627. Task t = new Task(() => Optimize.InstallOneDrive());
  1628. t.Start();
  1629. }
  1630. Options.CurrentOptions.UninstallOneDrive = !toggleSwitch14.Checked;
  1631. }
  1632. private void toggleSwitch25_Click(object sender, EventArgs e)
  1633. {
  1634. if (!toggleSwitch25.Checked)
  1635. {
  1636. Optimize.DisableMyPeople();
  1637. }
  1638. else
  1639. {
  1640. Optimize.EnableMyPeople();
  1641. }
  1642. Options.CurrentOptions.DisableMyPeople = !toggleSwitch25.Checked;
  1643. }
  1644. private void toggleSwitch24_Click(object sender, EventArgs e)
  1645. {
  1646. if (!toggleSwitch24.Checked)
  1647. {
  1648. Optimize.DisableAutomaticUpdates();
  1649. }
  1650. else
  1651. {
  1652. Optimize.EnableAutomaticUpdates();
  1653. }
  1654. Options.CurrentOptions.DisableAutomaticUpdates = !toggleSwitch24.Checked;
  1655. }
  1656. private void toggleSwitch30_Click(object sender, EventArgs e)
  1657. {
  1658. if (!toggleSwitch30.Checked)
  1659. {
  1660. Optimize.ExcludeDrivers();
  1661. }
  1662. else
  1663. {
  1664. Optimize.IncludeDrivers();
  1665. }
  1666. Options.CurrentOptions.ExcludeDrivers = !toggleSwitch30.Checked;
  1667. }
  1668. private void toggleSwitch23_Click(object sender, EventArgs e)
  1669. {
  1670. if (!toggleSwitch23.Checked)
  1671. {
  1672. Optimize.DisableTelemetryServices();
  1673. }
  1674. else
  1675. {
  1676. Optimize.EnableTelemetryServices();
  1677. }
  1678. Options.CurrentOptions.DisableTelemetryServices = !toggleSwitch23.Checked;
  1679. }
  1680. private void toggleSwitch21_Click(object sender, EventArgs e)
  1681. {
  1682. if (!toggleSwitch21.Checked)
  1683. {
  1684. Optimize.DisablePrivacyOptions();
  1685. }
  1686. else
  1687. {
  1688. Optimize.EnablePrivacyOptions();
  1689. }
  1690. Options.CurrentOptions.DisablePrivacyOptions = !toggleSwitch21.Checked;
  1691. }
  1692. private void toggleSwitch16_Click(object sender, EventArgs e)
  1693. {
  1694. if (!toggleSwitch16.Checked)
  1695. {
  1696. Optimize.DisableCortana();
  1697. }
  1698. else
  1699. {
  1700. Optimize.EnableCortana();
  1701. }
  1702. Options.CurrentOptions.DisableCortana = !toggleSwitch16.Checked;
  1703. }
  1704. private void toggleSwitch20_Click(object sender, EventArgs e)
  1705. {
  1706. if (!toggleSwitch20.Checked)
  1707. {
  1708. Optimize.DisableSensorServices();
  1709. }
  1710. else
  1711. {
  1712. Optimize.EnableSensorServices();
  1713. }
  1714. Options.CurrentOptions.DisableSensorServices = !toggleSwitch20.Checked;
  1715. }
  1716. private void toggleSwitch29_Click(object sender, EventArgs e)
  1717. {
  1718. if (!toggleSwitch29.Checked)
  1719. {
  1720. Optimize.DisableWindowsInk();
  1721. }
  1722. else
  1723. {
  1724. Optimize.EnableWindowsInk();
  1725. }
  1726. Options.CurrentOptions.DisableWindowsInk = !toggleSwitch29.Checked;
  1727. }
  1728. private void toggleSwitch28_Click(object sender, EventArgs e)
  1729. {
  1730. if (!toggleSwitch28.Checked)
  1731. {
  1732. Optimize.DisableSpellingAndTypingFeatures();
  1733. }
  1734. else
  1735. {
  1736. Optimize.EnableSpellingAndTypingFeatures();
  1737. }
  1738. Options.CurrentOptions.DisableSpellingTyping = !toggleSwitch28.Checked;
  1739. }
  1740. private void toggleSwitch17_Click(object sender, EventArgs e)
  1741. {
  1742. if (!toggleSwitch17.Checked)
  1743. {
  1744. Optimize.DisableXboxLive();
  1745. }
  1746. else
  1747. {
  1748. Optimize.EnableXboxLive();
  1749. }
  1750. Options.CurrentOptions.DisableXboxLive = !toggleSwitch17.Checked;
  1751. }
  1752. private void toggleSwitch15_Click(object sender, EventArgs e)
  1753. {
  1754. if (!toggleSwitch15.Checked)
  1755. {
  1756. Optimize.DisableGameBar();
  1757. }
  1758. else
  1759. {
  1760. Optimize.EnableGameBar();
  1761. }
  1762. Options.CurrentOptions.DisableGameBar = !toggleSwitch15.Checked;
  1763. }
  1764. private void toggleSwitch31_Click(object sender, EventArgs e)
  1765. {
  1766. if (!toggleSwitch31.Checked)
  1767. {
  1768. Optimize.DisableOneDrive();
  1769. }
  1770. else
  1771. {
  1772. Optimize.EnableOneDrive();
  1773. }
  1774. Options.CurrentOptions.DisableOneDrive = !toggleSwitch31.Checked;
  1775. }
  1776. private void toggleSwitch32_Click(object sender, EventArgs e)
  1777. {
  1778. if (!toggleSwitch32.Checked)
  1779. {
  1780. Optimize.DisableCompatibilityAssistant();
  1781. }
  1782. else
  1783. {
  1784. Optimize.EnableCompatibilityAssistant();
  1785. }
  1786. Options.CurrentOptions.DisableCompatibilityAssistant = !toggleSwitch32.Checked;
  1787. }
  1788. private void btnUpdate_Click(object sender, EventArgs e)
  1789. {
  1790. CheckForUpdate();
  1791. }
  1792. private void btnChangelog_Click(object sender, EventArgs e)
  1793. {
  1794. try
  1795. {
  1796. Process.Start(_changelogLink);
  1797. }
  1798. catch (Exception ex)
  1799. {
  1800. ErrorLogger.LogError("MainForm.btnChangelog_Click", ex.Message, ex.StackTrace);
  1801. MessageBox.Show(ex.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1802. }
  1803. }
  1804. private void chkReadOnly_CheckedChanged(object sender, EventArgs e)
  1805. {
  1806. HostsHelper.ReadOnly(chkReadOnly.Checked);
  1807. button47.Enabled = !chkReadOnly.Checked;
  1808. button46.Enabled = !chkReadOnly.Checked;
  1809. button42.Enabled = !chkReadOnly.Checked;
  1810. button41.Enabled = !chkReadOnly.Checked;
  1811. linkLabel4.Enabled = !chkReadOnly.Checked;
  1812. chkBlock.Enabled = !chkReadOnly.Checked;
  1813. txtDomain.Enabled = !chkReadOnly.Checked;
  1814. txtIP.Enabled = !chkReadOnly.Checked;
  1815. button1.Enabled = !chkReadOnly.Checked;
  1816. button2.Enabled = !chkReadOnly.Checked;
  1817. button3.Enabled = !chkReadOnly.Checked;
  1818. button4.Enabled = !chkReadOnly.Checked;
  1819. txtIP.Focus();
  1820. }
  1821. private void button1_Click(object sender, EventArgs e)
  1822. {
  1823. HostsHelper.AdblockBasic();
  1824. GetHostsEntries();
  1825. }
  1826. private void button3_Click(object sender, EventArgs e)
  1827. {
  1828. HostsHelper.AdBlockWithPorn();
  1829. GetHostsEntries();
  1830. }
  1831. private void button2_Click(object sender, EventArgs e)
  1832. {
  1833. HostsHelper.AdBlockWithSocial();
  1834. GetHostsEntries();
  1835. }
  1836. private void button4_Click(object sender, EventArgs e)
  1837. {
  1838. HostsHelper.AdBlockWithSocial();
  1839. GetHostsEntries();
  1840. }
  1841. private void RenderAppDownloaderBusy()
  1842. {
  1843. btnDownloadApps.Enabled = false;
  1844. button5.Enabled = false;
  1845. txtDownloadFolder.ReadOnly = true;
  1846. linkLabel1.Visible = false;
  1847. }
  1848. private void RenderAppDownloaderFree()
  1849. {
  1850. btnDownloadApps.Enabled = true;
  1851. button5.Enabled = true;
  1852. txtDownloadFolder.ReadOnly = false;
  1853. linkLabel1.Visible = !string.IsNullOrEmpty(downloadLog);
  1854. txtDownloadStatus.Text = "Finished";
  1855. }
  1856. string appNameTemp = string.Empty;
  1857. int maxCount = 0;
  1858. int count = 0;
  1859. Process p;
  1860. string downloadLog = string.Empty;
  1861. private async void btnDownloadApps_Click(object sender, EventArgs e)
  1862. {
  1863. if (!Directory.Exists(txtDownloadFolder.Text))
  1864. {
  1865. MessageBox.Show("Download folder specified is not valid!", "Invalid folder", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1866. return;
  1867. }
  1868. RenderAppDownloaderBusy();
  1869. maxCount = 0;
  1870. count = 0;
  1871. downloadLog = string.Empty;
  1872. foreach (Control c in Utilities.GetSelfAndChildrenRecursive(appsTab))
  1873. {
  1874. if (c.Name == "cAutoInstall") continue;
  1875. if (c is ColoredCheckBox && ((ColoredCheckBox)c).Checked) maxCount++;
  1876. }
  1877. ColoredCheckBox currentCheck;
  1878. Control[] temp;
  1879. foreach (FeedApp x in AppsFromFeed)
  1880. {
  1881. if (string.IsNullOrEmpty(x.Tag)) continue;
  1882. temp = appsTab.Controls.Find(x.Tag, true);
  1883. if (temp.Count() == 0) continue;
  1884. currentCheck = (ColoredCheckBox)temp[0];
  1885. if (currentCheck == null) continue;
  1886. if (!currentCheck.Checked) continue;
  1887. appNameTemp = x.Title;
  1888. if (c64.Checked)
  1889. {
  1890. count++;
  1891. if (string.IsNullOrEmpty(x.Link64))
  1892. {
  1893. downloadLog += "• " + x.Title + ":" + Environment.NewLine + "No 64-bit available, downloading 32-bit" + Environment.NewLine + Environment.NewLine;
  1894. await DownloadApp(x, false);
  1895. }
  1896. else
  1897. {
  1898. await DownloadApp(x, true);
  1899. }
  1900. }
  1901. else
  1902. {
  1903. count++;
  1904. if (!string.IsNullOrEmpty(x.Link))
  1905. {
  1906. await DownloadApp(x, false);
  1907. }
  1908. else
  1909. {
  1910. downloadLog += "• " + x.Title + ":" + Environment.NewLine + "No 32-bit available, skipping" + Environment.NewLine + Environment.NewLine;
  1911. }
  1912. }
  1913. }
  1914. if (cAutoInstall.Checked)
  1915. {
  1916. count = 0;
  1917. foreach (string a in Directory.GetFiles(txtDownloadFolder.Text, "*.*", SearchOption.TopDirectoryOnly))
  1918. {
  1919. using (p = new Process())
  1920. {
  1921. count++;
  1922. p.StartInfo.FileName = a;
  1923. p.EnableRaisingEvents = true;
  1924. p.StartInfo.WorkingDirectory = txtDownloadFolder.Text;
  1925. // APP-SPECIFIC HACKS //
  1926. if (a.Contains("Sumatra")) p.StartInfo.Arguments = " -install";
  1927. // *** //
  1928. txtDownloadStatus.Text = string.Format("{0}/{1} - Installing {2} ...", count, maxCount, Path.GetFileNameWithoutExtension(a));
  1929. await p.RunAsync();
  1930. };
  1931. }
  1932. }
  1933. // reset all checkboxes
  1934. foreach (Control c in Utilities.GetSelfAndChildrenRecursive(appsTab))
  1935. {
  1936. if (c.Name == "cAutoInstall") continue;
  1937. if (c is ColoredCheckBox && ((ColoredCheckBox)c).Checked) ((ColoredCheckBox)c).Checked = false;
  1938. }
  1939. RenderAppDownloaderFree();
  1940. }
  1941. string fileExtension = ".exe";
  1942. private async Task DownloadApp(FeedApp app, bool pref64)
  1943. {
  1944. try
  1945. {
  1946. using (WebClient downloader = new WebClient())
  1947. {
  1948. downloader.Headers.Add("User-Agent: Other");
  1949. downloader.Encoding = Encoding.UTF8;
  1950. downloader.DownloadProgressChanged += Downloader_DownloadProgressChanged;
  1951. downloader.DownloadFileCompleted += Downloader_DownloadFileCompleted;
  1952. if (pref64)
  1953. {
  1954. if (app.Link64.Contains(".msi"))
  1955. {
  1956. fileExtension = ".msi";
  1957. }
  1958. else
  1959. {
  1960. fileExtension = ".exe";
  1961. }
  1962. await downloader.DownloadFileTaskAsync(new Uri(app.Link64), Path.Combine(txtDownloadFolder.Text, app.Title + "-x64" + fileExtension));
  1963. }
  1964. else
  1965. {
  1966. if (app.Link.Contains(".msi"))
  1967. {
  1968. fileExtension = ".msi";
  1969. }
  1970. else
  1971. {
  1972. fileExtension = ".exe";
  1973. }
  1974. await downloader.DownloadFileTaskAsync(new Uri(app.Link), Path.Combine(txtDownloadFolder.Text, app.Title + "-x86" + fileExtension));
  1975. }
  1976. }
  1977. }
  1978. catch (Exception ex)
  1979. {
  1980. ErrorLogger.LogError("MainForm.DownloadApp", ex.Message, ex.StackTrace);
  1981. downloadLog += "• " + app.Title + ":" + Environment.NewLine + "Link is no longer valid!" + Environment.NewLine + Environment.NewLine;
  1982. if (pref64) try { File.Delete(Path.Combine(txtDownloadFolder.Text, app.Title + "-x64.exe")); } catch { }
  1983. if (!pref64) try { File.Delete(Path.Combine(txtDownloadFolder.Text, app.Title + "-x86.exe")); } catch { }
  1984. if (pref64) try { File.Delete(Path.Combine(txtDownloadFolder.Text, app.Title + "-x64.msi")); } catch { }
  1985. if (!pref64) try { File.Delete(Path.Combine(txtDownloadFolder.Text, app.Title + "-x86.msi")); } catch { }
  1986. }
  1987. }
  1988. private void Downloader_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
  1989. {
  1990. this.BeginInvoke((MethodInvoker)delegate
  1991. {
  1992. //txtDownloadStatus.Text = "Finished";
  1993. });
  1994. }
  1995. int tempProgress;
  1996. private void Downloader_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
  1997. {
  1998. this.BeginInvoke((MethodInvoker)delegate
  1999. {
  2000. double bytesIn = double.Parse(e.BytesReceived.ToString());
  2001. double totalBytes = double.Parse(e.TotalBytesToReceive.ToString());
  2002. double percentage = bytesIn / totalBytes * 100;
  2003. tempProgress = int.Parse(Math.Truncate(percentage).ToString());
  2004. // if Content-Length header is missing, just show an animation
  2005. if (Math.Abs(tempProgress) > 100)
  2006. {
  2007. txtDownloadStatus.Text = string.Format("({1}/{2}) - {0} ...", appNameTemp, count, maxCount);
  2008. progressDownloader.Style = ProgressBarStyle.Marquee;
  2009. }
  2010. // if not, show actual progress
  2011. else
  2012. {
  2013. txtDownloadStatus.Text = string.Format("({1}/{2}) - {0} - {3} / {4}", appNameTemp, count, maxCount, ByteSize.FromBytes(e.BytesReceived).ToString("MB"), ByteSize.FromBytes(e.TotalBytesToReceive).ToString("MB"));
  2014. progressDownloader.Style = ProgressBarStyle.Continuous;
  2015. progressDownloader.Value = tempProgress;
  2016. }
  2017. });
  2018. }
  2019. private void button5_Click(object sender, EventArgs e)
  2020. {
  2021. FolderBrowserDialog d = new FolderBrowserDialog();
  2022. if (d.ShowDialog() == DialogResult.OK)
  2023. {
  2024. txtDownloadFolder.Text = d.SelectedPath;
  2025. Options.CurrentOptions.AppsFolder = d.SelectedPath;
  2026. Options.SaveSettings();
  2027. }
  2028. }
  2029. private void button6_Click(object sender, EventArgs e)
  2030. {
  2031. Process.Start(txtDownloadFolder.Text);
  2032. }
  2033. private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  2034. {
  2035. InfoForm lf = new InfoForm(downloadLog);
  2036. lf.ShowDialog(this);
  2037. }
  2038. private void txtDownloadFolder_TextChanged(object sender, EventArgs e)
  2039. {
  2040. Options.CurrentOptions.AppsFolder = txtDownloadFolder.Text;
  2041. Options.SaveSettings();
  2042. }
  2043. private void chkOnlyRemovable_CheckedChanged(object sender, EventArgs e)
  2044. {
  2045. GetModernApps(!chkOnlyRemovable.Checked);
  2046. }
  2047. private void btnGetFeed_Click(object sender, EventArgs e)
  2048. {
  2049. GetFeed();
  2050. }
  2051. private void l2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  2052. {
  2053. Process.Start("https://github.com/hellzerg/optimizer");
  2054. }
  2055. private void btnViewLog_Click(object sender, EventArgs e)
  2056. {
  2057. if (File.Exists(ErrorLogger.ErrorLogFile))
  2058. {
  2059. InfoForm iform = new InfoForm(File.ReadAllText(ErrorLogger.ErrorLogFile, Encoding.UTF8));
  2060. iform.ShowDialog();
  2061. }
  2062. else
  2063. {
  2064. MessageBox.Show("There are no errors to show!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
  2065. }
  2066. }
  2067. private void btnOpenConf_Click(object sender, EventArgs e)
  2068. {
  2069. Process.Start(Required.CoreFolder);
  2070. }
  2071. private void btnPing_Click(object sender, EventArgs e)
  2072. {
  2073. if (string.IsNullOrEmpty(txtPingInput.Text)) return;
  2074. _pingResults = new List<PingReply>();
  2075. listPingResults.Items.Clear();
  2076. if (Utilities.PingHost(txtPingInput.Text) == null)
  2077. {
  2078. listPingResults.Items.Add(string.Format("Could not find host [{0}]", txtPingInput.Text));
  2079. return;
  2080. }
  2081. Task pinger = new Task(() =>
  2082. {
  2083. btnShodan.Enabled = false;
  2084. btnPing.Enabled = false;
  2085. listPingResults.Items.Add(string.Format("Pinging [{0}] with 32 bytes - 9 times...", txtPingInput.Text));
  2086. listPingResults.Items.Add("");
  2087. for (int i = 0; i < 9; i++)
  2088. {
  2089. tmpReply = Utilities.PingHost(txtPingInput.Text);
  2090. if (tmpReply.Address == null)
  2091. {
  2092. listPingResults.Items.Add(tmpReply.Status);
  2093. }
  2094. else
  2095. {
  2096. _pingResults.Add(tmpReply);
  2097. _shodanIP = _pingResults[i].Address.ToString();
  2098. listPingResults.Items.Add(string.Format("{0} - LATENCY: {1} ms - TTL: {2}", _pingResults[i].Status, _pingResults[i].RoundtripTime, _pingResults[i].Options.Ttl));
  2099. }
  2100. }
  2101. listPingResults.Items.Add("");
  2102. // calculate statistics
  2103. if (_pingResults.Count > 0)
  2104. {
  2105. long maxLatency = _pingResults.Max(x => x.RoundtripTime);
  2106. long minLatency = _pingResults.Min(x => x.RoundtripTime);
  2107. double averageLatency = _pingResults.Average(x => x.RoundtripTime);
  2108. listPingResults.Items.Add(string.Format("LATENCY: Min = {0}, Max = {1}, Average = {2:F2}", minLatency, maxLatency, averageLatency));
  2109. }
  2110. else
  2111. {
  2112. listPingResults.Items.Add("All packets timed out");
  2113. }
  2114. btnPing.Enabled = true;
  2115. btnShodan.Enabled = true;
  2116. });
  2117. pinger.Start();
  2118. }
  2119. private void btnCheckFootprint_Click(object sender, EventArgs e)
  2120. {
  2121. CleanHelper.CheckFootprint();
  2122. }
  2123. private void btnShodan_Click(object sender, EventArgs e)
  2124. {
  2125. IPAddress tryIP;
  2126. if (IPAddress.TryParse(txtPingInput.Text, out tryIP))
  2127. {
  2128. Process.Start(string.Format("https://www.shodan.io/host/{0}", txtPingInput.Text));
  2129. return;
  2130. }
  2131. if (!string.IsNullOrEmpty(_shodanIP))
  2132. {
  2133. Process.Start(string.Format("https://www.shodan.io/host/{0}", _shodanIP));
  2134. return;
  2135. }
  2136. }
  2137. private void button9_Click(object sender, EventArgs e)
  2138. {
  2139. try
  2140. {
  2141. Clipboard.SetText(_shodanIP);
  2142. }
  2143. catch { }
  2144. }
  2145. private void button7_Click(object sender, EventArgs e)
  2146. {
  2147. try
  2148. {
  2149. Clipboard.SetText(txtPingInput.Text);
  2150. }
  2151. catch { }
  2152. }
  2153. private void txtPingInput_KeyDown(object sender, KeyEventArgs e)
  2154. {
  2155. if (e.KeyCode == Keys.Enter) btnPing.PerformClick();
  2156. }
  2157. private void btnExport_Click(object sender, EventArgs e)
  2158. {
  2159. if (ExportDialog.ShowDialog() == DialogResult.OK)
  2160. {
  2161. try
  2162. {
  2163. File.WriteAllLines(ExportDialog.FileName, listPingResults.Items.Cast<string>());
  2164. }
  2165. catch (Exception ex)
  2166. {
  2167. ErrorLogger.LogError("btnExport.Click", ex.Message, ex.StackTrace);
  2168. MessageBox.Show(ex.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
  2169. }
  2170. }
  2171. }
  2172. private void startupItem_Click(object sender, EventArgs e)
  2173. {
  2174. tabCollection.SelectedTab = startupTab;
  2175. RestoreWindow();
  2176. }
  2177. private void cleanerItem_Click(object sender, EventArgs e)
  2178. {
  2179. tabCollection.SelectedTab = cleanerTab;
  2180. RestoreWindow();
  2181. }
  2182. private void pingerItem_Click(object sender, EventArgs e)
  2183. {
  2184. tabCollection.SelectedTab = pingerTab;
  2185. RestoreWindow();
  2186. txtPingInput.Focus();
  2187. }
  2188. private void hostsItem_Click(object sender, EventArgs e)
  2189. {
  2190. tabCollection.SelectedTab = hostsEditorTab;
  2191. RestoreWindow();
  2192. txtIP.Focus();
  2193. }
  2194. private void appsItem_Click(object sender, EventArgs e)
  2195. {
  2196. tabCollection.SelectedTab = appsTab;
  2197. RestoreWindow();
  2198. }
  2199. private void exitItem_Click(object sender, EventArgs e)
  2200. {
  2201. _trayMenu = false;
  2202. Options.CurrentOptions.AppsFolder = txtDownloadFolder.Text;
  2203. Options.SaveSettings();
  2204. Application.Exit();
  2205. }
  2206. private void RestoreWindow()
  2207. {
  2208. if (this.WindowState == FormWindowState.Minimized) this.WindowState = FormWindowState.Normal;
  2209. this.Show();
  2210. this.Activate();
  2211. this.Focus();
  2212. }
  2213. private void launcherIcon_MouseDoubleClick(object sender, MouseEventArgs e)
  2214. {
  2215. if (this.Visible)
  2216. {
  2217. if (this.WindowState == FormWindowState.Minimized) this.WindowState = FormWindowState.Normal;
  2218. this.Hide();
  2219. }
  2220. else
  2221. {
  2222. RestoreWindow();
  2223. }
  2224. }
  2225. private void quickAccessToggle_CheckedChanged(object sender, EventArgs e)
  2226. {
  2227. Options.CurrentOptions.EnableTray = quickAccessToggle.Checked;
  2228. Options.SaveSettings();
  2229. _trayMenu = quickAccessToggle.Checked;
  2230. launcherIcon.Visible = quickAccessToggle.Checked;
  2231. }
  2232. }
  2233. }