private void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { PCS.process("blb\\bleachbit_console.exe", " --update-winapp2", true); PCS.process(Global.system + "blb\\bleachbit_console.exe", " --update-winapp2", true); if (PCS.CheckForInternetConnection() == true) { using (System.Net.WebClient myWebClient = new System.Net.WebClient()) { myWebClient.DownloadFile("http://www.pcstarters.net/pcsm/update/downloadsettings.ini", "settings\\downloadsettingsnew.ini"); } } }
private void Maintainer_FormClosing(object sender, FormClosingEventArgs e) { PCS.process("cmd", "/c taskkill /im lrc.exe /im bleachbit_console.exe /im udefrag.exe /t /f", true); backgroundWorker1.CancelAsync(); log.WriteLog("Maintainer Closed"); }
public void start_repair(DoWorkEventArgs e) { log.WriteLog("Maintainer Repair start"); Global.currentprocess = "repair"; data.Add("button1.enabled", "false"); data.Add("button2.enabled", "false"); data.Add("checkbox1.visible", "false"); data.Add("checkbox2.visible", "false"); data.Add("checkbox3.visible", "false"); data.Add("checkbox5.visible", "false"); data.Add("linklabel1.visible", "false"); data.Add("linklabel2.visible", "false"); data.Add("linklabel3.visible", "false"); data.Add("linklabel9.visible", "false"); data["button1.visible"] = "true"; data["button2.text"] = "Repair"; if (checkBox1.Checked) { data.Add("checkbox1.checked", "true"); } else { data.Add("checkbox1.checked", "false"); } if (checkBox2.Checked) { data.Add("checkbox2.checked", "true"); } else { data.Add("checkbox2.checked", "false"); } if (checkBox3.Checked) { data.Add("checkbox3.checked", "true"); } else { data.Add("checkbox3.checked", "false"); } if (checkBox4.Checked) { data.Add("checkbox4.checked", "true"); } else { data.Add("checkbox4.checked", "false"); } if (checkBox5.Checked) { data.Add("checkbox5.checked", "true"); } else { data.Add("checkbox5.checked", "false"); } data.Add("label4.visible", "true"); data.Add("label6.visible", "true"); data.Add("label7.visible", "true"); data.Add("label8.visible", "true"); data.Add("label11.visible", "true"); backgroundWorker1.ReportProgress(5, data); if (checkBox1.Checked) { data["label4.visible"] = "false"; backgroundWorker1.ReportProgress(10, data); data.Add("linklabel5.visible", "false"); data.Add("picturebox11.visible", "true"); backgroundWorker1.ReportProgress(10, data); if (this.backgroundWorker1.CancellationPending) { e.Cancel = true; return; } Application.DoEvents(); rc.repair(); data.Add("linklabel5.text", Global.registry + " Registry\nProblems Cleared"); data["picturebox11.visible"] = "false"; data["linklabel5.visible"] = "true"; data["linklabel5.enabled"] = "false"; backgroundWorker1.ReportProgress(20, data); Thread.Sleep(500); } if (checkBox2.Checked) { data["label6.visible"] = "false"; backgroundWorker1.ReportProgress(30, data); data.Add("picturebox12.visible", "true"); backgroundWorker1.ReportProgress(30, data); if (this.backgroundWorker1.CancellationPending) { e.Cancel = true; return; } Application.DoEvents(); dc.clean(); data.Add("linklabel6.text", Global.cleanupsize + " space is\nRecovered"); data["picturebox12.visible"] = "false"; data["linklabel6.visible"] = "true"; data["linklabel6.enabled"] = "false"; backgroundWorker1.ReportProgress(40, data); Thread.Sleep(500); } if (checkBox3.Checked) { data["label7.visible"] = "false"; data.Add("linklabel8.visible", "false"); data.Add("picturebox5.visible", "false"); data.Add("progressbar2.visible", "true"); data.Add("picturebox5.enabled", "false"); data["label9.visible"] = "true"; string uncompress = PCS.IniReadValue("settings//defragsettings.ini", "main", "uncompress"); if (uncompress == "True") { if (data.ContainsKey("progressbar2.visible")) { data["progressbar2.visible"] = "true"; } else { data.Add("progressbar2.visible", "true"); } } backgroundWorker1.ReportProgress(50, data); if (this.backgroundWorker1.CancellationPending) { e.Cancel = true; return; } Application.DoEvents(); this.timer1.Interval = 300; timer1.Start(); dd.defrag(); timer1.Stop(); this.timer1.Interval = 3000; data.Add("linklabel8.text", ""); data["linklabel8.text"] = "Defragmentation\nComplete"; data["linklabel8.enabled"] = "false"; data["progressbar2.visible"] = "false"; data["linklabel8.visible"] = "true"; data["label9.visible"] = "false"; backgroundWorker1.ReportProgress(60, data); Thread.Sleep(500); } if (checkBox4.Checked) { data["label11.visible"] = "false"; backgroundWorker1.ReportProgress(65, data); data.Add("picturebox14.visible", "true"); backgroundWorker1.ReportProgress(68, data); if (this.backgroundWorker1.CancellationPending) { e.Cancel = true; return; } Application.DoEvents(); Thread.Sleep(500); if (!Global.serviceanalysed) { so.diagonise(); } int j = 0; for (int i = 0; i < so.LstServices.Items.Count; i++) { if (so.LstServices.Items[i].Checked) { j++; } } so.Fix(); data.Add("linklabel4.text", j.ToString() + " Services Optimized"); data["picturebox14.visible"] = "false"; data["linklabel4.visible"] = "true"; data["linklabel4.enabled"] = "false"; backgroundWorker1.ReportProgress(70, data); Thread.Sleep(500); } if (checkBox5.Checked) { DialogResult dlogResult = MessageBox.Show("Registry Defragmentation Analysis is a system intensive process. Please close your other windows. Your computer may not resond for several minutes while the scan is being completed. \n\n Do you wish to CONTINUE?", "Contine with Registry Defragmentation!", MessageBoxButtons.YesNo); if (dlogResult == DialogResult.Yes) { data["label8.visible"] = "false"; backgroundWorker1.ReportProgress(70, data); data.Add("linklabel7.Visible", "false"); backgroundWorker1.ReportProgress(70, data); if (this.backgroundWorker1.CancellationPending) { e.Cancel = true; return; } Application.DoEvents(); rd.defrag(); data["linklabel7.visible"] = "true"; data.Add("linklabel7.text", "Defragmentation\nComplete"); data["linklabel7.enabled"] = "false"; backgroundWorker1.ReportProgress(100, data); DialogResult dialogResult = MessageBox.Show("Restart Required to complete Registry Defragmentation. Do you want to restart NOW?", "Restart Required!", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { PCS.process("shutdown.exe", "-r -t 0", true); Thread.Sleep(1000); Application.Exit(); } } } data["button2.enabled"] = "true"; data["button1.visible"] = "false"; data["button2.text"] = "Close"; backgroundWorker1.ReportProgress(100, data); log.WriteLog("Maintainer Analysis end"); }