MainForm.cs 110 KB

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