MainForm.cs 111 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142
  1. using Newtonsoft.Json;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Diagnostics;
  6. using System.Drawing;
  7. using System.Globalization;
  8. using System.IO;
  9. using System.IO.Compression;
  10. using System.Linq;
  11. using System.Net;
  12. using System.Net.NetworkInformation;
  13. using System.Reflection;
  14. using System.Text;
  15. using System.Threading.Tasks;
  16. using System.Windows.Forms;
  17. namespace Optimizer
  18. {
  19. public partial class MainForm : Form
  20. {
  21. ListViewColumnSorter _columnSorter;
  22. List<StartupItem> _startUpItems = new List<StartupItem>();
  23. List<StartupBackupItem> _backupItems = new List<StartupBackupItem>();
  24. List<string> _hostsEntries = new List<string>();
  25. List<string> _customCommands = new List<string>();
  26. List<string> _desktopItems = new List<string>();
  27. List<string> _modernApps = new List<string>();
  28. bool _trayMenu = false;
  29. List<PingReply> _pingResults;
  30. string _shodanIP = string.Empty;
  31. PingReply tmpReply;
  32. //NetworkMonitor _networkMonitor;
  33. //double uploadSpeed = 0;
  34. //double downloadSpeed = 0;
  35. DesktopItemType _desktopItemType = DesktopItemType.Program;
  36. DesktopTypePosition _desktopItemPosition = DesktopTypePosition.Top;
  37. public List<FeedApp> AppsFromFeed = new List<FeedApp>();
  38. readonly string _feedLink = "https://raw.githubusercontent.com/hellzerg/optimizer/master/feed.json";
  39. readonly string _feedImages = "https://raw.githubusercontent.com/hellzerg/optimizer/master/images/feed.zip";
  40. readonly string _licenseLink = "https://www.gnu.org/licenses/gpl-3.0.en.html";
  41. readonly string _openSourceLink = "https://opensource.org/";
  42. readonly string _latestVersionLink = "https://raw.githubusercontent.com/hellzerg/optimizer/master/version.txt";
  43. readonly string _changelogLink = "https://github.com/hellzerg/optimizer/blob/master/CHANGELOG.md";
  44. string _noNewVersionMessage = "You already have the latest version!";
  45. string _betaVersionMessage = "You are using an experimental version!";
  46. readonly string _blockedIP = "0.0.0.0";
  47. string _restartMessage = "Restart to apply changes?";
  48. string _removeStartupItemsMessage = "Are you sure you want to delete these startup items?\n\n";
  49. string _removeHostsEntriesMessage = "Are you sure you want to delete all hosts entries?";
  50. string _removeDesktopItemsMessage = "Are you sure you want to delete all desktop items?";
  51. string _removeModernAppsMessage = "Are you sure you want to uninstall the following app(s)?";
  52. string _errorModernAppsMessage = "The following app(s) couldn't be uninstalled:\n";
  53. 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!";
  54. private string NewVersionMessage(string latestVersion)
  55. {
  56. return Options.TranslationList["newVersion"].ToString().Replace("{LATEST}", latestVersion).Replace("{CURRENT}", Program.GetCurrentVersionTostring());
  57. }
  58. private string NewDownloadLink(string latestVersion)
  59. {
  60. return string.Format("https://github.com/hellzerg/optimizer/releases/download/{0}/Optimizer-{0}.exe", latestVersion);
  61. }
  62. private void CheckForUpdate(bool silentCheck = false)
  63. {
  64. WebClient client = new WebClient
  65. {
  66. Encoding = Encoding.UTF8
  67. };
  68. string latestVersion = string.Empty;
  69. try
  70. {
  71. latestVersion = client.DownloadString(_latestVersionLink).Trim();
  72. }
  73. catch (Exception ex)
  74. {
  75. ErrorLogger.LogError("MainForm.CheckForUpdate", ex.Message, ex.StackTrace);
  76. MessageBox.Show(ex.Message, "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
  77. }
  78. if (!string.IsNullOrEmpty(latestVersion))
  79. {
  80. if (float.Parse(latestVersion) > Program.GetCurrentVersion())
  81. {
  82. // show UPDATE AVAILABLE on app launch
  83. if (silentCheck)
  84. {
  85. linkUpdate.Visible = true;
  86. return;
  87. }
  88. if (MessageBox.Show(NewVersionMessage(latestVersion), "Optimizer", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  89. {
  90. // PATCHING PROCESS
  91. try
  92. {
  93. Assembly currentAssembly = Assembly.GetEntryAssembly();
  94. if (currentAssembly == null)
  95. {
  96. currentAssembly = Assembly.GetCallingAssembly();
  97. }
  98. string appFolder = Path.GetDirectoryName(currentAssembly.Location);
  99. string appName = Path.GetFileNameWithoutExtension(currentAssembly.Location);
  100. string appExtension = Path.GetExtension(currentAssembly.Location);
  101. string archiveFile = Path.Combine(appFolder, "Optimizer_old" + appExtension);
  102. string appFile = Path.Combine(appFolder, appName + appExtension);
  103. string tempFile = Path.Combine(appFolder, "Optimizer_tmp" + appExtension);
  104. // DOWNLOAD NEW VERSION
  105. client.DownloadFile(NewDownloadLink(latestVersion), tempFile);
  106. // DELETE PREVIOUS BACK-UP
  107. if (File.Exists(archiveFile))
  108. {
  109. File.Delete(archiveFile);
  110. }
  111. // MAKE BACK-UP
  112. File.Move(appFile, archiveFile);
  113. // PATCH
  114. File.Move(tempFile, appFile);
  115. _trayMenu = false;
  116. // BYPASS SINGLE-INSTANCE MECHANISM
  117. if (Program.MUTEX != null)
  118. {
  119. Program.MUTEX.ReleaseMutex();
  120. Program.MUTEX.Dispose();
  121. Program.MUTEX = null;
  122. }
  123. Application.Restart();
  124. }
  125. catch (Exception ex)
  126. {
  127. ErrorLogger.LogError("MainForm.CheckForUpdate", ex.Message, ex.StackTrace);
  128. MessageBox.Show(ex.Message);
  129. }
  130. }
  131. }
  132. else if (float.Parse(latestVersion) == Program.GetCurrentVersion())
  133. {
  134. if (!silentCheck) MessageBox.Show(_noNewVersionMessage, "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
  135. }
  136. else
  137. {
  138. if (!silentCheck) MessageBox.Show(_betaVersionMessage, "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
  139. }
  140. }
  141. }
  142. private void EnableToggleEvents()
  143. {
  144. actionSw.Click += new EventHandler(ToggleSwitch7_Click);
  145. officeTelemetrySw.Click += new EventHandler(toggleSwitch12_Click);
  146. telemetryTasksSw.Click += new EventHandler(toggleSwitch11_Click);
  147. superfetchSw.Click += new EventHandler(toggleSwitch10_Click);
  148. homegroupSw.Click += new EventHandler(toggleSwitch9_Click);
  149. reportingSw.Click += new EventHandler(toggleSwitch8_Click);
  150. mediaSharingSw.Click += new EventHandler(toggleSwitch6_Click);
  151. printSw.Click += new EventHandler(toggleSwitch5_Click);
  152. systemRestoreSw.Click += new EventHandler(toggleSwitch4_Click);
  153. performanceSw.Click += new EventHandler(toggleSwitch1_Click);
  154. defenderSw.Click += new EventHandler(toggleSwitch3_Click);
  155. networkSw.Click += new EventHandler(toggleSwitch2_Click);
  156. darkSw.Click += new EventHandler(toggleSwitch27_Click);
  157. spellSw.Click += new EventHandler(toggleSwitch28_Click);
  158. inkSw.Click += new EventHandler(toggleSwitch29_Click);
  159. driversSw.Click += new EventHandler(toggleSwitch30_Click);
  160. sensorSw.Click += new EventHandler(toggleSwitch20_Click);
  161. privacySw.Click += new EventHandler(toggleSwitch21_Click);
  162. telemetryServicesSw.Click += new EventHandler(toggleSwitch23_Click);
  163. autoUpdatesSw.Click += new EventHandler(toggleSwitch24_Click);
  164. peopleSw.Click += new EventHandler(toggleSwitch25_Click);
  165. adsSw.Click += new EventHandler(toggleSwitch26_Click);
  166. xboxSw.Click += new EventHandler(toggleSwitch17_Click);
  167. cortanaSw.Click += new EventHandler(toggleSwitch16_Click);
  168. gameBarSw.Click += new EventHandler(toggleSwitch15_Click);
  169. uODSw.Click += new EventHandler(toggleSwitch14_Click);
  170. oldMixerSw.Click += new EventHandler(toggleSwitch13_Click);
  171. disableOneDriveSw.Click += new EventHandler(toggleSwitch31_Click);
  172. oldExplorerSw.Click += new EventHandler(toggleSwitch18_Click);
  173. colorBarSw.Click += new EventHandler(toggleSwitch19_Click);
  174. compatSw.Click += new EventHandler(toggleSwitch32_Click);
  175. faxSw.Click += new EventHandler(ToggleSwitch33_Click);
  176. insiderSw.Click += new EventHandler(ToggleSwitch34_Click);
  177. featuresSw.Click += new EventHandler(ToggleSwitch35_Click);
  178. smartScreenSw.Click += new EventHandler(ToggleSwitch36_Click);
  179. ccSw.Click += new EventHandler(ToggleSwitch37_Click);
  180. stickySw.Click += new EventHandler(ToggleSwitch38_Click);
  181. longPathsSw.Click += new EventHandler(ToggleSwitch39_Click);
  182. castSw.Click += new EventHandler(ToggleSwitch40_Click);
  183. leftTaskbarSw.Click += LeftTaskbarSw_Click;
  184. snapAssistSw.Click += SnapAssistSw_Click;
  185. widgetsSw.Click += WidgetsSw_Click;
  186. smallerTaskbarSw.Click += SmallerTaskbarSw_Click;
  187. chatSw.Click += chatSw_Click;
  188. classicRibbonSw.Click += ClassicRibbonSw_Click;
  189. classicContextSw.Click += ClassicContextSw_Click;
  190. }
  191. private void ClassicContextSw_Click(object sender, EventArgs e)
  192. {
  193. if (!classicContextSw.Checked)
  194. {
  195. Optimize.DisableShowMoreOptions();
  196. }
  197. else
  198. {
  199. Optimize.EnableShowMoreOptions();
  200. }
  201. Options.CurrentOptions.ClassicMenu = !classicContextSw.Checked;
  202. }
  203. private void ClassicRibbonSw_Click(object sender, EventArgs e)
  204. {
  205. if (!classicRibbonSw.Checked)
  206. {
  207. Optimize.EnableFileExplorerClassicRibbon();
  208. }
  209. else
  210. {
  211. Optimize.DisableFileExplorerClassicRibbon();
  212. }
  213. Options.CurrentOptions.ClassicRibbon = !classicContextSw.Checked;
  214. }
  215. private void chatSw_Click(object sender, EventArgs e)
  216. {
  217. if (!chatSw.Checked)
  218. {
  219. Optimize.DisableChat();
  220. }
  221. else
  222. {
  223. Optimize.EnableChat();
  224. }
  225. Options.CurrentOptions.DisableChat = !chatSw.Checked;
  226. }
  227. private void SmallerTaskbarSw_Click(object sender, EventArgs e)
  228. {
  229. if (!smallerTaskbarSw.Checked)
  230. {
  231. Optimize.SmallerTaskbar();
  232. }
  233. else
  234. {
  235. Optimize.DefaultTaskbarSize();
  236. }
  237. Options.CurrentOptions.TaskbarSmaller = !smallerTaskbarSw.Checked;
  238. }
  239. private void WidgetsSw_Click(object sender, EventArgs e)
  240. {
  241. if (!widgetsSw.Checked)
  242. {
  243. Optimize.DisableWidgets();
  244. }
  245. else
  246. {
  247. Optimize.EnableWidgets();
  248. }
  249. Options.CurrentOptions.DisableWidgets = !widgetsSw.Checked;
  250. }
  251. private void SnapAssistSw_Click(object sender, EventArgs e)
  252. {
  253. if (!snapAssistSw.Checked)
  254. {
  255. Optimize.DisableSnapAssist();
  256. }
  257. else
  258. {
  259. Optimize.EnableSnapAssist();
  260. }
  261. Options.CurrentOptions.DisableSnapAssist = !snapAssistSw.Checked;
  262. }
  263. private void LeftTaskbarSw_Click(object sender, EventArgs e)
  264. {
  265. if (!leftTaskbarSw.Checked)
  266. {
  267. Optimize.AlignTaskbarToLeft();
  268. }
  269. else
  270. {
  271. Optimize.AlignTaskbarToCenter();
  272. }
  273. Options.CurrentOptions.TaskbarToLeft = !leftTaskbarSw.Checked;
  274. }
  275. private void SetHelpBoxTranslation()
  276. {
  277. helpBox.SetToolTip(performanceSw, Options.TranslationList["performanceTip"].ToString());
  278. helpBox.SetToolTip(networkSw, Options.TranslationList["networkTip"].ToString());
  279. helpBox.SetToolTip(defenderSw, Options.TranslationList["defenderTip"].ToString());
  280. helpBox.SetToolTip(smartScreenSw, Options.TranslationList["smartScreenTip"].ToString());
  281. helpBox.SetToolTip(systemRestoreSw, Options.TranslationList["systemRestoreTip"].ToString());
  282. helpBox.SetToolTip(reportingSw, Options.TranslationList["reportingTip"].ToString());
  283. helpBox.SetToolTip(telemetryTasksSw, Options.TranslationList["telemetryTasksTip"].ToString());
  284. helpBox.SetToolTip(officeTelemetrySw, Options.TranslationList["officeTelemetryTip"].ToString());
  285. helpBox.SetToolTip(printSw, Options.TranslationList["printTip"].ToString());
  286. helpBox.SetToolTip(faxSw, Options.TranslationList["faxTip"].ToString());
  287. helpBox.SetToolTip(mediaSharingSw, Options.TranslationList["mediaSharingTip"].ToString());
  288. helpBox.SetToolTip(stickySw, Options.TranslationList["stickyTip"].ToString());
  289. helpBox.SetToolTip(homegroupSw, Options.TranslationList["homegroupTip"].ToString());
  290. helpBox.SetToolTip(superfetchSw, Options.TranslationList["superfetchTip"].ToString());
  291. helpBox.SetToolTip(compatSw, Options.TranslationList["compatTip"].ToString());
  292. helpBox.SetToolTip(disableOneDriveSw, Options.TranslationList["disableOneDriveTip"].ToString());
  293. helpBox.SetToolTip(oldMixerSw, Options.TranslationList["oldMixerTip"].ToString());
  294. helpBox.SetToolTip(colorBarSw, Options.TranslationList["colorBarTip"].ToString());
  295. helpBox.SetToolTip(oldExplorerSw, Options.TranslationList["oldExplorerTip"].ToString());
  296. helpBox.SetToolTip(adsSw, Options.TranslationList["adsTip"].ToString());
  297. helpBox.SetToolTip(darkSw, Options.TranslationList["darkTip"].ToString());
  298. helpBox.SetToolTip(uODSw, Options.TranslationList["uODTip"].ToString());
  299. helpBox.SetToolTip(peopleSw, Options.TranslationList["peopleTip"].ToString());
  300. helpBox.SetToolTip(longPathsSw, Options.TranslationList["longPathsTip"].ToString());
  301. helpBox.SetToolTip(inkSw, Options.TranslationList["inkTip"].ToString());
  302. helpBox.SetToolTip(spellSw, Options.TranslationList["spellTip"].ToString());
  303. helpBox.SetToolTip(xboxSw, Options.TranslationList["xboxTip"].ToString());
  304. helpBox.SetToolTip(actionSw, Options.TranslationList["actionTip"].ToString());
  305. helpBox.SetToolTip(autoUpdatesSw, Options.TranslationList["autoUpdatesTip"].ToString());
  306. helpBox.SetToolTip(driversSw, Options.TranslationList["driversTip"].ToString());
  307. helpBox.SetToolTip(telemetryServicesSw, Options.TranslationList["telemetryServicesTip"].ToString());
  308. helpBox.SetToolTip(privacySw, Options.TranslationList["privacyTip"].ToString());
  309. helpBox.SetToolTip(ccSw, Options.TranslationList["ccTip"].ToString());
  310. helpBox.SetToolTip(cortanaSw, Options.TranslationList["cortanaTip"].ToString());
  311. helpBox.SetToolTip(sensorSw, Options.TranslationList["sensorTip"].ToString());
  312. helpBox.SetToolTip(castSw, Options.TranslationList["castTip"].ToString());
  313. helpBox.SetToolTip(gameBarSw, Options.TranslationList["gameBarTip"].ToString());
  314. helpBox.SetToolTip(insiderSw, Options.TranslationList["insiderTip"].ToString());
  315. helpBox.SetToolTip(featuresSw, Options.TranslationList["featuresTip"].ToString());
  316. helpBox.SetToolTip(tpmSw, Options.TranslationList["tpmTip"].ToString());
  317. helpBox.SetToolTip(leftTaskbarSw, Options.TranslationList["leftTaskbarTip"].ToString());
  318. helpBox.SetToolTip(snapAssistSw, Options.TranslationList["snapAssistTip"].ToString());
  319. helpBox.SetToolTip(widgetsSw, Options.TranslationList["widgetsTip"].ToString());
  320. helpBox.SetToolTip(chatSw, Options.TranslationList["chatTip"].ToString());
  321. helpBox.SetToolTip(smallerTaskbarSw, Options.TranslationList["smallerTaskbarTip"].ToString());
  322. helpBox.SetToolTip(classicRibbonSw, Options.TranslationList["classicRibbonTip"].ToString());
  323. helpBox.SetToolTip(classicContextSw, Options.TranslationList["classicContextTip"].ToString());
  324. helpBox.ToolTipTitle = Options.TranslationList["tipWhatsThis"].ToString();
  325. }
  326. private void ToggleSwitch7_Click(object sender, EventArgs e)
  327. {
  328. if (!actionSw.Checked)
  329. {
  330. Optimize.DisableActionCenter();
  331. }
  332. else
  333. {
  334. Optimize.EnableActionCenter();
  335. }
  336. Options.CurrentOptions.DisableActionCenter = !actionSw.Checked;
  337. }
  338. private void ToggleSwitch40_Click(object sender, EventArgs e)
  339. {
  340. if (!castSw.Checked)
  341. {
  342. Optimize.RemoveCastToDevice();
  343. }
  344. else
  345. {
  346. Optimize.AddCastToDevice();
  347. }
  348. Options.CurrentOptions.RemoveCastToDevice = !castSw.Checked;
  349. }
  350. private void ToggleSwitch39_Click(object sender, EventArgs e)
  351. {
  352. if (!longPathsSw.Checked)
  353. {
  354. Optimize.EnableLongPaths();
  355. }
  356. else
  357. {
  358. Optimize.DisableLongPaths();
  359. }
  360. Options.CurrentOptions.EnableLongPaths = !longPathsSw.Checked;
  361. }
  362. private void ToggleSwitch38_Click(object sender, EventArgs e)
  363. {
  364. if (!stickySw.Checked)
  365. {
  366. Optimize.DisableStickyKeys();
  367. }
  368. else
  369. {
  370. Optimize.EnableStickyKeys();
  371. }
  372. Options.CurrentOptions.DisableStickyKeys = !stickySw.Checked;
  373. }
  374. private void ToggleSwitch37_Click(object sender, EventArgs e)
  375. {
  376. if (!ccSw.Checked)
  377. {
  378. Optimize.DisableCloudClipboard();
  379. }
  380. else
  381. {
  382. Optimize.EnableCloudClipboard();
  383. }
  384. Options.CurrentOptions.DisableCloudClipboard = !ccSw.Checked;
  385. }
  386. private void ToggleSwitch36_Click(object sender, EventArgs e)
  387. {
  388. if (!smartScreenSw.Checked)
  389. {
  390. Optimize.DisableSmartScreen();
  391. }
  392. else
  393. {
  394. Optimize.EnableSmartScreen();
  395. }
  396. Options.CurrentOptions.DisableSmartScreen = !smartScreenSw.Checked;
  397. }
  398. private void ToggleSwitch35_Click(object sender, EventArgs e)
  399. {
  400. if (!featuresSw.Checked)
  401. {
  402. Optimize.DisableForcedFeatureUpdates();
  403. }
  404. else
  405. {
  406. Optimize.EnableForcedFeatureUpdates();
  407. }
  408. Options.CurrentOptions.DisableFeatureUpdates = !featuresSw.Checked;
  409. }
  410. private void ToggleSwitch34_Click(object sender, EventArgs e)
  411. {
  412. if (!insiderSw.Checked)
  413. {
  414. Optimize.DisableInsiderService();
  415. }
  416. else
  417. {
  418. Optimize.EnableInsiderService();
  419. }
  420. Options.CurrentOptions.DisableInsiderService = !insiderSw.Checked;
  421. }
  422. private void ToggleSwitch33_Click(object sender, EventArgs e)
  423. {
  424. if (!faxSw.Checked)
  425. {
  426. Optimize.DisableFaxService();
  427. }
  428. else
  429. {
  430. Optimize.EnableFaxService();
  431. }
  432. Options.CurrentOptions.DisableFaxService = !faxSw.Checked;
  433. }
  434. private void LoadSettings()
  435. {
  436. switch (Options.CurrentOptions.Color)
  437. {
  438. case Theme.Caramel:
  439. radioCaramel.Checked = true;
  440. break;
  441. case Theme.Lime:
  442. radioLime.Checked = true;
  443. break;
  444. case Theme.Magma:
  445. radioMagma.Checked = true;
  446. break;
  447. case Theme.Minimal:
  448. radioMinimal.Checked = true;
  449. break;
  450. case Theme.Ocean:
  451. radioOcean.Checked = true;
  452. break;
  453. case Theme.Zerg:
  454. radioZerg.Checked = true;
  455. break;
  456. }
  457. }
  458. // INIT
  459. public MainForm()
  460. {
  461. InitializeComponent();
  462. CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US");
  463. CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo("en-US");
  464. CheckForIllegalCrossThreadCalls = false;
  465. EnableToggleEvents();
  466. // theming
  467. Options.ApplyTheme(this);
  468. launcherMenu.Renderer = new ToolStripRendererMaterial();
  469. progressDownloader.BackColor = Options.ForegroundColor;
  470. progressDownloader.ForeColor = Options.ForegroundAccentColor;
  471. // quick access
  472. _trayMenu = Options.CurrentOptions.EnableTray;
  473. quickAccessToggle.Checked = Options.CurrentOptions.EnableTray;
  474. launcherIcon.Visible = Options.CurrentOptions.EnableTray;
  475. // help tips
  476. helpBox.Active = Options.CurrentOptions.ShowHelp;
  477. helpTipsToggle.Checked = Options.CurrentOptions.ShowHelp;
  478. // fix SSL/TLS error when contacting internet
  479. ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
  480. // initial states
  481. chkOnlyRemovable.Checked = true;
  482. checkDefaultIcon.Checked = true;
  483. radioProgram.Checked = true;
  484. radioTop.Checked = true;
  485. c64.Checked = Environment.Is64BitOperatingSystem;
  486. c32.Checked = !Environment.Is64BitOperatingSystem;
  487. // EXPERIMENTAL message
  488. lblLab.Visible = Program.EXPERIMENTAL_BUILD;
  489. // Windows version, architecture, .NET Framework
  490. txtOS.Text = Utilities.GetOS();
  491. txtBitness.Text = Utilities.GetBitness();
  492. txtNetFw.Text = ".NET Framework " + Utilities.GetNETFramework();
  493. if (Utilities.CurrentWindowsVersion == WindowsVersion.Unsupported)
  494. {
  495. tabCollection.TabPages.Remove(universalTab);
  496. tabCollection.TabPages.Remove(windows8Tab);
  497. tabCollection.TabPages.Remove(windows10Tab);
  498. tabCollection.TabPages.Remove(modernAppsTab);
  499. }
  500. if (Utilities.CurrentWindowsVersion == WindowsVersion.Windows7)
  501. {
  502. LoadUniversalToggleStates();
  503. tabCollection.TabPages.Remove(windows8Tab);
  504. tabCollection.TabPages.Remove(windows10Tab);
  505. tabCollection.TabPages.Remove(modernAppsTab);
  506. }
  507. if (Utilities.CurrentWindowsVersion == WindowsVersion.Windows8)
  508. {
  509. LoadUniversalToggleStates();
  510. LoadWindowsVIIIToggleStates();
  511. tabCollection.TabPages.Remove(windows10Tab);
  512. GetModernApps(false);
  513. }
  514. if (Utilities.CurrentWindowsVersion == WindowsVersion.Windows10)
  515. {
  516. LoadUniversalToggleStates();
  517. LoadWindowsXToggleStates();
  518. tabCollection.TabPages.Remove(windows8Tab);
  519. this.Controls.Remove(panelWin11Tweaks);
  520. GetModernApps(false);
  521. txtOS.Text += string.Format(" ({0})", Utilities.GetWindows10Build());
  522. }
  523. if (Utilities.CurrentWindowsVersion == WindowsVersion.Windows11)
  524. {
  525. LoadUniversalToggleStates();
  526. LoadWindowsXToggleStates();
  527. LoadWindowsXIToggleStates();
  528. tabCollection.TabPages.Remove(windows8Tab);
  529. windows10Tab.Text = "Windows 11";
  530. panelWin11Tweaks.Visible = true;
  531. actionSw.Visible = false;
  532. oldMixerSw.Visible = false;
  533. GetModernApps(false);
  534. txtOS.Text += string.Format(" ({0})", Utilities.GetWindows10Build());
  535. }
  536. _columnSorter = new ListViewColumnSorter();
  537. listStartupItems.ListViewItemSorter = _columnSorter;
  538. GetStartupItems();
  539. GetHostsEntries();
  540. GetDesktopItems();
  541. GetCustomCommands();
  542. GetFeed();
  543. GetFootprint();
  544. LoadSettings();
  545. // Translation-related
  546. if (Options.CurrentOptions.LanguageCode == LanguageCode.EN)
  547. {
  548. radioEnglish.Checked = true;
  549. Translate(true);
  550. }
  551. else
  552. {
  553. Translate();
  554. }
  555. if (Options.CurrentOptions.LanguageCode == LanguageCode.RU) radioRussian.Checked = true;
  556. if (Options.CurrentOptions.LanguageCode == LanguageCode.TR) radioTurkish.Checked = true;
  557. if (Options.CurrentOptions.LanguageCode == LanguageCode.EL) radioHellenic.Checked = true;
  558. if (Options.CurrentOptions.LanguageCode == LanguageCode.DE) radioGerman.Checked = true;
  559. if (Options.CurrentOptions.LanguageCode == LanguageCode.PT) radioPortuguese.Checked = true;
  560. if (Options.CurrentOptions.LanguageCode == LanguageCode.FR) radioFrench.Checked = true;
  561. if (Options.CurrentOptions.LanguageCode == LanguageCode.ES) radioSpanish.Checked = true;
  562. Program.MainForm = this;
  563. if (string.IsNullOrEmpty(Options.CurrentOptions.AppsFolder))
  564. {
  565. txtDownloadFolder.Text = Path.Combine(Application.StartupPath, "Optimizer Downloads");
  566. Options.CurrentOptions.AppsFolder = Path.Combine(Application.StartupPath, "Optimizer Downloads");
  567. Directory.CreateDirectory(Options.CurrentOptions.AppsFolder);
  568. Options.SaveSettings();
  569. }
  570. else
  571. {
  572. if (!Directory.Exists(Options.CurrentOptions.AppsFolder))
  573. {
  574. try
  575. {
  576. Directory.CreateDirectory(Options.CurrentOptions.AppsFolder);
  577. }
  578. catch (Exception ex)
  579. {
  580. txtDownloadFolder.Text = string.Empty;
  581. ErrorLogger.LogError("MainForm.INIT", ex.Message, ex.StackTrace);
  582. }
  583. }
  584. txtDownloadFolder.Text = Options.CurrentOptions.AppsFolder;
  585. }
  586. if (!Program.EXPERIMENTAL_BUILD && Utilities.IsInternetAvailable()) CheckForUpdate(true);
  587. if (Program.EXPERIMENTAL_BUILD)
  588. {
  589. btnUpdate.Enabled = false;
  590. lblUpdateDisabled.Visible = true;
  591. }
  592. //_networkMonitor = new NetworkMonitor();
  593. }
  594. //private void NetworkMonitoring()
  595. //{
  596. // while (true)
  597. // {
  598. // downloadSpeed = 0;
  599. // uploadSpeed = 0;
  600. // foreach (NetworkAdapter adapter in _networkMonitor.Adapters)
  601. // {
  602. // //adapter.Refresh();
  603. // downloadSpeed += Math.Round(adapter.DownloadSpeedMbps, 2);
  604. // uploadSpeed += Math.Round(adapter.UploadSpeedMbps, 2);
  605. // }
  606. // this.Text = string.Format("Optimizer - DOWN: {0} UP: {1}", downloadSpeed, uploadSpeed);
  607. // Thread.Sleep(1000);
  608. // }
  609. //}
  610. private void Translate(bool skipFull = false)
  611. {
  612. Dictionary<string, string> translationList = Options.TranslationList.ToObject<Dictionary<string, string>>();
  613. if (Environment.Is64BitOperatingSystem)
  614. {
  615. translationList["txtBitness"] = translationList["txtBitness"].Replace("{BITS}", translationList["c64"]);
  616. }
  617. else
  618. {
  619. translationList["txtBitness"] = translationList["txtBitness"].Replace("{BITS}", translationList["c32"]);
  620. }
  621. SetHelpBoxTranslation();
  622. if (!skipFull)
  623. {
  624. _noNewVersionMessage = Options.TranslationList["noNewVersion"];
  625. _betaVersionMessage = Options.TranslationList["betaVersion"];
  626. _restartMessage = Options.TranslationList["restartAndApply"];
  627. _removeStartupItemsMessage = Options.TranslationList["removeAllStartup"];
  628. _removeHostsEntriesMessage = Options.TranslationList["removeAllHosts"];
  629. _removeDesktopItemsMessage = Options.TranslationList["removeAllItems"];
  630. _removeModernAppsMessage = Options.TranslationList["removeModernApps"];
  631. _errorModernAppsMessage = Options.TranslationList["errorModernApps"];
  632. _resetMessage = Options.TranslationList["resetMessage"];
  633. listStartupItems.Columns[0].Text = translationList["startupItemName"];
  634. listStartupItems.Columns[1].Text = translationList["startupItemLocation"];
  635. listStartupItems.Columns[2].Text = translationList["startupItemType"];
  636. trayStartup.Text = translationList["trayStartup"];
  637. trayCleaner.Text = translationList["trayCleaner"];
  638. trayPinger.Text = translationList["trayPinger"];
  639. trayHosts.Text = translationList["trayHosts"];
  640. trayAD.Text = translationList["trayAD"];
  641. trayRestartExplorer.Text = translationList["trayRestartExplorer"];
  642. trayExit.Text = translationList["trayExit"];
  643. Control element;
  644. foreach (var x in translationList)
  645. {
  646. if (x.Key == null || x.Key == string.Empty) continue;
  647. element = this.Controls.Find(x.Key, true).FirstOrDefault();
  648. if (element == null) continue;
  649. if (element is ToggleSwitch)
  650. {
  651. ((ToggleSwitch)element).OnText = x.Value;
  652. continue;
  653. }
  654. element.Text = x.Value;
  655. }
  656. }
  657. txtVersion.Text = txtVersion.Text.Replace("{VN}", Program.GetCurrentVersionTostring());
  658. }
  659. private void GetFootprint()
  660. {
  661. ByteSize footprint = CleanHelper.CheckFootprint();
  662. lblFootprint.Text = footprint.ToString();
  663. }
  664. private void GetFeed()
  665. {
  666. WebClient client = new WebClient
  667. {
  668. Encoding = Encoding.UTF8
  669. };
  670. client.Headers.Add("Cache-Control", "no-cache");
  671. try
  672. {
  673. byte[] feedData;
  674. string tmpImageFileName = string.Empty;
  675. feedData = client.DownloadData(_feedImages);
  676. using (ZipArchive zip = new ZipArchive(new MemoryStream(feedData)))
  677. {
  678. var zipEntries = zip.Entries;
  679. try
  680. {
  681. string feed = client.DownloadString(_feedLink);
  682. AppsFromFeed = JsonConvert.DeserializeObject<List<FeedApp>>(feed);
  683. AppCard appCard;
  684. groupSystemTools.Controls.Clear();
  685. groupInternet.Controls.Clear();
  686. groupCoding.Controls.Clear();
  687. groupSoundVideo.Controls.Clear();
  688. foreach (FeedApp x in AppsFromFeed)
  689. {
  690. appCard = new AppCard();
  691. appCard.AutoSize = true;
  692. appCard.Anchor = AnchorStyles.None;
  693. appCard.Anchor = AnchorStyles.Top | AnchorStyles.Left;
  694. appCard.appTitle.Text = x.Title;
  695. appCard.appTitle.Name = x.Tag;
  696. appCard.appImage.SizeMode = PictureBoxSizeMode.Zoom;
  697. tmpImageFileName = x.Image.Substring(x.Image.LastIndexOf("/") + 1, x.Image.Length - (x.Image.LastIndexOf("/") + 1));
  698. appCard.appImage.Image = Image.FromStream(zipEntries.First(ifn => ifn.Name == tmpImageFileName).Open());
  699. switch (x.Group)
  700. {
  701. case "SystemTools":
  702. appCard.Location = new Point(0, groupSystemTools.Controls.Count * 30);
  703. groupSystemTools.Controls.Add(appCard);
  704. break;
  705. case "Internet":
  706. appCard.Location = new Point(0, groupInternet.Controls.Count * 30);
  707. groupInternet.Controls.Add(appCard);
  708. break;
  709. case "Coding":
  710. appCard.Location = new Point(0, groupCoding.Controls.Count * 30);
  711. groupCoding.Controls.Add(appCard);
  712. break;
  713. case "GraphicsSound":
  714. appCard.Location = new Point(0, groupSoundVideo.Controls.Count * 30);
  715. groupSoundVideo.Controls.Add(appCard);
  716. break;
  717. default:
  718. break;
  719. }
  720. }
  721. // UI handling
  722. btnDownloadApps.Enabled = true;
  723. txtFeedError.Visible = false;
  724. }
  725. catch (Exception ex)
  726. {
  727. btnDownloadApps.Enabled = false;
  728. txtFeedError.Visible = true;
  729. ErrorLogger.LogError("MainForm.GetFeed", ex.Message, ex.StackTrace);
  730. }
  731. }
  732. }
  733. catch (Exception ex)
  734. {
  735. btnDownloadApps.Enabled = false;
  736. txtFeedError.Visible = true;
  737. ErrorLogger.LogError("MainForm.GetFeed-DownloadImages", ex.Message, ex.StackTrace);
  738. }
  739. }
  740. private void CleanPC()
  741. {
  742. try
  743. {
  744. if (checkTemp.Checked)
  745. {
  746. CleanHelper.PreviewTemp();
  747. }
  748. if (checkMiniDumps.Checked)
  749. {
  750. CleanHelper.PreviewMinidumps();
  751. }
  752. if (checkErrorReports.Checked)
  753. {
  754. CleanHelper.PreviewErrorReports();
  755. }
  756. if (checkBin.Checked)
  757. {
  758. CleanHelper.EmptyRecycleBin();
  759. }
  760. }
  761. catch (Exception ex)
  762. {
  763. ErrorLogger.LogError("MainForm.CleanPC", ex.Message, ex.StackTrace);
  764. }
  765. finally
  766. {
  767. if (CleanHelper.PreviewCleanList.Count > 0) new CleanPreviewForm(CleanHelper.PreviewCleanList).ShowDialog();
  768. GetFootprint();
  769. }
  770. }
  771. private bool FixRegistry()
  772. {
  773. bool changeDetected = false;
  774. try
  775. {
  776. if (checkFirewall.Checked)
  777. {
  778. Utilities.EnableFirewall();
  779. changeDetected = true;
  780. }
  781. if (checkCommandPrompt.Checked)
  782. {
  783. Utilities.EnableCommandPrompt();
  784. changeDetected = true;
  785. }
  786. if (checkControlPanel.Checked)
  787. {
  788. Utilities.EnableControlPanel();
  789. changeDetected = true;
  790. }
  791. if (checkFolderOptions.Checked)
  792. {
  793. Utilities.EnableFolderOptions();
  794. changeDetected = true;
  795. }
  796. if (checkRunDialog.Checked)
  797. {
  798. Utilities.EnableRunDialog();
  799. changeDetected = true;
  800. }
  801. if (checkContextMenu.Checked)
  802. {
  803. Utilities.EnableContextMenu();
  804. changeDetected = true;
  805. }
  806. if (checkTaskManager.Checked)
  807. {
  808. Utilities.EnableTaskManager();
  809. changeDetected = true;
  810. }
  811. if (checkRegistryEditor.Checked)
  812. {
  813. Utilities.EnableRegistryEditor();
  814. changeDetected = true;
  815. }
  816. }
  817. catch (Exception ex)
  818. {
  819. ErrorLogger.LogError("MainForm.FixRegistry", ex.Message, ex.StackTrace);
  820. }
  821. return changeDetected;
  822. }
  823. private void LoadUniversalToggleStates()
  824. {
  825. performanceSw.Checked = Options.CurrentOptions.EnablePerformanceTweaks;
  826. networkSw.Checked = Options.CurrentOptions.DisableNetworkThrottling;
  827. defenderSw.Checked = Options.CurrentOptions.DisableWindowsDefender;
  828. systemRestoreSw.Checked = Options.CurrentOptions.DisableSystemRestore;
  829. printSw.Checked = Options.CurrentOptions.DisablePrintService;
  830. mediaSharingSw.Checked = Options.CurrentOptions.DisableMediaPlayerSharing;
  831. reportingSw.Checked = Options.CurrentOptions.DisableErrorReporting;
  832. homegroupSw.Checked = Options.CurrentOptions.DisableHomeGroup;
  833. superfetchSw.Checked = Options.CurrentOptions.DisableSuperfetch;
  834. telemetryTasksSw.Checked = Options.CurrentOptions.DisableTelemetryTasks;
  835. officeTelemetrySw.Checked = Options.CurrentOptions.DisableOffice2016Telemetry;
  836. compatSw.Checked = Options.CurrentOptions.DisableCompatibilityAssistant;
  837. faxSw.Checked = Options.CurrentOptions.DisableFaxService;
  838. smartScreenSw.Checked = Options.CurrentOptions.DisableSmartScreen;
  839. stickySw.Checked = Options.CurrentOptions.DisableStickyKeys;
  840. }
  841. private void LoadWindowsVIIIToggleStates()
  842. {
  843. disableOneDriveSw.Checked = Options.CurrentOptions.DisableOneDrive;
  844. }
  845. private void LoadWindowsXToggleStates()
  846. {
  847. oldMixerSw.Checked = Options.CurrentOptions.EnableLegacyVolumeSlider;
  848. uODSw.Checked = Options.CurrentOptions.UninstallOneDrive;
  849. gameBarSw.Checked = Options.CurrentOptions.DisableGameBar;
  850. cortanaSw.Checked = Options.CurrentOptions.DisableCortana;
  851. xboxSw.Checked = Options.CurrentOptions.DisableXboxLive;
  852. oldExplorerSw.Checked = Options.CurrentOptions.DisableQuickAccessHistory;
  853. colorBarSw.Checked = Options.CurrentOptions.EnableTaskbarColor;
  854. sensorSw.Checked = Options.CurrentOptions.DisableSensorServices;
  855. privacySw.Checked = Options.CurrentOptions.DisablePrivacyOptions;
  856. telemetryServicesSw.Checked = Options.CurrentOptions.DisableTelemetryServices;
  857. autoUpdatesSw.Checked = Options.CurrentOptions.DisableAutomaticUpdates;
  858. peopleSw.Checked = Options.CurrentOptions.DisableMyPeople;
  859. adsSw.Checked = Options.CurrentOptions.DisableStartMenuAds;
  860. darkSw.Checked = Options.CurrentOptions.EnableDarkTheme;
  861. spellSw.Checked = Options.CurrentOptions.DisableSpellingTyping;
  862. inkSw.Checked = Options.CurrentOptions.DisableWindowsInk;
  863. driversSw.Checked = Options.CurrentOptions.ExcludeDrivers;
  864. insiderSw.Checked = Options.CurrentOptions.DisableInsiderService;
  865. featuresSw.Checked = Options.CurrentOptions.DisableFeatureUpdates;
  866. ccSw.Checked = Options.CurrentOptions.DisableCloudClipboard;
  867. longPathsSw.Checked = Options.CurrentOptions.EnableLongPaths;
  868. castSw.Checked = Options.CurrentOptions.RemoveCastToDevice;
  869. actionSw.Checked = Options.CurrentOptions.DisableActionCenter;
  870. }
  871. private void LoadWindowsXIToggleStates()
  872. {
  873. leftTaskbarSw.Checked = Options.CurrentOptions.TaskbarToLeft;
  874. snapAssistSw.Checked = Options.CurrentOptions.DisableSnapAssist;
  875. widgetsSw.Checked = Options.CurrentOptions.DisableWidgets;
  876. chatSw.Checked = Options.CurrentOptions.DisableChat;
  877. smallerTaskbarSw.Checked = Options.CurrentOptions.TaskbarSmaller;
  878. classicRibbonSw.Checked = Options.CurrentOptions.ClassicRibbon;
  879. classicContextSw.Checked = Options.CurrentOptions.ClassicMenu;
  880. tpmSw.Checked = Options.CurrentOptions.DisableTPMCheck;
  881. }
  882. private void Main_Load(object sender, EventArgs e)
  883. {
  884. }
  885. private void GetDesktopItems()
  886. {
  887. _desktopItems = Integrator.GetDesktopItems();
  888. listDesktopItems.Items.Clear();
  889. for (int i = 0; i < _desktopItems.Count; i++)
  890. {
  891. if (!string.IsNullOrEmpty(_desktopItems[i]))
  892. {
  893. listDesktopItems.Items.Add(_desktopItems[i]);
  894. }
  895. }
  896. if (_desktopItems.Count > 0) listDesktopItems.SelectedIndex = 0;
  897. }
  898. private void GetHostsEntries()
  899. {
  900. ((Control)this.hostsEditorTab).Enabled = false;
  901. _hostsEntries = HostsHelper.GetHostsEntries();
  902. listHostEntries.Items.Clear();
  903. listHostEntries.Items.AddRange(_hostsEntries.ToArray());
  904. chkReadOnly.Checked = HostsHelper.GetReadOnly();
  905. addHostB.Enabled = !chkReadOnly.Checked;
  906. removeAllHostsB.Enabled = !chkReadOnly.Checked;
  907. removeHostB.Enabled = !chkReadOnly.Checked;
  908. refreshHostsB.Enabled = !chkReadOnly.Checked;
  909. linkRestoreDefault.Enabled = !chkReadOnly.Checked;
  910. chkBlock.Enabled = !chkReadOnly.Checked;
  911. txtDomain.Enabled = !chkReadOnly.Checked;
  912. txtIP.Enabled = !chkReadOnly.Checked;
  913. adblockBasic.Enabled = !chkReadOnly.Checked;
  914. adblockS.Enabled = !chkReadOnly.Checked;
  915. adblockP.Enabled = !chkReadOnly.Checked;
  916. adblockUlti.Enabled = !chkReadOnly.Checked;
  917. ((Control)this.hostsEditorTab).Enabled = true;
  918. if (_hostsEntries.Count > 0) listHostEntries.SelectedIndex = 0;
  919. }
  920. private void GetStartupItems()
  921. {
  922. _startUpItems = Utilities.GetStartupItems();
  923. listStartupItems.Items.Clear();
  924. for (int i = 0; i < _startUpItems.Count; i++)
  925. {
  926. ListViewItem list = new ListViewItem(_startUpItems[i].Name);
  927. list.SubItems.Add(_startUpItems[i].FileLocation);
  928. list.SubItems.Add(_startUpItems[i].ToString());
  929. listStartupItems.Items.Add(list);
  930. }
  931. }
  932. private void GetModernApps(bool showAll)
  933. {
  934. uninstallModernAppsButton.Enabled = false;
  935. refreshModernAppsButton.Enabled = false;
  936. listModernApps.Enabled = false;
  937. listModernApps.Items.Clear();
  938. _modernApps = Utilities.GetModernApps(showAll);
  939. foreach (string x in _modernApps)
  940. {
  941. listModernApps.Items.Add(x);
  942. }
  943. uninstallModernAppsButton.Enabled = true;
  944. refreshModernAppsButton.Enabled = true;
  945. listModernApps.Enabled = true;
  946. if (_modernApps.Count > 0) listModernApps.SelectedIndex = 0;
  947. }
  948. private async void UninstallModernApps()
  949. {
  950. string selectedApps = string.Empty;
  951. if (listModernApps.CheckedItems.Count > 0)
  952. {
  953. foreach (string x in listModernApps.CheckedItems)
  954. {
  955. if (string.IsNullOrEmpty(selectedApps))
  956. {
  957. selectedApps = x;
  958. }
  959. else
  960. {
  961. selectedApps += Environment.NewLine + x;
  962. }
  963. }
  964. if (MessageBox.Show(_removeModernAppsMessage + "\n\n" + selectedApps, "Optimizer", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  965. {
  966. uninstallModernAppsButton.Enabled = false;
  967. refreshModernAppsButton.Enabled = false;
  968. listModernApps.Enabled = false;
  969. bool errorOccured = false;
  970. string failedApps = string.Empty;
  971. foreach (string app in listModernApps.CheckedItems)
  972. {
  973. await Task.Run(() => errorOccured = Utilities.UninstallModernApp(app));
  974. if (errorOccured)
  975. {
  976. failedApps += Environment.NewLine + app;
  977. }
  978. }
  979. if (!string.IsNullOrEmpty(failedApps))
  980. {
  981. MessageBox.Show(_errorModernAppsMessage + failedApps, "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
  982. }
  983. GetModernApps(!chkOnlyRemovable.Checked);
  984. }
  985. }
  986. }
  987. private void GetCustomCommands()
  988. {
  989. _customCommands = Integrator.GetCustomCommands();
  990. listCustomCommands.Items.Clear();
  991. foreach (string s in _customCommands)
  992. {
  993. listCustomCommands.Items.Add(s);
  994. }
  995. if (_customCommands.Count > 0) listCustomCommands.SelectedIndex = 0;
  996. }
  997. private void Main_FormClosing(object sender, FormClosingEventArgs e)
  998. {
  999. if (_trayMenu)
  1000. {
  1001. e.Cancel = true;
  1002. this.Hide();
  1003. }
  1004. else
  1005. {
  1006. Options.CurrentOptions.AppsFolder = txtDownloadFolder.Text;
  1007. Options.SaveSettings();
  1008. }
  1009. }
  1010. private void button39_Click(object sender, EventArgs e)
  1011. {
  1012. HelperForm f = new HelperForm(this, MessageType.Restart, _restartMessage);
  1013. f.ShowDialog();
  1014. }
  1015. private void button43_Click(object sender, EventArgs e)
  1016. {
  1017. HelperForm f = new HelperForm(this, MessageType.Restart, _restartMessage);
  1018. f.ShowDialog();
  1019. }
  1020. private void button44_Click(object sender, EventArgs e)
  1021. {
  1022. HelperForm f = new HelperForm(this, MessageType.Restart, _restartMessage);
  1023. f.ShowDialog();
  1024. }
  1025. private void button45_Click(object sender, EventArgs e)
  1026. {
  1027. HelperForm f = new HelperForm(this, MessageType.Restart, _restartMessage);
  1028. f.ShowDialog();
  1029. }
  1030. private void checkSelectAll_CheckedChanged(object sender, EventArgs e)
  1031. {
  1032. checkTemp.Checked = checkSelectAll.Checked;
  1033. checkMiniDumps.Checked = checkSelectAll.Checked;
  1034. checkErrorReports.Checked = checkSelectAll.Checked;
  1035. }
  1036. private void button20_Click(object sender, EventArgs e)
  1037. {
  1038. CleanHelper.PreviewCleanList.Clear();
  1039. CleanPC();
  1040. }
  1041. private void button32_Click(object sender, EventArgs e)
  1042. {
  1043. if (listStartupItems.CheckedItems.Count <= 0) return;
  1044. string report = string.Empty;
  1045. foreach (ListViewItem i in listStartupItems.CheckedItems)
  1046. {
  1047. report += i.Text + Environment.NewLine;
  1048. }
  1049. if (MessageBox.Show(_removeStartupItemsMessage + Environment.NewLine + Environment.NewLine + report, "Optimizer", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  1050. {
  1051. foreach (int x in listStartupItems.CheckedIndices)
  1052. {
  1053. _startUpItems[x].Remove();
  1054. }
  1055. GetStartupItems();
  1056. }
  1057. //foreach (int x in listStartupItems.CheckedIndices)
  1058. //{
  1059. // MessageBox.Show(x.ToString());
  1060. //}
  1061. //if (listStartupItems.SelectedItems.Count == 1)
  1062. //{
  1063. // _startUpItems[listStartupItems.SelectedIndices[0]].Remove();
  1064. // GetStartupItems();
  1065. //}
  1066. }
  1067. internal void RemoveAllStartupItems()
  1068. {
  1069. foreach (ListViewItem i in listStartupItems.Items)
  1070. {
  1071. _startUpItems[i.Index].Remove();
  1072. }
  1073. GetStartupItems();
  1074. }
  1075. // REMOVE ALL STARTUP ITEMS BUTTON
  1076. //private void button22_Click(object sender, EventArgs e)
  1077. //{
  1078. // if (listStartupItems.Items.Count > 0)
  1079. // {
  1080. // HelperForm r = new HelperForm(this, MessageType.Startup, _removeStartupItemsMessage);
  1081. // r.ShowDialog(this);
  1082. // }
  1083. //}
  1084. private void button31_Click(object sender, EventArgs e)
  1085. {
  1086. if (listStartupItems.SelectedItems.Count == 1)
  1087. {
  1088. _startUpItems[listStartupItems.SelectedIndices[0]].LocateFile();
  1089. }
  1090. }
  1091. private void checkEnableAll_CheckedChanged(object sender, EventArgs e)
  1092. {
  1093. checkTaskManager.Checked = checkEnableAll.Checked;
  1094. checkCommandPrompt.Checked = checkEnableAll.Checked;
  1095. checkControlPanel.Checked = checkEnableAll.Checked;
  1096. checkFolderOptions.Checked = checkEnableAll.Checked;
  1097. checkRunDialog.Checked = checkEnableAll.Checked;
  1098. checkContextMenu.Checked = checkEnableAll.Checked;
  1099. checkFirewall.Checked = checkEnableAll.Checked;
  1100. checkRegistryEditor.Checked = checkEnableAll.Checked;
  1101. }
  1102. private void button33_Click(object sender, EventArgs e)
  1103. {
  1104. bool flag = FixRegistry();
  1105. if (flag)
  1106. {
  1107. panel2.Enabled = false;
  1108. regFixB.Enabled = false;
  1109. if (checkRestartExplorer.Checked)
  1110. {
  1111. Utilities.RestartExplorer();
  1112. }
  1113. panel2.Enabled = true;
  1114. regFixB.Enabled = true;
  1115. }
  1116. }
  1117. private void pictureBox1_Click(object sender, EventArgs e)
  1118. {
  1119. AboutForm f = new AboutForm();
  1120. f.ShowDialog(this);
  1121. }
  1122. private void button37_Click(object sender, EventArgs e)
  1123. {
  1124. GetStartupItems();
  1125. }
  1126. private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  1127. {
  1128. HostsHelper.LocateHosts();
  1129. }
  1130. private void linkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  1131. {
  1132. HostsEditorForm f = new HostsEditorForm();
  1133. f.ShowDialog(this);
  1134. GetHostsEntries();
  1135. }
  1136. private void linkLabel4_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  1137. {
  1138. HostsHelper.RestoreDefaultHosts();
  1139. GetHostsEntries();
  1140. }
  1141. private void button47_Click(object sender, EventArgs e)
  1142. {
  1143. if ((txtIP.Text != string.Empty) && (txtDomain.Text != string.Empty))
  1144. {
  1145. string ip = txtIP.Text.Trim();
  1146. string domain = txtDomain.Text.Trim();
  1147. string recommendedDomain = string.Empty;
  1148. if (!domain.StartsWith("www."))
  1149. {
  1150. recommendedDomain = "www." + domain;
  1151. }
  1152. else
  1153. {
  1154. recommendedDomain = domain.Replace("www.", string.Empty);
  1155. }
  1156. HostsHelper.AddEntry(HostsHelper.SanitizeEntry(ip) + " " + HostsHelper.SanitizeEntry(domain));
  1157. if (!string.IsNullOrEmpty(recommendedDomain))
  1158. {
  1159. HostsHelper.AddEntry(HostsHelper.SanitizeEntry(ip) + " " + HostsHelper.SanitizeEntry(recommendedDomain));
  1160. }
  1161. GetHostsEntries();
  1162. txtIP.Clear();
  1163. txtDomain.Clear();
  1164. chkBlock.Checked = false;
  1165. }
  1166. }
  1167. private void button41_Click(object sender, EventArgs e)
  1168. {
  1169. GetHostsEntries();
  1170. }
  1171. private void button42_Click(object sender, EventArgs e)
  1172. {
  1173. if (listHostEntries.SelectedItems.Count == 1)
  1174. {
  1175. HostsHelper.RemoveEntry(listHostEntries.SelectedItem.ToString().Replace(" : ", " "));
  1176. GetHostsEntries();
  1177. }
  1178. }
  1179. private void button46_Click(object sender, EventArgs e)
  1180. {
  1181. if (listHostEntries.Items.Count > 0)
  1182. {
  1183. HelperForm r = new HelperForm(this, MessageType.Hosts, _removeHostsEntriesMessage);
  1184. r.ShowDialog(this);
  1185. }
  1186. }
  1187. internal void RemoveAllHostsEntries()
  1188. {
  1189. List<string> collection = new List<string>();
  1190. foreach (string item in listHostEntries.Items)
  1191. {
  1192. collection.Add(item.Replace(" : ", " "));
  1193. }
  1194. HostsHelper.RemoveAllEntries(collection);
  1195. GetHostsEntries();
  1196. }
  1197. private void aio_SelectedIndexChanged(object sender, EventArgs e)
  1198. {
  1199. if (tabCollection.SelectedTab == hostsEditorTab) txtIP.Focus();
  1200. if (tabCollection.SelectedTab == pingerTab)
  1201. {
  1202. txtPingInput.Focus();
  1203. //_networkMonitor.StartMonitoring();
  1204. //NetworkMonitoring();
  1205. }
  1206. //else
  1207. //{
  1208. // _networkMonitor.StopMonitoring();
  1209. //}
  1210. }
  1211. private void button48_Click(object sender, EventArgs e)
  1212. {
  1213. defineCommandDialog.ShowDialog();
  1214. }
  1215. private void button50_Click(object sender, EventArgs e)
  1216. {
  1217. if (!string.IsNullOrEmpty(txtRunFile.Text) && !string.IsNullOrEmpty(txtRunKeyword.Text))
  1218. {
  1219. Integrator.CreateCustomCommand(txtRunFile.Text, txtRunKeyword.Text);
  1220. txtRunFile.Clear();
  1221. txtRunKeyword.Clear();
  1222. GetCustomCommands();
  1223. }
  1224. }
  1225. private void DefineCmd_FileOk(object sender, CancelEventArgs e)
  1226. {
  1227. txtRunFile.Text = defineCommandDialog.FileName;
  1228. txtRunKeyword.Text = Path.GetFileNameWithoutExtension(txtRunFile.Text).ToLower();
  1229. }
  1230. private void button59_Click(object sender, EventArgs e)
  1231. {
  1232. Utilities.ImportRegistryScript(Required.ReadyMadeMenusFolder + "\\PowerMenu.reg");
  1233. GetDesktopItems();
  1234. }
  1235. private void button53_Click(object sender, EventArgs e)
  1236. {
  1237. Utilities.ImportRegistryScript(Required.ReadyMadeMenusFolder + "\\SystemTools.reg");
  1238. GetDesktopItems();
  1239. }
  1240. private void button54_Click(object sender, EventArgs e)
  1241. {
  1242. Utilities.ImportRegistryScript(Required.ReadyMadeMenusFolder + "\\WindowsApps.reg");
  1243. GetDesktopItems();
  1244. }
  1245. private void button51_Click(object sender, EventArgs e)
  1246. {
  1247. Utilities.ImportRegistryScript(Required.ReadyMadeMenusFolder + "\\SystemShortcuts.reg");
  1248. GetDesktopItems();
  1249. }
  1250. private void button57_Click(object sender, EventArgs e)
  1251. {
  1252. Utilities.ImportRegistryScript(Required.ReadyMadeMenusFolder + "\\DesktopShortcuts.reg");
  1253. GetDesktopItems();
  1254. }
  1255. private void button60_Click(object sender, EventArgs e)
  1256. {
  1257. GetDesktopItems();
  1258. }
  1259. private void button61_Click(object sender, EventArgs e)
  1260. {
  1261. if (listDesktopItems.SelectedItems.Count == 1)
  1262. {
  1263. Integrator.RemoveItem(listDesktopItems.SelectedItem.ToString());
  1264. GetDesktopItems();
  1265. }
  1266. }
  1267. internal void RemoveAllDesktopItems()
  1268. {
  1269. List<string> collection = new List<string>();
  1270. foreach (string item in listDesktopItems.Items)
  1271. {
  1272. collection.Add(item);
  1273. }
  1274. Integrator.RemoveAllItems(collection);
  1275. GetDesktopItems();
  1276. }
  1277. private void button62_Click(object sender, EventArgs e)
  1278. {
  1279. if (listDesktopItems.Items.Count > 0)
  1280. {
  1281. HelperForm r = new HelperForm(this, MessageType.Integrator, _removeDesktopItemsMessage);
  1282. r.ShowDialog(this);
  1283. }
  1284. }
  1285. private void radioProgram_CheckedChanged(object sender, EventArgs e)
  1286. {
  1287. if (radioProgram.Checked)
  1288. {
  1289. btnBrowseItem.Enabled = true;
  1290. txtItem.Clear();
  1291. checkDefaultIcon.Checked = true;
  1292. txtIcon.Enabled = false;
  1293. btnBrowseIcon.Enabled = false;
  1294. itemtoaddgroup.Text = Options.TranslationList["itemtoaddgroup"];
  1295. checkDefaultIcon.Visible = true;
  1296. checkDefaultIcon.Text = Options.TranslationList["checkDefaultIcon"];
  1297. txtItemName.Clear();
  1298. txtItem.ReadOnly = true;
  1299. txtIcon.ReadOnly = true;
  1300. _desktopItemType = DesktopItemType.Program;
  1301. }
  1302. }
  1303. private void radioFolder_CheckedChanged(object sender, EventArgs e)
  1304. {
  1305. if (radioFolder.Checked)
  1306. {
  1307. checkDefaultIcon.Checked = true;
  1308. btnBrowseItem.Enabled = true;
  1309. txtItem.Clear();
  1310. itemtoaddgroup.Text = Options.TranslationList["folderToAdd"];
  1311. checkDefaultIcon.Text = Options.TranslationList["checkDefaultFolderIcon"];
  1312. txtItemName.Clear();
  1313. txtItem.ReadOnly = true;
  1314. txtIcon.ReadOnly = true;
  1315. _desktopItemType = DesktopItemType.Folder;
  1316. }
  1317. }
  1318. private void radioLink_CheckedChanged(object sender, EventArgs e)
  1319. {
  1320. if (radioLink.Checked)
  1321. {
  1322. checkDefaultIcon.Checked = true;
  1323. checkDefaultIcon.Text = Options.TranslationList["checkFavicon"];
  1324. btnBrowseItem.Enabled = false;
  1325. itemtoaddgroup.Text = Options.TranslationList["linkToAdd"];
  1326. checkDefaultIcon.Visible = true;
  1327. txtItem.Text = "http://";
  1328. txtItemName.Clear();
  1329. txtItem.ReadOnly = false;
  1330. txtIcon.ReadOnly = true;
  1331. _desktopItemType = DesktopItemType.Link;
  1332. }
  1333. }
  1334. private void radioFile_CheckedChanged(object sender, EventArgs e)
  1335. {
  1336. if (radioFile.Checked)
  1337. {
  1338. checkDefaultIcon.Checked = true;
  1339. checkDefaultIcon.Text = Options.TranslationList["checkNoIcon"];
  1340. btnBrowseItem.Enabled = true;
  1341. itemtoaddgroup.Text = Options.TranslationList["fileToAdd"];
  1342. checkDefaultIcon.Visible = true;
  1343. txtItem.Clear();
  1344. txtItemName.Clear();
  1345. txtItem.ReadOnly = true;
  1346. txtIcon.ReadOnly = true;
  1347. _desktopItemType = DesktopItemType.File;
  1348. }
  1349. }
  1350. private void radioCommand_CheckedChanged(object sender, EventArgs e)
  1351. {
  1352. if (radioCommand.Checked)
  1353. {
  1354. btnBrowseItem.Enabled = false;
  1355. txtItem.Clear();
  1356. checkDefaultIcon.Checked = true;
  1357. txtIcon.Enabled = false;
  1358. btnBrowseIcon.Enabled = false;
  1359. itemtoaddgroup.Text = Options.TranslationList["commandToAdd"];
  1360. checkDefaultIcon.Visible = true;
  1361. checkDefaultIcon.Text = Options.TranslationList["checkNoIcon"];
  1362. txtItemName.Clear();
  1363. txtItem.ReadOnly = false;
  1364. txtIcon.ReadOnly = true;
  1365. _desktopItemType = DesktopItemType.Command;
  1366. }
  1367. }
  1368. private void checkDefaultIcon_CheckedChanged(object sender, EventArgs e)
  1369. {
  1370. if (checkDefaultIcon.Checked)
  1371. {
  1372. txtIcon.Clear();
  1373. txtIcon.Enabled = false;
  1374. btnBrowseIcon.Enabled = false;
  1375. }
  1376. else
  1377. {
  1378. txtIcon.Clear();
  1379. txtIcon.Enabled = true;
  1380. btnBrowseIcon.Enabled = true;
  1381. }
  1382. }
  1383. private void btnBrowseItem_Click(object sender, EventArgs e)
  1384. {
  1385. switch (_desktopItemType)
  1386. {
  1387. case DesktopItemType.Program:
  1388. defineProgramDialog.ShowDialog();
  1389. break;
  1390. case DesktopItemType.Folder:
  1391. defineFolderDialog.ShowDialog();
  1392. txtItem.Text = defineFolderDialog.SelectedPath;
  1393. int i = defineFolderDialog.SelectedPath.LastIndexOf("\\");
  1394. txtItemName.Text = defineFolderDialog.SelectedPath.Remove(0, i + 1);
  1395. break;
  1396. case DesktopItemType.File:
  1397. defineFileDialog.ShowDialog();
  1398. break;
  1399. }
  1400. }
  1401. private void DefineProgramDialog_FileOk(object sender, CancelEventArgs e)
  1402. {
  1403. txtItem.Text = defineProgramDialog.FileName;
  1404. txtItemName.Text = defineProgramDialog.SafeFileName.Replace(".exe", string.Empty);
  1405. }
  1406. private void DefineFileDialog_FileOk(object sender, CancelEventArgs e)
  1407. {
  1408. txtItem.Text = defineFileDialog.FileName;
  1409. txtItemName.Text = defineFileDialog.SafeFileName;
  1410. }
  1411. private void btnBrowseIcon_Click(object sender, EventArgs e)
  1412. {
  1413. switch (_desktopItemType)
  1414. {
  1415. case DesktopItemType.Program:
  1416. DefineProgramIconDialog.ShowDialog();
  1417. break;
  1418. case DesktopItemType.Folder:
  1419. DefineFolderIconDialog.ShowDialog();
  1420. break;
  1421. case DesktopItemType.Link:
  1422. DefineURLIconDialog.ShowDialog();
  1423. break;
  1424. case DesktopItemType.File:
  1425. DefineFileIconDialog.ShowDialog();
  1426. break;
  1427. case DesktopItemType.Command:
  1428. DefineCommandIconDialog.ShowDialog();
  1429. break;
  1430. }
  1431. }
  1432. private void DefineProgramIconDialog_FileOk(object sender, CancelEventArgs e)
  1433. {
  1434. txtIcon.Text = DefineProgramIconDialog.FileName;
  1435. if (txtIcon.Text.Contains(".exe"))
  1436. {
  1437. string iconpath = Integrator.ExtractIconFromExecutable(txtItemName.Text, DefineProgramIconDialog.FileName);
  1438. txtIcon.Text = iconpath;
  1439. }
  1440. }
  1441. private void DefineFolderIconDialog_FileOk(object sender, CancelEventArgs e)
  1442. {
  1443. txtIcon.Text = DefineFolderIconDialog.FileName;
  1444. if (txtIcon.Text.Contains(".exe"))
  1445. {
  1446. string iconpath = Integrator.ExtractIconFromExecutable(txtItemName.Text, DefineFolderIconDialog.FileName);
  1447. txtIcon.Text = iconpath;
  1448. }
  1449. }
  1450. private void DefineURLIconDialog_FileOk(object sender, CancelEventArgs e)
  1451. {
  1452. txtIcon.Text = DefineURLIconDialog.FileName;
  1453. if (txtIcon.Text.Contains(".exe"))
  1454. {
  1455. string iconpath = Integrator.ExtractIconFromExecutable(txtItemName.Text, DefineURLIconDialog.FileName);
  1456. txtIcon.Text = iconpath;
  1457. }
  1458. }
  1459. private void DefineFileIconDialog_FileOk(object sender, CancelEventArgs e)
  1460. {
  1461. txtIcon.Text = DefineFileIconDialog.FileName;
  1462. if (txtIcon.Text.Contains(".exe"))
  1463. {
  1464. string iconpath = Integrator.ExtractIconFromExecutable(txtItemName.Text, DefineFileIconDialog.FileName);
  1465. txtIcon.Text = iconpath;
  1466. }
  1467. }
  1468. private void DefineCommandIconDialog_FileOk(object sender, CancelEventArgs e)
  1469. {
  1470. txtIcon.Text = DefineCommandIconDialog.FileName;
  1471. if (txtIcon.Text.Contains(".exe"))
  1472. {
  1473. string iconpath = Integrator.ExtractIconFromExecutable(txtItemName.Text, DefineCommandIconDialog.FileName);
  1474. txtIcon.Text = iconpath;
  1475. }
  1476. }
  1477. private void btnAddItem_Click(object sender, EventArgs e)
  1478. {
  1479. if (!checkDefaultIcon.Checked && (string.IsNullOrEmpty(txtItem.Text) || string.IsNullOrEmpty(txtItemName.Text) || string.IsNullOrEmpty(txtIcon.Text)))
  1480. {
  1481. return;
  1482. }
  1483. if (checkDefaultIcon.Checked && (string.IsNullOrEmpty(txtItem.Text) || string.IsNullOrEmpty(txtItemName.Text)))
  1484. {
  1485. return;
  1486. }
  1487. string icon = string.Empty;
  1488. switch (_desktopItemType)
  1489. {
  1490. case DesktopItemType.Program:
  1491. if (checkDefaultIcon.Checked)
  1492. {
  1493. icon = txtItem.Text;
  1494. }
  1495. else
  1496. {
  1497. icon = txtIcon.Text;
  1498. }
  1499. Integrator.AddItem(txtItemName.Text, txtItem.Text, icon, _desktopItemPosition, checkShift.Checked, DesktopItemType.Program);
  1500. break;
  1501. case DesktopItemType.Folder:
  1502. if (checkDefaultIcon.Checked)
  1503. {
  1504. icon = Integrator.FolderDefaultIcon;
  1505. }
  1506. else
  1507. {
  1508. icon = txtIcon.Text;
  1509. }
  1510. Integrator.AddItem(txtItemName.Text, txtItem.Text, icon, _desktopItemPosition, checkShift.Checked, DesktopItemType.Folder);
  1511. break;
  1512. case DesktopItemType.Link:
  1513. if (checkDefaultIcon.Checked)
  1514. {
  1515. icon = Integrator.DownloadFavicon(txtItem.Text, txtItemName.Text);
  1516. }
  1517. else
  1518. {
  1519. icon = txtIcon.Text;
  1520. }
  1521. Integrator.AddItem(txtItemName.Text, txtItem.Text, icon, _desktopItemPosition, checkShift.Checked, DesktopItemType.Link);
  1522. break;
  1523. case DesktopItemType.File:
  1524. if (!checkDefaultIcon.Checked)
  1525. {
  1526. icon = txtIcon.Text;
  1527. }
  1528. Integrator.AddItem(txtItemName.Text, txtItem.Text, icon, _desktopItemPosition, checkShift.Checked, DesktopItemType.File);
  1529. break;
  1530. case DesktopItemType.Command:
  1531. if (!checkDefaultIcon.Checked)
  1532. {
  1533. icon = txtIcon.Text;
  1534. }
  1535. Integrator.AddItem(txtItemName.Text, txtItem.Text, icon, _desktopItemPosition, checkShift.Checked, DesktopItemType.Command);
  1536. break;
  1537. }
  1538. GetDesktopItems();
  1539. ResetIntegratorForm();
  1540. }
  1541. private void radioTop_CheckedChanged(object sender, EventArgs e)
  1542. {
  1543. if (radioTop.Checked)
  1544. {
  1545. _desktopItemPosition = DesktopTypePosition.Top;
  1546. }
  1547. }
  1548. private void radioMiddle_CheckedChanged(object sender, EventArgs e)
  1549. {
  1550. if (radioMiddle.Checked)
  1551. {
  1552. _desktopItemPosition = DesktopTypePosition.Middle;
  1553. }
  1554. }
  1555. private void radioBottom_CheckedChanged(object sender, EventArgs e)
  1556. {
  1557. if (radioBottom.Checked)
  1558. {
  1559. _desktopItemPosition = DesktopTypePosition.Bottom;
  1560. }
  1561. }
  1562. private void ResetIntegratorForm()
  1563. {
  1564. txtItem.Clear();
  1565. txtIcon.Clear();
  1566. checkDefaultIcon.Checked = true;
  1567. txtItemName.Clear();
  1568. if (radioLink.Checked)
  1569. {
  1570. txtItem.Text = "http://";
  1571. }
  1572. }
  1573. private void radioOcean_CheckedChanged(object sender, EventArgs e)
  1574. {
  1575. Options.CurrentOptions.Color = Theme.Ocean;
  1576. Options.ApplyTheme(this);
  1577. }
  1578. private void radioMagma_CheckedChanged(object sender, EventArgs e)
  1579. {
  1580. Options.CurrentOptions.Color = Theme.Magma;
  1581. Options.ApplyTheme(this);
  1582. }
  1583. private void radioZerg_CheckedChanged(object sender, EventArgs e)
  1584. {
  1585. Options.CurrentOptions.Color = Theme.Zerg;
  1586. Options.ApplyTheme(this);
  1587. }
  1588. private void radioMinimal_CheckedChanged(object sender, EventArgs e)
  1589. {
  1590. Options.CurrentOptions.Color = Theme.Minimal;
  1591. Options.ApplyTheme(this);
  1592. }
  1593. private void radioCaramel_CheckedChanged(object sender, EventArgs e)
  1594. {
  1595. Options.CurrentOptions.Color = Theme.Caramel;
  1596. Options.ApplyTheme(this);
  1597. }
  1598. private void radioLime_CheckedChanged(object sender, EventArgs e)
  1599. {
  1600. Options.CurrentOptions.Color = Theme.Lime;
  1601. Options.ApplyTheme(this);
  1602. }
  1603. private void button64_Click(object sender, EventArgs e)
  1604. {
  1605. if (listStartupItems.SelectedItems.Count == 1)
  1606. {
  1607. _startUpItems[listStartupItems.SelectedIndices[0]].LocateKey();
  1608. }
  1609. }
  1610. private void button66_Click(object sender, EventArgs e)
  1611. {
  1612. Integrator.TakeOwnership(false);
  1613. }
  1614. private void button65_Click(object sender, EventArgs e)
  1615. {
  1616. Integrator.TakeOwnership(true);
  1617. }
  1618. private void listStartupItems_ColumnClick(object sender, ColumnClickEventArgs e)
  1619. {
  1620. if (e.Column == _columnSorter.CurrentColumn)
  1621. {
  1622. if (_columnSorter.SortOrder == SortOrder.Ascending)
  1623. {
  1624. _columnSorter.SortOrder = SortOrder.Descending;
  1625. }
  1626. else
  1627. {
  1628. _columnSorter.SortOrder = SortOrder.Ascending;
  1629. }
  1630. }
  1631. else
  1632. {
  1633. _columnSorter.CurrentColumn = e.Column;
  1634. _columnSorter.SortOrder = SortOrder.Ascending;
  1635. }
  1636. listStartupItems.Sort();
  1637. }
  1638. private void chkBlock_CheckedChanged(object sender, EventArgs e)
  1639. {
  1640. if (chkBlock.Checked)
  1641. {
  1642. txtIP.Text = _blockedIP;
  1643. txtIP.Enabled = false;
  1644. }
  1645. else
  1646. {
  1647. txtIP.Clear();
  1648. txtIP.Enabled = true;
  1649. }
  1650. }
  1651. private void button8_Click(object sender, EventArgs e)
  1652. {
  1653. GetCustomCommands();
  1654. }
  1655. private void button26_Click(object sender, EventArgs e)
  1656. {
  1657. if (listCustomCommands.SelectedItems.Count == 1)
  1658. {
  1659. Integrator.DeleteCustomCommand(listCustomCommands.SelectedItem.ToString());
  1660. GetCustomCommands();
  1661. }
  1662. }
  1663. private void button75_Click(object sender, EventArgs e)
  1664. {
  1665. GetModernApps(!chkOnlyRemovable.Checked);
  1666. }
  1667. private void button74_Click(object sender, EventArgs e)
  1668. {
  1669. UninstallModernApps();
  1670. }
  1671. private void chkSelectAllModernApps_CheckedChanged(object sender, EventArgs e)
  1672. {
  1673. for (int i = 0; i < listModernApps.Items.Count; i++)
  1674. {
  1675. listModernApps.SetItemChecked(i, chkSelectAllModernApps.Checked);
  1676. }
  1677. }
  1678. private void btnResetConfig_Click(object sender, EventArgs e)
  1679. {
  1680. if (MessageBox.Show(_resetMessage, "Optimizer", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  1681. {
  1682. Utilities.ResetConfiguration();
  1683. }
  1684. }
  1685. private void toggleSwitch1_Click(object sender, EventArgs e)
  1686. {
  1687. if (!performanceSw.Checked)
  1688. {
  1689. Optimize.EnablePerformanceTweaks();
  1690. }
  1691. else
  1692. {
  1693. Optimize.DisablePerformanceTweaks();
  1694. }
  1695. Options.CurrentOptions.EnablePerformanceTweaks = !performanceSw.Checked;
  1696. }
  1697. private void toggleSwitch2_Click(object sender, EventArgs e)
  1698. {
  1699. if (!networkSw.Checked)
  1700. {
  1701. Optimize.DisableNetworkThrottling();
  1702. }
  1703. else
  1704. {
  1705. Optimize.EnableNetworkThrottling();
  1706. }
  1707. Options.CurrentOptions.DisableNetworkThrottling = !networkSw.Checked;
  1708. }
  1709. private void toggleSwitch3_Click(object sender, EventArgs e)
  1710. {
  1711. if (!defenderSw.Checked)
  1712. {
  1713. Optimize.DisableDefender();
  1714. }
  1715. else
  1716. {
  1717. Optimize.EnableDefender();
  1718. }
  1719. Options.CurrentOptions.DisableWindowsDefender = !defenderSw.Checked;
  1720. }
  1721. private void toggleSwitch4_Click(object sender, EventArgs e)
  1722. {
  1723. if (!systemRestoreSw.Checked)
  1724. {
  1725. Optimize.DisableSystemRestore();
  1726. }
  1727. else
  1728. {
  1729. Optimize.EnableSystemRestore();
  1730. }
  1731. Options.CurrentOptions.DisableSystemRestore = !systemRestoreSw.Checked;
  1732. }
  1733. private void toggleSwitch5_Click(object sender, EventArgs e)
  1734. {
  1735. if (!printSw.Checked)
  1736. {
  1737. Optimize.DisablePrintService();
  1738. }
  1739. else
  1740. {
  1741. Optimize.EnablePrintService();
  1742. }
  1743. Options.CurrentOptions.DisablePrintService = !printSw.Checked;
  1744. }
  1745. private void toggleSwitch6_Click(object sender, EventArgs e)
  1746. {
  1747. if (!mediaSharingSw.Checked)
  1748. {
  1749. Optimize.DisableMediaPlayerSharing();
  1750. }
  1751. else
  1752. {
  1753. Optimize.EnableMediaPlayerSharing();
  1754. }
  1755. Options.CurrentOptions.DisableMediaPlayerSharing = !mediaSharingSw.Checked;
  1756. }
  1757. private void toggleSwitch8_Click(object sender, EventArgs e)
  1758. {
  1759. if (!reportingSw.Checked)
  1760. {
  1761. Optimize.DisableErrorReporting();
  1762. }
  1763. else
  1764. {
  1765. Optimize.EnableErrorReporting();
  1766. }
  1767. Options.CurrentOptions.DisableErrorReporting = !reportingSw.Checked;
  1768. }
  1769. private void toggleSwitch9_Click(object sender, EventArgs e)
  1770. {
  1771. if (!homegroupSw.Checked)
  1772. {
  1773. Optimize.DisableHomeGroup();
  1774. }
  1775. else
  1776. {
  1777. Optimize.EnableHomeGroup();
  1778. }
  1779. Options.CurrentOptions.DisableHomeGroup = !homegroupSw.Checked;
  1780. }
  1781. private void toggleSwitch10_Click(object sender, EventArgs e)
  1782. {
  1783. if (!superfetchSw.Checked)
  1784. {
  1785. Optimize.DisableSuperfetch();
  1786. }
  1787. else
  1788. {
  1789. Optimize.EnableSuperfetch();
  1790. }
  1791. Options.CurrentOptions.DisableSuperfetch = !superfetchSw.Checked;
  1792. }
  1793. private void toggleSwitch11_Click(object sender, EventArgs e)
  1794. {
  1795. if (!telemetryTasksSw.Checked)
  1796. {
  1797. Optimize.DisableTelemetryTasks();
  1798. }
  1799. else
  1800. {
  1801. Optimize.EnableTelemetryTasks();
  1802. }
  1803. Options.CurrentOptions.DisableTelemetryTasks = !telemetryTasksSw.Checked;
  1804. }
  1805. private void toggleSwitch12_Click(object sender, EventArgs e)
  1806. {
  1807. if (!officeTelemetrySw.Checked)
  1808. {
  1809. Optimize.DisableOffice2016Telemetry();
  1810. }
  1811. else
  1812. {
  1813. Optimize.EnableOffice2016Telemetry();
  1814. }
  1815. Options.CurrentOptions.DisableOffice2016Telemetry = !officeTelemetrySw.Checked;
  1816. }
  1817. private void toggleSwitch13_Click(object sender, EventArgs e)
  1818. {
  1819. if (!oldMixerSw.Checked)
  1820. {
  1821. Optimize.EnableLegacyVolumeSlider();
  1822. }
  1823. else
  1824. {
  1825. Optimize.DisableLegacyVolumeSlider();
  1826. }
  1827. Options.CurrentOptions.EnableLegacyVolumeSlider = !oldMixerSw.Checked;
  1828. }
  1829. private void toggleSwitch19_Click(object sender, EventArgs e)
  1830. {
  1831. if (!colorBarSw.Checked)
  1832. {
  1833. Optimize.EnableTaskbarColor();
  1834. }
  1835. else
  1836. {
  1837. Optimize.DisableTaskbarColor();
  1838. }
  1839. Options.CurrentOptions.EnableTaskbarColor = !colorBarSw.Checked;
  1840. }
  1841. private void toggleSwitch18_Click(object sender, EventArgs e)
  1842. {
  1843. if (!oldExplorerSw.Checked)
  1844. {
  1845. Optimize.DisableQuickAccessHistory();
  1846. }
  1847. else
  1848. {
  1849. Optimize.EnableQuickAccessHistory();
  1850. }
  1851. Options.CurrentOptions.DisableQuickAccessHistory = !oldExplorerSw.Checked;
  1852. }
  1853. private void toggleSwitch26_Click(object sender, EventArgs e)
  1854. {
  1855. if (!adsSw.Checked)
  1856. {
  1857. Optimize.DisableStartMenuAds();
  1858. }
  1859. else
  1860. {
  1861. Optimize.EnableStartMenuAds();
  1862. }
  1863. Options.CurrentOptions.DisableStartMenuAds = !adsSw.Checked;
  1864. }
  1865. private void toggleSwitch27_Click(object sender, EventArgs e)
  1866. {
  1867. if (!darkSw.Checked)
  1868. {
  1869. Optimize.EnableDarkTheme();
  1870. }
  1871. else
  1872. {
  1873. Optimize.EnableLightTheme();
  1874. }
  1875. Options.CurrentOptions.EnableDarkTheme = !darkSw.Checked;
  1876. }
  1877. private void toggleSwitch14_Click(object sender, EventArgs e)
  1878. {
  1879. if (!uODSw.Checked)
  1880. {
  1881. Task t = new Task(() => Optimize.UninstallOneDrive());
  1882. t.Start();
  1883. }
  1884. else
  1885. {
  1886. Task t = new Task(() => Optimize.InstallOneDrive());
  1887. t.Start();
  1888. }
  1889. Options.CurrentOptions.UninstallOneDrive = !uODSw.Checked;
  1890. }
  1891. private void toggleSwitch25_Click(object sender, EventArgs e)
  1892. {
  1893. if (!peopleSw.Checked)
  1894. {
  1895. Optimize.DisableMyPeople();
  1896. }
  1897. else
  1898. {
  1899. Optimize.EnableMyPeople();
  1900. }
  1901. Options.CurrentOptions.DisableMyPeople = !peopleSw.Checked;
  1902. }
  1903. private void toggleSwitch24_Click(object sender, EventArgs e)
  1904. {
  1905. if (!autoUpdatesSw.Checked)
  1906. {
  1907. Optimize.DisableAutomaticUpdates();
  1908. }
  1909. else
  1910. {
  1911. Optimize.EnableAutomaticUpdates();
  1912. }
  1913. Options.CurrentOptions.DisableAutomaticUpdates = !autoUpdatesSw.Checked;
  1914. }
  1915. private void toggleSwitch30_Click(object sender, EventArgs e)
  1916. {
  1917. if (!driversSw.Checked)
  1918. {
  1919. Optimize.ExcludeDrivers();
  1920. }
  1921. else
  1922. {
  1923. Optimize.IncludeDrivers();
  1924. }
  1925. Options.CurrentOptions.ExcludeDrivers = !driversSw.Checked;
  1926. }
  1927. private void toggleSwitch23_Click(object sender, EventArgs e)
  1928. {
  1929. if (!telemetryServicesSw.Checked)
  1930. {
  1931. Optimize.DisableTelemetryServices();
  1932. }
  1933. else
  1934. {
  1935. Optimize.EnableTelemetryServices();
  1936. }
  1937. Options.CurrentOptions.DisableTelemetryServices = !telemetryServicesSw.Checked;
  1938. }
  1939. private void toggleSwitch21_Click(object sender, EventArgs e)
  1940. {
  1941. if (!privacySw.Checked)
  1942. {
  1943. Optimize.EnhancePrivacy();
  1944. }
  1945. else
  1946. {
  1947. Optimize.CompromisePrivacy();
  1948. }
  1949. Options.CurrentOptions.DisablePrivacyOptions = !privacySw.Checked;
  1950. }
  1951. private void toggleSwitch16_Click(object sender, EventArgs e)
  1952. {
  1953. if (!cortanaSw.Checked)
  1954. {
  1955. Optimize.DisableCortana();
  1956. }
  1957. else
  1958. {
  1959. Optimize.EnableCortana();
  1960. }
  1961. Options.CurrentOptions.DisableCortana = !cortanaSw.Checked;
  1962. }
  1963. private void toggleSwitch20_Click(object sender, EventArgs e)
  1964. {
  1965. if (!sensorSw.Checked)
  1966. {
  1967. Optimize.DisableSensorServices();
  1968. }
  1969. else
  1970. {
  1971. Optimize.EnableSensorServices();
  1972. }
  1973. Options.CurrentOptions.DisableSensorServices = !sensorSw.Checked;
  1974. }
  1975. private void toggleSwitch29_Click(object sender, EventArgs e)
  1976. {
  1977. if (!inkSw.Checked)
  1978. {
  1979. Optimize.DisableWindowsInk();
  1980. }
  1981. else
  1982. {
  1983. Optimize.EnableWindowsInk();
  1984. }
  1985. Options.CurrentOptions.DisableWindowsInk = !inkSw.Checked;
  1986. }
  1987. private void toggleSwitch28_Click(object sender, EventArgs e)
  1988. {
  1989. if (!spellSw.Checked)
  1990. {
  1991. Optimize.DisableSpellingAndTypingFeatures();
  1992. }
  1993. else
  1994. {
  1995. Optimize.EnableSpellingAndTypingFeatures();
  1996. }
  1997. Options.CurrentOptions.DisableSpellingTyping = !spellSw.Checked;
  1998. }
  1999. private void toggleSwitch17_Click(object sender, EventArgs e)
  2000. {
  2001. if (!xboxSw.Checked)
  2002. {
  2003. Optimize.DisableXboxLive();
  2004. }
  2005. else
  2006. {
  2007. Optimize.EnableXboxLive();
  2008. }
  2009. Options.CurrentOptions.DisableXboxLive = !xboxSw.Checked;
  2010. }
  2011. private void toggleSwitch15_Click(object sender, EventArgs e)
  2012. {
  2013. if (!gameBarSw.Checked)
  2014. {
  2015. Optimize.DisableGameBar();
  2016. }
  2017. else
  2018. {
  2019. Optimize.EnableGameBar();
  2020. }
  2021. Options.CurrentOptions.DisableGameBar = !gameBarSw.Checked;
  2022. }
  2023. private void toggleSwitch31_Click(object sender, EventArgs e)
  2024. {
  2025. if (!disableOneDriveSw.Checked)
  2026. {
  2027. Optimize.DisableOneDrive();
  2028. }
  2029. else
  2030. {
  2031. Optimize.EnableOneDrive();
  2032. }
  2033. Options.CurrentOptions.DisableOneDrive = !disableOneDriveSw.Checked;
  2034. }
  2035. private void toggleSwitch32_Click(object sender, EventArgs e)
  2036. {
  2037. if (!compatSw.Checked)
  2038. {
  2039. Optimize.DisableCompatibilityAssistant();
  2040. }
  2041. else
  2042. {
  2043. Optimize.EnableCompatibilityAssistant();
  2044. }
  2045. Options.CurrentOptions.DisableCompatibilityAssistant = !compatSw.Checked;
  2046. }
  2047. private void btnUpdate_Click(object sender, EventArgs e)
  2048. {
  2049. CheckForUpdate();
  2050. }
  2051. private void btnChangelog_Click(object sender, EventArgs e)
  2052. {
  2053. try
  2054. {
  2055. Process.Start(_changelogLink);
  2056. }
  2057. catch (Exception ex)
  2058. {
  2059. ErrorLogger.LogError("MainForm.btnChangelog_Click", ex.Message, ex.StackTrace);
  2060. MessageBox.Show(ex.Message, "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
  2061. }
  2062. }
  2063. private void chkReadOnly_CheckedChanged(object sender, EventArgs e)
  2064. {
  2065. HostsHelper.ReadOnly(chkReadOnly.Checked);
  2066. addHostB.Enabled = !chkReadOnly.Checked;
  2067. removeAllHostsB.Enabled = !chkReadOnly.Checked;
  2068. removeHostB.Enabled = !chkReadOnly.Checked;
  2069. refreshHostsB.Enabled = !chkReadOnly.Checked;
  2070. linkRestoreDefault.Enabled = !chkReadOnly.Checked;
  2071. chkBlock.Enabled = !chkReadOnly.Checked;
  2072. txtDomain.Enabled = !chkReadOnly.Checked;
  2073. txtIP.Enabled = !chkReadOnly.Checked;
  2074. adblockBasic.Enabled = !chkReadOnly.Checked;
  2075. adblockS.Enabled = !chkReadOnly.Checked;
  2076. adblockP.Enabled = !chkReadOnly.Checked;
  2077. adblockUlti.Enabled = !chkReadOnly.Checked;
  2078. txtIP.Focus();
  2079. }
  2080. private void button1_Click(object sender, EventArgs e)
  2081. {
  2082. HostsHelper.AdblockBasic();
  2083. GetHostsEntries();
  2084. }
  2085. private void button3_Click(object sender, EventArgs e)
  2086. {
  2087. HostsHelper.AdBlockWithPorn();
  2088. GetHostsEntries();
  2089. }
  2090. private void button2_Click(object sender, EventArgs e)
  2091. {
  2092. HostsHelper.AdBlockWithSocial();
  2093. GetHostsEntries();
  2094. }
  2095. private void button4_Click(object sender, EventArgs e)
  2096. {
  2097. HostsHelper.AdBlockWithSocial();
  2098. GetHostsEntries();
  2099. }
  2100. private void RenderAppDownloaderBusy()
  2101. {
  2102. btnDownloadApps.Enabled = false;
  2103. changeDownDirB.Enabled = false;
  2104. txtDownloadFolder.ReadOnly = true;
  2105. linkWarnings.Visible = false;
  2106. }
  2107. private void RenderAppDownloaderFree()
  2108. {
  2109. btnDownloadApps.Enabled = true;
  2110. changeDownDirB.Enabled = true;
  2111. txtDownloadFolder.ReadOnly = false;
  2112. linkWarnings.Visible = !string.IsNullOrEmpty(downloadLog);
  2113. txtDownloadStatus.Text = Options.TranslationList["Finished"];
  2114. }
  2115. string appNameTemp = string.Empty;
  2116. int maxCount = 0;
  2117. int count = 0;
  2118. Process p;
  2119. string downloadLog = string.Empty;
  2120. private async void btnDownloadApps_Click(object sender, EventArgs e)
  2121. {
  2122. if (!Directory.Exists(txtDownloadFolder.Text))
  2123. {
  2124. MessageBox.Show(Options.TranslationList["downloadDirInvalid"].ToString(), "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
  2125. return;
  2126. }
  2127. RenderAppDownloaderBusy();
  2128. maxCount = 0;
  2129. count = 0;
  2130. downloadLog = string.Empty;
  2131. foreach (Control c in Utilities.GetSelfAndChildrenRecursive(appsTab))
  2132. {
  2133. if (c.Name == "cAutoInstall") continue;
  2134. if (c is ColoredCheckBox && ((ColoredCheckBox)c).Checked) maxCount++;
  2135. }
  2136. ColoredCheckBox currentCheck;
  2137. Control[] temp;
  2138. foreach (FeedApp x in AppsFromFeed)
  2139. {
  2140. if (string.IsNullOrEmpty(x.Tag)) continue;
  2141. temp = appsTab.Controls.Find(x.Tag, true);
  2142. if (temp.Count() == 0) continue;
  2143. currentCheck = (ColoredCheckBox)temp[0];
  2144. if (currentCheck == null) continue;
  2145. if (!currentCheck.Checked) continue;
  2146. appNameTemp = x.Title;
  2147. if (c64.Checked)
  2148. {
  2149. count++;
  2150. if (string.IsNullOrEmpty(x.Link64))
  2151. {
  2152. downloadLog += "• " + x.Title + ":" + Environment.NewLine + Options.TranslationList["no64Download"] + Environment.NewLine + Environment.NewLine;
  2153. await DownloadApp(x, false);
  2154. }
  2155. else
  2156. {
  2157. await DownloadApp(x, true);
  2158. }
  2159. }
  2160. else
  2161. {
  2162. count++;
  2163. if (!string.IsNullOrEmpty(x.Link))
  2164. {
  2165. await DownloadApp(x, false);
  2166. }
  2167. else
  2168. {
  2169. downloadLog += "• " + x.Title + ":" + Environment.NewLine + Options.TranslationList["no32Download"] + Environment.NewLine + Environment.NewLine;
  2170. }
  2171. }
  2172. }
  2173. if (cAutoInstall.Checked)
  2174. {
  2175. count = 0;
  2176. foreach (string a in Directory.GetFiles(txtDownloadFolder.Text, "*.*", SearchOption.TopDirectoryOnly))
  2177. {
  2178. using (p = new Process())
  2179. {
  2180. count++;
  2181. p.StartInfo.FileName = a;
  2182. p.EnableRaisingEvents = true;
  2183. p.StartInfo.WorkingDirectory = txtDownloadFolder.Text;
  2184. // APP-SPECIFIC HACKS //
  2185. if (a.Contains("Sumatra")) p.StartInfo.Arguments = " -install";
  2186. // *** //
  2187. txtDownloadStatus.Text = string.Format("{0}/{1} - {2} {3} ...", count, maxCount, Options.TranslationList["installing"], Path.GetFileNameWithoutExtension(a));
  2188. await p.RunAsync();
  2189. };
  2190. }
  2191. }
  2192. // reset all checkboxes
  2193. foreach (Control c in Utilities.GetSelfAndChildrenRecursive(appsTab))
  2194. {
  2195. if (c.Name == "cAutoInstall") continue;
  2196. if (c is ColoredCheckBox && ((ColoredCheckBox)c).Checked) ((ColoredCheckBox)c).Checked = false;
  2197. }
  2198. RenderAppDownloaderFree();
  2199. }
  2200. string fileExtension = ".exe";
  2201. private async Task DownloadApp(FeedApp app, bool pref64)
  2202. {
  2203. try
  2204. {
  2205. using (WebClient downloader = new WebClient())
  2206. {
  2207. downloader.Headers.Add("User-Agent: Other");
  2208. downloader.Encoding = Encoding.UTF8;
  2209. downloader.DownloadProgressChanged += Downloader_DownloadProgressChanged;
  2210. downloader.DownloadFileCompleted += Downloader_DownloadFileCompleted;
  2211. if (pref64)
  2212. {
  2213. if (app.Link64.Contains(".msi"))
  2214. {
  2215. fileExtension = ".msi";
  2216. }
  2217. else
  2218. {
  2219. fileExtension = ".exe";
  2220. }
  2221. await downloader.DownloadFileTaskAsync(new Uri(app.Link64), Path.Combine(txtDownloadFolder.Text, app.Title + "-x64" + fileExtension));
  2222. }
  2223. else
  2224. {
  2225. if (app.Link.Contains(".msi"))
  2226. {
  2227. fileExtension = ".msi";
  2228. }
  2229. else
  2230. {
  2231. fileExtension = ".exe";
  2232. }
  2233. await downloader.DownloadFileTaskAsync(new Uri(app.Link), Path.Combine(txtDownloadFolder.Text, app.Title + "-x86" + fileExtension));
  2234. }
  2235. }
  2236. }
  2237. catch (Exception ex)
  2238. {
  2239. ErrorLogger.LogError("MainForm.DownloadApp", ex.Message, ex.StackTrace);
  2240. downloadLog += "• " + app.Title + ":" + Environment.NewLine + Options.TranslationList["linkInvalid"] + Environment.NewLine + Environment.NewLine;
  2241. if (pref64) try { File.Delete(Path.Combine(txtDownloadFolder.Text, app.Title + "-x64.exe")); } catch { }
  2242. if (!pref64) try { File.Delete(Path.Combine(txtDownloadFolder.Text, app.Title + "-x86.exe")); } catch { }
  2243. if (pref64) try { File.Delete(Path.Combine(txtDownloadFolder.Text, app.Title + "-x64.msi")); } catch { }
  2244. if (!pref64) try { File.Delete(Path.Combine(txtDownloadFolder.Text, app.Title + "-x86.msi")); } catch { }
  2245. }
  2246. }
  2247. private void Downloader_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
  2248. {
  2249. this.BeginInvoke((MethodInvoker)delegate
  2250. {
  2251. //txtDownloadStatus.Text = "Finished";
  2252. });
  2253. }
  2254. int tempProgress;
  2255. private void Downloader_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
  2256. {
  2257. this.BeginInvoke((MethodInvoker)delegate
  2258. {
  2259. double bytesIn = double.Parse(e.BytesReceived.ToString());
  2260. double totalBytes = double.Parse(e.TotalBytesToReceive.ToString());
  2261. double percentage = bytesIn / totalBytes * 100;
  2262. tempProgress = int.Parse(Math.Truncate(percentage).ToString());
  2263. // if Content-Length header is missing, just show an animation
  2264. if (Math.Abs(tempProgress) > 100)
  2265. {
  2266. txtDownloadStatus.Text = string.Format("({1}/{2}) - {0} ...", appNameTemp, count, maxCount);
  2267. progressDownloader.Style = ProgressBarStyle.Marquee;
  2268. }
  2269. // if not, show actual progress
  2270. else
  2271. {
  2272. txtDownloadStatus.Text = string.Format("({1}/{2}) - {0} - {3} / {4}", appNameTemp, count, maxCount, ByteSize.FromBytes(e.BytesReceived).ToString("MB"), ByteSize.FromBytes(e.TotalBytesToReceive).ToString("MB"));
  2273. progressDownloader.Style = ProgressBarStyle.Continuous;
  2274. progressDownloader.Value = tempProgress;
  2275. }
  2276. });
  2277. }
  2278. private void button5_Click(object sender, EventArgs e)
  2279. {
  2280. FolderBrowserDialog d = new FolderBrowserDialog();
  2281. if (d.ShowDialog() == DialogResult.OK)
  2282. {
  2283. txtDownloadFolder.Text = d.SelectedPath;
  2284. Options.CurrentOptions.AppsFolder = d.SelectedPath;
  2285. Options.SaveSettings();
  2286. }
  2287. }
  2288. private void button6_Click(object sender, EventArgs e)
  2289. {
  2290. Process.Start(txtDownloadFolder.Text);
  2291. }
  2292. private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  2293. {
  2294. InfoForm lf = new InfoForm(downloadLog);
  2295. lf.ShowDialog(this);
  2296. }
  2297. private void txtDownloadFolder_TextChanged(object sender, EventArgs e)
  2298. {
  2299. Options.CurrentOptions.AppsFolder = txtDownloadFolder.Text;
  2300. Options.SaveSettings();
  2301. }
  2302. private void chkOnlyRemovable_CheckedChanged(object sender, EventArgs e)
  2303. {
  2304. GetModernApps(!chkOnlyRemovable.Checked);
  2305. }
  2306. private void btnGetFeed_Click(object sender, EventArgs e)
  2307. {
  2308. GetFeed();
  2309. }
  2310. private void l2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  2311. {
  2312. AboutForm f = new AboutForm();
  2313. f.ShowDialog(this);
  2314. //Process.Start("https://github.com/hellzerg/optimizer");
  2315. }
  2316. private void btnViewLog_Click(object sender, EventArgs e)
  2317. {
  2318. if (File.Exists(ErrorLogger.ErrorLogFile))
  2319. {
  2320. InfoForm iform = new InfoForm(File.ReadAllText(ErrorLogger.ErrorLogFile, Encoding.UTF8));
  2321. iform.ShowDialog();
  2322. }
  2323. else
  2324. {
  2325. MessageBox.Show(Options.TranslationList["noErrorsM"].ToString(), "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
  2326. }
  2327. }
  2328. private void btnOpenConf_Click(object sender, EventArgs e)
  2329. {
  2330. Process.Start(Required.CoreFolder);
  2331. }
  2332. private void btnPing_Click(object sender, EventArgs e)
  2333. {
  2334. if (string.IsNullOrEmpty(txtPingInput.Text)) return;
  2335. _pingResults = new List<PingReply>();
  2336. listPingResults.Items.Clear();
  2337. if (Utilities.PingHost(txtPingInput.Text) == null)
  2338. {
  2339. listPingResults.Items.Add(string.Format("{0} [{1}]", Options.TranslationList["hostNotFound"], txtPingInput.Text));
  2340. return;
  2341. }
  2342. Task pinger = new Task(() =>
  2343. {
  2344. btnShodan.Enabled = false;
  2345. btnPing.Enabled = false;
  2346. listPingResults.Items.Add(string.Format("{0} [{1}]", Options.TranslationList["pinging"], txtPingInput.Text));
  2347. listPingResults.Items.Add("");
  2348. for (int i = 0; i < 9; i++)
  2349. {
  2350. // wait before each pinging
  2351. System.Threading.Thread.Sleep(888);
  2352. tmpReply = Utilities.PingHost(txtPingInput.Text);
  2353. if (tmpReply.Address == null)
  2354. {
  2355. listPingResults.Items.Add(tmpReply.Status);
  2356. }
  2357. else
  2358. {
  2359. _pingResults.Add(tmpReply);
  2360. _shodanIP = _pingResults[i].Address.ToString();
  2361. listPingResults.Items.Add(string.Format("{0} - {1}: {2} ms - TTL: {3}", _pingResults[i].Status, Options.TranslationList["latency"], _pingResults[i].RoundtripTime, _pingResults[i].Options.Ttl));
  2362. }
  2363. }
  2364. listPingResults.Items.Add("");
  2365. // calculate statistics
  2366. if (_pingResults.Count > 0)
  2367. {
  2368. long maxLatency = _pingResults.Max(x => x.RoundtripTime);
  2369. long minLatency = _pingResults.Min(x => x.RoundtripTime);
  2370. double averageLatency = _pingResults.Average(x => x.RoundtripTime);
  2371. listPingResults.Items.Add(string.Format("{0} = {1}, {2} = {3}, {4} = {5:F2}", Options.TranslationList["min"], minLatency, Options.TranslationList["max"], maxLatency, Options.TranslationList["avg"], averageLatency));
  2372. }
  2373. else
  2374. {
  2375. listPingResults.Items.Add(Options.TranslationList["timeout"]);
  2376. }
  2377. btnPing.Enabled = true;
  2378. btnShodan.Enabled = true;
  2379. });
  2380. pinger.Start();
  2381. }
  2382. private void btnCheckFootprint_Click(object sender, EventArgs e)
  2383. {
  2384. CleanHelper.CheckFootprint();
  2385. }
  2386. private void btnShodan_Click(object sender, EventArgs e)
  2387. {
  2388. IPAddress tryIP;
  2389. if (IPAddress.TryParse(txtPingInput.Text, out tryIP))
  2390. {
  2391. Process.Start(string.Format("https://www.shodan.io/host/{0}", txtPingInput.Text));
  2392. return;
  2393. }
  2394. if (!string.IsNullOrEmpty(_shodanIP))
  2395. {
  2396. Process.Start(string.Format("https://www.shodan.io/host/{0}", _shodanIP));
  2397. return;
  2398. }
  2399. }
  2400. private void button9_Click(object sender, EventArgs e)
  2401. {
  2402. try
  2403. {
  2404. Clipboard.SetText(_shodanIP);
  2405. }
  2406. catch { }
  2407. }
  2408. private void button7_Click(object sender, EventArgs e)
  2409. {
  2410. try
  2411. {
  2412. Clipboard.SetText(txtPingInput.Text);
  2413. }
  2414. catch { }
  2415. }
  2416. private void txtPingInput_KeyDown(object sender, KeyEventArgs e)
  2417. {
  2418. if (e.KeyCode == Keys.Enter) btnPing.PerformClick();
  2419. }
  2420. private void btnExport_Click(object sender, EventArgs e)
  2421. {
  2422. if (ExportDialog.ShowDialog() == DialogResult.OK)
  2423. {
  2424. try
  2425. {
  2426. File.WriteAllLines(ExportDialog.FileName, listPingResults.Items.Cast<string>());
  2427. }
  2428. catch (Exception ex)
  2429. {
  2430. ErrorLogger.LogError("btnExport.Click", ex.Message, ex.StackTrace);
  2431. MessageBox.Show(ex.Message, "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
  2432. }
  2433. }
  2434. }
  2435. private void startupItem_Click(object sender, EventArgs e)
  2436. {
  2437. tabCollection.SelectedTab = startupTab;
  2438. RestoreWindow();
  2439. }
  2440. private void cleanerItem_Click(object sender, EventArgs e)
  2441. {
  2442. tabCollection.SelectedTab = cleanerTab;
  2443. RestoreWindow();
  2444. }
  2445. private void pingerItem_Click(object sender, EventArgs e)
  2446. {
  2447. tabCollection.SelectedTab = pingerTab;
  2448. RestoreWindow();
  2449. txtPingInput.Focus();
  2450. }
  2451. private void hostsItem_Click(object sender, EventArgs e)
  2452. {
  2453. tabCollection.SelectedTab = hostsEditorTab;
  2454. RestoreWindow();
  2455. txtIP.Focus();
  2456. }
  2457. private void appsItem_Click(object sender, EventArgs e)
  2458. {
  2459. tabCollection.SelectedTab = appsTab;
  2460. RestoreWindow();
  2461. }
  2462. private void exitItem_Click(object sender, EventArgs e)
  2463. {
  2464. _trayMenu = false;
  2465. Options.CurrentOptions.AppsFolder = txtDownloadFolder.Text;
  2466. Options.SaveSettings();
  2467. Application.Exit();
  2468. }
  2469. private void RestoreWindow()
  2470. {
  2471. if (this.WindowState == FormWindowState.Minimized) this.WindowState = FormWindowState.Normal;
  2472. this.Show();
  2473. this.Activate();
  2474. this.Focus();
  2475. }
  2476. private void launcherIcon_MouseDoubleClick(object sender, MouseEventArgs e)
  2477. {
  2478. if (this.Visible)
  2479. {
  2480. if (this.WindowState == FormWindowState.Minimized) this.WindowState = FormWindowState.Normal;
  2481. this.Hide();
  2482. }
  2483. else
  2484. {
  2485. RestoreWindow();
  2486. }
  2487. }
  2488. private void quickAccessToggle_CheckedChanged(object sender, EventArgs e)
  2489. {
  2490. Options.CurrentOptions.EnableTray = quickAccessToggle.Checked;
  2491. Options.SaveSettings();
  2492. _trayMenu = quickAccessToggle.Checked;
  2493. launcherIcon.Visible = quickAccessToggle.Checked;
  2494. }
  2495. private void linkLabel5_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  2496. {
  2497. Process.Start(_licenseLink);
  2498. }
  2499. private void linkLabel6_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  2500. {
  2501. Process.Start(_openSourceLink);
  2502. }
  2503. private void linkUpdate_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  2504. {
  2505. CheckForUpdate();
  2506. }
  2507. private void restartExpolorerItem_Click(object sender, EventArgs e)
  2508. {
  2509. Utilities.RestartExplorer();
  2510. }
  2511. private void button10_Click(object sender, EventArgs e)
  2512. {
  2513. Utilities.FlushDNSCache();
  2514. }
  2515. private void helpTipsToggle_CheckedChanged(object sender, EventArgs e)
  2516. {
  2517. Options.CurrentOptions.ShowHelp = helpTipsToggle.Checked;
  2518. Options.SaveSettings();
  2519. helpBox.Active = helpTipsToggle.Checked;
  2520. }
  2521. private void button11_Click(object sender, EventArgs e)
  2522. {
  2523. ShowBackupConfirm();
  2524. }
  2525. private void ShowBackupConfirm()
  2526. {
  2527. removeStartupItemB.Visible = false;
  2528. locateFileB.Visible = false;
  2529. findInRegB.Visible = false;
  2530. refreshStartupB.Visible = false;
  2531. restoreStartupB.Visible = false;
  2532. backupStartupB.Visible = false;
  2533. lblBackupTitle.Visible = true;
  2534. doBackup.Visible = true;
  2535. cancelBackup.Visible = true;
  2536. txtBackupTitle.Visible = true;
  2537. }
  2538. private void HideBackupConfirm()
  2539. {
  2540. removeStartupItemB.Visible = true;
  2541. locateFileB.Visible = true;
  2542. findInRegB.Visible = true;
  2543. refreshStartupB.Visible = true;
  2544. restoreStartupB.Visible = true;
  2545. backupStartupB.Visible = true;
  2546. lblBackupTitle.Visible = false;
  2547. doBackup.Visible = false;
  2548. cancelBackup.Visible = false;
  2549. txtBackupTitle.Visible = false;
  2550. }
  2551. private void button12_Click(object sender, EventArgs e)
  2552. {
  2553. StartupRestoreForm f = new StartupRestoreForm();
  2554. f.ShowDialog(this);
  2555. GetStartupItems();
  2556. }
  2557. private void button14_Click(object sender, EventArgs e)
  2558. {
  2559. HideBackupConfirm();
  2560. }
  2561. private void button13_Click(object sender, EventArgs e)
  2562. {
  2563. if (!string.IsNullOrEmpty(txtBackupTitle.Text.Trim()))
  2564. {
  2565. HideBackupConfirm();
  2566. _backupItems.Clear();
  2567. foreach (var x in _startUpItems)
  2568. {
  2569. _backupItems.Add(new StartupBackupItem(x.Name, x.FileLocation, x.RegistryLocation.ToString(), x.StartupType.ToString()));
  2570. }
  2571. try
  2572. {
  2573. File.WriteAllText(Required.StartupItemsBackupFolder + Utilities.SanitizeFileFolderName(txtBackupTitle.Text + " - [" + DateTime.Now.ToShortDateString() + "-" + DateTime.Now.ToShortTimeString()) + "].json", JsonConvert.SerializeObject(_backupItems, Formatting.Indented));
  2574. }
  2575. catch (Exception ex)
  2576. {
  2577. ErrorLogger.LogError("MainForm.BackupStartupItems", ex.Message, ex.StackTrace);
  2578. }
  2579. }
  2580. }
  2581. private void pictureBox86_Click(object sender, EventArgs e)
  2582. {
  2583. radioEnglish.PerformClick();
  2584. }
  2585. private void pictureBox87_Click(object sender, EventArgs e)
  2586. {
  2587. radioRussian.PerformClick();
  2588. }
  2589. private void radioEnglish_Click(object sender, EventArgs e)
  2590. {
  2591. radioEnglish.Checked = true;
  2592. Options.CurrentOptions.LanguageCode = LanguageCode.EN;
  2593. Options.SaveSettings();
  2594. Options.LoadTranslation();
  2595. Translate();
  2596. }
  2597. private void radioRussian_Click(object sender, EventArgs e)
  2598. {
  2599. radioRussian.Checked = true;
  2600. Options.CurrentOptions.LanguageCode = LanguageCode.RU;
  2601. Options.SaveSettings();
  2602. Options.LoadTranslation();
  2603. Translate();
  2604. }
  2605. private void pictureBox88_Click(object sender, EventArgs e)
  2606. {
  2607. radioHellenic.PerformClick();
  2608. }
  2609. private void radioHellenic_Click(object sender, EventArgs e)
  2610. {
  2611. radioHellenic.Checked = true;
  2612. Options.CurrentOptions.LanguageCode = LanguageCode.EL;
  2613. Options.SaveSettings();
  2614. Options.LoadTranslation();
  2615. Translate();
  2616. }
  2617. private void pictureBox89_Click(object sender, EventArgs e)
  2618. {
  2619. radioTurkish.PerformClick();
  2620. }
  2621. private void radioTurkish_Click(object sender, EventArgs e)
  2622. {
  2623. radioTurkish.Checked = true;
  2624. Options.CurrentOptions.LanguageCode = LanguageCode.TR;
  2625. Options.SaveSettings();
  2626. Options.LoadTranslation();
  2627. Translate();
  2628. }
  2629. private void radioGerman_Click(object sender, EventArgs e)
  2630. {
  2631. radioGerman.Checked = true;
  2632. Options.CurrentOptions.LanguageCode = LanguageCode.DE;
  2633. Options.SaveSettings();
  2634. Options.LoadTranslation();
  2635. Translate();
  2636. }
  2637. private void pictureBox2_Click(object sender, EventArgs e)
  2638. {
  2639. radioGerman.PerformClick();
  2640. }
  2641. private void pictureBox3_Click(object sender, EventArgs e)
  2642. {
  2643. radioSpanish.PerformClick();
  2644. }
  2645. private void radioSpanish_Click(object sender, EventArgs e)
  2646. {
  2647. radioSpanish.Checked = true;
  2648. Options.CurrentOptions.LanguageCode = LanguageCode.ES;
  2649. Options.SaveSettings();
  2650. Options.LoadTranslation();
  2651. Translate();
  2652. }
  2653. private void radioPortuguese_Click(object sender, EventArgs e)
  2654. {
  2655. radioPortuguese.Checked = true;
  2656. Options.CurrentOptions.LanguageCode = LanguageCode.PT;
  2657. Options.SaveSettings();
  2658. Options.LoadTranslation();
  2659. Translate();
  2660. }
  2661. private void pictureBox4_Click(object sender, EventArgs e)
  2662. {
  2663. radioPortuguese.PerformClick();
  2664. }
  2665. private void txtIPv4_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  2666. {
  2667. Clipboard.SetText(txtIPv4.Text);
  2668. }
  2669. private void txtIPv4A_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  2670. {
  2671. Clipboard.SetText(txtIPv4A.Text);
  2672. }
  2673. private void txtIPv6_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  2674. {
  2675. Clipboard.SetText(txtIPv6.Text);
  2676. }
  2677. private void txtIPv6A_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  2678. {
  2679. Clipboard.SetText(txtIPv6A.Text);
  2680. }
  2681. private void btnOpenNetwork_Click(object sender, EventArgs e)
  2682. {
  2683. Process.Start("NCPA.cpl");
  2684. }
  2685. private void radioFrench_Click(object sender, EventArgs e)
  2686. {
  2687. radioFrench.Checked = true;
  2688. Options.CurrentOptions.LanguageCode = LanguageCode.FR;
  2689. Options.SaveSettings();
  2690. Options.LoadTranslation();
  2691. Translate();
  2692. }
  2693. private void pictureBox5_Click(object sender, EventArgs e)
  2694. {
  2695. radioFrench.PerformClick();
  2696. }
  2697. private void listStartupItems_ItemChecked(object sender, ItemCheckedEventArgs e)
  2698. {
  2699. if (e.Item.Checked)
  2700. {
  2701. e.Item.ForeColor = Options.ForegroundColor;
  2702. }
  2703. else
  2704. {
  2705. e.Item.ForeColor = Color.White;
  2706. }
  2707. }
  2708. private void trayOptions_Click(object sender, EventArgs e)
  2709. {
  2710. tabCollection.SelectedTab = optionsTab;
  2711. RestoreWindow();
  2712. }
  2713. private void trayRegistry_Click(object sender, EventArgs e)
  2714. {
  2715. tabCollection.SelectedTab = registryFixerTab;
  2716. RestoreWindow();
  2717. }
  2718. }
  2719. }