2
0

MainForm.cs 113 KB

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