MainForm.cs 110 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129
  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. Program.MainForm = this;
  562. if (string.IsNullOrEmpty(Options.CurrentOptions.AppsFolder))
  563. {
  564. txtDownloadFolder.Text = Path.Combine(Application.StartupPath, "Optimizer Downloads");
  565. Options.CurrentOptions.AppsFolder = Path.Combine(Application.StartupPath, "Optimizer Downloads");
  566. Directory.CreateDirectory(Options.CurrentOptions.AppsFolder);
  567. Options.SaveSettings();
  568. }
  569. else
  570. {
  571. if (!Directory.Exists(Options.CurrentOptions.AppsFolder))
  572. {
  573. try
  574. {
  575. Directory.CreateDirectory(Options.CurrentOptions.AppsFolder);
  576. }
  577. catch (Exception ex)
  578. {
  579. txtDownloadFolder.Text = string.Empty;
  580. ErrorLogger.LogError("MainForm.INIT", ex.Message, ex.StackTrace);
  581. }
  582. }
  583. txtDownloadFolder.Text = Options.CurrentOptions.AppsFolder;
  584. }
  585. if (!Program.EXPERIMENTAL_BUILD && Utilities.IsInternetAvailable()) CheckForUpdate(true);
  586. if (Program.EXPERIMENTAL_BUILD)
  587. {
  588. btnUpdate.Enabled = false;
  589. lblUpdateDisabled.Visible = true;
  590. }
  591. //_networkMonitor = new NetworkMonitor();
  592. }
  593. //private void NetworkMonitoring()
  594. //{
  595. // while (true)
  596. // {
  597. // downloadSpeed = 0;
  598. // uploadSpeed = 0;
  599. // foreach (NetworkAdapter adapter in _networkMonitor.Adapters)
  600. // {
  601. // //adapter.Refresh();
  602. // downloadSpeed += Math.Round(adapter.DownloadSpeedMbps, 2);
  603. // uploadSpeed += Math.Round(adapter.UploadSpeedMbps, 2);
  604. // }
  605. // this.Text = string.Format("Optimizer - DOWN: {0} UP: {1}", downloadSpeed, uploadSpeed);
  606. // Thread.Sleep(1000);
  607. // }
  608. //}
  609. private void Translate(bool skipFull = false)
  610. {
  611. Dictionary<string, string> translationList = Options.TranslationList.ToObject<Dictionary<string, string>>();
  612. if (Environment.Is64BitOperatingSystem)
  613. {
  614. translationList["txtBitness"] = translationList["txtBitness"].Replace("{BITS}", translationList["c64"]);
  615. }
  616. else
  617. {
  618. translationList["txtBitness"] = translationList["txtBitness"].Replace("{BITS}", translationList["c32"]);
  619. }
  620. SetHelpBoxTranslation();
  621. if (!skipFull)
  622. {
  623. _noNewVersionMessage = Options.TranslationList["noNewVersion"];
  624. _betaVersionMessage = Options.TranslationList["betaVersion"];
  625. _restartMessage = Options.TranslationList["restartAndApply"];
  626. _removeStartupItemsMessage = Options.TranslationList["removeAllStartup"];
  627. _removeHostsEntriesMessage = Options.TranslationList["removeAllHosts"];
  628. _removeDesktopItemsMessage = Options.TranslationList["removeAllItems"];
  629. _removeModernAppsMessage = Options.TranslationList["removeModernApps"];
  630. _errorModernAppsMessage = Options.TranslationList["errorModernApps"];
  631. _resetMessage = Options.TranslationList["resetMessage"];
  632. listStartupItems.Columns[0].Text = translationList["startupItemName"];
  633. listStartupItems.Columns[1].Text = translationList["startupItemLocation"];
  634. listStartupItems.Columns[2].Text = translationList["startupItemType"];
  635. trayStartup.Text = translationList["trayStartup"];
  636. trayCleaner.Text = translationList["trayCleaner"];
  637. trayPinger.Text = translationList["trayPinger"];
  638. trayHosts.Text = translationList["trayHosts"];
  639. trayAD.Text = translationList["trayAD"];
  640. trayRestartExplorer.Text = translationList["trayRestartExplorer"];
  641. trayExit.Text = translationList["trayExit"];
  642. Control element;
  643. foreach (var x in translationList)
  644. {
  645. if (x.Key == null || x.Key == string.Empty) continue;
  646. element = this.Controls.Find(x.Key, true).FirstOrDefault();
  647. if (element == null) continue;
  648. if (element is ToggleSwitch)
  649. {
  650. ((ToggleSwitch)element).OnText = x.Value;
  651. continue;
  652. }
  653. element.Text = x.Value;
  654. }
  655. }
  656. txtVersion.Text = txtVersion.Text.Replace("{VN}", Program.GetCurrentVersionTostring());
  657. }
  658. private void GetFootprint()
  659. {
  660. ByteSize footprint = CleanHelper.CheckFootprint();
  661. lblFootprint.Text = footprint.ToString();
  662. }
  663. private void GetFeed()
  664. {
  665. WebClient client = new WebClient
  666. {
  667. Encoding = Encoding.UTF8
  668. };
  669. client.Headers.Add("Cache-Control", "no-cache");
  670. try
  671. {
  672. byte[] feedData;
  673. string tmpImageFileName = string.Empty;
  674. feedData = client.DownloadData(_feedImages);
  675. using (ZipArchive zip = new ZipArchive(new MemoryStream(feedData)))
  676. {
  677. var zipEntries = zip.Entries;
  678. try
  679. {
  680. string feed = client.DownloadString(_feedLink);
  681. AppsFromFeed = JsonConvert.DeserializeObject<List<FeedApp>>(feed);
  682. AppCard appCard;
  683. groupSystemTools.Controls.Clear();
  684. groupInternet.Controls.Clear();
  685. groupCoding.Controls.Clear();
  686. groupSoundVideo.Controls.Clear();
  687. foreach (FeedApp x in AppsFromFeed)
  688. {
  689. appCard = new AppCard();
  690. appCard.AutoSize = true;
  691. appCard.Anchor = AnchorStyles.None;
  692. appCard.Anchor = AnchorStyles.Top | AnchorStyles.Left;
  693. appCard.appTitle.Text = x.Title;
  694. appCard.appTitle.Name = x.Tag;
  695. appCard.appImage.SizeMode = PictureBoxSizeMode.Zoom;
  696. tmpImageFileName = x.Image.Substring(x.Image.LastIndexOf("/") + 1, x.Image.Length - (x.Image.LastIndexOf("/") + 1));
  697. appCard.appImage.Image = Image.FromStream(zipEntries.First(ifn => ifn.Name == tmpImageFileName).Open());
  698. switch (x.Group)
  699. {
  700. case "SystemTools":
  701. appCard.Location = new Point(0, groupSystemTools.Controls.Count * 30);
  702. groupSystemTools.Controls.Add(appCard);
  703. break;
  704. case "Internet":
  705. appCard.Location = new Point(0, groupInternet.Controls.Count * 30);
  706. groupInternet.Controls.Add(appCard);
  707. break;
  708. case "Coding":
  709. appCard.Location = new Point(0, groupCoding.Controls.Count * 30);
  710. groupCoding.Controls.Add(appCard);
  711. break;
  712. case "GraphicsSound":
  713. appCard.Location = new Point(0, groupSoundVideo.Controls.Count * 30);
  714. groupSoundVideo.Controls.Add(appCard);
  715. break;
  716. default:
  717. break;
  718. }
  719. }
  720. // UI handling
  721. btnDownloadApps.Enabled = true;
  722. txtFeedError.Visible = false;
  723. }
  724. catch (Exception ex)
  725. {
  726. btnDownloadApps.Enabled = false;
  727. txtFeedError.Visible = true;
  728. ErrorLogger.LogError("MainForm.GetFeed", ex.Message, ex.StackTrace);
  729. }
  730. }
  731. }
  732. catch (Exception ex)
  733. {
  734. btnDownloadApps.Enabled = false;
  735. txtFeedError.Visible = true;
  736. ErrorLogger.LogError("MainForm.GetFeed-DownloadImages", ex.Message, ex.StackTrace);
  737. }
  738. }
  739. private void CleanPC()
  740. {
  741. try
  742. {
  743. if (checkTemp.Checked)
  744. {
  745. CleanHelper.PreviewTemp();
  746. }
  747. if (checkMiniDumps.Checked)
  748. {
  749. CleanHelper.PreviewMinidumps();
  750. }
  751. if (checkErrorReports.Checked)
  752. {
  753. CleanHelper.PreviewErrorReports();
  754. }
  755. if (checkBin.Checked)
  756. {
  757. CleanHelper.EmptyRecycleBin();
  758. }
  759. }
  760. catch (Exception ex)
  761. {
  762. ErrorLogger.LogError("MainForm.CleanPC", ex.Message, ex.StackTrace);
  763. }
  764. finally
  765. {
  766. if (CleanHelper.PreviewCleanList.Count > 0) new CleanPreviewForm(CleanHelper.PreviewCleanList).ShowDialog();
  767. GetFootprint();
  768. }
  769. }
  770. private bool FixRegistry()
  771. {
  772. bool changeDetected = false;
  773. try
  774. {
  775. if (checkFirewall.Checked)
  776. {
  777. Utilities.EnableFirewall();
  778. changeDetected = true;
  779. }
  780. if (checkCommandPrompt.Checked)
  781. {
  782. Utilities.EnableCommandPrompt();
  783. changeDetected = true;
  784. }
  785. if (checkControlPanel.Checked)
  786. {
  787. Utilities.EnableControlPanel();
  788. changeDetected = true;
  789. }
  790. if (checkFolderOptions.Checked)
  791. {
  792. Utilities.EnableFolderOptions();
  793. changeDetected = true;
  794. }
  795. if (checkRunDialog.Checked)
  796. {
  797. Utilities.EnableRunDialog();
  798. changeDetected = true;
  799. }
  800. if (checkContextMenu.Checked)
  801. {
  802. Utilities.EnableContextMenu();
  803. changeDetected = true;
  804. }
  805. if (checkTaskManager.Checked)
  806. {
  807. Utilities.EnableTaskManager();
  808. changeDetected = true;
  809. }
  810. if (checkRegistryEditor.Checked)
  811. {
  812. Utilities.EnableRegistryEditor();
  813. changeDetected = true;
  814. }
  815. }
  816. catch (Exception ex)
  817. {
  818. ErrorLogger.LogError("MainForm.FixRegistry", ex.Message, ex.StackTrace);
  819. }
  820. return changeDetected;
  821. }
  822. private void LoadUniversalToggleStates()
  823. {
  824. performanceSw.Checked = Options.CurrentOptions.EnablePerformanceTweaks;
  825. networkSw.Checked = Options.CurrentOptions.DisableNetworkThrottling;
  826. defenderSw.Checked = Options.CurrentOptions.DisableWindowsDefender;
  827. systemRestoreSw.Checked = Options.CurrentOptions.DisableSystemRestore;
  828. printSw.Checked = Options.CurrentOptions.DisablePrintService;
  829. mediaSharingSw.Checked = Options.CurrentOptions.DisableMediaPlayerSharing;
  830. reportingSw.Checked = Options.CurrentOptions.DisableErrorReporting;
  831. homegroupSw.Checked = Options.CurrentOptions.DisableHomeGroup;
  832. superfetchSw.Checked = Options.CurrentOptions.DisableSuperfetch;
  833. telemetryTasksSw.Checked = Options.CurrentOptions.DisableTelemetryTasks;
  834. officeTelemetrySw.Checked = Options.CurrentOptions.DisableOffice2016Telemetry;
  835. compatSw.Checked = Options.CurrentOptions.DisableCompatibilityAssistant;
  836. faxSw.Checked = Options.CurrentOptions.DisableFaxService;
  837. smartScreenSw.Checked = Options.CurrentOptions.DisableSmartScreen;
  838. stickySw.Checked = Options.CurrentOptions.DisableStickyKeys;
  839. }
  840. private void LoadWindowsVIIIToggleStates()
  841. {
  842. disableOneDriveSw.Checked = Options.CurrentOptions.DisableOneDrive;
  843. }
  844. private void LoadWindowsXToggleStates()
  845. {
  846. oldMixerSw.Checked = Options.CurrentOptions.EnableLegacyVolumeSlider;
  847. uODSw.Checked = Options.CurrentOptions.UninstallOneDrive;
  848. gameBarSw.Checked = Options.CurrentOptions.DisableGameBar;
  849. cortanaSw.Checked = Options.CurrentOptions.DisableCortana;
  850. xboxSw.Checked = Options.CurrentOptions.DisableXboxLive;
  851. oldExplorerSw.Checked = Options.CurrentOptions.DisableQuickAccessHistory;
  852. colorBarSw.Checked = Options.CurrentOptions.EnableTaskbarColor;
  853. sensorSw.Checked = Options.CurrentOptions.DisableSensorServices;
  854. privacySw.Checked = Options.CurrentOptions.DisablePrivacyOptions;
  855. telemetryServicesSw.Checked = Options.CurrentOptions.DisableTelemetryServices;
  856. autoUpdatesSw.Checked = Options.CurrentOptions.DisableAutomaticUpdates;
  857. peopleSw.Checked = Options.CurrentOptions.DisableMyPeople;
  858. adsSw.Checked = Options.CurrentOptions.DisableStartMenuAds;
  859. darkSw.Checked = Options.CurrentOptions.EnableDarkTheme;
  860. spellSw.Checked = Options.CurrentOptions.DisableSpellingTyping;
  861. inkSw.Checked = Options.CurrentOptions.DisableWindowsInk;
  862. driversSw.Checked = Options.CurrentOptions.ExcludeDrivers;
  863. insiderSw.Checked = Options.CurrentOptions.DisableInsiderService;
  864. featuresSw.Checked = Options.CurrentOptions.DisableFeatureUpdates;
  865. ccSw.Checked = Options.CurrentOptions.DisableCloudClipboard;
  866. longPathsSw.Checked = Options.CurrentOptions.EnableLongPaths;
  867. castSw.Checked = Options.CurrentOptions.RemoveCastToDevice;
  868. actionSw.Checked = Options.CurrentOptions.DisableActionCenter;
  869. }
  870. private void LoadWindowsXIToggleStates()
  871. {
  872. leftTaskbarSw.Checked = Options.CurrentOptions.TaskbarToLeft;
  873. snapAssistSw.Checked = Options.CurrentOptions.DisableSnapAssist;
  874. widgetsSw.Checked = Options.CurrentOptions.DisableWidgets;
  875. chatSw.Checked = Options.CurrentOptions.DisableChat;
  876. smallerTaskbarSw.Checked = Options.CurrentOptions.TaskbarSmaller;
  877. classicRibbonSw.Checked = Options.CurrentOptions.ClassicRibbon;
  878. classicContextSw.Checked = Options.CurrentOptions.ClassicMenu;
  879. tpmSw.Checked = Options.CurrentOptions.DisableTPMCheck;
  880. }
  881. private void Main_Load(object sender, EventArgs e)
  882. {
  883. }
  884. private void GetDesktopItems()
  885. {
  886. _desktopItems = Integrator.GetDesktopItems();
  887. listDesktopItems.Items.Clear();
  888. for (int i = 0; i < _desktopItems.Count; i++)
  889. {
  890. if (!string.IsNullOrEmpty(_desktopItems[i]))
  891. {
  892. listDesktopItems.Items.Add(_desktopItems[i]);
  893. }
  894. }
  895. if (_desktopItems.Count > 0) listDesktopItems.SelectedIndex = 0;
  896. }
  897. private void GetHostsEntries()
  898. {
  899. ((Control)this.hostsEditorTab).Enabled = false;
  900. _hostsEntries = HostsHelper.GetHostsEntries();
  901. listHostEntries.Items.Clear();
  902. listHostEntries.Items.AddRange(_hostsEntries.ToArray());
  903. chkReadOnly.Checked = HostsHelper.GetReadOnly();
  904. addHostB.Enabled = !chkReadOnly.Checked;
  905. removeAllHostsB.Enabled = !chkReadOnly.Checked;
  906. removeHostB.Enabled = !chkReadOnly.Checked;
  907. refreshHostsB.Enabled = !chkReadOnly.Checked;
  908. linkRestoreDefault.Enabled = !chkReadOnly.Checked;
  909. chkBlock.Enabled = !chkReadOnly.Checked;
  910. txtDomain.Enabled = !chkReadOnly.Checked;
  911. txtIP.Enabled = !chkReadOnly.Checked;
  912. adblockBasic.Enabled = !chkReadOnly.Checked;
  913. adblockS.Enabled = !chkReadOnly.Checked;
  914. adblockP.Enabled = !chkReadOnly.Checked;
  915. adblockUlti.Enabled = !chkReadOnly.Checked;
  916. ((Control)this.hostsEditorTab).Enabled = true;
  917. if (_hostsEntries.Count > 0) listHostEntries.SelectedIndex = 0;
  918. }
  919. private void GetStartupItems()
  920. {
  921. _startUpItems = Utilities.GetStartupItems();
  922. listStartupItems.Items.Clear();
  923. for (int i = 0; i < _startUpItems.Count; i++)
  924. {
  925. ListViewItem list = new ListViewItem(_startUpItems[i].Name);
  926. list.SubItems.Add(_startUpItems[i].FileLocation);
  927. list.SubItems.Add(_startUpItems[i].ToString());
  928. listStartupItems.Items.Add(list);
  929. }
  930. }
  931. private void GetModernApps(bool showAll)
  932. {
  933. uninstallModernAppsButton.Enabled = false;
  934. refreshModernAppsButton.Enabled = false;
  935. listModernApps.Enabled = false;
  936. listModernApps.Items.Clear();
  937. _modernApps = Utilities.GetModernApps(showAll);
  938. foreach (string x in _modernApps)
  939. {
  940. listModernApps.Items.Add(x);
  941. }
  942. uninstallModernAppsButton.Enabled = true;
  943. refreshModernAppsButton.Enabled = true;
  944. listModernApps.Enabled = true;
  945. if (_modernApps.Count > 0) listModernApps.SelectedIndex = 0;
  946. }
  947. private async void UninstallModernApps()
  948. {
  949. string selectedApps = string.Empty;
  950. if (listModernApps.CheckedItems.Count > 0)
  951. {
  952. foreach (string x in listModernApps.CheckedItems)
  953. {
  954. if (string.IsNullOrEmpty(selectedApps))
  955. {
  956. selectedApps = x;
  957. }
  958. else
  959. {
  960. selectedApps += Environment.NewLine + x;
  961. }
  962. }
  963. if (MessageBox.Show(_removeModernAppsMessage + "\n\n" + selectedApps, "Optimizer", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  964. {
  965. uninstallModernAppsButton.Enabled = false;
  966. refreshModernAppsButton.Enabled = false;
  967. listModernApps.Enabled = false;
  968. bool errorOccured = false;
  969. string failedApps = string.Empty;
  970. foreach (string app in listModernApps.CheckedItems)
  971. {
  972. await Task.Run(() => errorOccured = Utilities.UninstallModernApp(app));
  973. if (errorOccured)
  974. {
  975. failedApps += Environment.NewLine + app;
  976. }
  977. }
  978. if (!string.IsNullOrEmpty(failedApps))
  979. {
  980. MessageBox.Show(_errorModernAppsMessage + failedApps, "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
  981. }
  982. GetModernApps(!chkOnlyRemovable.Checked);
  983. }
  984. }
  985. }
  986. private void GetCustomCommands()
  987. {
  988. _customCommands = Integrator.GetCustomCommands();
  989. listCustomCommands.Items.Clear();
  990. foreach (string s in _customCommands)
  991. {
  992. listCustomCommands.Items.Add(s);
  993. }
  994. if (_customCommands.Count > 0) listCustomCommands.SelectedIndex = 0;
  995. }
  996. private void Main_FormClosing(object sender, FormClosingEventArgs e)
  997. {
  998. if (_trayMenu)
  999. {
  1000. e.Cancel = true;
  1001. this.Hide();
  1002. }
  1003. else
  1004. {
  1005. Options.CurrentOptions.AppsFolder = txtDownloadFolder.Text;
  1006. Options.SaveSettings();
  1007. }
  1008. }
  1009. private void button39_Click(object sender, EventArgs e)
  1010. {
  1011. HelperForm f = new HelperForm(this, MessageType.Restart, _restartMessage);
  1012. f.ShowDialog();
  1013. }
  1014. private void button43_Click(object sender, EventArgs e)
  1015. {
  1016. HelperForm f = new HelperForm(this, MessageType.Restart, _restartMessage);
  1017. f.ShowDialog();
  1018. }
  1019. private void button44_Click(object sender, EventArgs e)
  1020. {
  1021. HelperForm f = new HelperForm(this, MessageType.Restart, _restartMessage);
  1022. f.ShowDialog();
  1023. }
  1024. private void button45_Click(object sender, EventArgs e)
  1025. {
  1026. HelperForm f = new HelperForm(this, MessageType.Restart, _restartMessage);
  1027. f.ShowDialog();
  1028. }
  1029. private void checkSelectAll_CheckedChanged(object sender, EventArgs e)
  1030. {
  1031. checkTemp.Checked = checkSelectAll.Checked;
  1032. checkMiniDumps.Checked = checkSelectAll.Checked;
  1033. checkErrorReports.Checked = checkSelectAll.Checked;
  1034. }
  1035. private void button20_Click(object sender, EventArgs e)
  1036. {
  1037. CleanHelper.PreviewCleanList.Clear();
  1038. CleanPC();
  1039. }
  1040. private void button32_Click(object sender, EventArgs e)
  1041. {
  1042. if (listStartupItems.CheckedItems.Count <= 0) return;
  1043. string report = string.Empty;
  1044. foreach (ListViewItem i in listStartupItems.CheckedItems)
  1045. {
  1046. report += i.Text + Environment.NewLine;
  1047. }
  1048. if (MessageBox.Show(_removeStartupItemsMessage + Environment.NewLine + Environment.NewLine + report, "Optimizer", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  1049. {
  1050. foreach (int x in listStartupItems.CheckedIndices)
  1051. {
  1052. _startUpItems[x].Remove();
  1053. }
  1054. GetStartupItems();
  1055. }
  1056. //foreach (int x in listStartupItems.CheckedIndices)
  1057. //{
  1058. // MessageBox.Show(x.ToString());
  1059. //}
  1060. //if (listStartupItems.SelectedItems.Count == 1)
  1061. //{
  1062. // _startUpItems[listStartupItems.SelectedIndices[0]].Remove();
  1063. // GetStartupItems();
  1064. //}
  1065. }
  1066. internal void RemoveAllStartupItems()
  1067. {
  1068. foreach (ListViewItem i in listStartupItems.Items)
  1069. {
  1070. _startUpItems[i.Index].Remove();
  1071. }
  1072. GetStartupItems();
  1073. }
  1074. // REMOVE ALL STARTUP ITEMS BUTTON
  1075. //private void button22_Click(object sender, EventArgs e)
  1076. //{
  1077. // if (listStartupItems.Items.Count > 0)
  1078. // {
  1079. // HelperForm r = new HelperForm(this, MessageType.Startup, _removeStartupItemsMessage);
  1080. // r.ShowDialog(this);
  1081. // }
  1082. //}
  1083. private void button31_Click(object sender, EventArgs e)
  1084. {
  1085. if (listStartupItems.SelectedItems.Count == 1)
  1086. {
  1087. _startUpItems[listStartupItems.SelectedIndices[0]].LocateFile();
  1088. }
  1089. }
  1090. private void checkEnableAll_CheckedChanged(object sender, EventArgs e)
  1091. {
  1092. checkTaskManager.Checked = checkEnableAll.Checked;
  1093. checkCommandPrompt.Checked = checkEnableAll.Checked;
  1094. checkControlPanel.Checked = checkEnableAll.Checked;
  1095. checkFolderOptions.Checked = checkEnableAll.Checked;
  1096. checkRunDialog.Checked = checkEnableAll.Checked;
  1097. checkContextMenu.Checked = checkEnableAll.Checked;
  1098. checkFirewall.Checked = checkEnableAll.Checked;
  1099. checkRegistryEditor.Checked = checkEnableAll.Checked;
  1100. }
  1101. private void button33_Click(object sender, EventArgs e)
  1102. {
  1103. bool flag = FixRegistry();
  1104. if (flag)
  1105. {
  1106. panel2.Enabled = false;
  1107. regFixB.Enabled = false;
  1108. if (checkRestartExplorer.Checked)
  1109. {
  1110. Utilities.RestartExplorer();
  1111. }
  1112. panel2.Enabled = true;
  1113. regFixB.Enabled = true;
  1114. }
  1115. }
  1116. private void pictureBox1_Click(object sender, EventArgs e)
  1117. {
  1118. AboutForm f = new AboutForm();
  1119. f.ShowDialog(this);
  1120. }
  1121. private void button37_Click(object sender, EventArgs e)
  1122. {
  1123. GetStartupItems();
  1124. }
  1125. private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  1126. {
  1127. HostsHelper.LocateHosts();
  1128. }
  1129. private void linkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  1130. {
  1131. HostsEditorForm f = new HostsEditorForm();
  1132. f.ShowDialog(this);
  1133. GetHostsEntries();
  1134. }
  1135. private void linkLabel4_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  1136. {
  1137. HostsHelper.RestoreDefaultHosts();
  1138. GetHostsEntries();
  1139. }
  1140. private void button47_Click(object sender, EventArgs e)
  1141. {
  1142. if ((txtIP.Text != string.Empty) && (txtDomain.Text != string.Empty))
  1143. {
  1144. string ip = txtIP.Text.Trim();
  1145. string domain = txtDomain.Text.Trim();
  1146. string recommendedDomain = string.Empty;
  1147. if (!domain.StartsWith("www."))
  1148. {
  1149. recommendedDomain = "www." + domain;
  1150. }
  1151. else
  1152. {
  1153. recommendedDomain = domain.Replace("www.", string.Empty);
  1154. }
  1155. HostsHelper.AddEntry(HostsHelper.SanitizeEntry(ip) + " " + HostsHelper.SanitizeEntry(domain));
  1156. if (!string.IsNullOrEmpty(recommendedDomain))
  1157. {
  1158. HostsHelper.AddEntry(HostsHelper.SanitizeEntry(ip) + " " + HostsHelper.SanitizeEntry(recommendedDomain));
  1159. }
  1160. GetHostsEntries();
  1161. txtIP.Clear();
  1162. txtDomain.Clear();
  1163. chkBlock.Checked = false;
  1164. }
  1165. }
  1166. private void button41_Click(object sender, EventArgs e)
  1167. {
  1168. GetHostsEntries();
  1169. }
  1170. private void button42_Click(object sender, EventArgs e)
  1171. {
  1172. if (listHostEntries.SelectedItems.Count == 1)
  1173. {
  1174. HostsHelper.RemoveEntry(listHostEntries.SelectedItem.ToString().Replace(" : ", " "));
  1175. GetHostsEntries();
  1176. }
  1177. }
  1178. private void button46_Click(object sender, EventArgs e)
  1179. {
  1180. if (listHostEntries.Items.Count > 0)
  1181. {
  1182. HelperForm r = new HelperForm(this, MessageType.Hosts, _removeHostsEntriesMessage);
  1183. r.ShowDialog(this);
  1184. }
  1185. }
  1186. internal void RemoveAllHostsEntries()
  1187. {
  1188. List<string> collection = new List<string>();
  1189. foreach (string item in listHostEntries.Items)
  1190. {
  1191. collection.Add(item.Replace(" : ", " "));
  1192. }
  1193. HostsHelper.RemoveAllEntries(collection);
  1194. GetHostsEntries();
  1195. }
  1196. private void aio_SelectedIndexChanged(object sender, EventArgs e)
  1197. {
  1198. if (tabCollection.SelectedTab == hostsEditorTab) txtIP.Focus();
  1199. if (tabCollection.SelectedTab == pingerTab)
  1200. {
  1201. txtPingInput.Focus();
  1202. //_networkMonitor.StartMonitoring();
  1203. //NetworkMonitoring();
  1204. }
  1205. //else
  1206. //{
  1207. // _networkMonitor.StopMonitoring();
  1208. //}
  1209. }
  1210. private void button48_Click(object sender, EventArgs e)
  1211. {
  1212. defineCommandDialog.ShowDialog();
  1213. }
  1214. private void button50_Click(object sender, EventArgs e)
  1215. {
  1216. if (!string.IsNullOrEmpty(txtRunFile.Text) && !string.IsNullOrEmpty(txtRunKeyword.Text))
  1217. {
  1218. Integrator.CreateCustomCommand(txtRunFile.Text, txtRunKeyword.Text);
  1219. txtRunFile.Clear();
  1220. txtRunKeyword.Clear();
  1221. GetCustomCommands();
  1222. }
  1223. }
  1224. private void DefineCmd_FileOk(object sender, CancelEventArgs e)
  1225. {
  1226. txtRunFile.Text = defineCommandDialog.FileName;
  1227. txtRunKeyword.Text = Path.GetFileNameWithoutExtension(txtRunFile.Text).ToLower();
  1228. }
  1229. private void button59_Click(object sender, EventArgs e)
  1230. {
  1231. Utilities.ImportRegistryScript(Required.ReadyMadeMenusFolder + "\\PowerMenu.reg");
  1232. GetDesktopItems();
  1233. }
  1234. private void button53_Click(object sender, EventArgs e)
  1235. {
  1236. Utilities.ImportRegistryScript(Required.ReadyMadeMenusFolder + "\\SystemTools.reg");
  1237. GetDesktopItems();
  1238. }
  1239. private void button54_Click(object sender, EventArgs e)
  1240. {
  1241. Utilities.ImportRegistryScript(Required.ReadyMadeMenusFolder + "\\WindowsApps.reg");
  1242. GetDesktopItems();
  1243. }
  1244. private void button51_Click(object sender, EventArgs e)
  1245. {
  1246. Utilities.ImportRegistryScript(Required.ReadyMadeMenusFolder + "\\SystemShortcuts.reg");
  1247. GetDesktopItems();
  1248. }
  1249. private void button57_Click(object sender, EventArgs e)
  1250. {
  1251. Utilities.ImportRegistryScript(Required.ReadyMadeMenusFolder + "\\DesktopShortcuts.reg");
  1252. GetDesktopItems();
  1253. }
  1254. private void button60_Click(object sender, EventArgs e)
  1255. {
  1256. GetDesktopItems();
  1257. }
  1258. private void button61_Click(object sender, EventArgs e)
  1259. {
  1260. if (listDesktopItems.SelectedItems.Count == 1)
  1261. {
  1262. Integrator.RemoveItem(listDesktopItems.SelectedItem.ToString());
  1263. GetDesktopItems();
  1264. }
  1265. }
  1266. internal void RemoveAllDesktopItems()
  1267. {
  1268. List<string> collection = new List<string>();
  1269. foreach (string item in listDesktopItems.Items)
  1270. {
  1271. collection.Add(item);
  1272. }
  1273. Integrator.RemoveAllItems(collection);
  1274. GetDesktopItems();
  1275. }
  1276. private void button62_Click(object sender, EventArgs e)
  1277. {
  1278. if (listDesktopItems.Items.Count > 0)
  1279. {
  1280. HelperForm r = new HelperForm(this, MessageType.Integrator, _removeDesktopItemsMessage);
  1281. r.ShowDialog(this);
  1282. }
  1283. }
  1284. private void radioProgram_CheckedChanged(object sender, EventArgs e)
  1285. {
  1286. if (radioProgram.Checked)
  1287. {
  1288. btnBrowseItem.Enabled = true;
  1289. txtItem.Clear();
  1290. checkDefaultIcon.Checked = true;
  1291. txtIcon.Enabled = false;
  1292. btnBrowseIcon.Enabled = false;
  1293. itemtoaddgroup.Text = Options.TranslationList["itemtoaddgroup"];
  1294. checkDefaultIcon.Visible = true;
  1295. checkDefaultIcon.Text = Options.TranslationList["checkDefaultIcon"];
  1296. txtItemName.Clear();
  1297. txtItem.ReadOnly = true;
  1298. txtIcon.ReadOnly = true;
  1299. _desktopItemType = DesktopItemType.Program;
  1300. }
  1301. }
  1302. private void radioFolder_CheckedChanged(object sender, EventArgs e)
  1303. {
  1304. if (radioFolder.Checked)
  1305. {
  1306. checkDefaultIcon.Checked = true;
  1307. btnBrowseItem.Enabled = true;
  1308. txtItem.Clear();
  1309. itemtoaddgroup.Text = Options.TranslationList["folderToAdd"];
  1310. checkDefaultIcon.Text = Options.TranslationList["checkDefaultFolderIcon"];
  1311. txtItemName.Clear();
  1312. txtItem.ReadOnly = true;
  1313. txtIcon.ReadOnly = true;
  1314. _desktopItemType = DesktopItemType.Folder;
  1315. }
  1316. }
  1317. private void radioLink_CheckedChanged(object sender, EventArgs e)
  1318. {
  1319. if (radioLink.Checked)
  1320. {
  1321. checkDefaultIcon.Checked = true;
  1322. checkDefaultIcon.Text = Options.TranslationList["checkFavicon"];
  1323. btnBrowseItem.Enabled = false;
  1324. itemtoaddgroup.Text = Options.TranslationList["linkToAdd"];
  1325. checkDefaultIcon.Visible = true;
  1326. txtItem.Text = "http://";
  1327. txtItemName.Clear();
  1328. txtItem.ReadOnly = false;
  1329. txtIcon.ReadOnly = true;
  1330. _desktopItemType = DesktopItemType.Link;
  1331. }
  1332. }
  1333. private void radioFile_CheckedChanged(object sender, EventArgs e)
  1334. {
  1335. if (radioFile.Checked)
  1336. {
  1337. checkDefaultIcon.Checked = true;
  1338. checkDefaultIcon.Text = Options.TranslationList["checkNoIcon"];
  1339. btnBrowseItem.Enabled = true;
  1340. itemtoaddgroup.Text = Options.TranslationList["fileToAdd"];
  1341. checkDefaultIcon.Visible = true;
  1342. txtItem.Clear();
  1343. txtItemName.Clear();
  1344. txtItem.ReadOnly = true;
  1345. txtIcon.ReadOnly = true;
  1346. _desktopItemType = DesktopItemType.File;
  1347. }
  1348. }
  1349. private void radioCommand_CheckedChanged(object sender, EventArgs e)
  1350. {
  1351. if (radioCommand.Checked)
  1352. {
  1353. btnBrowseItem.Enabled = false;
  1354. txtItem.Clear();
  1355. checkDefaultIcon.Checked = true;
  1356. txtIcon.Enabled = false;
  1357. btnBrowseIcon.Enabled = false;
  1358. itemtoaddgroup.Text = Options.TranslationList["commandToAdd"];
  1359. checkDefaultIcon.Visible = true;
  1360. checkDefaultIcon.Text = Options.TranslationList["checkNoIcon"];
  1361. txtItemName.Clear();
  1362. txtItem.ReadOnly = false;
  1363. txtIcon.ReadOnly = true;
  1364. _desktopItemType = DesktopItemType.Command;
  1365. }
  1366. }
  1367. private void checkDefaultIcon_CheckedChanged(object sender, EventArgs e)
  1368. {
  1369. if (checkDefaultIcon.Checked)
  1370. {
  1371. txtIcon.Clear();
  1372. txtIcon.Enabled = false;
  1373. btnBrowseIcon.Enabled = false;
  1374. }
  1375. else
  1376. {
  1377. txtIcon.Clear();
  1378. txtIcon.Enabled = true;
  1379. btnBrowseIcon.Enabled = true;
  1380. }
  1381. }
  1382. private void btnBrowseItem_Click(object sender, EventArgs e)
  1383. {
  1384. switch (_desktopItemType)
  1385. {
  1386. case DesktopItemType.Program:
  1387. defineProgramDialog.ShowDialog();
  1388. break;
  1389. case DesktopItemType.Folder:
  1390. defineFolderDialog.ShowDialog();
  1391. txtItem.Text = defineFolderDialog.SelectedPath;
  1392. int i = defineFolderDialog.SelectedPath.LastIndexOf("\\");
  1393. txtItemName.Text = defineFolderDialog.SelectedPath.Remove(0, i + 1);
  1394. break;
  1395. case DesktopItemType.File:
  1396. defineFileDialog.ShowDialog();
  1397. break;
  1398. }
  1399. }
  1400. private void DefineProgramDialog_FileOk(object sender, CancelEventArgs e)
  1401. {
  1402. txtItem.Text = defineProgramDialog.FileName;
  1403. txtItemName.Text = defineProgramDialog.SafeFileName.Replace(".exe", string.Empty);
  1404. }
  1405. private void DefineFileDialog_FileOk(object sender, CancelEventArgs e)
  1406. {
  1407. txtItem.Text = defineFileDialog.FileName;
  1408. txtItemName.Text = defineFileDialog.SafeFileName;
  1409. }
  1410. private void btnBrowseIcon_Click(object sender, EventArgs e)
  1411. {
  1412. switch (_desktopItemType)
  1413. {
  1414. case DesktopItemType.Program:
  1415. DefineProgramIconDialog.ShowDialog();
  1416. break;
  1417. case DesktopItemType.Folder:
  1418. DefineFolderIconDialog.ShowDialog();
  1419. break;
  1420. case DesktopItemType.Link:
  1421. DefineURLIconDialog.ShowDialog();
  1422. break;
  1423. case DesktopItemType.File:
  1424. DefineFileIconDialog.ShowDialog();
  1425. break;
  1426. case DesktopItemType.Command:
  1427. DefineCommandIconDialog.ShowDialog();
  1428. break;
  1429. }
  1430. }
  1431. private void DefineProgramIconDialog_FileOk(object sender, CancelEventArgs e)
  1432. {
  1433. txtIcon.Text = DefineProgramIconDialog.FileName;
  1434. if (txtIcon.Text.Contains(".exe"))
  1435. {
  1436. string iconpath = Integrator.ExtractIconFromExecutable(txtItemName.Text, DefineProgramIconDialog.FileName);
  1437. txtIcon.Text = iconpath;
  1438. }
  1439. }
  1440. private void DefineFolderIconDialog_FileOk(object sender, CancelEventArgs e)
  1441. {
  1442. txtIcon.Text = DefineFolderIconDialog.FileName;
  1443. if (txtIcon.Text.Contains(".exe"))
  1444. {
  1445. string iconpath = Integrator.ExtractIconFromExecutable(txtItemName.Text, DefineFolderIconDialog.FileName);
  1446. txtIcon.Text = iconpath;
  1447. }
  1448. }
  1449. private void DefineURLIconDialog_FileOk(object sender, CancelEventArgs e)
  1450. {
  1451. txtIcon.Text = DefineURLIconDialog.FileName;
  1452. if (txtIcon.Text.Contains(".exe"))
  1453. {
  1454. string iconpath = Integrator.ExtractIconFromExecutable(txtItemName.Text, DefineURLIconDialog.FileName);
  1455. txtIcon.Text = iconpath;
  1456. }
  1457. }
  1458. private void DefineFileIconDialog_FileOk(object sender, CancelEventArgs e)
  1459. {
  1460. txtIcon.Text = DefineFileIconDialog.FileName;
  1461. if (txtIcon.Text.Contains(".exe"))
  1462. {
  1463. string iconpath = Integrator.ExtractIconFromExecutable(txtItemName.Text, DefineFileIconDialog.FileName);
  1464. txtIcon.Text = iconpath;
  1465. }
  1466. }
  1467. private void DefineCommandIconDialog_FileOk(object sender, CancelEventArgs e)
  1468. {
  1469. txtIcon.Text = DefineCommandIconDialog.FileName;
  1470. if (txtIcon.Text.Contains(".exe"))
  1471. {
  1472. string iconpath = Integrator.ExtractIconFromExecutable(txtItemName.Text, DefineCommandIconDialog.FileName);
  1473. txtIcon.Text = iconpath;
  1474. }
  1475. }
  1476. private void btnAddItem_Click(object sender, EventArgs e)
  1477. {
  1478. if (!checkDefaultIcon.Checked && (string.IsNullOrEmpty(txtItem.Text) || string.IsNullOrEmpty(txtItemName.Text) || string.IsNullOrEmpty(txtIcon.Text)))
  1479. {
  1480. return;
  1481. }
  1482. if (checkDefaultIcon.Checked && (string.IsNullOrEmpty(txtItem.Text) || string.IsNullOrEmpty(txtItemName.Text)))
  1483. {
  1484. return;
  1485. }
  1486. string icon = string.Empty;
  1487. switch (_desktopItemType)
  1488. {
  1489. case DesktopItemType.Program:
  1490. if (checkDefaultIcon.Checked)
  1491. {
  1492. icon = txtItem.Text;
  1493. }
  1494. else
  1495. {
  1496. icon = txtIcon.Text;
  1497. }
  1498. Integrator.AddItem(txtItemName.Text, txtItem.Text, icon, _desktopItemPosition, checkShift.Checked, DesktopItemType.Program);
  1499. break;
  1500. case DesktopItemType.Folder:
  1501. if (checkDefaultIcon.Checked)
  1502. {
  1503. icon = Integrator.FolderDefaultIcon;
  1504. }
  1505. else
  1506. {
  1507. icon = txtIcon.Text;
  1508. }
  1509. Integrator.AddItem(txtItemName.Text, txtItem.Text, icon, _desktopItemPosition, checkShift.Checked, DesktopItemType.Folder);
  1510. break;
  1511. case DesktopItemType.Link:
  1512. if (checkDefaultIcon.Checked)
  1513. {
  1514. icon = Integrator.DownloadFavicon(txtItem.Text, txtItemName.Text);
  1515. }
  1516. else
  1517. {
  1518. icon = txtIcon.Text;
  1519. }
  1520. Integrator.AddItem(txtItemName.Text, txtItem.Text, icon, _desktopItemPosition, checkShift.Checked, DesktopItemType.Link);
  1521. break;
  1522. case DesktopItemType.File:
  1523. if (!checkDefaultIcon.Checked)
  1524. {
  1525. icon = txtIcon.Text;
  1526. }
  1527. Integrator.AddItem(txtItemName.Text, txtItem.Text, icon, _desktopItemPosition, checkShift.Checked, DesktopItemType.File);
  1528. break;
  1529. case DesktopItemType.Command:
  1530. if (!checkDefaultIcon.Checked)
  1531. {
  1532. icon = txtIcon.Text;
  1533. }
  1534. Integrator.AddItem(txtItemName.Text, txtItem.Text, icon, _desktopItemPosition, checkShift.Checked, DesktopItemType.Command);
  1535. break;
  1536. }
  1537. GetDesktopItems();
  1538. ResetIntegratorForm();
  1539. }
  1540. private void radioTop_CheckedChanged(object sender, EventArgs e)
  1541. {
  1542. if (radioTop.Checked)
  1543. {
  1544. _desktopItemPosition = DesktopTypePosition.Top;
  1545. }
  1546. }
  1547. private void radioMiddle_CheckedChanged(object sender, EventArgs e)
  1548. {
  1549. if (radioMiddle.Checked)
  1550. {
  1551. _desktopItemPosition = DesktopTypePosition.Middle;
  1552. }
  1553. }
  1554. private void radioBottom_CheckedChanged(object sender, EventArgs e)
  1555. {
  1556. if (radioBottom.Checked)
  1557. {
  1558. _desktopItemPosition = DesktopTypePosition.Bottom;
  1559. }
  1560. }
  1561. private void ResetIntegratorForm()
  1562. {
  1563. txtItem.Clear();
  1564. txtIcon.Clear();
  1565. checkDefaultIcon.Checked = true;
  1566. txtItemName.Clear();
  1567. if (radioLink.Checked)
  1568. {
  1569. txtItem.Text = "http://";
  1570. }
  1571. }
  1572. private void radioOcean_CheckedChanged(object sender, EventArgs e)
  1573. {
  1574. Options.CurrentOptions.Color = Theme.Ocean;
  1575. Options.ApplyTheme(this);
  1576. }
  1577. private void radioMagma_CheckedChanged(object sender, EventArgs e)
  1578. {
  1579. Options.CurrentOptions.Color = Theme.Magma;
  1580. Options.ApplyTheme(this);
  1581. }
  1582. private void radioZerg_CheckedChanged(object sender, EventArgs e)
  1583. {
  1584. Options.CurrentOptions.Color = Theme.Zerg;
  1585. Options.ApplyTheme(this);
  1586. }
  1587. private void radioMinimal_CheckedChanged(object sender, EventArgs e)
  1588. {
  1589. Options.CurrentOptions.Color = Theme.Minimal;
  1590. Options.ApplyTheme(this);
  1591. }
  1592. private void radioCaramel_CheckedChanged(object sender, EventArgs e)
  1593. {
  1594. Options.CurrentOptions.Color = Theme.Caramel;
  1595. Options.ApplyTheme(this);
  1596. }
  1597. private void radioLime_CheckedChanged(object sender, EventArgs e)
  1598. {
  1599. Options.CurrentOptions.Color = Theme.Lime;
  1600. Options.ApplyTheme(this);
  1601. }
  1602. private void button64_Click(object sender, EventArgs e)
  1603. {
  1604. if (listStartupItems.SelectedItems.Count == 1)
  1605. {
  1606. _startUpItems[listStartupItems.SelectedIndices[0]].LocateKey();
  1607. }
  1608. }
  1609. private void button66_Click(object sender, EventArgs e)
  1610. {
  1611. Integrator.TakeOwnership(false);
  1612. }
  1613. private void button65_Click(object sender, EventArgs e)
  1614. {
  1615. Integrator.TakeOwnership(true);
  1616. }
  1617. private void listStartupItems_ColumnClick(object sender, ColumnClickEventArgs e)
  1618. {
  1619. if (e.Column == _columnSorter.CurrentColumn)
  1620. {
  1621. if (_columnSorter.SortOrder == SortOrder.Ascending)
  1622. {
  1623. _columnSorter.SortOrder = SortOrder.Descending;
  1624. }
  1625. else
  1626. {
  1627. _columnSorter.SortOrder = SortOrder.Ascending;
  1628. }
  1629. }
  1630. else
  1631. {
  1632. _columnSorter.CurrentColumn = e.Column;
  1633. _columnSorter.SortOrder = SortOrder.Ascending;
  1634. }
  1635. listStartupItems.Sort();
  1636. }
  1637. private void chkBlock_CheckedChanged(object sender, EventArgs e)
  1638. {
  1639. if (chkBlock.Checked)
  1640. {
  1641. txtIP.Text = _blockedIP;
  1642. txtIP.Enabled = false;
  1643. }
  1644. else
  1645. {
  1646. txtIP.Clear();
  1647. txtIP.Enabled = true;
  1648. }
  1649. }
  1650. private void button8_Click(object sender, EventArgs e)
  1651. {
  1652. GetCustomCommands();
  1653. }
  1654. private void button26_Click(object sender, EventArgs e)
  1655. {
  1656. if (listCustomCommands.SelectedItems.Count == 1)
  1657. {
  1658. Integrator.DeleteCustomCommand(listCustomCommands.SelectedItem.ToString());
  1659. GetCustomCommands();
  1660. }
  1661. }
  1662. private void button75_Click(object sender, EventArgs e)
  1663. {
  1664. GetModernApps(!chkOnlyRemovable.Checked);
  1665. }
  1666. private void button74_Click(object sender, EventArgs e)
  1667. {
  1668. UninstallModernApps();
  1669. }
  1670. private void chkSelectAllModernApps_CheckedChanged(object sender, EventArgs e)
  1671. {
  1672. for (int i = 0; i < listModernApps.Items.Count; i++)
  1673. {
  1674. listModernApps.SetItemChecked(i, chkSelectAllModernApps.Checked);
  1675. }
  1676. }
  1677. private void btnResetConfig_Click(object sender, EventArgs e)
  1678. {
  1679. if (MessageBox.Show(_resetMessage, "Optimizer", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  1680. {
  1681. Utilities.ResetConfiguration();
  1682. }
  1683. }
  1684. private void toggleSwitch1_Click(object sender, EventArgs e)
  1685. {
  1686. if (!performanceSw.Checked)
  1687. {
  1688. Optimize.EnablePerformanceTweaks();
  1689. }
  1690. else
  1691. {
  1692. Optimize.DisablePerformanceTweaks();
  1693. }
  1694. Options.CurrentOptions.EnablePerformanceTweaks = !performanceSw.Checked;
  1695. }
  1696. private void toggleSwitch2_Click(object sender, EventArgs e)
  1697. {
  1698. if (!networkSw.Checked)
  1699. {
  1700. Optimize.DisableNetworkThrottling();
  1701. }
  1702. else
  1703. {
  1704. Optimize.EnableNetworkThrottling();
  1705. }
  1706. Options.CurrentOptions.DisableNetworkThrottling = !networkSw.Checked;
  1707. }
  1708. private void toggleSwitch3_Click(object sender, EventArgs e)
  1709. {
  1710. if (!defenderSw.Checked)
  1711. {
  1712. Optimize.DisableDefender();
  1713. }
  1714. else
  1715. {
  1716. Optimize.EnableDefender();
  1717. }
  1718. Options.CurrentOptions.DisableWindowsDefender = !defenderSw.Checked;
  1719. }
  1720. private void toggleSwitch4_Click(object sender, EventArgs e)
  1721. {
  1722. if (!systemRestoreSw.Checked)
  1723. {
  1724. Optimize.DisableSystemRestore();
  1725. }
  1726. else
  1727. {
  1728. Optimize.EnableSystemRestore();
  1729. }
  1730. Options.CurrentOptions.DisableSystemRestore = !systemRestoreSw.Checked;
  1731. }
  1732. private void toggleSwitch5_Click(object sender, EventArgs e)
  1733. {
  1734. if (!printSw.Checked)
  1735. {
  1736. Optimize.DisablePrintService();
  1737. }
  1738. else
  1739. {
  1740. Optimize.EnablePrintService();
  1741. }
  1742. Options.CurrentOptions.DisablePrintService = !printSw.Checked;
  1743. }
  1744. private void toggleSwitch6_Click(object sender, EventArgs e)
  1745. {
  1746. if (!mediaSharingSw.Checked)
  1747. {
  1748. Optimize.DisableMediaPlayerSharing();
  1749. }
  1750. else
  1751. {
  1752. Optimize.EnableMediaPlayerSharing();
  1753. }
  1754. Options.CurrentOptions.DisableMediaPlayerSharing = !mediaSharingSw.Checked;
  1755. }
  1756. private void toggleSwitch8_Click(object sender, EventArgs e)
  1757. {
  1758. if (!reportingSw.Checked)
  1759. {
  1760. Optimize.DisableErrorReporting();
  1761. }
  1762. else
  1763. {
  1764. Optimize.EnableErrorReporting();
  1765. }
  1766. Options.CurrentOptions.DisableErrorReporting = !reportingSw.Checked;
  1767. }
  1768. private void toggleSwitch9_Click(object sender, EventArgs e)
  1769. {
  1770. if (!homegroupSw.Checked)
  1771. {
  1772. Optimize.DisableHomeGroup();
  1773. }
  1774. else
  1775. {
  1776. Optimize.EnableHomeGroup();
  1777. }
  1778. Options.CurrentOptions.DisableHomeGroup = !homegroupSw.Checked;
  1779. }
  1780. private void toggleSwitch10_Click(object sender, EventArgs e)
  1781. {
  1782. if (!superfetchSw.Checked)
  1783. {
  1784. Optimize.DisableSuperfetch();
  1785. }
  1786. else
  1787. {
  1788. Optimize.EnableSuperfetch();
  1789. }
  1790. Options.CurrentOptions.DisableSuperfetch = !superfetchSw.Checked;
  1791. }
  1792. private void toggleSwitch11_Click(object sender, EventArgs e)
  1793. {
  1794. if (!telemetryTasksSw.Checked)
  1795. {
  1796. Optimize.DisableTelemetryTasks();
  1797. }
  1798. else
  1799. {
  1800. Optimize.EnableTelemetryTasks();
  1801. }
  1802. Options.CurrentOptions.DisableTelemetryTasks = !telemetryTasksSw.Checked;
  1803. }
  1804. private void toggleSwitch12_Click(object sender, EventArgs e)
  1805. {
  1806. if (!officeTelemetrySw.Checked)
  1807. {
  1808. Optimize.DisableOffice2016Telemetry();
  1809. }
  1810. else
  1811. {
  1812. Optimize.EnableOffice2016Telemetry();
  1813. }
  1814. Options.CurrentOptions.DisableOffice2016Telemetry = !officeTelemetrySw.Checked;
  1815. }
  1816. private void toggleSwitch13_Click(object sender, EventArgs e)
  1817. {
  1818. if (!oldMixerSw.Checked)
  1819. {
  1820. Optimize.EnableLegacyVolumeSlider();
  1821. }
  1822. else
  1823. {
  1824. Optimize.DisableLegacyVolumeSlider();
  1825. }
  1826. Options.CurrentOptions.EnableLegacyVolumeSlider = !oldMixerSw.Checked;
  1827. }
  1828. private void toggleSwitch19_Click(object sender, EventArgs e)
  1829. {
  1830. if (!colorBarSw.Checked)
  1831. {
  1832. Optimize.EnableTaskbarColor();
  1833. }
  1834. else
  1835. {
  1836. Optimize.DisableTaskbarColor();
  1837. }
  1838. Options.CurrentOptions.EnableTaskbarColor = !colorBarSw.Checked;
  1839. }
  1840. private void toggleSwitch18_Click(object sender, EventArgs e)
  1841. {
  1842. if (!oldExplorerSw.Checked)
  1843. {
  1844. Optimize.DisableQuickAccessHistory();
  1845. }
  1846. else
  1847. {
  1848. Optimize.EnableQuickAccessHistory();
  1849. }
  1850. Options.CurrentOptions.DisableQuickAccessHistory = !oldExplorerSw.Checked;
  1851. }
  1852. private void toggleSwitch26_Click(object sender, EventArgs e)
  1853. {
  1854. if (!adsSw.Checked)
  1855. {
  1856. Optimize.DisableStartMenuAds();
  1857. }
  1858. else
  1859. {
  1860. Optimize.EnableStartMenuAds();
  1861. }
  1862. Options.CurrentOptions.DisableStartMenuAds = !adsSw.Checked;
  1863. }
  1864. private void toggleSwitch27_Click(object sender, EventArgs e)
  1865. {
  1866. if (!darkSw.Checked)
  1867. {
  1868. Optimize.EnableDarkTheme();
  1869. }
  1870. else
  1871. {
  1872. Optimize.EnableLightTheme();
  1873. }
  1874. Options.CurrentOptions.EnableDarkTheme = !darkSw.Checked;
  1875. }
  1876. private void toggleSwitch14_Click(object sender, EventArgs e)
  1877. {
  1878. if (!uODSw.Checked)
  1879. {
  1880. Task t = new Task(() => Optimize.UninstallOneDrive());
  1881. t.Start();
  1882. }
  1883. else
  1884. {
  1885. Task t = new Task(() => Optimize.InstallOneDrive());
  1886. t.Start();
  1887. }
  1888. Options.CurrentOptions.UninstallOneDrive = !uODSw.Checked;
  1889. }
  1890. private void toggleSwitch25_Click(object sender, EventArgs e)
  1891. {
  1892. if (!peopleSw.Checked)
  1893. {
  1894. Optimize.DisableMyPeople();
  1895. }
  1896. else
  1897. {
  1898. Optimize.EnableMyPeople();
  1899. }
  1900. Options.CurrentOptions.DisableMyPeople = !peopleSw.Checked;
  1901. }
  1902. private void toggleSwitch24_Click(object sender, EventArgs e)
  1903. {
  1904. if (!autoUpdatesSw.Checked)
  1905. {
  1906. Optimize.DisableAutomaticUpdates();
  1907. }
  1908. else
  1909. {
  1910. Optimize.EnableAutomaticUpdates();
  1911. }
  1912. Options.CurrentOptions.DisableAutomaticUpdates = !autoUpdatesSw.Checked;
  1913. }
  1914. private void toggleSwitch30_Click(object sender, EventArgs e)
  1915. {
  1916. if (!driversSw.Checked)
  1917. {
  1918. Optimize.ExcludeDrivers();
  1919. }
  1920. else
  1921. {
  1922. Optimize.IncludeDrivers();
  1923. }
  1924. Options.CurrentOptions.ExcludeDrivers = !driversSw.Checked;
  1925. }
  1926. private void toggleSwitch23_Click(object sender, EventArgs e)
  1927. {
  1928. if (!telemetryServicesSw.Checked)
  1929. {
  1930. Optimize.DisableTelemetryServices();
  1931. }
  1932. else
  1933. {
  1934. Optimize.EnableTelemetryServices();
  1935. }
  1936. Options.CurrentOptions.DisableTelemetryServices = !telemetryServicesSw.Checked;
  1937. }
  1938. private void toggleSwitch21_Click(object sender, EventArgs e)
  1939. {
  1940. if (!privacySw.Checked)
  1941. {
  1942. Optimize.EnhancePrivacy();
  1943. }
  1944. else
  1945. {
  1946. Optimize.CompromisePrivacy();
  1947. }
  1948. Options.CurrentOptions.DisablePrivacyOptions = !privacySw.Checked;
  1949. }
  1950. private void toggleSwitch16_Click(object sender, EventArgs e)
  1951. {
  1952. if (!cortanaSw.Checked)
  1953. {
  1954. Optimize.DisableCortana();
  1955. }
  1956. else
  1957. {
  1958. Optimize.EnableCortana();
  1959. }
  1960. Options.CurrentOptions.DisableCortana = !cortanaSw.Checked;
  1961. }
  1962. private void toggleSwitch20_Click(object sender, EventArgs e)
  1963. {
  1964. if (!sensorSw.Checked)
  1965. {
  1966. Optimize.DisableSensorServices();
  1967. }
  1968. else
  1969. {
  1970. Optimize.EnableSensorServices();
  1971. }
  1972. Options.CurrentOptions.DisableSensorServices = !sensorSw.Checked;
  1973. }
  1974. private void toggleSwitch29_Click(object sender, EventArgs e)
  1975. {
  1976. if (!inkSw.Checked)
  1977. {
  1978. Optimize.DisableWindowsInk();
  1979. }
  1980. else
  1981. {
  1982. Optimize.EnableWindowsInk();
  1983. }
  1984. Options.CurrentOptions.DisableWindowsInk = !inkSw.Checked;
  1985. }
  1986. private void toggleSwitch28_Click(object sender, EventArgs e)
  1987. {
  1988. if (!spellSw.Checked)
  1989. {
  1990. Optimize.DisableSpellingAndTypingFeatures();
  1991. }
  1992. else
  1993. {
  1994. Optimize.EnableSpellingAndTypingFeatures();
  1995. }
  1996. Options.CurrentOptions.DisableSpellingTyping = !spellSw.Checked;
  1997. }
  1998. private void toggleSwitch17_Click(object sender, EventArgs e)
  1999. {
  2000. if (!xboxSw.Checked)
  2001. {
  2002. Optimize.DisableXboxLive();
  2003. }
  2004. else
  2005. {
  2006. Optimize.EnableXboxLive();
  2007. }
  2008. Options.CurrentOptions.DisableXboxLive = !xboxSw.Checked;
  2009. }
  2010. private void toggleSwitch15_Click(object sender, EventArgs e)
  2011. {
  2012. if (!gameBarSw.Checked)
  2013. {
  2014. Optimize.DisableGameBar();
  2015. }
  2016. else
  2017. {
  2018. Optimize.EnableGameBar();
  2019. }
  2020. Options.CurrentOptions.DisableGameBar = !gameBarSw.Checked;
  2021. }
  2022. private void toggleSwitch31_Click(object sender, EventArgs e)
  2023. {
  2024. if (!disableOneDriveSw.Checked)
  2025. {
  2026. Optimize.DisableOneDrive();
  2027. }
  2028. else
  2029. {
  2030. Optimize.EnableOneDrive();
  2031. }
  2032. Options.CurrentOptions.DisableOneDrive = !disableOneDriveSw.Checked;
  2033. }
  2034. private void toggleSwitch32_Click(object sender, EventArgs e)
  2035. {
  2036. if (!compatSw.Checked)
  2037. {
  2038. Optimize.DisableCompatibilityAssistant();
  2039. }
  2040. else
  2041. {
  2042. Optimize.EnableCompatibilityAssistant();
  2043. }
  2044. Options.CurrentOptions.DisableCompatibilityAssistant = !compatSw.Checked;
  2045. }
  2046. private void btnUpdate_Click(object sender, EventArgs e)
  2047. {
  2048. CheckForUpdate();
  2049. }
  2050. private void btnChangelog_Click(object sender, EventArgs e)
  2051. {
  2052. try
  2053. {
  2054. Process.Start(_changelogLink);
  2055. }
  2056. catch (Exception ex)
  2057. {
  2058. ErrorLogger.LogError("MainForm.btnChangelog_Click", ex.Message, ex.StackTrace);
  2059. MessageBox.Show(ex.Message, "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
  2060. }
  2061. }
  2062. private void chkReadOnly_CheckedChanged(object sender, EventArgs e)
  2063. {
  2064. HostsHelper.ReadOnly(chkReadOnly.Checked);
  2065. addHostB.Enabled = !chkReadOnly.Checked;
  2066. removeAllHostsB.Enabled = !chkReadOnly.Checked;
  2067. removeHostB.Enabled = !chkReadOnly.Checked;
  2068. refreshHostsB.Enabled = !chkReadOnly.Checked;
  2069. linkRestoreDefault.Enabled = !chkReadOnly.Checked;
  2070. chkBlock.Enabled = !chkReadOnly.Checked;
  2071. txtDomain.Enabled = !chkReadOnly.Checked;
  2072. txtIP.Enabled = !chkReadOnly.Checked;
  2073. adblockBasic.Enabled = !chkReadOnly.Checked;
  2074. adblockS.Enabled = !chkReadOnly.Checked;
  2075. adblockP.Enabled = !chkReadOnly.Checked;
  2076. adblockUlti.Enabled = !chkReadOnly.Checked;
  2077. txtIP.Focus();
  2078. }
  2079. private void button1_Click(object sender, EventArgs e)
  2080. {
  2081. HostsHelper.AdblockBasic();
  2082. GetHostsEntries();
  2083. }
  2084. private void button3_Click(object sender, EventArgs e)
  2085. {
  2086. HostsHelper.AdBlockWithPorn();
  2087. GetHostsEntries();
  2088. }
  2089. private void button2_Click(object sender, EventArgs e)
  2090. {
  2091. HostsHelper.AdBlockWithSocial();
  2092. GetHostsEntries();
  2093. }
  2094. private void button4_Click(object sender, EventArgs e)
  2095. {
  2096. HostsHelper.AdBlockWithSocial();
  2097. GetHostsEntries();
  2098. }
  2099. private void RenderAppDownloaderBusy()
  2100. {
  2101. btnDownloadApps.Enabled = false;
  2102. changeDownDirB.Enabled = false;
  2103. txtDownloadFolder.ReadOnly = true;
  2104. linkWarnings.Visible = false;
  2105. }
  2106. private void RenderAppDownloaderFree()
  2107. {
  2108. btnDownloadApps.Enabled = true;
  2109. changeDownDirB.Enabled = true;
  2110. txtDownloadFolder.ReadOnly = false;
  2111. linkWarnings.Visible = !string.IsNullOrEmpty(downloadLog);
  2112. txtDownloadStatus.Text = Options.TranslationList["Finished"];
  2113. }
  2114. string appNameTemp = string.Empty;
  2115. int maxCount = 0;
  2116. int count = 0;
  2117. Process p;
  2118. string downloadLog = string.Empty;
  2119. private async void btnDownloadApps_Click(object sender, EventArgs e)
  2120. {
  2121. if (!Directory.Exists(txtDownloadFolder.Text))
  2122. {
  2123. MessageBox.Show(Options.TranslationList["downloadDirInvalid"].ToString(), "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
  2124. return;
  2125. }
  2126. RenderAppDownloaderBusy();
  2127. maxCount = 0;
  2128. count = 0;
  2129. downloadLog = string.Empty;
  2130. foreach (Control c in Utilities.GetSelfAndChildrenRecursive(appsTab))
  2131. {
  2132. if (c.Name == "cAutoInstall") continue;
  2133. if (c is ColoredCheckBox && ((ColoredCheckBox)c).Checked) maxCount++;
  2134. }
  2135. ColoredCheckBox currentCheck;
  2136. Control[] temp;
  2137. foreach (FeedApp x in AppsFromFeed)
  2138. {
  2139. if (string.IsNullOrEmpty(x.Tag)) continue;
  2140. temp = appsTab.Controls.Find(x.Tag, true);
  2141. if (temp.Count() == 0) continue;
  2142. currentCheck = (ColoredCheckBox)temp[0];
  2143. if (currentCheck == null) continue;
  2144. if (!currentCheck.Checked) continue;
  2145. appNameTemp = x.Title;
  2146. if (c64.Checked)
  2147. {
  2148. count++;
  2149. if (string.IsNullOrEmpty(x.Link64))
  2150. {
  2151. downloadLog += "• " + x.Title + ":" + Environment.NewLine + Options.TranslationList["no64Download"] + Environment.NewLine + Environment.NewLine;
  2152. await DownloadApp(x, false);
  2153. }
  2154. else
  2155. {
  2156. await DownloadApp(x, true);
  2157. }
  2158. }
  2159. else
  2160. {
  2161. count++;
  2162. if (!string.IsNullOrEmpty(x.Link))
  2163. {
  2164. await DownloadApp(x, false);
  2165. }
  2166. else
  2167. {
  2168. downloadLog += "• " + x.Title + ":" + Environment.NewLine + Options.TranslationList["no32Download"] + Environment.NewLine + Environment.NewLine;
  2169. }
  2170. }
  2171. }
  2172. if (cAutoInstall.Checked)
  2173. {
  2174. count = 0;
  2175. foreach (string a in Directory.GetFiles(txtDownloadFolder.Text, "*.*", SearchOption.TopDirectoryOnly))
  2176. {
  2177. using (p = new Process())
  2178. {
  2179. count++;
  2180. p.StartInfo.FileName = a;
  2181. p.EnableRaisingEvents = true;
  2182. p.StartInfo.WorkingDirectory = txtDownloadFolder.Text;
  2183. // APP-SPECIFIC HACKS //
  2184. if (a.Contains("Sumatra")) p.StartInfo.Arguments = " -install";
  2185. // *** //
  2186. txtDownloadStatus.Text = string.Format("{0}/{1} - {2} {3} ...", count, maxCount, Options.TranslationList["installing"], Path.GetFileNameWithoutExtension(a));
  2187. await p.RunAsync();
  2188. };
  2189. }
  2190. }
  2191. // reset all checkboxes
  2192. foreach (Control c in Utilities.GetSelfAndChildrenRecursive(appsTab))
  2193. {
  2194. if (c.Name == "cAutoInstall") continue;
  2195. if (c is ColoredCheckBox && ((ColoredCheckBox)c).Checked) ((ColoredCheckBox)c).Checked = false;
  2196. }
  2197. RenderAppDownloaderFree();
  2198. }
  2199. string fileExtension = ".exe";
  2200. private async Task DownloadApp(FeedApp app, bool pref64)
  2201. {
  2202. try
  2203. {
  2204. using (WebClient downloader = new WebClient())
  2205. {
  2206. downloader.Headers.Add("User-Agent: Other");
  2207. downloader.Encoding = Encoding.UTF8;
  2208. downloader.DownloadProgressChanged += Downloader_DownloadProgressChanged;
  2209. downloader.DownloadFileCompleted += Downloader_DownloadFileCompleted;
  2210. if (pref64)
  2211. {
  2212. if (app.Link64.Contains(".msi"))
  2213. {
  2214. fileExtension = ".msi";
  2215. }
  2216. else
  2217. {
  2218. fileExtension = ".exe";
  2219. }
  2220. await downloader.DownloadFileTaskAsync(new Uri(app.Link64), Path.Combine(txtDownloadFolder.Text, app.Title + "-x64" + fileExtension));
  2221. }
  2222. else
  2223. {
  2224. if (app.Link.Contains(".msi"))
  2225. {
  2226. fileExtension = ".msi";
  2227. }
  2228. else
  2229. {
  2230. fileExtension = ".exe";
  2231. }
  2232. await downloader.DownloadFileTaskAsync(new Uri(app.Link), Path.Combine(txtDownloadFolder.Text, app.Title + "-x86" + fileExtension));
  2233. }
  2234. }
  2235. }
  2236. catch (Exception ex)
  2237. {
  2238. ErrorLogger.LogError("MainForm.DownloadApp", ex.Message, ex.StackTrace);
  2239. downloadLog += "• " + app.Title + ":" + Environment.NewLine + Options.TranslationList["linkInvalid"] + Environment.NewLine + Environment.NewLine;
  2240. if (pref64) try { File.Delete(Path.Combine(txtDownloadFolder.Text, app.Title + "-x64.exe")); } catch { }
  2241. if (!pref64) try { File.Delete(Path.Combine(txtDownloadFolder.Text, app.Title + "-x86.exe")); } catch { }
  2242. if (pref64) try { File.Delete(Path.Combine(txtDownloadFolder.Text, app.Title + "-x64.msi")); } catch { }
  2243. if (!pref64) try { File.Delete(Path.Combine(txtDownloadFolder.Text, app.Title + "-x86.msi")); } catch { }
  2244. }
  2245. }
  2246. private void Downloader_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
  2247. {
  2248. this.BeginInvoke((MethodInvoker)delegate
  2249. {
  2250. //txtDownloadStatus.Text = "Finished";
  2251. });
  2252. }
  2253. int tempProgress;
  2254. private void Downloader_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
  2255. {
  2256. this.BeginInvoke((MethodInvoker)delegate
  2257. {
  2258. double bytesIn = double.Parse(e.BytesReceived.ToString());
  2259. double totalBytes = double.Parse(e.TotalBytesToReceive.ToString());
  2260. double percentage = bytesIn / totalBytes * 100;
  2261. tempProgress = int.Parse(Math.Truncate(percentage).ToString());
  2262. // if Content-Length header is missing, just show an animation
  2263. if (Math.Abs(tempProgress) > 100)
  2264. {
  2265. txtDownloadStatus.Text = string.Format("({1}/{2}) - {0} ...", appNameTemp, count, maxCount);
  2266. progressDownloader.Style = ProgressBarStyle.Marquee;
  2267. }
  2268. // if not, show actual progress
  2269. else
  2270. {
  2271. txtDownloadStatus.Text = string.Format("({1}/{2}) - {0} - {3} / {4}", appNameTemp, count, maxCount, ByteSize.FromBytes(e.BytesReceived).ToString("MB"), ByteSize.FromBytes(e.TotalBytesToReceive).ToString("MB"));
  2272. progressDownloader.Style = ProgressBarStyle.Continuous;
  2273. progressDownloader.Value = tempProgress;
  2274. }
  2275. });
  2276. }
  2277. private void button5_Click(object sender, EventArgs e)
  2278. {
  2279. FolderBrowserDialog d = new FolderBrowserDialog();
  2280. if (d.ShowDialog() == DialogResult.OK)
  2281. {
  2282. txtDownloadFolder.Text = d.SelectedPath;
  2283. Options.CurrentOptions.AppsFolder = d.SelectedPath;
  2284. Options.SaveSettings();
  2285. }
  2286. }
  2287. private void button6_Click(object sender, EventArgs e)
  2288. {
  2289. Process.Start(txtDownloadFolder.Text);
  2290. }
  2291. private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  2292. {
  2293. InfoForm lf = new InfoForm(downloadLog);
  2294. lf.ShowDialog(this);
  2295. }
  2296. private void txtDownloadFolder_TextChanged(object sender, EventArgs e)
  2297. {
  2298. Options.CurrentOptions.AppsFolder = txtDownloadFolder.Text;
  2299. Options.SaveSettings();
  2300. }
  2301. private void chkOnlyRemovable_CheckedChanged(object sender, EventArgs e)
  2302. {
  2303. GetModernApps(!chkOnlyRemovable.Checked);
  2304. }
  2305. private void btnGetFeed_Click(object sender, EventArgs e)
  2306. {
  2307. GetFeed();
  2308. }
  2309. private void l2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  2310. {
  2311. AboutForm f = new AboutForm();
  2312. f.ShowDialog(this);
  2313. //Process.Start("https://github.com/hellzerg/optimizer");
  2314. }
  2315. private void btnViewLog_Click(object sender, EventArgs e)
  2316. {
  2317. if (File.Exists(ErrorLogger.ErrorLogFile))
  2318. {
  2319. InfoForm iform = new InfoForm(File.ReadAllText(ErrorLogger.ErrorLogFile, Encoding.UTF8));
  2320. iform.ShowDialog();
  2321. }
  2322. else
  2323. {
  2324. MessageBox.Show(Options.TranslationList["noErrorsM"].ToString(), "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
  2325. }
  2326. }
  2327. private void btnOpenConf_Click(object sender, EventArgs e)
  2328. {
  2329. Process.Start(Required.CoreFolder);
  2330. }
  2331. private void btnPing_Click(object sender, EventArgs e)
  2332. {
  2333. if (string.IsNullOrEmpty(txtPingInput.Text)) return;
  2334. _pingResults = new List<PingReply>();
  2335. listPingResults.Items.Clear();
  2336. if (Utilities.PingHost(txtPingInput.Text) == null)
  2337. {
  2338. listPingResults.Items.Add(string.Format("{0} [{1}]", Options.TranslationList["hostNotFound"], txtPingInput.Text));
  2339. return;
  2340. }
  2341. Task pinger = new Task(() =>
  2342. {
  2343. btnShodan.Enabled = false;
  2344. btnPing.Enabled = false;
  2345. listPingResults.Items.Add(string.Format("{0} [{1}]", Options.TranslationList["pinging"], txtPingInput.Text));
  2346. listPingResults.Items.Add("");
  2347. for (int i = 0; i < 9; i++)
  2348. {
  2349. // wait before each pinging
  2350. System.Threading.Thread.Sleep(888);
  2351. tmpReply = Utilities.PingHost(txtPingInput.Text);
  2352. if (tmpReply.Address == null)
  2353. {
  2354. listPingResults.Items.Add(tmpReply.Status);
  2355. }
  2356. else
  2357. {
  2358. _pingResults.Add(tmpReply);
  2359. _shodanIP = _pingResults[i].Address.ToString();
  2360. listPingResults.Items.Add(string.Format("{0} - {1}: {2} ms - TTL: {3}", _pingResults[i].Status, Options.TranslationList["latency"], _pingResults[i].RoundtripTime, _pingResults[i].Options.Ttl));
  2361. }
  2362. }
  2363. listPingResults.Items.Add("");
  2364. // calculate statistics
  2365. if (_pingResults.Count > 0)
  2366. {
  2367. long maxLatency = _pingResults.Max(x => x.RoundtripTime);
  2368. long minLatency = _pingResults.Min(x => x.RoundtripTime);
  2369. double averageLatency = _pingResults.Average(x => x.RoundtripTime);
  2370. listPingResults.Items.Add(string.Format("{0} = {1}, {2} = {3}, {4} = {5:F2}", Options.TranslationList["min"], minLatency, Options.TranslationList["max"], maxLatency, Options.TranslationList["avg"], averageLatency));
  2371. }
  2372. else
  2373. {
  2374. listPingResults.Items.Add(Options.TranslationList["timeout"]);
  2375. }
  2376. btnPing.Enabled = true;
  2377. btnShodan.Enabled = true;
  2378. });
  2379. pinger.Start();
  2380. }
  2381. private void btnCheckFootprint_Click(object sender, EventArgs e)
  2382. {
  2383. CleanHelper.CheckFootprint();
  2384. }
  2385. private void btnShodan_Click(object sender, EventArgs e)
  2386. {
  2387. IPAddress tryIP;
  2388. if (IPAddress.TryParse(txtPingInput.Text, out tryIP))
  2389. {
  2390. Process.Start(string.Format("https://www.shodan.io/host/{0}", txtPingInput.Text));
  2391. return;
  2392. }
  2393. if (!string.IsNullOrEmpty(_shodanIP))
  2394. {
  2395. Process.Start(string.Format("https://www.shodan.io/host/{0}", _shodanIP));
  2396. return;
  2397. }
  2398. }
  2399. private void button9_Click(object sender, EventArgs e)
  2400. {
  2401. try
  2402. {
  2403. Clipboard.SetText(_shodanIP);
  2404. }
  2405. catch { }
  2406. }
  2407. private void button7_Click(object sender, EventArgs e)
  2408. {
  2409. try
  2410. {
  2411. Clipboard.SetText(txtPingInput.Text);
  2412. }
  2413. catch { }
  2414. }
  2415. private void txtPingInput_KeyDown(object sender, KeyEventArgs e)
  2416. {
  2417. if (e.KeyCode == Keys.Enter) btnPing.PerformClick();
  2418. }
  2419. private void btnExport_Click(object sender, EventArgs e)
  2420. {
  2421. if (ExportDialog.ShowDialog() == DialogResult.OK)
  2422. {
  2423. try
  2424. {
  2425. File.WriteAllLines(ExportDialog.FileName, listPingResults.Items.Cast<string>());
  2426. }
  2427. catch (Exception ex)
  2428. {
  2429. ErrorLogger.LogError("btnExport.Click", ex.Message, ex.StackTrace);
  2430. MessageBox.Show(ex.Message, "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
  2431. }
  2432. }
  2433. }
  2434. private void startupItem_Click(object sender, EventArgs e)
  2435. {
  2436. tabCollection.SelectedTab = startupTab;
  2437. RestoreWindow();
  2438. }
  2439. private void cleanerItem_Click(object sender, EventArgs e)
  2440. {
  2441. tabCollection.SelectedTab = cleanerTab;
  2442. RestoreWindow();
  2443. }
  2444. private void pingerItem_Click(object sender, EventArgs e)
  2445. {
  2446. tabCollection.SelectedTab = pingerTab;
  2447. RestoreWindow();
  2448. txtPingInput.Focus();
  2449. }
  2450. private void hostsItem_Click(object sender, EventArgs e)
  2451. {
  2452. tabCollection.SelectedTab = hostsEditorTab;
  2453. RestoreWindow();
  2454. txtIP.Focus();
  2455. }
  2456. private void appsItem_Click(object sender, EventArgs e)
  2457. {
  2458. tabCollection.SelectedTab = appsTab;
  2459. RestoreWindow();
  2460. }
  2461. private void exitItem_Click(object sender, EventArgs e)
  2462. {
  2463. _trayMenu = false;
  2464. Options.CurrentOptions.AppsFolder = txtDownloadFolder.Text;
  2465. Options.SaveSettings();
  2466. Application.Exit();
  2467. }
  2468. private void RestoreWindow()
  2469. {
  2470. if (this.WindowState == FormWindowState.Minimized) this.WindowState = FormWindowState.Normal;
  2471. this.Show();
  2472. this.Activate();
  2473. this.Focus();
  2474. }
  2475. private void launcherIcon_MouseDoubleClick(object sender, MouseEventArgs e)
  2476. {
  2477. if (this.Visible)
  2478. {
  2479. if (this.WindowState == FormWindowState.Minimized) this.WindowState = FormWindowState.Normal;
  2480. this.Hide();
  2481. }
  2482. else
  2483. {
  2484. RestoreWindow();
  2485. }
  2486. }
  2487. private void quickAccessToggle_CheckedChanged(object sender, EventArgs e)
  2488. {
  2489. Options.CurrentOptions.EnableTray = quickAccessToggle.Checked;
  2490. Options.SaveSettings();
  2491. _trayMenu = quickAccessToggle.Checked;
  2492. launcherIcon.Visible = quickAccessToggle.Checked;
  2493. }
  2494. private void linkLabel5_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  2495. {
  2496. Process.Start(_licenseLink);
  2497. }
  2498. private void linkLabel6_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  2499. {
  2500. Process.Start(_openSourceLink);
  2501. }
  2502. private void linkUpdate_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  2503. {
  2504. CheckForUpdate();
  2505. }
  2506. private void restartExpolorerItem_Click(object sender, EventArgs e)
  2507. {
  2508. Utilities.RestartExplorer();
  2509. }
  2510. private void button10_Click(object sender, EventArgs e)
  2511. {
  2512. Utilities.FlushDNSCache();
  2513. }
  2514. private void helpTipsToggle_CheckedChanged(object sender, EventArgs e)
  2515. {
  2516. Options.CurrentOptions.ShowHelp = helpTipsToggle.Checked;
  2517. Options.SaveSettings();
  2518. helpBox.Active = helpTipsToggle.Checked;
  2519. }
  2520. private void button11_Click(object sender, EventArgs e)
  2521. {
  2522. ShowBackupConfirm();
  2523. }
  2524. private void ShowBackupConfirm()
  2525. {
  2526. removeStartupItemB.Visible = false;
  2527. locateFileB.Visible = false;
  2528. findInRegB.Visible = false;
  2529. refreshStartupB.Visible = false;
  2530. restoreStartupB.Visible = false;
  2531. backupStartupB.Visible = false;
  2532. lblBackupTitle.Visible = true;
  2533. doBackup.Visible = true;
  2534. cancelBackup.Visible = true;
  2535. txtBackupTitle.Visible = true;
  2536. }
  2537. private void HideBackupConfirm()
  2538. {
  2539. removeStartupItemB.Visible = true;
  2540. locateFileB.Visible = true;
  2541. findInRegB.Visible = true;
  2542. refreshStartupB.Visible = true;
  2543. restoreStartupB.Visible = true;
  2544. backupStartupB.Visible = true;
  2545. lblBackupTitle.Visible = false;
  2546. doBackup.Visible = false;
  2547. cancelBackup.Visible = false;
  2548. txtBackupTitle.Visible = false;
  2549. }
  2550. private void button12_Click(object sender, EventArgs e)
  2551. {
  2552. StartupRestoreForm f = new StartupRestoreForm();
  2553. f.ShowDialog(this);
  2554. GetStartupItems();
  2555. }
  2556. private void button14_Click(object sender, EventArgs e)
  2557. {
  2558. HideBackupConfirm();
  2559. }
  2560. private void button13_Click(object sender, EventArgs e)
  2561. {
  2562. if (!string.IsNullOrEmpty(txtBackupTitle.Text.Trim()))
  2563. {
  2564. HideBackupConfirm();
  2565. _backupItems.Clear();
  2566. foreach (var x in _startUpItems)
  2567. {
  2568. _backupItems.Add(new StartupBackupItem(x.Name, x.FileLocation, x.RegistryLocation.ToString(), x.StartupType.ToString()));
  2569. }
  2570. try
  2571. {
  2572. File.WriteAllText(Required.StartupItemsBackupFolder + Utilities.SanitizeFileFolderName(txtBackupTitle.Text + " - [" + DateTime.Now.ToShortDateString() + "-" + DateTime.Now.ToShortTimeString()) + "].json", JsonConvert.SerializeObject(_backupItems, Formatting.Indented));
  2573. }
  2574. catch (Exception ex)
  2575. {
  2576. ErrorLogger.LogError("MainForm.BackupStartupItems", ex.Message, ex.StackTrace);
  2577. }
  2578. }
  2579. }
  2580. private void pictureBox86_Click(object sender, EventArgs e)
  2581. {
  2582. radioEnglish.PerformClick();
  2583. }
  2584. private void pictureBox87_Click(object sender, EventArgs e)
  2585. {
  2586. radioRussian.PerformClick();
  2587. }
  2588. private void radioEnglish_Click(object sender, EventArgs e)
  2589. {
  2590. radioEnglish.Checked = true;
  2591. Options.CurrentOptions.LanguageCode = LanguageCode.EN;
  2592. Options.SaveSettings();
  2593. Options.LoadTranslation();
  2594. Translate();
  2595. }
  2596. private void radioRussian_Click(object sender, EventArgs e)
  2597. {
  2598. radioRussian.Checked = true;
  2599. Options.CurrentOptions.LanguageCode = LanguageCode.RU;
  2600. Options.SaveSettings();
  2601. Options.LoadTranslation();
  2602. Translate();
  2603. }
  2604. private void pictureBox88_Click(object sender, EventArgs e)
  2605. {
  2606. radioHellenic.PerformClick();
  2607. }
  2608. private void radioHellenic_Click(object sender, EventArgs e)
  2609. {
  2610. radioHellenic.Checked = true;
  2611. Options.CurrentOptions.LanguageCode = LanguageCode.EL;
  2612. Options.SaveSettings();
  2613. Options.LoadTranslation();
  2614. Translate();
  2615. }
  2616. private void pictureBox89_Click(object sender, EventArgs e)
  2617. {
  2618. radioTurkish.PerformClick();
  2619. }
  2620. private void radioTurkish_Click(object sender, EventArgs e)
  2621. {
  2622. radioTurkish.Checked = true;
  2623. Options.CurrentOptions.LanguageCode = LanguageCode.TR;
  2624. Options.SaveSettings();
  2625. Options.LoadTranslation();
  2626. Translate();
  2627. }
  2628. private void radioGerman_Click(object sender, EventArgs e)
  2629. {
  2630. radioGerman.Checked = true;
  2631. Options.CurrentOptions.LanguageCode = LanguageCode.DE;
  2632. Options.SaveSettings();
  2633. Options.LoadTranslation();
  2634. Translate();
  2635. }
  2636. private void pictureBox2_Click(object sender, EventArgs e)
  2637. {
  2638. radioGerman.PerformClick();
  2639. }
  2640. private void pictureBox3_Click(object sender, EventArgs e)
  2641. {
  2642. radioSpanish.PerformClick();
  2643. }
  2644. private void radioSpanish_Click(object sender, EventArgs e)
  2645. {
  2646. radioSpanish.Checked = true;
  2647. Options.CurrentOptions.LanguageCode = LanguageCode.ES;
  2648. Options.SaveSettings();
  2649. Options.LoadTranslation();
  2650. Translate();
  2651. }
  2652. private void radioPortuguese_Click(object sender, EventArgs e)
  2653. {
  2654. radioPortuguese.Checked = true;
  2655. Options.CurrentOptions.LanguageCode = LanguageCode.PT;
  2656. Options.SaveSettings();
  2657. Options.LoadTranslation();
  2658. Translate();
  2659. }
  2660. private void pictureBox4_Click(object sender, EventArgs e)
  2661. {
  2662. radioPortuguese.PerformClick();
  2663. }
  2664. private void txtIPv4_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  2665. {
  2666. Clipboard.SetText(txtIPv4.Text);
  2667. }
  2668. private void txtIPv4A_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  2669. {
  2670. Clipboard.SetText(txtIPv4A.Text);
  2671. }
  2672. private void txtIPv6_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  2673. {
  2674. Clipboard.SetText(txtIPv6.Text);
  2675. }
  2676. private void txtIPv6A_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  2677. {
  2678. Clipboard.SetText(txtIPv6A.Text);
  2679. }
  2680. private void btnOpenNetwork_Click(object sender, EventArgs e)
  2681. {
  2682. Process.Start("NCPA.cpl");
  2683. }
  2684. private void radioFrench_Click(object sender, EventArgs e)
  2685. {
  2686. radioFrench.Checked = true;
  2687. Options.CurrentOptions.LanguageCode = LanguageCode.FR;
  2688. Options.SaveSettings();
  2689. Options.LoadTranslation();
  2690. Translate();
  2691. }
  2692. private void pictureBox5_Click(object sender, EventArgs e)
  2693. {
  2694. radioFrench.PerformClick();
  2695. }
  2696. private void listStartupItems_ItemChecked(object sender, ItemCheckedEventArgs e)
  2697. {
  2698. if (e.Item.Checked)
  2699. {
  2700. e.Item.ForeColor = Options.ForegroundColor;
  2701. }
  2702. else
  2703. {
  2704. e.Item.ForeColor = Color.White;
  2705. }
  2706. }
  2707. }
  2708. }