MainForm.cs 89 KB

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