1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157 |
- using Newtonsoft.Json;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Diagnostics;
- using System.Drawing;
- using System.Globalization;
- using System.IO;
- using System.IO.Compression;
- using System.Linq;
- using System.Net;
- using System.Net.NetworkInformation;
- using System.Reflection;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace Optimizer
- {
- public partial class MainForm : Form
- {
- ListViewColumnSorter _columnSorter;
- List<StartupItem> _startUpItems = new List<StartupItem>();
- List<StartupBackupItem> _backupItems = new List<StartupBackupItem>();
- List<string> _hostsEntries = new List<string>();
- List<string> _customCommands = new List<string>();
- List<string> _desktopItems = new List<string>();
- List<string> _modernApps = new List<string>();
- bool _trayMenu = false;
- List<PingReply> _pingResults;
- string _shodanIP = string.Empty;
- PingReply tmpReply;
- //NetworkMonitor _networkMonitor;
- //double uploadSpeed = 0;
- //double downloadSpeed = 0;
- DesktopItemType _desktopItemType = DesktopItemType.Program;
- DesktopTypePosition _desktopItemPosition = DesktopTypePosition.Top;
- public List<FeedApp> AppsFromFeed = new List<FeedApp>();
- readonly string _feedLink = "https://raw.githubusercontent.com/hellzerg/optimizer/master/feed.json";
- readonly string _feedImages = "https://raw.githubusercontent.com/hellzerg/optimizer/master/images/feed.zip";
- readonly string _licenseLink = "https://www.gnu.org/licenses/gpl-3.0.en.html";
- readonly string _openSourceLink = "https://opensource.org/";
- readonly string _latestVersionLink = "https://raw.githubusercontent.com/hellzerg/optimizer/master/version.txt";
- readonly string _changelogLink = "https://github.com/hellzerg/optimizer/blob/master/CHANGELOG.md";
- string _noNewVersionMessage = "You already have the latest version!";
- string _betaVersionMessage = "You are using an experimental version!";
- readonly string _blockedIP = "0.0.0.0";
- string _restartMessage = "Restart to apply changes?";
- string _removeStartupItemsMessage = "Are you sure you want to delete these startup items?\n\n";
- string _removeHostsEntriesMessage = "Are you sure you want to delete all hosts entries?";
- string _removeDesktopItemsMessage = "Are you sure you want to delete all desktop items?";
- string _removeModernAppsMessage = "Are you sure you want to uninstall the following app(s)?";
- string _errorModernAppsMessage = "The following app(s) couldn't be uninstalled:\n";
- 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!";
- private string NewVersionMessage(string latestVersion)
- {
- return Options.TranslationList["newVersion"].ToString().Replace("{LATEST}", latestVersion).Replace("{CURRENT}", Program.GetCurrentVersionTostring());
- }
- private string NewDownloadLink(string latestVersion)
- {
- return string.Format("https://github.com/hellzerg/optimizer/releases/download/{0}/Optimizer-{0}.exe", latestVersion);
- }
- private void CheckForUpdate(bool silentCheck = false)
- {
- WebClient client = new WebClient
- {
- Encoding = Encoding.UTF8
- };
- string latestVersion = string.Empty;
- try
- {
- latestVersion = client.DownloadString(_latestVersionLink).Trim();
- }
- catch (Exception ex)
- {
- ErrorLogger.LogError("MainForm.CheckForUpdate", ex.Message, ex.StackTrace);
- MessageBox.Show(ex.Message, "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- if (!string.IsNullOrEmpty(latestVersion))
- {
- if (float.Parse(latestVersion) > Program.GetCurrentVersion())
- {
- // show UPDATE AVAILABLE on app launch
- if (silentCheck)
- {
- linkUpdate.Visible = true;
- return;
- }
- if (MessageBox.Show(NewVersionMessage(latestVersion), "Optimizer", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
- {
- // PATCHING PROCESS
- try
- {
- Assembly currentAssembly = Assembly.GetEntryAssembly();
- if (currentAssembly == null)
- {
- currentAssembly = Assembly.GetCallingAssembly();
- }
- string appFolder = Path.GetDirectoryName(currentAssembly.Location);
- string appName = Path.GetFileNameWithoutExtension(currentAssembly.Location);
- string appExtension = Path.GetExtension(currentAssembly.Location);
- string archiveFile = Path.Combine(appFolder, "Optimizer_old" + appExtension);
- string appFile = Path.Combine(appFolder, appName + appExtension);
- string tempFile = Path.Combine(appFolder, "Optimizer_tmp" + appExtension);
- // DOWNLOAD NEW VERSION
- client.DownloadFile(NewDownloadLink(latestVersion), tempFile);
- // DELETE PREVIOUS BACK-UP
- if (File.Exists(archiveFile))
- {
- File.Delete(archiveFile);
- }
- // MAKE BACK-UP
- File.Move(appFile, archiveFile);
- // PATCH
- File.Move(tempFile, appFile);
- _trayMenu = false;
- // BYPASS SINGLE-INSTANCE MECHANISM
- if (Program.MUTEX != null)
- {
- Program.MUTEX.ReleaseMutex();
- Program.MUTEX.Dispose();
- Program.MUTEX = null;
- }
- Application.Restart();
- }
- catch (Exception ex)
- {
- ErrorLogger.LogError("MainForm.CheckForUpdate", ex.Message, ex.StackTrace);
- MessageBox.Show(ex.Message);
- }
- }
- }
- else if (float.Parse(latestVersion) == Program.GetCurrentVersion())
- {
- if (!silentCheck) MessageBox.Show(_noNewVersionMessage, "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- else
- {
- if (!silentCheck) MessageBox.Show(_betaVersionMessage, "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- }
- private void EnableToggleEvents()
- {
- actionSw.Click += new EventHandler(ToggleSwitch7_Click);
- officeTelemetrySw.Click += new EventHandler(toggleSwitch12_Click);
- telemetryTasksSw.Click += new EventHandler(toggleSwitch11_Click);
- superfetchSw.Click += new EventHandler(toggleSwitch10_Click);
- homegroupSw.Click += new EventHandler(toggleSwitch9_Click);
- reportingSw.Click += new EventHandler(toggleSwitch8_Click);
- mediaSharingSw.Click += new EventHandler(toggleSwitch6_Click);
- printSw.Click += new EventHandler(toggleSwitch5_Click);
- systemRestoreSw.Click += new EventHandler(toggleSwitch4_Click);
- performanceSw.Click += new EventHandler(toggleSwitch1_Click);
- defenderSw.Click += new EventHandler(toggleSwitch3_Click);
- networkSw.Click += new EventHandler(toggleSwitch2_Click);
- darkSw.Click += new EventHandler(toggleSwitch27_Click);
- spellSw.Click += new EventHandler(toggleSwitch28_Click);
- inkSw.Click += new EventHandler(toggleSwitch29_Click);
- driversSw.Click += new EventHandler(toggleSwitch30_Click);
- sensorSw.Click += new EventHandler(toggleSwitch20_Click);
- privacySw.Click += new EventHandler(toggleSwitch21_Click);
- telemetryServicesSw.Click += new EventHandler(toggleSwitch23_Click);
- autoUpdatesSw.Click += new EventHandler(toggleSwitch24_Click);
- peopleSw.Click += new EventHandler(toggleSwitch25_Click);
- adsSw.Click += new EventHandler(toggleSwitch26_Click);
- xboxSw.Click += new EventHandler(toggleSwitch17_Click);
- cortanaSw.Click += new EventHandler(toggleSwitch16_Click);
- gameBarSw.Click += new EventHandler(toggleSwitch15_Click);
- uODSw.Click += new EventHandler(toggleSwitch14_Click);
- oldMixerSw.Click += new EventHandler(toggleSwitch13_Click);
- disableOneDriveSw.Click += new EventHandler(toggleSwitch31_Click);
- oldExplorerSw.Click += new EventHandler(toggleSwitch18_Click);
- colorBarSw.Click += new EventHandler(toggleSwitch19_Click);
- compatSw.Click += new EventHandler(toggleSwitch32_Click);
- faxSw.Click += new EventHandler(ToggleSwitch33_Click);
- insiderSw.Click += new EventHandler(ToggleSwitch34_Click);
- featuresSw.Click += new EventHandler(ToggleSwitch35_Click);
- smartScreenSw.Click += new EventHandler(ToggleSwitch36_Click);
- ccSw.Click += new EventHandler(ToggleSwitch37_Click);
- stickySw.Click += new EventHandler(ToggleSwitch38_Click);
- longPathsSw.Click += new EventHandler(ToggleSwitch39_Click);
- castSw.Click += new EventHandler(ToggleSwitch40_Click);
- leftTaskbarSw.Click += LeftTaskbarSw_Click;
- snapAssistSw.Click += SnapAssistSw_Click;
- widgetsSw.Click += WidgetsSw_Click;
- smallerTaskbarSw.Click += SmallerTaskbarSw_Click;
- chatSw.Click += chatSw_Click;
- classicRibbonSw.Click += ClassicRibbonSw_Click;
- classicContextSw.Click += ClassicContextSw_Click;
- }
- private void ClassicContextSw_Click(object sender, EventArgs e)
- {
- if (!classicContextSw.Checked)
- {
- Optimize.DisableShowMoreOptions();
- }
- else
- {
- Optimize.EnableShowMoreOptions();
- }
- Options.CurrentOptions.ClassicMenu = !classicContextSw.Checked;
- }
- private void ClassicRibbonSw_Click(object sender, EventArgs e)
- {
- if (!classicRibbonSw.Checked)
- {
- Optimize.EnableFileExplorerClassicRibbon();
- }
- else
- {
- Optimize.DisableFileExplorerClassicRibbon();
- }
- Options.CurrentOptions.ClassicRibbon = !classicContextSw.Checked;
- }
- private void chatSw_Click(object sender, EventArgs e)
- {
- if (!chatSw.Checked)
- {
- Optimize.DisableChat();
- }
- else
- {
- Optimize.EnableChat();
- }
- Options.CurrentOptions.DisableChat = !chatSw.Checked;
- }
- private void SmallerTaskbarSw_Click(object sender, EventArgs e)
- {
- if (!smallerTaskbarSw.Checked)
- {
- Optimize.SmallerTaskbar();
- }
- else
- {
- Optimize.DefaultTaskbarSize();
- }
- Options.CurrentOptions.TaskbarSmaller = !smallerTaskbarSw.Checked;
- }
- private void WidgetsSw_Click(object sender, EventArgs e)
- {
- if (!widgetsSw.Checked)
- {
- Optimize.DisableWidgets();
- }
- else
- {
- Optimize.EnableWidgets();
- }
- Options.CurrentOptions.DisableWidgets = !widgetsSw.Checked;
- }
- private void SnapAssistSw_Click(object sender, EventArgs e)
- {
- if (!snapAssistSw.Checked)
- {
- Optimize.DisableSnapAssist();
- }
- else
- {
- Optimize.EnableSnapAssist();
- }
- Options.CurrentOptions.DisableSnapAssist = !snapAssistSw.Checked;
- }
- private void LeftTaskbarSw_Click(object sender, EventArgs e)
- {
- if (!leftTaskbarSw.Checked)
- {
- Optimize.AlignTaskbarToLeft();
- }
- else
- {
- Optimize.AlignTaskbarToCenter();
- }
- Options.CurrentOptions.TaskbarToLeft = !leftTaskbarSw.Checked;
- }
- private void SetHelpBoxTranslation()
- {
- helpBox.SetToolTip(performanceSw, Options.TranslationList["performanceTip"].ToString());
- helpBox.SetToolTip(networkSw, Options.TranslationList["networkTip"].ToString());
- helpBox.SetToolTip(defenderSw, Options.TranslationList["defenderTip"].ToString());
- helpBox.SetToolTip(smartScreenSw, Options.TranslationList["smartScreenTip"].ToString());
- helpBox.SetToolTip(systemRestoreSw, Options.TranslationList["systemRestoreTip"].ToString());
- helpBox.SetToolTip(reportingSw, Options.TranslationList["reportingTip"].ToString());
- helpBox.SetToolTip(telemetryTasksSw, Options.TranslationList["telemetryTasksTip"].ToString());
- helpBox.SetToolTip(officeTelemetrySw, Options.TranslationList["officeTelemetryTip"].ToString());
- helpBox.SetToolTip(printSw, Options.TranslationList["printTip"].ToString());
- helpBox.SetToolTip(faxSw, Options.TranslationList["faxTip"].ToString());
- helpBox.SetToolTip(mediaSharingSw, Options.TranslationList["mediaSharingTip"].ToString());
- helpBox.SetToolTip(stickySw, Options.TranslationList["stickyTip"].ToString());
- helpBox.SetToolTip(homegroupSw, Options.TranslationList["homegroupTip"].ToString());
- helpBox.SetToolTip(superfetchSw, Options.TranslationList["superfetchTip"].ToString());
- helpBox.SetToolTip(compatSw, Options.TranslationList["compatTip"].ToString());
- helpBox.SetToolTip(disableOneDriveSw, Options.TranslationList["disableOneDriveTip"].ToString());
- helpBox.SetToolTip(oldMixerSw, Options.TranslationList["oldMixerTip"].ToString());
- helpBox.SetToolTip(colorBarSw, Options.TranslationList["colorBarTip"].ToString());
- helpBox.SetToolTip(oldExplorerSw, Options.TranslationList["oldExplorerTip"].ToString());
- helpBox.SetToolTip(adsSw, Options.TranslationList["adsTip"].ToString());
- helpBox.SetToolTip(darkSw, Options.TranslationList["darkTip"].ToString());
- helpBox.SetToolTip(uODSw, Options.TranslationList["uODTip"].ToString());
- helpBox.SetToolTip(peopleSw, Options.TranslationList["peopleTip"].ToString());
- helpBox.SetToolTip(longPathsSw, Options.TranslationList["longPathsTip"].ToString());
- helpBox.SetToolTip(inkSw, Options.TranslationList["inkTip"].ToString());
- helpBox.SetToolTip(spellSw, Options.TranslationList["spellTip"].ToString());
- helpBox.SetToolTip(xboxSw, Options.TranslationList["xboxTip"].ToString());
- helpBox.SetToolTip(actionSw, Options.TranslationList["actionTip"].ToString());
- helpBox.SetToolTip(autoUpdatesSw, Options.TranslationList["autoUpdatesTip"].ToString());
- helpBox.SetToolTip(driversSw, Options.TranslationList["driversTip"].ToString());
- helpBox.SetToolTip(telemetryServicesSw, Options.TranslationList["telemetryServicesTip"].ToString());
- helpBox.SetToolTip(privacySw, Options.TranslationList["privacyTip"].ToString());
- helpBox.SetToolTip(ccSw, Options.TranslationList["ccTip"].ToString());
- helpBox.SetToolTip(cortanaSw, Options.TranslationList["cortanaTip"].ToString());
- helpBox.SetToolTip(sensorSw, Options.TranslationList["sensorTip"].ToString());
- helpBox.SetToolTip(castSw, Options.TranslationList["castTip"].ToString());
- helpBox.SetToolTip(gameBarSw, Options.TranslationList["gameBarTip"].ToString());
- helpBox.SetToolTip(insiderSw, Options.TranslationList["insiderTip"].ToString());
- helpBox.SetToolTip(featuresSw, Options.TranslationList["featuresTip"].ToString());
- helpBox.SetToolTip(tpmSw, Options.TranslationList["tpmTip"].ToString());
- helpBox.SetToolTip(leftTaskbarSw, Options.TranslationList["leftTaskbarTip"].ToString());
- helpBox.SetToolTip(snapAssistSw, Options.TranslationList["snapAssistTip"].ToString());
- helpBox.SetToolTip(widgetsSw, Options.TranslationList["widgetsTip"].ToString());
- helpBox.SetToolTip(chatSw, Options.TranslationList["chatTip"].ToString());
- helpBox.SetToolTip(smallerTaskbarSw, Options.TranslationList["smallerTaskbarTip"].ToString());
- helpBox.SetToolTip(classicRibbonSw, Options.TranslationList["classicRibbonTip"].ToString());
- helpBox.SetToolTip(classicContextSw, Options.TranslationList["classicContextTip"].ToString());
- helpBox.ToolTipTitle = Options.TranslationList["tipWhatsThis"].ToString();
- }
- private void ToggleSwitch7_Click(object sender, EventArgs e)
- {
- if (!actionSw.Checked)
- {
- Optimize.DisableActionCenter();
- }
- else
- {
- Optimize.EnableActionCenter();
- }
- Options.CurrentOptions.DisableActionCenter = !actionSw.Checked;
- }
- private void ToggleSwitch40_Click(object sender, EventArgs e)
- {
- if (!castSw.Checked)
- {
- Optimize.RemoveCastToDevice();
- }
- else
- {
- Optimize.AddCastToDevice();
- }
- Options.CurrentOptions.RemoveCastToDevice = !castSw.Checked;
- }
- private void ToggleSwitch39_Click(object sender, EventArgs e)
- {
- if (!longPathsSw.Checked)
- {
- Optimize.EnableLongPaths();
- }
- else
- {
- Optimize.DisableLongPaths();
- }
- Options.CurrentOptions.EnableLongPaths = !longPathsSw.Checked;
- }
- private void ToggleSwitch38_Click(object sender, EventArgs e)
- {
- if (!stickySw.Checked)
- {
- Optimize.DisableStickyKeys();
- }
- else
- {
- Optimize.EnableStickyKeys();
- }
- Options.CurrentOptions.DisableStickyKeys = !stickySw.Checked;
- }
- private void ToggleSwitch37_Click(object sender, EventArgs e)
- {
- if (!ccSw.Checked)
- {
- Optimize.DisableCloudClipboard();
- }
- else
- {
- Optimize.EnableCloudClipboard();
- }
- Options.CurrentOptions.DisableCloudClipboard = !ccSw.Checked;
- }
- private void ToggleSwitch36_Click(object sender, EventArgs e)
- {
- if (!smartScreenSw.Checked)
- {
- Optimize.DisableSmartScreen();
- }
- else
- {
- Optimize.EnableSmartScreen();
- }
- Options.CurrentOptions.DisableSmartScreen = !smartScreenSw.Checked;
- }
- private void ToggleSwitch35_Click(object sender, EventArgs e)
- {
- if (!featuresSw.Checked)
- {
- Optimize.DisableForcedFeatureUpdates();
- }
- else
- {
- Optimize.EnableForcedFeatureUpdates();
- }
- Options.CurrentOptions.DisableFeatureUpdates = !featuresSw.Checked;
- }
- private void ToggleSwitch34_Click(object sender, EventArgs e)
- {
- if (!insiderSw.Checked)
- {
- Optimize.DisableInsiderService();
- }
- else
- {
- Optimize.EnableInsiderService();
- }
- Options.CurrentOptions.DisableInsiderService = !insiderSw.Checked;
- }
- private void ToggleSwitch33_Click(object sender, EventArgs e)
- {
- if (!faxSw.Checked)
- {
- Optimize.DisableFaxService();
- }
- else
- {
- Optimize.EnableFaxService();
- }
- Options.CurrentOptions.DisableFaxService = !faxSw.Checked;
- }
- private void LoadSettings()
- {
- switch (Options.CurrentOptions.Color)
- {
- case Theme.Caramel:
- radioCaramel.Checked = true;
- break;
- case Theme.Lime:
- radioLime.Checked = true;
- break;
- case Theme.Magma:
- radioMagma.Checked = true;
- break;
- case Theme.Minimal:
- radioMinimal.Checked = true;
- break;
- case Theme.Ocean:
- radioOcean.Checked = true;
- break;
- case Theme.Zerg:
- radioZerg.Checked = true;
- break;
- }
- }
- // INIT
- public MainForm()
- {
- InitializeComponent();
- CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US");
- CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo("en-US");
- CheckForIllegalCrossThreadCalls = false;
- EnableToggleEvents();
- // theming
- Options.ApplyTheme(this);
- launcherMenu.Renderer = new ToolStripRendererMaterial();
- progressDownloader.BackColor = Options.ForegroundColor;
- progressDownloader.ForeColor = Options.ForegroundAccentColor;
- // quick access
- _trayMenu = Options.CurrentOptions.EnableTray;
- quickAccessToggle.Checked = Options.CurrentOptions.EnableTray;
- launcherIcon.Visible = Options.CurrentOptions.EnableTray;
- // help tips
- helpBox.Active = Options.CurrentOptions.ShowHelp;
- helpTipsToggle.Checked = Options.CurrentOptions.ShowHelp;
- // fix SSL/TLS error when contacting internet
- ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
- // initial states
- chkOnlyRemovable.Checked = true;
- checkDefaultIcon.Checked = true;
- radioProgram.Checked = true;
- radioTop.Checked = true;
- c64.Checked = Environment.Is64BitOperatingSystem;
- c32.Checked = !Environment.Is64BitOperatingSystem;
- // EXPERIMENTAL message
- lblLab.Visible = Program.EXPERIMENTAL_BUILD;
- // Windows version, architecture, .NET Framework
- txtOS.Text = Utilities.GetOS();
- txtBitness.Text = Utilities.GetBitness();
- txtNetFw.Text = ".NET Framework " + Utilities.GetNETFramework();
- if (Utilities.CurrentWindowsVersion == WindowsVersion.Unsupported)
- {
- tabCollection.TabPages.Remove(universalTab);
- tabCollection.TabPages.Remove(windows8Tab);
- tabCollection.TabPages.Remove(windows10Tab);
- tabCollection.TabPages.Remove(modernAppsTab);
- }
- if (Utilities.CurrentWindowsVersion == WindowsVersion.Windows7)
- {
- LoadUniversalToggleStates();
- tabCollection.TabPages.Remove(windows8Tab);
- tabCollection.TabPages.Remove(windows10Tab);
- tabCollection.TabPages.Remove(modernAppsTab);
- }
- if (Utilities.CurrentWindowsVersion == WindowsVersion.Windows8)
- {
- LoadUniversalToggleStates();
- LoadWindowsVIIIToggleStates();
- tabCollection.TabPages.Remove(windows10Tab);
- GetModernApps(false);
- }
- if (Utilities.CurrentWindowsVersion == WindowsVersion.Windows10)
- {
- LoadUniversalToggleStates();
- LoadWindowsXToggleStates();
- tabCollection.TabPages.Remove(windows8Tab);
- this.Controls.Remove(panelWin11Tweaks);
- GetModernApps(false);
- txtOS.Text += string.Format(" ({0})", Utilities.GetWindows10Build());
- }
- if (Utilities.CurrentWindowsVersion == WindowsVersion.Windows11)
- {
- LoadUniversalToggleStates();
- LoadWindowsXToggleStates();
- LoadWindowsXIToggleStates();
- tabCollection.TabPages.Remove(windows8Tab);
- windows10Tab.Text = "Windows 11";
- panelWin11Tweaks.Visible = true;
- actionSw.Visible = false;
- oldMixerSw.Visible = false;
- GetModernApps(false);
- txtOS.Text += string.Format(" ({0})", Utilities.GetWindows10Build());
- }
- _columnSorter = new ListViewColumnSorter();
- listStartupItems.ListViewItemSorter = _columnSorter;
- GetStartupItems();
- GetHostsEntries();
- GetDesktopItems();
- GetCustomCommands();
- GetFeed();
- GetFootprint();
- LoadSettings();
- // Translation-related
- if (Options.CurrentOptions.LanguageCode == LanguageCode.EN)
- {
- radioEnglish.Checked = true;
- Translate(true);
- }
- else
- {
- Translate();
- }
- if (Options.CurrentOptions.LanguageCode == LanguageCode.RU) radioRussian.Checked = true;
- if (Options.CurrentOptions.LanguageCode == LanguageCode.TR) radioTurkish.Checked = true;
- if (Options.CurrentOptions.LanguageCode == LanguageCode.EL) radioHellenic.Checked = true;
- if (Options.CurrentOptions.LanguageCode == LanguageCode.DE) radioGerman.Checked = true;
- if (Options.CurrentOptions.LanguageCode == LanguageCode.PT) radioPortuguese.Checked = true;
- if (Options.CurrentOptions.LanguageCode == LanguageCode.FR) radioFrench.Checked = true;
- if (Options.CurrentOptions.LanguageCode == LanguageCode.ES) radioSpanish.Checked = true;
- if (Options.CurrentOptions.LanguageCode == LanguageCode.IT) radioItalian.Checked = true;
- Program._MainForm = this;
- if (string.IsNullOrEmpty(Options.CurrentOptions.AppsFolder))
- {
- txtDownloadFolder.Text = Path.Combine(Application.StartupPath, "Optimizer Downloads");
- Options.CurrentOptions.AppsFolder = Path.Combine(Application.StartupPath, "Optimizer Downloads");
- Directory.CreateDirectory(Options.CurrentOptions.AppsFolder);
- Options.SaveSettings();
- }
- else
- {
- if (!Directory.Exists(Options.CurrentOptions.AppsFolder))
- {
- try
- {
- Directory.CreateDirectory(Options.CurrentOptions.AppsFolder);
- }
- catch (Exception ex)
- {
- txtDownloadFolder.Text = string.Empty;
- ErrorLogger.LogError("MainForm.INIT", ex.Message, ex.StackTrace);
- }
- }
- txtDownloadFolder.Text = Options.CurrentOptions.AppsFolder;
- }
- if (!Program.EXPERIMENTAL_BUILD && Utilities.IsInternetAvailable()) CheckForUpdate(true);
- if (Program.EXPERIMENTAL_BUILD)
- {
- btnUpdate.Enabled = false;
- lblUpdateDisabled.Visible = true;
- }
- //_networkMonitor = new NetworkMonitor();
- }
- //private void NetworkMonitoring()
- //{
- // while (true)
- // {
- // downloadSpeed = 0;
- // uploadSpeed = 0;
- // foreach (NetworkAdapter adapter in _networkMonitor.Adapters)
- // {
- // //adapter.Refresh();
- // downloadSpeed += Math.Round(adapter.DownloadSpeedMbps, 2);
- // uploadSpeed += Math.Round(adapter.UploadSpeedMbps, 2);
- // }
- // this.Text = string.Format("Optimizer - DOWN: {0} UP: {1}", downloadSpeed, uploadSpeed);
- // Thread.Sleep(1000);
- // }
- //}
- private void Translate(bool skipFull = false)
- {
- Dictionary<string, string> translationList = Options.TranslationList.ToObject<Dictionary<string, string>>();
- if (Environment.Is64BitOperatingSystem)
- {
- translationList["txtBitness"] = translationList["txtBitness"].Replace("{BITS}", translationList["c64"]);
- }
- else
- {
- translationList["txtBitness"] = translationList["txtBitness"].Replace("{BITS}", translationList["c32"]);
- }
- SetHelpBoxTranslation();
- if (!skipFull)
- {
- _noNewVersionMessage = Options.TranslationList["noNewVersion"];
- _betaVersionMessage = Options.TranslationList["betaVersion"];
- _restartMessage = Options.TranslationList["restartAndApply"];
- _removeStartupItemsMessage = Options.TranslationList["removeAllStartup"];
- _removeHostsEntriesMessage = Options.TranslationList["removeAllHosts"];
- _removeDesktopItemsMessage = Options.TranslationList["removeAllItems"];
- _removeModernAppsMessage = Options.TranslationList["removeModernApps"];
- _errorModernAppsMessage = Options.TranslationList["errorModernApps"];
- _resetMessage = Options.TranslationList["resetMessage"];
- listStartupItems.Columns[0].Text = translationList["startupItemName"];
- listStartupItems.Columns[1].Text = translationList["startupItemLocation"];
- listStartupItems.Columns[2].Text = translationList["startupItemType"];
- trayStartup.Text = translationList["trayStartup"];
- trayCleaner.Text = translationList["trayCleaner"];
- trayPinger.Text = translationList["trayPinger"];
- trayHosts.Text = translationList["trayHosts"];
- trayAD.Text = translationList["trayAD"];
- trayRestartExplorer.Text = translationList["trayRestartExplorer"];
- trayExit.Text = translationList["trayExit"];
- Control element;
- foreach (var x in translationList)
- {
- if (x.Key == null || x.Key == string.Empty) continue;
- element = this.Controls.Find(x.Key, true).FirstOrDefault();
- if (element == null) continue;
- if (element is ToggleSwitch)
- {
- ((ToggleSwitch)element).OnText = x.Value;
- continue;
- }
- element.Text = x.Value;
- }
- }
- txtVersion.Text = txtVersion.Text.Replace("{VN}", Program.GetCurrentVersionTostring());
- }
- private void GetFootprint()
- {
- ByteSize footprint = CleanHelper.CheckFootprint();
- lblFootprint.Text = footprint.ToString();
- }
- private void GetFeed()
- {
- WebClient client = new WebClient
- {
- Encoding = Encoding.UTF8
- };
- client.Headers.Add("Cache-Control", "no-cache");
- try
- {
- byte[] feedData;
- string tmpImageFileName = string.Empty;
- feedData = client.DownloadData(_feedImages);
- using (ZipArchive zip = new ZipArchive(new MemoryStream(feedData)))
- {
- var zipEntries = zip.Entries;
- try
- {
- string feed = client.DownloadString(_feedLink);
- AppsFromFeed = JsonConvert.DeserializeObject<List<FeedApp>>(feed);
- AppCard appCard;
- groupSystemTools.Controls.Clear();
- groupInternet.Controls.Clear();
- groupCoding.Controls.Clear();
- groupSoundVideo.Controls.Clear();
- foreach (FeedApp x in AppsFromFeed)
- {
- appCard = new AppCard();
- appCard.AutoSize = true;
- appCard.Anchor = AnchorStyles.None;
- appCard.Anchor = AnchorStyles.Top | AnchorStyles.Left;
- appCard.appTitle.Text = x.Title;
- appCard.appTitle.Name = x.Tag;
- appCard.appImage.SizeMode = PictureBoxSizeMode.Zoom;
- tmpImageFileName = x.Image.Substring(x.Image.LastIndexOf("/") + 1, x.Image.Length - (x.Image.LastIndexOf("/") + 1));
- appCard.appImage.Image = Image.FromStream(zipEntries.First(ifn => ifn.Name == tmpImageFileName).Open());
- switch (x.Group)
- {
- case "SystemTools":
- appCard.Location = new Point(0, groupSystemTools.Controls.Count * 30);
- groupSystemTools.Controls.Add(appCard);
- break;
- case "Internet":
- appCard.Location = new Point(0, groupInternet.Controls.Count * 30);
- groupInternet.Controls.Add(appCard);
- break;
- case "Coding":
- appCard.Location = new Point(0, groupCoding.Controls.Count * 30);
- groupCoding.Controls.Add(appCard);
- break;
- case "GraphicsSound":
- appCard.Location = new Point(0, groupSoundVideo.Controls.Count * 30);
- groupSoundVideo.Controls.Add(appCard);
- break;
- default:
- break;
- }
- }
- // UI handling
- btnDownloadApps.Enabled = true;
- txtFeedError.Visible = false;
- }
- catch (Exception ex)
- {
- btnDownloadApps.Enabled = false;
- txtFeedError.Visible = true;
- ErrorLogger.LogError("MainForm.GetFeed", ex.Message, ex.StackTrace);
- }
- }
- }
- catch (Exception ex)
- {
- btnDownloadApps.Enabled = false;
- txtFeedError.Visible = true;
- ErrorLogger.LogError("MainForm.GetFeed-DownloadImages", ex.Message, ex.StackTrace);
- }
- }
- private void CleanPC()
- {
- try
- {
- if (checkTemp.Checked)
- {
- CleanHelper.PreviewTemp();
- }
- if (checkMiniDumps.Checked)
- {
- CleanHelper.PreviewMinidumps();
- }
- if (checkErrorReports.Checked)
- {
- CleanHelper.PreviewErrorReports();
- }
- if (checkBin.Checked)
- {
- CleanHelper.EmptyRecycleBin();
- }
- }
- catch (Exception ex)
- {
- ErrorLogger.LogError("MainForm.CleanPC", ex.Message, ex.StackTrace);
- }
- finally
- {
- if (CleanHelper.PreviewCleanList.Count > 0) new CleanPreviewForm(CleanHelper.PreviewCleanList).ShowDialog();
- GetFootprint();
- }
- }
- private bool FixRegistry()
- {
- bool changeDetected = false;
- try
- {
- if (checkFirewall.Checked)
- {
- Utilities.EnableFirewall();
- changeDetected = true;
- }
- if (checkCommandPrompt.Checked)
- {
- Utilities.EnableCommandPrompt();
- changeDetected = true;
- }
- if (checkControlPanel.Checked)
- {
- Utilities.EnableControlPanel();
- changeDetected = true;
- }
- if (checkFolderOptions.Checked)
- {
- Utilities.EnableFolderOptions();
- changeDetected = true;
- }
- if (checkRunDialog.Checked)
- {
- Utilities.EnableRunDialog();
- changeDetected = true;
- }
- if (checkContextMenu.Checked)
- {
- Utilities.EnableContextMenu();
- changeDetected = true;
- }
- if (checkTaskManager.Checked)
- {
- Utilities.EnableTaskManager();
- changeDetected = true;
- }
- if (checkRegistryEditor.Checked)
- {
- Utilities.EnableRegistryEditor();
- changeDetected = true;
- }
- }
- catch (Exception ex)
- {
- ErrorLogger.LogError("MainForm.FixRegistry", ex.Message, ex.StackTrace);
- }
- return changeDetected;
- }
- private void LoadUniversalToggleStates()
- {
- performanceSw.Checked = Options.CurrentOptions.EnablePerformanceTweaks;
- networkSw.Checked = Options.CurrentOptions.DisableNetworkThrottling;
- defenderSw.Checked = Options.CurrentOptions.DisableWindowsDefender;
- systemRestoreSw.Checked = Options.CurrentOptions.DisableSystemRestore;
- printSw.Checked = Options.CurrentOptions.DisablePrintService;
- mediaSharingSw.Checked = Options.CurrentOptions.DisableMediaPlayerSharing;
- reportingSw.Checked = Options.CurrentOptions.DisableErrorReporting;
- homegroupSw.Checked = Options.CurrentOptions.DisableHomeGroup;
- superfetchSw.Checked = Options.CurrentOptions.DisableSuperfetch;
- telemetryTasksSw.Checked = Options.CurrentOptions.DisableTelemetryTasks;
- officeTelemetrySw.Checked = Options.CurrentOptions.DisableOffice2016Telemetry;
- compatSw.Checked = Options.CurrentOptions.DisableCompatibilityAssistant;
- faxSw.Checked = Options.CurrentOptions.DisableFaxService;
- smartScreenSw.Checked = Options.CurrentOptions.DisableSmartScreen;
- stickySw.Checked = Options.CurrentOptions.DisableStickyKeys;
- }
- private void LoadWindowsVIIIToggleStates()
- {
- disableOneDriveSw.Checked = Options.CurrentOptions.DisableOneDrive;
- }
- private void LoadWindowsXToggleStates()
- {
- oldMixerSw.Checked = Options.CurrentOptions.EnableLegacyVolumeSlider;
- uODSw.Checked = Options.CurrentOptions.UninstallOneDrive;
- gameBarSw.Checked = Options.CurrentOptions.DisableGameBar;
- cortanaSw.Checked = Options.CurrentOptions.DisableCortana;
- xboxSw.Checked = Options.CurrentOptions.DisableXboxLive;
- oldExplorerSw.Checked = Options.CurrentOptions.DisableQuickAccessHistory;
- colorBarSw.Checked = Options.CurrentOptions.EnableTaskbarColor;
- sensorSw.Checked = Options.CurrentOptions.DisableSensorServices;
- privacySw.Checked = Options.CurrentOptions.DisablePrivacyOptions;
- telemetryServicesSw.Checked = Options.CurrentOptions.DisableTelemetryServices;
- autoUpdatesSw.Checked = Options.CurrentOptions.DisableAutomaticUpdates;
- peopleSw.Checked = Options.CurrentOptions.DisableMyPeople;
- adsSw.Checked = Options.CurrentOptions.DisableStartMenuAds;
- darkSw.Checked = Options.CurrentOptions.EnableDarkTheme;
- spellSw.Checked = Options.CurrentOptions.DisableSpellingTyping;
- inkSw.Checked = Options.CurrentOptions.DisableWindowsInk;
- driversSw.Checked = Options.CurrentOptions.ExcludeDrivers;
- insiderSw.Checked = Options.CurrentOptions.DisableInsiderService;
- featuresSw.Checked = Options.CurrentOptions.DisableFeatureUpdates;
- ccSw.Checked = Options.CurrentOptions.DisableCloudClipboard;
- longPathsSw.Checked = Options.CurrentOptions.EnableLongPaths;
- castSw.Checked = Options.CurrentOptions.RemoveCastToDevice;
- actionSw.Checked = Options.CurrentOptions.DisableActionCenter;
- }
- private void LoadWindowsXIToggleStates()
- {
- leftTaskbarSw.Checked = Options.CurrentOptions.TaskbarToLeft;
- snapAssistSw.Checked = Options.CurrentOptions.DisableSnapAssist;
- widgetsSw.Checked = Options.CurrentOptions.DisableWidgets;
- chatSw.Checked = Options.CurrentOptions.DisableChat;
- smallerTaskbarSw.Checked = Options.CurrentOptions.TaskbarSmaller;
- classicRibbonSw.Checked = Options.CurrentOptions.ClassicRibbon;
- classicContextSw.Checked = Options.CurrentOptions.ClassicMenu;
- tpmSw.Checked = Options.CurrentOptions.DisableTPMCheck;
- }
- private void Main_Load(object sender, EventArgs e)
- {
- }
- private void GetDesktopItems()
- {
- _desktopItems = Integrator.GetDesktopItems();
- listDesktopItems.Items.Clear();
- for (int i = 0; i < _desktopItems.Count; i++)
- {
- if (!string.IsNullOrEmpty(_desktopItems[i]))
- {
- listDesktopItems.Items.Add(_desktopItems[i]);
- }
- }
- if (_desktopItems.Count > 0) listDesktopItems.SelectedIndex = 0;
- }
- private void GetHostsEntries()
- {
- ((Control)this.hostsEditorTab).Enabled = false;
- _hostsEntries = HostsHelper.GetHostsEntries();
- listHostEntries.Items.Clear();
- listHostEntries.Items.AddRange(_hostsEntries.ToArray());
- chkReadOnly.Checked = HostsHelper.GetReadOnly();
- addHostB.Enabled = !chkReadOnly.Checked;
- removeAllHostsB.Enabled = !chkReadOnly.Checked;
- removeHostB.Enabled = !chkReadOnly.Checked;
- refreshHostsB.Enabled = !chkReadOnly.Checked;
- linkRestoreDefault.Enabled = !chkReadOnly.Checked;
- chkBlock.Enabled = !chkReadOnly.Checked;
- txtDomain.Enabled = !chkReadOnly.Checked;
- txtIP.Enabled = !chkReadOnly.Checked;
- adblockBasic.Enabled = !chkReadOnly.Checked;
- adblockS.Enabled = !chkReadOnly.Checked;
- adblockP.Enabled = !chkReadOnly.Checked;
- adblockUlti.Enabled = !chkReadOnly.Checked;
- ((Control)this.hostsEditorTab).Enabled = true;
- if (_hostsEntries.Count > 0) listHostEntries.SelectedIndex = 0;
- }
- private void GetStartupItems()
- {
- _startUpItems = Utilities.GetStartupItems();
- listStartupItems.Items.Clear();
- for (int i = 0; i < _startUpItems.Count; i++)
- {
- ListViewItem list = new ListViewItem(_startUpItems[i].Name);
- list.SubItems.Add(_startUpItems[i].FileLocation);
- list.SubItems.Add(_startUpItems[i].ToString());
- listStartupItems.Items.Add(list);
- }
- }
- private void GetModernApps(bool showAll)
- {
- uninstallModernAppsButton.Enabled = false;
- refreshModernAppsButton.Enabled = false;
- listModernApps.Enabled = false;
- listModernApps.Items.Clear();
- _modernApps = Utilities.GetModernApps(showAll);
- foreach (string x in _modernApps)
- {
- listModernApps.Items.Add(x);
- }
- uninstallModernAppsButton.Enabled = true;
- refreshModernAppsButton.Enabled = true;
- listModernApps.Enabled = true;
- if (_modernApps.Count > 0) listModernApps.SelectedIndex = 0;
- }
- private async void UninstallModernApps()
- {
- string selectedApps = string.Empty;
- if (listModernApps.CheckedItems.Count > 0)
- {
- foreach (string x in listModernApps.CheckedItems)
- {
- if (string.IsNullOrEmpty(selectedApps))
- {
- selectedApps = x;
- }
- else
- {
- selectedApps += Environment.NewLine + x;
- }
- }
- if (MessageBox.Show(_removeModernAppsMessage + "\n\n" + selectedApps, "Optimizer", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
- {
- uninstallModernAppsButton.Enabled = false;
- refreshModernAppsButton.Enabled = false;
- listModernApps.Enabled = false;
- bool errorOccured = false;
- string failedApps = string.Empty;
- foreach (string app in listModernApps.CheckedItems)
- {
- await Task.Run(() => errorOccured = Utilities.UninstallModernApp(app));
- if (errorOccured)
- {
- failedApps += Environment.NewLine + app;
- }
- }
- if (!string.IsNullOrEmpty(failedApps))
- {
- MessageBox.Show(_errorModernAppsMessage + failedApps, "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- GetModernApps(!chkOnlyRemovable.Checked);
- }
- }
- }
- private void GetCustomCommands()
- {
- _customCommands = Integrator.GetCustomCommands();
- listCustomCommands.Items.Clear();
- foreach (string s in _customCommands)
- {
- listCustomCommands.Items.Add(s);
- }
- if (_customCommands.Count > 0) listCustomCommands.SelectedIndex = 0;
- }
- private void Main_FormClosing(object sender, FormClosingEventArgs e)
- {
- if (_trayMenu)
- {
- e.Cancel = true;
- this.Hide();
- }
- else
- {
- Options.CurrentOptions.AppsFolder = txtDownloadFolder.Text;
- Options.SaveSettings();
- }
- }
- private void button39_Click(object sender, EventArgs e)
- {
- HelperForm f = new HelperForm(this, MessageType.Restart, _restartMessage);
- f.ShowDialog();
- }
- private void button43_Click(object sender, EventArgs e)
- {
- HelperForm f = new HelperForm(this, MessageType.Restart, _restartMessage);
- f.ShowDialog();
- }
- private void button44_Click(object sender, EventArgs e)
- {
- HelperForm f = new HelperForm(this, MessageType.Restart, _restartMessage);
- f.ShowDialog();
- }
- private void button45_Click(object sender, EventArgs e)
- {
- HelperForm f = new HelperForm(this, MessageType.Restart, _restartMessage);
- f.ShowDialog();
- }
- private void checkSelectAll_CheckedChanged(object sender, EventArgs e)
- {
- checkTemp.Checked = checkSelectAll.Checked;
- checkMiniDumps.Checked = checkSelectAll.Checked;
- checkErrorReports.Checked = checkSelectAll.Checked;
- }
- private void button20_Click(object sender, EventArgs e)
- {
- CleanHelper.PreviewCleanList.Clear();
- CleanPC();
- }
- private void button32_Click(object sender, EventArgs e)
- {
- if (listStartupItems.CheckedItems.Count <= 0) return;
- string report = string.Empty;
- foreach (ListViewItem i in listStartupItems.CheckedItems)
- {
- report += i.Text + Environment.NewLine;
- }
- if (MessageBox.Show(_removeStartupItemsMessage + Environment.NewLine + Environment.NewLine + report, "Optimizer", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
- {
- foreach (int x in listStartupItems.CheckedIndices)
- {
- _startUpItems[x].Remove();
- }
- GetStartupItems();
- }
- //foreach (int x in listStartupItems.CheckedIndices)
- //{
- // MessageBox.Show(x.ToString());
- //}
- //if (listStartupItems.SelectedItems.Count == 1)
- //{
- // _startUpItems[listStartupItems.SelectedIndices[0]].Remove();
- // GetStartupItems();
- //}
- }
- internal void RemoveAllStartupItems()
- {
- foreach (ListViewItem i in listStartupItems.Items)
- {
- _startUpItems[i.Index].Remove();
- }
- GetStartupItems();
- }
- // REMOVE ALL STARTUP ITEMS BUTTON
- //private void button22_Click(object sender, EventArgs e)
- //{
- // if (listStartupItems.Items.Count > 0)
- // {
- // HelperForm r = new HelperForm(this, MessageType.Startup, _removeStartupItemsMessage);
- // r.ShowDialog(this);
- // }
- //}
- private void button31_Click(object sender, EventArgs e)
- {
- if (listStartupItems.SelectedItems.Count == 1)
- {
- _startUpItems[listStartupItems.SelectedIndices[0]].LocateFile();
- }
- }
- private void checkEnableAll_CheckedChanged(object sender, EventArgs e)
- {
- checkTaskManager.Checked = checkEnableAll.Checked;
- checkCommandPrompt.Checked = checkEnableAll.Checked;
- checkControlPanel.Checked = checkEnableAll.Checked;
- checkFolderOptions.Checked = checkEnableAll.Checked;
- checkRunDialog.Checked = checkEnableAll.Checked;
- checkContextMenu.Checked = checkEnableAll.Checked;
- checkFirewall.Checked = checkEnableAll.Checked;
- checkRegistryEditor.Checked = checkEnableAll.Checked;
- }
- private void button33_Click(object sender, EventArgs e)
- {
- bool flag = FixRegistry();
- if (flag)
- {
- panel2.Enabled = false;
- regFixB.Enabled = false;
- if (checkRestartExplorer.Checked)
- {
- Utilities.RestartExplorer();
- }
- panel2.Enabled = true;
- regFixB.Enabled = true;
- }
- }
- private void pictureBox1_Click(object sender, EventArgs e)
- {
- AboutForm f = new AboutForm();
- f.ShowDialog(this);
- }
- private void button37_Click(object sender, EventArgs e)
- {
- GetStartupItems();
- }
- private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
- {
- HostsHelper.LocateHosts();
- }
- private void linkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
- {
- HostsEditorForm f = new HostsEditorForm();
- f.ShowDialog(this);
- GetHostsEntries();
- }
- private void linkLabel4_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
- {
- HostsHelper.RestoreDefaultHosts();
- GetHostsEntries();
- }
- private void button47_Click(object sender, EventArgs e)
- {
- if ((txtIP.Text != string.Empty) && (txtDomain.Text != string.Empty))
- {
- string ip = txtIP.Text.Trim();
- string domain = txtDomain.Text.Trim();
- string recommendedDomain = string.Empty;
- if (!domain.StartsWith("www."))
- {
- recommendedDomain = "www." + domain;
- }
- else
- {
- recommendedDomain = domain.Replace("www.", string.Empty);
- }
- HostsHelper.AddEntry(HostsHelper.SanitizeEntry(ip) + " " + HostsHelper.SanitizeEntry(domain));
- if (!string.IsNullOrEmpty(recommendedDomain))
- {
- HostsHelper.AddEntry(HostsHelper.SanitizeEntry(ip) + " " + HostsHelper.SanitizeEntry(recommendedDomain));
- }
- GetHostsEntries();
- txtIP.Clear();
- txtDomain.Clear();
- chkBlock.Checked = false;
- }
- }
- private void button41_Click(object sender, EventArgs e)
- {
- GetHostsEntries();
- }
- private void button42_Click(object sender, EventArgs e)
- {
- if (listHostEntries.SelectedItems.Count == 1)
- {
- HostsHelper.RemoveEntry(listHostEntries.SelectedItem.ToString().Replace(" : ", " "));
- GetHostsEntries();
- }
- }
- private void button46_Click(object sender, EventArgs e)
- {
- if (listHostEntries.Items.Count > 0)
- {
- HelperForm r = new HelperForm(this, MessageType.Hosts, _removeHostsEntriesMessage);
- r.ShowDialog(this);
- }
- }
- internal void RemoveAllHostsEntries()
- {
- List<string> collection = new List<string>();
- foreach (string item in listHostEntries.Items)
- {
- collection.Add(item.Replace(" : ", " "));
- }
- HostsHelper.RemoveAllEntries(collection);
- GetHostsEntries();
- }
- private void aio_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (tabCollection.SelectedTab == hostsEditorTab) txtIP.Focus();
- if (tabCollection.SelectedTab == pingerTab)
- {
- txtPingInput.Focus();
- //_networkMonitor.StartMonitoring();
- //NetworkMonitoring();
- }
- //else
- //{
- // _networkMonitor.StopMonitoring();
- //}
- }
- private void button48_Click(object sender, EventArgs e)
- {
- defineCommandDialog.ShowDialog();
- }
- private void button50_Click(object sender, EventArgs e)
- {
- if (!string.IsNullOrEmpty(txtRunFile.Text) && !string.IsNullOrEmpty(txtRunKeyword.Text))
- {
- Integrator.CreateCustomCommand(txtRunFile.Text, txtRunKeyword.Text);
- txtRunFile.Clear();
- txtRunKeyword.Clear();
- GetCustomCommands();
- }
- }
- private void DefineCmd_FileOk(object sender, CancelEventArgs e)
- {
- txtRunFile.Text = defineCommandDialog.FileName;
- txtRunKeyword.Text = Path.GetFileNameWithoutExtension(txtRunFile.Text).ToLower();
- }
- private void button59_Click(object sender, EventArgs e)
- {
- Utilities.ImportRegistryScript(Required.ReadyMadeMenusFolder + "\\PowerMenu.reg");
- GetDesktopItems();
- }
- private void button53_Click(object sender, EventArgs e)
- {
- Utilities.ImportRegistryScript(Required.ReadyMadeMenusFolder + "\\SystemTools.reg");
- GetDesktopItems();
- }
- private void button54_Click(object sender, EventArgs e)
- {
- Utilities.ImportRegistryScript(Required.ReadyMadeMenusFolder + "\\WindowsApps.reg");
- GetDesktopItems();
- }
- private void button51_Click(object sender, EventArgs e)
- {
- Utilities.ImportRegistryScript(Required.ReadyMadeMenusFolder + "\\SystemShortcuts.reg");
- GetDesktopItems();
- }
- private void button57_Click(object sender, EventArgs e)
- {
- Utilities.ImportRegistryScript(Required.ReadyMadeMenusFolder + "\\DesktopShortcuts.reg");
- GetDesktopItems();
- }
- private void button60_Click(object sender, EventArgs e)
- {
- GetDesktopItems();
- }
- private void button61_Click(object sender, EventArgs e)
- {
- if (listDesktopItems.SelectedItems.Count == 1)
- {
- Integrator.RemoveItem(listDesktopItems.SelectedItem.ToString());
- GetDesktopItems();
- }
- }
- internal void RemoveAllDesktopItems()
- {
- List<string> collection = new List<string>();
- foreach (string item in listDesktopItems.Items)
- {
- collection.Add(item);
- }
- Integrator.RemoveAllItems(collection);
- GetDesktopItems();
- }
- private void button62_Click(object sender, EventArgs e)
- {
- if (listDesktopItems.Items.Count > 0)
- {
- HelperForm r = new HelperForm(this, MessageType.Integrator, _removeDesktopItemsMessage);
- r.ShowDialog(this);
- }
- }
- private void radioProgram_CheckedChanged(object sender, EventArgs e)
- {
- if (radioProgram.Checked)
- {
- btnBrowseItem.Enabled = true;
- txtItem.Clear();
- checkDefaultIcon.Checked = true;
- txtIcon.Enabled = false;
- btnBrowseIcon.Enabled = false;
- itemtoaddgroup.Text = Options.TranslationList["itemtoaddgroup"];
- checkDefaultIcon.Visible = true;
- checkDefaultIcon.Text = Options.TranslationList["checkDefaultIcon"];
- txtItemName.Clear();
- txtItem.ReadOnly = true;
- txtIcon.ReadOnly = true;
- _desktopItemType = DesktopItemType.Program;
- }
- }
- private void radioFolder_CheckedChanged(object sender, EventArgs e)
- {
- if (radioFolder.Checked)
- {
- checkDefaultIcon.Checked = true;
- btnBrowseItem.Enabled = true;
- txtItem.Clear();
- itemtoaddgroup.Text = Options.TranslationList["folderToAdd"];
- checkDefaultIcon.Text = Options.TranslationList["checkDefaultFolderIcon"];
- txtItemName.Clear();
- txtItem.ReadOnly = true;
- txtIcon.ReadOnly = true;
- _desktopItemType = DesktopItemType.Folder;
- }
- }
- private void radioLink_CheckedChanged(object sender, EventArgs e)
- {
- if (radioLink.Checked)
- {
- checkDefaultIcon.Checked = true;
- checkDefaultIcon.Text = Options.TranslationList["checkFavicon"];
- btnBrowseItem.Enabled = false;
- itemtoaddgroup.Text = Options.TranslationList["linkToAdd"];
- checkDefaultIcon.Visible = true;
- txtItem.Text = "http://";
- txtItemName.Clear();
- txtItem.ReadOnly = false;
- txtIcon.ReadOnly = true;
- _desktopItemType = DesktopItemType.Link;
- }
- }
- private void radioFile_CheckedChanged(object sender, EventArgs e)
- {
- if (radioFile.Checked)
- {
- checkDefaultIcon.Checked = true;
- checkDefaultIcon.Text = Options.TranslationList["checkNoIcon"];
- btnBrowseItem.Enabled = true;
- itemtoaddgroup.Text = Options.TranslationList["fileToAdd"];
- checkDefaultIcon.Visible = true;
- txtItem.Clear();
- txtItemName.Clear();
- txtItem.ReadOnly = true;
- txtIcon.ReadOnly = true;
- _desktopItemType = DesktopItemType.File;
- }
- }
- private void radioCommand_CheckedChanged(object sender, EventArgs e)
- {
- if (radioCommand.Checked)
- {
- btnBrowseItem.Enabled = false;
- txtItem.Clear();
- checkDefaultIcon.Checked = true;
- txtIcon.Enabled = false;
- btnBrowseIcon.Enabled = false;
- itemtoaddgroup.Text = Options.TranslationList["commandToAdd"];
- checkDefaultIcon.Visible = true;
- checkDefaultIcon.Text = Options.TranslationList["checkNoIcon"];
- txtItemName.Clear();
- txtItem.ReadOnly = false;
- txtIcon.ReadOnly = true;
- _desktopItemType = DesktopItemType.Command;
- }
- }
- private void checkDefaultIcon_CheckedChanged(object sender, EventArgs e)
- {
- if (checkDefaultIcon.Checked)
- {
- txtIcon.Clear();
- txtIcon.Enabled = false;
- btnBrowseIcon.Enabled = false;
- }
- else
- {
- txtIcon.Clear();
- txtIcon.Enabled = true;
- btnBrowseIcon.Enabled = true;
- }
- }
- private void btnBrowseItem_Click(object sender, EventArgs e)
- {
- switch (_desktopItemType)
- {
- case DesktopItemType.Program:
- defineProgramDialog.ShowDialog();
- break;
- case DesktopItemType.Folder:
- defineFolderDialog.ShowDialog();
- txtItem.Text = defineFolderDialog.SelectedPath;
- int i = defineFolderDialog.SelectedPath.LastIndexOf("\\");
- txtItemName.Text = defineFolderDialog.SelectedPath.Remove(0, i + 1);
- break;
- case DesktopItemType.File:
- defineFileDialog.ShowDialog();
- break;
- }
- }
- private void DefineProgramDialog_FileOk(object sender, CancelEventArgs e)
- {
- txtItem.Text = defineProgramDialog.FileName;
- txtItemName.Text = defineProgramDialog.SafeFileName.Replace(".exe", string.Empty);
- }
- private void DefineFileDialog_FileOk(object sender, CancelEventArgs e)
- {
- txtItem.Text = defineFileDialog.FileName;
- txtItemName.Text = defineFileDialog.SafeFileName;
- }
- private void btnBrowseIcon_Click(object sender, EventArgs e)
- {
- switch (_desktopItemType)
- {
- case DesktopItemType.Program:
- DefineProgramIconDialog.ShowDialog();
- break;
- case DesktopItemType.Folder:
- DefineFolderIconDialog.ShowDialog();
- break;
- case DesktopItemType.Link:
- DefineURLIconDialog.ShowDialog();
- break;
- case DesktopItemType.File:
- DefineFileIconDialog.ShowDialog();
- break;
- case DesktopItemType.Command:
- DefineCommandIconDialog.ShowDialog();
- break;
- }
- }
- private void DefineProgramIconDialog_FileOk(object sender, CancelEventArgs e)
- {
- txtIcon.Text = DefineProgramIconDialog.FileName;
- if (txtIcon.Text.Contains(".exe"))
- {
- string iconpath = Integrator.ExtractIconFromExecutable(txtItemName.Text, DefineProgramIconDialog.FileName);
- txtIcon.Text = iconpath;
- }
- }
- private void DefineFolderIconDialog_FileOk(object sender, CancelEventArgs e)
- {
- txtIcon.Text = DefineFolderIconDialog.FileName;
- if (txtIcon.Text.Contains(".exe"))
- {
- string iconpath = Integrator.ExtractIconFromExecutable(txtItemName.Text, DefineFolderIconDialog.FileName);
- txtIcon.Text = iconpath;
- }
- }
- private void DefineURLIconDialog_FileOk(object sender, CancelEventArgs e)
- {
- txtIcon.Text = DefineURLIconDialog.FileName;
- if (txtIcon.Text.Contains(".exe"))
- {
- string iconpath = Integrator.ExtractIconFromExecutable(txtItemName.Text, DefineURLIconDialog.FileName);
- txtIcon.Text = iconpath;
- }
- }
- private void DefineFileIconDialog_FileOk(object sender, CancelEventArgs e)
- {
- txtIcon.Text = DefineFileIconDialog.FileName;
- if (txtIcon.Text.Contains(".exe"))
- {
- string iconpath = Integrator.ExtractIconFromExecutable(txtItemName.Text, DefineFileIconDialog.FileName);
- txtIcon.Text = iconpath;
- }
- }
- private void DefineCommandIconDialog_FileOk(object sender, CancelEventArgs e)
- {
- txtIcon.Text = DefineCommandIconDialog.FileName;
- if (txtIcon.Text.Contains(".exe"))
- {
- string iconpath = Integrator.ExtractIconFromExecutable(txtItemName.Text, DefineCommandIconDialog.FileName);
- txtIcon.Text = iconpath;
- }
- }
- private void btnAddItem_Click(object sender, EventArgs e)
- {
- if (!checkDefaultIcon.Checked && (string.IsNullOrEmpty(txtItem.Text) || string.IsNullOrEmpty(txtItemName.Text) || string.IsNullOrEmpty(txtIcon.Text)))
- {
- return;
- }
- if (checkDefaultIcon.Checked && (string.IsNullOrEmpty(txtItem.Text) || string.IsNullOrEmpty(txtItemName.Text)))
- {
- return;
- }
- string icon = string.Empty;
- switch (_desktopItemType)
- {
- case DesktopItemType.Program:
- if (checkDefaultIcon.Checked)
- {
- icon = txtItem.Text;
- }
- else
- {
- icon = txtIcon.Text;
- }
- Integrator.AddItem(txtItemName.Text, txtItem.Text, icon, _desktopItemPosition, checkShift.Checked, DesktopItemType.Program);
- break;
- case DesktopItemType.Folder:
- if (checkDefaultIcon.Checked)
- {
- icon = Integrator.FolderDefaultIcon;
- }
- else
- {
- icon = txtIcon.Text;
- }
- Integrator.AddItem(txtItemName.Text, txtItem.Text, icon, _desktopItemPosition, checkShift.Checked, DesktopItemType.Folder);
- break;
- case DesktopItemType.Link:
- if (checkDefaultIcon.Checked)
- {
- icon = Integrator.DownloadFavicon(txtItem.Text, txtItemName.Text);
- }
- else
- {
- icon = txtIcon.Text;
- }
- Integrator.AddItem(txtItemName.Text, txtItem.Text, icon, _desktopItemPosition, checkShift.Checked, DesktopItemType.Link);
- break;
- case DesktopItemType.File:
- if (!checkDefaultIcon.Checked)
- {
- icon = txtIcon.Text;
- }
- Integrator.AddItem(txtItemName.Text, txtItem.Text, icon, _desktopItemPosition, checkShift.Checked, DesktopItemType.File);
- break;
- case DesktopItemType.Command:
- if (!checkDefaultIcon.Checked)
- {
- icon = txtIcon.Text;
- }
- Integrator.AddItem(txtItemName.Text, txtItem.Text, icon, _desktopItemPosition, checkShift.Checked, DesktopItemType.Command);
- break;
- }
- GetDesktopItems();
- ResetIntegratorForm();
- }
- private void radioTop_CheckedChanged(object sender, EventArgs e)
- {
- if (radioTop.Checked)
- {
- _desktopItemPosition = DesktopTypePosition.Top;
- }
- }
- private void radioMiddle_CheckedChanged(object sender, EventArgs e)
- {
- if (radioMiddle.Checked)
- {
- _desktopItemPosition = DesktopTypePosition.Middle;
- }
- }
- private void radioBottom_CheckedChanged(object sender, EventArgs e)
- {
- if (radioBottom.Checked)
- {
- _desktopItemPosition = DesktopTypePosition.Bottom;
- }
- }
- private void ResetIntegratorForm()
- {
- txtItem.Clear();
- txtIcon.Clear();
- checkDefaultIcon.Checked = true;
- txtItemName.Clear();
- if (radioLink.Checked)
- {
- txtItem.Text = "http://";
- }
- }
- private void radioOcean_CheckedChanged(object sender, EventArgs e)
- {
- Options.CurrentOptions.Color = Theme.Ocean;
- Options.ApplyTheme(this);
- }
- private void radioMagma_CheckedChanged(object sender, EventArgs e)
- {
- Options.CurrentOptions.Color = Theme.Magma;
- Options.ApplyTheme(this);
- }
- private void radioZerg_CheckedChanged(object sender, EventArgs e)
- {
- Options.CurrentOptions.Color = Theme.Zerg;
- Options.ApplyTheme(this);
- }
- private void radioMinimal_CheckedChanged(object sender, EventArgs e)
- {
- Options.CurrentOptions.Color = Theme.Minimal;
- Options.ApplyTheme(this);
- }
- private void radioCaramel_CheckedChanged(object sender, EventArgs e)
- {
- Options.CurrentOptions.Color = Theme.Caramel;
- Options.ApplyTheme(this);
- }
- private void radioLime_CheckedChanged(object sender, EventArgs e)
- {
- Options.CurrentOptions.Color = Theme.Lime;
- Options.ApplyTheme(this);
- }
- private void button64_Click(object sender, EventArgs e)
- {
- if (listStartupItems.SelectedItems.Count == 1)
- {
- _startUpItems[listStartupItems.SelectedIndices[0]].LocateKey();
- }
- }
- private void button66_Click(object sender, EventArgs e)
- {
- Integrator.TakeOwnership(false);
- }
- private void button65_Click(object sender, EventArgs e)
- {
- Integrator.TakeOwnership(true);
- }
- private void listStartupItems_ColumnClick(object sender, ColumnClickEventArgs e)
- {
- if (e.Column == _columnSorter.CurrentColumn)
- {
- if (_columnSorter.SortOrder == SortOrder.Ascending)
- {
- _columnSorter.SortOrder = SortOrder.Descending;
- }
- else
- {
- _columnSorter.SortOrder = SortOrder.Ascending;
- }
- }
- else
- {
- _columnSorter.CurrentColumn = e.Column;
- _columnSorter.SortOrder = SortOrder.Ascending;
- }
- listStartupItems.Sort();
- }
- private void chkBlock_CheckedChanged(object sender, EventArgs e)
- {
- if (chkBlock.Checked)
- {
- txtIP.Text = _blockedIP;
- txtIP.Enabled = false;
- }
- else
- {
- txtIP.Clear();
- txtIP.Enabled = true;
- }
- }
- private void button8_Click(object sender, EventArgs e)
- {
- GetCustomCommands();
- }
- private void button26_Click(object sender, EventArgs e)
- {
- if (listCustomCommands.SelectedItems.Count == 1)
- {
- Integrator.DeleteCustomCommand(listCustomCommands.SelectedItem.ToString());
- GetCustomCommands();
- }
- }
- private void button75_Click(object sender, EventArgs e)
- {
- GetModernApps(!chkOnlyRemovable.Checked);
- }
- private void button74_Click(object sender, EventArgs e)
- {
- UninstallModernApps();
- }
- private void chkSelectAllModernApps_CheckedChanged(object sender, EventArgs e)
- {
- for (int i = 0; i < listModernApps.Items.Count; i++)
- {
- listModernApps.SetItemChecked(i, chkSelectAllModernApps.Checked);
- }
- }
- private void btnResetConfig_Click(object sender, EventArgs e)
- {
- if (MessageBox.Show(_resetMessage, "Optimizer", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
- {
- Utilities.ResetConfiguration();
- }
- }
- private void toggleSwitch1_Click(object sender, EventArgs e)
- {
- if (!performanceSw.Checked)
- {
- Optimize.EnablePerformanceTweaks();
- }
- else
- {
- Optimize.DisablePerformanceTweaks();
- }
- Options.CurrentOptions.EnablePerformanceTweaks = !performanceSw.Checked;
- }
- private void toggleSwitch2_Click(object sender, EventArgs e)
- {
- if (!networkSw.Checked)
- {
- Optimize.DisableNetworkThrottling();
- }
- else
- {
- Optimize.EnableNetworkThrottling();
- }
- Options.CurrentOptions.DisableNetworkThrottling = !networkSw.Checked;
- }
- private void toggleSwitch3_Click(object sender, EventArgs e)
- {
- if (!defenderSw.Checked)
- {
- Optimize.DisableDefender();
- }
- else
- {
- Optimize.EnableDefender();
- }
- Options.CurrentOptions.DisableWindowsDefender = !defenderSw.Checked;
- }
- private void toggleSwitch4_Click(object sender, EventArgs e)
- {
- if (!systemRestoreSw.Checked)
- {
- Optimize.DisableSystemRestore();
- }
- else
- {
- Optimize.EnableSystemRestore();
- }
- Options.CurrentOptions.DisableSystemRestore = !systemRestoreSw.Checked;
- }
- private void toggleSwitch5_Click(object sender, EventArgs e)
- {
- if (!printSw.Checked)
- {
- Optimize.DisablePrintService();
- }
- else
- {
- Optimize.EnablePrintService();
- }
- Options.CurrentOptions.DisablePrintService = !printSw.Checked;
- }
- private void toggleSwitch6_Click(object sender, EventArgs e)
- {
- if (!mediaSharingSw.Checked)
- {
- Optimize.DisableMediaPlayerSharing();
- }
- else
- {
- Optimize.EnableMediaPlayerSharing();
- }
- Options.CurrentOptions.DisableMediaPlayerSharing = !mediaSharingSw.Checked;
- }
- private void toggleSwitch8_Click(object sender, EventArgs e)
- {
- if (!reportingSw.Checked)
- {
- Optimize.DisableErrorReporting();
- }
- else
- {
- Optimize.EnableErrorReporting();
- }
- Options.CurrentOptions.DisableErrorReporting = !reportingSw.Checked;
- }
- private void toggleSwitch9_Click(object sender, EventArgs e)
- {
- if (!homegroupSw.Checked)
- {
- Optimize.DisableHomeGroup();
- }
- else
- {
- Optimize.EnableHomeGroup();
- }
- Options.CurrentOptions.DisableHomeGroup = !homegroupSw.Checked;
- }
- private void toggleSwitch10_Click(object sender, EventArgs e)
- {
- if (!superfetchSw.Checked)
- {
- Optimize.DisableSuperfetch();
- }
- else
- {
- Optimize.EnableSuperfetch();
- }
- Options.CurrentOptions.DisableSuperfetch = !superfetchSw.Checked;
- }
- private void toggleSwitch11_Click(object sender, EventArgs e)
- {
- if (!telemetryTasksSw.Checked)
- {
- Optimize.DisableTelemetryTasks();
- }
- else
- {
- Optimize.EnableTelemetryTasks();
- }
- Options.CurrentOptions.DisableTelemetryTasks = !telemetryTasksSw.Checked;
- }
- private void toggleSwitch12_Click(object sender, EventArgs e)
- {
- if (!officeTelemetrySw.Checked)
- {
- Optimize.DisableOffice2016Telemetry();
- }
- else
- {
- Optimize.EnableOffice2016Telemetry();
- }
- Options.CurrentOptions.DisableOffice2016Telemetry = !officeTelemetrySw.Checked;
- }
- private void toggleSwitch13_Click(object sender, EventArgs e)
- {
- if (!oldMixerSw.Checked)
- {
- Optimize.EnableLegacyVolumeSlider();
- }
- else
- {
- Optimize.DisableLegacyVolumeSlider();
- }
- Options.CurrentOptions.EnableLegacyVolumeSlider = !oldMixerSw.Checked;
- }
- private void toggleSwitch19_Click(object sender, EventArgs e)
- {
- if (!colorBarSw.Checked)
- {
- Optimize.EnableTaskbarColor();
- }
- else
- {
- Optimize.DisableTaskbarColor();
- }
- Options.CurrentOptions.EnableTaskbarColor = !colorBarSw.Checked;
- }
- private void toggleSwitch18_Click(object sender, EventArgs e)
- {
- if (!oldExplorerSw.Checked)
- {
- Optimize.DisableQuickAccessHistory();
- }
- else
- {
- Optimize.EnableQuickAccessHistory();
- }
- Options.CurrentOptions.DisableQuickAccessHistory = !oldExplorerSw.Checked;
- }
- private void toggleSwitch26_Click(object sender, EventArgs e)
- {
- if (!adsSw.Checked)
- {
- Optimize.DisableStartMenuAds();
- }
- else
- {
- Optimize.EnableStartMenuAds();
- }
- Options.CurrentOptions.DisableStartMenuAds = !adsSw.Checked;
- }
- private void toggleSwitch27_Click(object sender, EventArgs e)
- {
- if (!darkSw.Checked)
- {
- Optimize.EnableDarkTheme();
- }
- else
- {
- Optimize.EnableLightTheme();
- }
- Options.CurrentOptions.EnableDarkTheme = !darkSw.Checked;
- }
- private void toggleSwitch14_Click(object sender, EventArgs e)
- {
- if (!uODSw.Checked)
- {
- Task t = new Task(() => Optimize.UninstallOneDrive());
- t.Start();
- }
- else
- {
- Task t = new Task(() => Optimize.InstallOneDrive());
- t.Start();
- }
- Options.CurrentOptions.UninstallOneDrive = !uODSw.Checked;
- }
- private void toggleSwitch25_Click(object sender, EventArgs e)
- {
- if (!peopleSw.Checked)
- {
- Optimize.DisableMyPeople();
- }
- else
- {
- Optimize.EnableMyPeople();
- }
- Options.CurrentOptions.DisableMyPeople = !peopleSw.Checked;
- }
- private void toggleSwitch24_Click(object sender, EventArgs e)
- {
- if (!autoUpdatesSw.Checked)
- {
- Optimize.DisableAutomaticUpdates();
- }
- else
- {
- Optimize.EnableAutomaticUpdates();
- }
- Options.CurrentOptions.DisableAutomaticUpdates = !autoUpdatesSw.Checked;
- }
- private void toggleSwitch30_Click(object sender, EventArgs e)
- {
- if (!driversSw.Checked)
- {
- Optimize.ExcludeDrivers();
- }
- else
- {
- Optimize.IncludeDrivers();
- }
- Options.CurrentOptions.ExcludeDrivers = !driversSw.Checked;
- }
- private void toggleSwitch23_Click(object sender, EventArgs e)
- {
- if (!telemetryServicesSw.Checked)
- {
- Optimize.DisableTelemetryServices();
- }
- else
- {
- Optimize.EnableTelemetryServices();
- }
- Options.CurrentOptions.DisableTelemetryServices = !telemetryServicesSw.Checked;
- }
- private void toggleSwitch21_Click(object sender, EventArgs e)
- {
- if (!privacySw.Checked)
- {
- Optimize.EnhancePrivacy();
- }
- else
- {
- Optimize.CompromisePrivacy();
- }
- Options.CurrentOptions.DisablePrivacyOptions = !privacySw.Checked;
- }
- private void toggleSwitch16_Click(object sender, EventArgs e)
- {
- if (!cortanaSw.Checked)
- {
- Optimize.DisableCortana();
- }
- else
- {
- Optimize.EnableCortana();
- }
- Options.CurrentOptions.DisableCortana = !cortanaSw.Checked;
- }
- private void toggleSwitch20_Click(object sender, EventArgs e)
- {
- if (!sensorSw.Checked)
- {
- Optimize.DisableSensorServices();
- }
- else
- {
- Optimize.EnableSensorServices();
- }
- Options.CurrentOptions.DisableSensorServices = !sensorSw.Checked;
- }
- private void toggleSwitch29_Click(object sender, EventArgs e)
- {
- if (!inkSw.Checked)
- {
- Optimize.DisableWindowsInk();
- }
- else
- {
- Optimize.EnableWindowsInk();
- }
- Options.CurrentOptions.DisableWindowsInk = !inkSw.Checked;
- }
- private void toggleSwitch28_Click(object sender, EventArgs e)
- {
- if (!spellSw.Checked)
- {
- Optimize.DisableSpellingAndTypingFeatures();
- }
- else
- {
- Optimize.EnableSpellingAndTypingFeatures();
- }
- Options.CurrentOptions.DisableSpellingTyping = !spellSw.Checked;
- }
- private void toggleSwitch17_Click(object sender, EventArgs e)
- {
- if (!xboxSw.Checked)
- {
- Optimize.DisableXboxLive();
- }
- else
- {
- Optimize.EnableXboxLive();
- }
- Options.CurrentOptions.DisableXboxLive = !xboxSw.Checked;
- }
- private void toggleSwitch15_Click(object sender, EventArgs e)
- {
- if (!gameBarSw.Checked)
- {
- Optimize.DisableGameBar();
- }
- else
- {
- Optimize.EnableGameBar();
- }
- Options.CurrentOptions.DisableGameBar = !gameBarSw.Checked;
- }
- private void toggleSwitch31_Click(object sender, EventArgs e)
- {
- if (!disableOneDriveSw.Checked)
- {
- Optimize.DisableOneDrive();
- }
- else
- {
- Optimize.EnableOneDrive();
- }
- Options.CurrentOptions.DisableOneDrive = !disableOneDriveSw.Checked;
- }
- private void toggleSwitch32_Click(object sender, EventArgs e)
- {
- if (!compatSw.Checked)
- {
- Optimize.DisableCompatibilityAssistant();
- }
- else
- {
- Optimize.EnableCompatibilityAssistant();
- }
- Options.CurrentOptions.DisableCompatibilityAssistant = !compatSw.Checked;
- }
- private void btnUpdate_Click(object sender, EventArgs e)
- {
- CheckForUpdate();
- }
- private void btnChangelog_Click(object sender, EventArgs e)
- {
- try
- {
- Process.Start(_changelogLink);
- }
- catch (Exception ex)
- {
- ErrorLogger.LogError("MainForm.btnChangelog_Click", ex.Message, ex.StackTrace);
- MessageBox.Show(ex.Message, "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- private void chkReadOnly_CheckedChanged(object sender, EventArgs e)
- {
- HostsHelper.ReadOnly(chkReadOnly.Checked);
- addHostB.Enabled = !chkReadOnly.Checked;
- removeAllHostsB.Enabled = !chkReadOnly.Checked;
- removeHostB.Enabled = !chkReadOnly.Checked;
- refreshHostsB.Enabled = !chkReadOnly.Checked;
- linkRestoreDefault.Enabled = !chkReadOnly.Checked;
- chkBlock.Enabled = !chkReadOnly.Checked;
- txtDomain.Enabled = !chkReadOnly.Checked;
- txtIP.Enabled = !chkReadOnly.Checked;
- adblockBasic.Enabled = !chkReadOnly.Checked;
- adblockS.Enabled = !chkReadOnly.Checked;
- adblockP.Enabled = !chkReadOnly.Checked;
- adblockUlti.Enabled = !chkReadOnly.Checked;
- txtIP.Focus();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- HostsHelper.AdblockBasic();
- GetHostsEntries();
- }
- private void button3_Click(object sender, EventArgs e)
- {
- HostsHelper.AdBlockWithPorn();
- GetHostsEntries();
- }
- private void button2_Click(object sender, EventArgs e)
- {
- HostsHelper.AdBlockWithSocial();
- GetHostsEntries();
- }
- private void button4_Click(object sender, EventArgs e)
- {
- HostsHelper.AdBlockWithSocial();
- GetHostsEntries();
- }
- private void RenderAppDownloaderBusy()
- {
- btnDownloadApps.Enabled = false;
- changeDownDirB.Enabled = false;
- txtDownloadFolder.ReadOnly = true;
- linkWarnings.Visible = false;
- }
- private void RenderAppDownloaderFree()
- {
- btnDownloadApps.Enabled = true;
- changeDownDirB.Enabled = true;
- txtDownloadFolder.ReadOnly = false;
- linkWarnings.Visible = !string.IsNullOrEmpty(downloadLog);
- txtDownloadStatus.Text = Options.TranslationList["Finished"];
- }
- string appNameTemp = string.Empty;
- int maxCount = 0;
- int count = 0;
- Process p;
- string downloadLog = string.Empty;
- private async void btnDownloadApps_Click(object sender, EventArgs e)
- {
- if (!Directory.Exists(txtDownloadFolder.Text))
- {
- MessageBox.Show(Options.TranslationList["downloadDirInvalid"].ToString(), "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- RenderAppDownloaderBusy();
- maxCount = 0;
- count = 0;
- downloadLog = string.Empty;
- foreach (Control c in Utilities.GetSelfAndChildrenRecursive(appsTab))
- {
- if (c.Name == "cAutoInstall") continue;
- if (c is ColoredCheckBox && ((ColoredCheckBox)c).Checked) maxCount++;
- }
- ColoredCheckBox currentCheck;
- Control[] temp;
- foreach (FeedApp x in AppsFromFeed)
- {
- if (string.IsNullOrEmpty(x.Tag)) continue;
- temp = appsTab.Controls.Find(x.Tag, true);
- if (temp.Count() == 0) continue;
- currentCheck = (ColoredCheckBox)temp[0];
- if (currentCheck == null) continue;
- if (!currentCheck.Checked) continue;
- appNameTemp = x.Title;
- if (c64.Checked)
- {
- count++;
- if (string.IsNullOrEmpty(x.Link64))
- {
- downloadLog += "• " + x.Title + ":" + Environment.NewLine + Options.TranslationList["no64Download"] + Environment.NewLine + Environment.NewLine;
- await DownloadApp(x, false);
- }
- else
- {
- await DownloadApp(x, true);
- }
- }
- else
- {
- count++;
- if (!string.IsNullOrEmpty(x.Link))
- {
- await DownloadApp(x, false);
- }
- else
- {
- downloadLog += "• " + x.Title + ":" + Environment.NewLine + Options.TranslationList["no32Download"] + Environment.NewLine + Environment.NewLine;
- }
- }
- }
- if (cAutoInstall.Checked)
- {
- count = 0;
- foreach (string a in Directory.GetFiles(txtDownloadFolder.Text, "*.*", SearchOption.TopDirectoryOnly))
- {
- using (p = new Process())
- {
- count++;
- p.StartInfo.FileName = a;
- p.EnableRaisingEvents = true;
- p.StartInfo.WorkingDirectory = txtDownloadFolder.Text;
- // APP-SPECIFIC HACKS //
- if (a.Contains("Sumatra")) p.StartInfo.Arguments = " -install";
- // *** //
- txtDownloadStatus.Text = string.Format("{0}/{1} - {2} {3} ...", count, maxCount, Options.TranslationList["installing"], Path.GetFileNameWithoutExtension(a));
- await p.RunAsync();
- };
- }
- }
- // reset all checkboxes
- foreach (Control c in Utilities.GetSelfAndChildrenRecursive(appsTab))
- {
- if (c.Name == "cAutoInstall") continue;
- if (c is ColoredCheckBox && ((ColoredCheckBox)c).Checked) ((ColoredCheckBox)c).Checked = false;
- }
- RenderAppDownloaderFree();
- }
- string fileExtension = ".exe";
- private async Task DownloadApp(FeedApp app, bool pref64)
- {
- try
- {
- using (WebClient downloader = new WebClient())
- {
- downloader.Headers.Add("User-Agent: Other");
- downloader.Encoding = Encoding.UTF8;
- downloader.DownloadProgressChanged += Downloader_DownloadProgressChanged;
- downloader.DownloadFileCompleted += Downloader_DownloadFileCompleted;
- if (pref64)
- {
- if (app.Link64.Contains(".msi"))
- {
- fileExtension = ".msi";
- }
- else
- {
- fileExtension = ".exe";
- }
- await downloader.DownloadFileTaskAsync(new Uri(app.Link64), Path.Combine(txtDownloadFolder.Text, app.Title + "-x64" + fileExtension));
- }
- else
- {
- if (app.Link.Contains(".msi"))
- {
- fileExtension = ".msi";
- }
- else
- {
- fileExtension = ".exe";
- }
- await downloader.DownloadFileTaskAsync(new Uri(app.Link), Path.Combine(txtDownloadFolder.Text, app.Title + "-x86" + fileExtension));
- }
- }
- }
- catch (Exception ex)
- {
- ErrorLogger.LogError("MainForm.DownloadApp", ex.Message, ex.StackTrace);
- downloadLog += "• " + app.Title + ":" + Environment.NewLine + Options.TranslationList["linkInvalid"] + Environment.NewLine + Environment.NewLine;
- if (pref64) try { File.Delete(Path.Combine(txtDownloadFolder.Text, app.Title + "-x64.exe")); } catch { }
- if (!pref64) try { File.Delete(Path.Combine(txtDownloadFolder.Text, app.Title + "-x86.exe")); } catch { }
- if (pref64) try { File.Delete(Path.Combine(txtDownloadFolder.Text, app.Title + "-x64.msi")); } catch { }
- if (!pref64) try { File.Delete(Path.Combine(txtDownloadFolder.Text, app.Title + "-x86.msi")); } catch { }
- }
- }
- private void Downloader_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
- {
- this.BeginInvoke((MethodInvoker)delegate
- {
- //txtDownloadStatus.Text = "Finished";
- });
- }
- int tempProgress;
- private void Downloader_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
- {
- this.BeginInvoke((MethodInvoker)delegate
- {
- double bytesIn = double.Parse(e.BytesReceived.ToString());
- double totalBytes = double.Parse(e.TotalBytesToReceive.ToString());
- double percentage = bytesIn / totalBytes * 100;
- tempProgress = int.Parse(Math.Truncate(percentage).ToString());
- // if Content-Length header is missing, just show an animation
- if (Math.Abs(tempProgress) > 100)
- {
- txtDownloadStatus.Text = string.Format("({1}/{2}) - {0} ...", appNameTemp, count, maxCount);
- progressDownloader.Style = ProgressBarStyle.Marquee;
- }
- // if not, show actual progress
- else
- {
- txtDownloadStatus.Text = string.Format("({1}/{2}) - {0} - {3} / {4}", appNameTemp, count, maxCount, ByteSize.FromBytes(e.BytesReceived).ToString("MB"), ByteSize.FromBytes(e.TotalBytesToReceive).ToString("MB"));
- progressDownloader.Style = ProgressBarStyle.Continuous;
- progressDownloader.Value = tempProgress;
- }
- });
- }
- private void button5_Click(object sender, EventArgs e)
- {
- FolderBrowserDialog d = new FolderBrowserDialog();
- if (d.ShowDialog() == DialogResult.OK)
- {
- txtDownloadFolder.Text = d.SelectedPath;
- Options.CurrentOptions.AppsFolder = d.SelectedPath;
- Options.SaveSettings();
- }
- }
- private void button6_Click(object sender, EventArgs e)
- {
- Process.Start(txtDownloadFolder.Text);
- }
- private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
- {
- InfoForm lf = new InfoForm(downloadLog);
- lf.ShowDialog(this);
- }
- private void txtDownloadFolder_TextChanged(object sender, EventArgs e)
- {
- Options.CurrentOptions.AppsFolder = txtDownloadFolder.Text;
- Options.SaveSettings();
- }
- private void chkOnlyRemovable_CheckedChanged(object sender, EventArgs e)
- {
- GetModernApps(!chkOnlyRemovable.Checked);
- }
- private void btnGetFeed_Click(object sender, EventArgs e)
- {
- GetFeed();
- }
- private void l2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
- {
- AboutForm f = new AboutForm();
- f.ShowDialog(this);
- //Process.Start("https://github.com/hellzerg/optimizer");
- }
- private void btnViewLog_Click(object sender, EventArgs e)
- {
- if (File.Exists(ErrorLogger.ErrorLogFile))
- {
- InfoForm iform = new InfoForm(File.ReadAllText(ErrorLogger.ErrorLogFile, Encoding.UTF8));
- iform.ShowDialog();
- }
- else
- {
- MessageBox.Show(Options.TranslationList["noErrorsM"].ToString(), "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- private void btnOpenConf_Click(object sender, EventArgs e)
- {
- Process.Start(Required.CoreFolder);
- }
- private void btnPing_Click(object sender, EventArgs e)
- {
- if (string.IsNullOrEmpty(txtPingInput.Text)) return;
- _pingResults = new List<PingReply>();
- listPingResults.Items.Clear();
- if (Utilities.PingHost(txtPingInput.Text) == null)
- {
- listPingResults.Items.Add(string.Format("{0} [{1}]", Options.TranslationList["hostNotFound"], txtPingInput.Text));
- return;
- }
- Task pinger = new Task(() =>
- {
- btnShodan.Enabled = false;
- btnPing.Enabled = false;
- listPingResults.Items.Add(string.Format("{0} [{1}]", Options.TranslationList["pinging"], txtPingInput.Text));
- listPingResults.Items.Add("");
- for (int i = 0; i < 9; i++)
- {
- // wait before each pinging
- System.Threading.Thread.Sleep(888);
- tmpReply = Utilities.PingHost(txtPingInput.Text);
- if (tmpReply.Address == null)
- {
- listPingResults.Items.Add(tmpReply.Status);
- }
- else
- {
- _pingResults.Add(tmpReply);
- _shodanIP = _pingResults[i].Address.ToString();
- listPingResults.Items.Add(string.Format("{0} - {1}: {2} ms - TTL: {3}", _pingResults[i].Status, Options.TranslationList["latency"], _pingResults[i].RoundtripTime, _pingResults[i].Options.Ttl));
- }
- }
- listPingResults.Items.Add("");
- // calculate statistics
- if (_pingResults.Count > 0)
- {
- long maxLatency = _pingResults.Max(x => x.RoundtripTime);
- long minLatency = _pingResults.Min(x => x.RoundtripTime);
- double averageLatency = _pingResults.Average(x => x.RoundtripTime);
- listPingResults.Items.Add(string.Format("{0} = {1}, {2} = {3}, {4} = {5:F2}", Options.TranslationList["min"], minLatency, Options.TranslationList["max"], maxLatency, Options.TranslationList["avg"], averageLatency));
- }
- else
- {
- listPingResults.Items.Add(Options.TranslationList["timeout"]);
- }
- btnPing.Enabled = true;
- btnShodan.Enabled = true;
- });
- pinger.Start();
- }
- private void btnCheckFootprint_Click(object sender, EventArgs e)
- {
- CleanHelper.CheckFootprint();
- }
- private void btnShodan_Click(object sender, EventArgs e)
- {
- IPAddress tryIP;
- if (IPAddress.TryParse(txtPingInput.Text, out tryIP))
- {
- Process.Start(string.Format("https://www.shodan.io/host/{0}", txtPingInput.Text));
- return;
- }
- if (!string.IsNullOrEmpty(_shodanIP))
- {
- Process.Start(string.Format("https://www.shodan.io/host/{0}", _shodanIP));
- return;
- }
- }
- private void button9_Click(object sender, EventArgs e)
- {
- try
- {
- Clipboard.SetText(_shodanIP);
- }
- catch { }
- }
- private void button7_Click(object sender, EventArgs e)
- {
- try
- {
- Clipboard.SetText(txtPingInput.Text);
- }
- catch { }
- }
- private void txtPingInput_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter) btnPing.PerformClick();
- }
- private void btnExport_Click(object sender, EventArgs e)
- {
- if (ExportDialog.ShowDialog() == DialogResult.OK)
- {
- try
- {
- File.WriteAllLines(ExportDialog.FileName, listPingResults.Items.Cast<string>());
- }
- catch (Exception ex)
- {
- ErrorLogger.LogError("btnExport.Click", ex.Message, ex.StackTrace);
- MessageBox.Show(ex.Message, "Optimizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- }
- private void startupItem_Click(object sender, EventArgs e)
- {
- tabCollection.SelectedTab = startupTab;
- RestoreWindow();
- }
- private void cleanerItem_Click(object sender, EventArgs e)
- {
- tabCollection.SelectedTab = cleanerTab;
- RestoreWindow();
- }
- private void pingerItem_Click(object sender, EventArgs e)
- {
- tabCollection.SelectedTab = pingerTab;
- RestoreWindow();
- txtPingInput.Focus();
- }
- private void hostsItem_Click(object sender, EventArgs e)
- {
- tabCollection.SelectedTab = hostsEditorTab;
- RestoreWindow();
- txtIP.Focus();
- }
- private void appsItem_Click(object sender, EventArgs e)
- {
- tabCollection.SelectedTab = appsTab;
- RestoreWindow();
- }
- private void exitItem_Click(object sender, EventArgs e)
- {
- _trayMenu = false;
- Options.CurrentOptions.AppsFolder = txtDownloadFolder.Text;
- Options.SaveSettings();
- Application.Exit();
- }
- private void RestoreWindow()
- {
- if (this.WindowState == FormWindowState.Minimized) this.WindowState = FormWindowState.Normal;
- this.Show();
- this.Activate();
- this.Focus();
- }
- private void launcherIcon_MouseDoubleClick(object sender, MouseEventArgs e)
- {
- if (this.Visible)
- {
- if (this.WindowState == FormWindowState.Minimized) this.WindowState = FormWindowState.Normal;
- this.Hide();
- }
- else
- {
- RestoreWindow();
- }
- }
- private void quickAccessToggle_CheckedChanged(object sender, EventArgs e)
- {
- Options.CurrentOptions.EnableTray = quickAccessToggle.Checked;
- Options.SaveSettings();
- _trayMenu = quickAccessToggle.Checked;
- launcherIcon.Visible = quickAccessToggle.Checked;
- }
- private void linkLabel5_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
- {
- Process.Start(_licenseLink);
- }
- private void linkLabel6_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
- {
- Process.Start(_openSourceLink);
- }
- private void linkUpdate_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
- {
- CheckForUpdate();
- }
- private void restartExpolorerItem_Click(object sender, EventArgs e)
- {
- Utilities.RestartExplorer();
- }
- private void button10_Click(object sender, EventArgs e)
- {
- Utilities.FlushDNSCache();
- }
- private void helpTipsToggle_CheckedChanged(object sender, EventArgs e)
- {
- Options.CurrentOptions.ShowHelp = helpTipsToggle.Checked;
- Options.SaveSettings();
- helpBox.Active = helpTipsToggle.Checked;
- }
- private void button11_Click(object sender, EventArgs e)
- {
- ShowBackupConfirm();
- }
- private void ShowBackupConfirm()
- {
- removeStartupItemB.Visible = false;
- locateFileB.Visible = false;
- findInRegB.Visible = false;
- refreshStartupB.Visible = false;
- restoreStartupB.Visible = false;
- backupStartupB.Visible = false;
- lblBackupTitle.Visible = true;
- doBackup.Visible = true;
- cancelBackup.Visible = true;
- txtBackupTitle.Visible = true;
- }
- private void HideBackupConfirm()
- {
- removeStartupItemB.Visible = true;
- locateFileB.Visible = true;
- findInRegB.Visible = true;
- refreshStartupB.Visible = true;
- restoreStartupB.Visible = true;
- backupStartupB.Visible = true;
- lblBackupTitle.Visible = false;
- doBackup.Visible = false;
- cancelBackup.Visible = false;
- txtBackupTitle.Visible = false;
- }
- private void button12_Click(object sender, EventArgs e)
- {
- StartupRestoreForm f = new StartupRestoreForm();
- f.ShowDialog(this);
- GetStartupItems();
- }
- private void button14_Click(object sender, EventArgs e)
- {
- HideBackupConfirm();
- }
- private void button13_Click(object sender, EventArgs e)
- {
- if (!string.IsNullOrEmpty(txtBackupTitle.Text.Trim()))
- {
- HideBackupConfirm();
- _backupItems.Clear();
- foreach (var x in _startUpItems)
- {
- _backupItems.Add(new StartupBackupItem(x.Name, x.FileLocation, x.RegistryLocation.ToString(), x.StartupType.ToString()));
- }
- try
- {
- File.WriteAllText(Required.StartupItemsBackupFolder + Utilities.SanitizeFileFolderName(txtBackupTitle.Text + " - [" + DateTime.Now.ToShortDateString() + "-" + DateTime.Now.ToShortTimeString()) + "].json", JsonConvert.SerializeObject(_backupItems, Formatting.Indented));
- }
- catch (Exception ex)
- {
- ErrorLogger.LogError("MainForm.BackupStartupItems", ex.Message, ex.StackTrace);
- }
- }
- }
- private void pictureBox86_Click(object sender, EventArgs e)
- {
- radioEnglish.PerformClick();
- }
- private void pictureBox87_Click(object sender, EventArgs e)
- {
- radioRussian.PerformClick();
- }
- private void radioEnglish_Click(object sender, EventArgs e)
- {
- radioEnglish.Checked = true;
- Options.CurrentOptions.LanguageCode = LanguageCode.EN;
- Options.SaveSettings();
- Options.LoadTranslation();
- Translate();
- }
- private void radioRussian_Click(object sender, EventArgs e)
- {
- radioRussian.Checked = true;
- Options.CurrentOptions.LanguageCode = LanguageCode.RU;
- Options.SaveSettings();
- Options.LoadTranslation();
- Translate();
- }
- private void pictureBox88_Click(object sender, EventArgs e)
- {
- radioHellenic.PerformClick();
- }
- private void radioHellenic_Click(object sender, EventArgs e)
- {
- radioHellenic.Checked = true;
- Options.CurrentOptions.LanguageCode = LanguageCode.EL;
- Options.SaveSettings();
- Options.LoadTranslation();
- Translate();
- }
- private void pictureBox89_Click(object sender, EventArgs e)
- {
- radioTurkish.PerformClick();
- }
- private void radioTurkish_Click(object sender, EventArgs e)
- {
- radioTurkish.Checked = true;
- Options.CurrentOptions.LanguageCode = LanguageCode.TR;
- Options.SaveSettings();
- Options.LoadTranslation();
- Translate();
- }
- private void radioGerman_Click(object sender, EventArgs e)
- {
- radioGerman.Checked = true;
- Options.CurrentOptions.LanguageCode = LanguageCode.DE;
- Options.SaveSettings();
- Options.LoadTranslation();
- Translate();
- }
- private void pictureBox2_Click(object sender, EventArgs e)
- {
- radioGerman.PerformClick();
- }
- private void pictureBox3_Click(object sender, EventArgs e)
- {
- radioSpanish.PerformClick();
- }
- private void radioSpanish_Click(object sender, EventArgs e)
- {
- radioSpanish.Checked = true;
- Options.CurrentOptions.LanguageCode = LanguageCode.ES;
- Options.SaveSettings();
- Options.LoadTranslation();
- Translate();
- }
- private void radioPortuguese_Click(object sender, EventArgs e)
- {
- radioPortuguese.Checked = true;
- Options.CurrentOptions.LanguageCode = LanguageCode.PT;
- Options.SaveSettings();
- Options.LoadTranslation();
- Translate();
- }
- private void pictureBox4_Click(object sender, EventArgs e)
- {
- radioPortuguese.PerformClick();
- }
- private void txtIPv4_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
- {
- Clipboard.SetText(txtIPv4.Text);
- }
- private void txtIPv4A_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
- {
- Clipboard.SetText(txtIPv4A.Text);
- }
- private void txtIPv6_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
- {
- Clipboard.SetText(txtIPv6.Text);
- }
- private void txtIPv6A_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
- {
- Clipboard.SetText(txtIPv6A.Text);
- }
- private void btnOpenNetwork_Click(object sender, EventArgs e)
- {
- Process.Start("NCPA.cpl");
- }
- private void radioFrench_Click(object sender, EventArgs e)
- {
- radioFrench.Checked = true;
- Options.CurrentOptions.LanguageCode = LanguageCode.FR;
- Options.SaveSettings();
- Options.LoadTranslation();
- Translate();
- }
- private void pictureBox5_Click(object sender, EventArgs e)
- {
- radioFrench.PerformClick();
- }
- private void listStartupItems_ItemChecked(object sender, ItemCheckedEventArgs e)
- {
- if (e.Item.Checked)
- {
- e.Item.ForeColor = Options.ForegroundColor;
- }
- else
- {
- e.Item.ForeColor = Color.White;
- }
- }
- private void trayOptions_Click(object sender, EventArgs e)
- {
- tabCollection.SelectedTab = optionsTab;
- RestoreWindow();
- }
- private void trayRegistry_Click(object sender, EventArgs e)
- {
- tabCollection.SelectedTab = registryFixerTab;
- RestoreWindow();
- }
- private void radioItalian_Click(object sender, EventArgs e)
- {
- radioItalian.Checked = true;
- Options.CurrentOptions.LanguageCode = LanguageCode.IT;
- Options.SaveSettings();
- Options.LoadTranslation();
- Translate();
- }
- private void pictureBox6_Click(object sender, EventArgs e)
- {
- radioItalian.PerformClick();
- }
- }
- }
|