MainForm.cs 90 KB

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