MainForm.cs 111 KB

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