MainForm.cs 109 KB

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