MainForm.cs 112 KB

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