private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { string notify = PCS.IniReadValue(Global.system + "settings\\downloadsettings.ini", "schedule", "notification"); if (notify == "true") { this.notifyIcon1.ShowBalloonTip(6000, "Performance Maintainer", "Maintenance Complete! \n\n Files Defragmented:" + Global.defragmented + "\n Disk Space Recovered: " + Global.cleanupsize + "\n Registry Problems Cleared: " + Global.registry, ToolTipIcon.Info); } notifyIcon1.Text = "Maintenance Complete!"; FormCollection fc = Application.OpenForms; bool closesignal = true; foreach (Form frm in fc) { if (frm.Name == "Options") { closesignal = false; break; } } if (closesignal) { Application.DoEvents(); System.Threading.Thread.Sleep(10000); this.Close(); } else { button2.Text = "Close"; } }
public bool selection(string cleanername) { string readselection = PCS.IniReadValue(Global.system + "blb\\Bleachbit.ini", "tree", cleanername); if (readselection == "0") { return(false); } else { return(true); } }
public static bool secselection(string cleanername, string settingsfile) { string readselection = PCS.IniReadValue(settingsfile, "tree", cleanername); if (readselection == "False") { return(false); } else { return(true); } }
private void Main_Load(object sender, EventArgs e) { //this.Hide(); //this.WindowState = FormWindowState.Minimized; foreach (string arg in Environment.GetCommandLineArgs()) { if (arg == "/S") { this.Hide(); } } log.WriteLog("Maintainer Started"); PCS pcs = new PCS(); string regclean = PCS.IniReadValue(Global.system + "settings\\downloadsettings.ini", "schedule", "regclean"); if (regclean == "true") { checkBox1.Checked = true; } string diskclean = PCS.IniReadValue(Global.system + "settings\\downloadsettings.ini", "schedule", "diskclean"); if (diskclean == "true") { checkBox2.Checked = true; } string diskdefrag = PCS.IniReadValue(Global.system + "settings\\downloadsettings.ini", "schedule", "diskdefrag"); if (diskdefrag == "true") { checkBox3.Checked = true; } }
public static void analyse(System.Windows.Forms.DataVisualization.Charting.Chart chart1) { log.WriteLog("Maintainer Registry Optimize analyse start"); chart1.Series.Clear(); PCS.process("lro\\lro.exe", " /analyse", false); string oldregistrysize = PCS.IniReadValue("settings\\regdefragresult.ini", "main", "oldregistrysize"); string newregistrysize = PCS.IniReadValue("settings\\regdefragresult.ini", "main", "newregistrysize"); string diffregistrysize = PCS.IniReadValue("settings\\regdefragresult.ini", "main", "diffregistrysize"); Global.newRegistrySize = Convert.ToDouble(newregistrysize); Global.oldRegistrySize = Convert.ToDouble(oldregistrysize); System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series(); series1.BackGradientStyle = System.Windows.Forms.DataVisualization.Charting.GradientStyle.DiagonalLeft; series1.ChartArea = "ChartArea1"; series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Pie; series1.Legend = "Legend1"; series1.Name = "Series1"; series1.Points.AddXY("Registry Size: " + newregistrysize + " MB", Convert.ToDouble(newregistrysize)); series1.Points.AddXY("Size Saving: " + diffregistrysize + " MB", Convert.ToDouble(diffregistrysize)); chart1.Series.Add(series1); chart1.Series[0]["PieLabelStyle"] = "Disabled"; log.WriteLog("Maintainer Registry Optimize analyse end"); }
public void read_defragsettings(bool silent) { string optimize = PCS.IniReadValue(Global.system + "settings\\defragsettings.ini", "main", "optimize"); if (optimize == "True") { checkBox1.CheckState = CheckState.Checked; } else { checkBox1.CheckState = CheckState.Unchecked; } string optimizemft = PCS.IniReadValue(Global.system + "settings\\defragsettings.ini", "main", "optimizemft"); if (optimizemft == "True") { checkBox2.CheckState = CheckState.Checked; } else { checkBox2.CheckState = CheckState.Unchecked; } string fixeddrives = dataGridView1.Rows.Count.ToString(); string settingsfixeddrives = PCS.IniReadValue(Global.system + "settings\\defragsettings.ini", "main", "fixeddrives"); if (fixeddrives == settingsfixeddrives) { for (int j = 0; j < dataGridView1.Rows.Count; j++) { string settingsdrive = PCS.IniReadValue(Global.system + "settings\\defragsettings.ini", j.ToString(), "drivename"); string detecteddrive = this.dataGridView1.Rows[j].Cells[1].Value.ToString().Substring(0, 2); if (settingsdrive == detecteddrive) { string drivechecked = PCS.IniReadValue(Global.system + "settings\\defragsettings.ini", j.ToString(), "checked"); if (drivechecked == "True") { this.dataGridView1.Rows[j].Cells[0].Value = true; } else { this.dataGridView1.Rows[j].Cells[0].Value = false; } } else { if (silent == false) { MessageBox.Show("Drive Configurations has been changed. Rewriting Configuration."); } save_defragsettings(); } } } else { if (silent == false) { MessageBox.Show("Drive Configurations has been changed. Rewriting Configuration."); } save_defragsettings(); } }
public void start_repair() { 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("label4.visible", "true"); data.Add("label6.visible", "true"); data.Add("label7.visible", "true"); data.Add("label8.visible", "true"); backgroundWorker1.ReportProgress(5, data); string notify = PCS.IniReadValue(Global.system + "settings\\downloadsettings.ini", "schedule", "notification"); if (checkBox1.Checked) { if (notify == "true") { this.notifyIcon1.ShowBalloonTip(6000, "Performance Maintainer", "Cleaning Registry Problems...", ToolTipIcon.Info); } notifyIcon1.Text = "Cleaning Registry Problems..."; data["label4.visible"] = "false"; backgroundWorker1.ReportProgress(10, data); data.Add("linklabel5.visible", "false"); data.Add("picturebox11.visible", "true"); backgroundWorker1.ReportProgress(10, data); 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) { if (notify == "true") { this.notifyIcon1.ShowBalloonTip(6000, "Performance Maintainer", "Performing Disk Cleanup...", ToolTipIcon.Info); } notifyIcon1.Text = "Performing Disk Cleanup..."; data["label6.visible"] = "false"; backgroundWorker1.ReportProgress(30, data); data.Add("picturebox12.visible", "true"); backgroundWorker1.ReportProgress(30, data); 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) { if (notify == "true") { this.notifyIcon1.ShowBalloonTip(6000, "Performance Maintainer", "Defragmenting Drive...", ToolTipIcon.Info); } notifyIcon1.Text = "Defragmenting Drive..."; 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); 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); } backgroundWorker1.ReportProgress(100, data); log.WriteLog("Maintainer Analysis end"); }
public static void read_defragsettings(DataGridView dataGridView1, CheckBox optimize, CheckBox optimizemft, CheckBox uncompress, string settingsfile, bool silent) { string optimize1 = PCS.IniReadValue(settingsfile, "main", "optimize"); if (optimize1 == "True") { optimize.CheckState = CheckState.Checked; } else { optimize.CheckState = CheckState.Unchecked; } string optimizemft1 = PCS.IniReadValue(settingsfile, "main", "optimizemft"); if (optimizemft1 == "True") { optimizemft.CheckState = CheckState.Checked; } else { optimizemft.CheckState = CheckState.Unchecked; } string uncompress1 = PCS.IniReadValue(settingsfile, "main", "uncompress"); if (uncompress1 == "True") { uncompress.CheckState = CheckState.Checked; } else { uncompress.CheckState = CheckState.Unchecked; } string fixeddrives = dataGridView1.Rows.Count.ToString(); string settingsfixeddrives = PCS.IniReadValue(settingsfile, "main", "fixeddrives"); if (fixeddrives == settingsfixeddrives) { for (int j = 0; j < dataGridView1.Rows.Count; j++) { string settingsdrive = PCS.IniReadValue(settingsfile, j.ToString(), "drivename"); string detecteddrive = dataGridView1.Rows[j].Cells[1].Value.ToString().Substring(0, 2); if (settingsdrive == detecteddrive) { string drivechecked = PCS.IniReadValue(settingsfile, j.ToString(), "checked"); if (drivechecked == "True") { dataGridView1.Rows[j].Cells[0].Value = true; } else { dataGridView1.Rows[j].Cells[0].Value = false; } } else { if (silent == false) { MessageBox.Show("Drive Configurations has been changed. Rewriting Configuration."); } DiskDefragger.save_defragsettings(dataGridView1, optimize, optimizemft, uncompress, settingsfile); } } } else { if (silent == false) { MessageBox.Show("Drive Configurations has been changed. Rewriting Configuration."); } save_defragsettings(dataGridView1, optimize, optimizemft, uncompress, settingsfile); } }
public static void defrag(DataGridView dataGridView1, string settingsfile) { PCS pcs = new PCS(); log.WriteLog("Maintainer DiskDefrag defrag start"); string series = " "; for (int i = 0; i < dataGridView1.Rows.Count; i++) { string driveselection = dataGridView1[0, i].Value.ToString(); if (driveselection == "True") { series = series + dataGridView1[1, i].Value.ToString().Substring(0, 2) + " "; } } string argoptions = " "; string optimize = PCS.IniReadValue(settingsfile, "main", "optimize"); log.WriteLog("Maintainer DiskDefrag defrag optimize: " + optimize); if (optimize == "True") { argoptions = argoptions + "-o "; } string uncompress = PCS.IniReadValue(settingsfile, "main", "uncompress"); log.WriteLog("Maintainer DiskDefrag defrag uncompress: " + uncompress); if (uncompress == "True") { log.WriteLog("Maintainer DiskDefrag defrag uncompress start"); Global.compactstatus = true; try { ProcessStartInfo startInfo1 = new ProcessStartInfo("compact.exe"); startInfo1.UseShellExecute = false; startInfo1.RedirectStandardInput = true; startInfo1.RedirectStandardOutput = true; startInfo1.Arguments = "/u /s /a /q /i *.*"; startInfo1.WorkingDirectory = "c:\\"; startInfo1.CreateNoWindow = true; startInfo1.WindowStyle = ProcessWindowStyle.Hidden; Process process1 = new Process(); process1.StartInfo = startInfo1; process1.Start(); string lineVal = process1.StandardOutput.ReadLine(); while (lineVal != null) { if (lineVal != "") { Global.compactprocess = lineVal; } Application.DoEvents(); lineVal = process1.StandardOutput.ReadLine(); } log.WriteLog("Maintainer DiskDefrag defrag uncompress end"); } catch { } } Global.compactstatus = false; PCS.process("cmd", "/C set UD_TIME_LIMIT=1h 30m && set UD_LOG_FILE_PATH=ud\\d.log && ud\\udefrag.exe -a C:", true); Global.defragmented = pcs.findword("ud\\d.log", "fragmented files", 41); try { ProcessStartInfo startInfo2 = new ProcessStartInfo("ud\\udefrag.exe"); startInfo2.UseShellExecute = false; startInfo2.RedirectStandardInput = true; startInfo2.RedirectStandardOutput = true; startInfo2.Arguments = argoptions + series; startInfo2.CreateNoWindow = true; startInfo2.WindowStyle = ProcessWindowStyle.Hidden; Process process2 = new Process(); process2.StartInfo = startInfo2; process2.Start(); string lineVal2 = process2.StandardOutput.ReadLine(); while (lineVal2 != null) { if (lineVal2.Length > 14) { string checkanalyse = lineVal2.Substring(3, 8); if (checkanalyse != "analyse:") { Global.diskdefragdrive = lineVal2.Substring(0, 2); Global.diskdefragprogress = lineVal2.Substring(14, 2); } } Application.DoEvents(); lineVal2 = process2.StandardOutput.ReadLine(); } log.WriteLog("Maintainer DiskDefrag defrag uncompress end"); } catch { } string optimizemft = PCS.IniReadValue(settingsfile, "main", "optimizemft"); log.WriteLog("Maintainer DiskDefrag defrag optimizemft: " + optimizemft); if (optimizemft == "True") { log.WriteLog("Maintainer DiskDefrag defrag optimizemft start"); try { ProcessStartInfo startInfo3 = new ProcessStartInfo("ud\\udefrag.exe"); startInfo3.UseShellExecute = false; startInfo3.RedirectStandardInput = true; startInfo3.RedirectStandardOutput = true; startInfo3.Arguments = " --optimize-mft " + series; startInfo3.CreateNoWindow = true; startInfo3.WindowStyle = ProcessWindowStyle.Hidden; Process process3 = new Process(); process3.StartInfo = startInfo3; process3.Start(); string lineVal1 = process3.StandardOutput.ReadLine(); while (lineVal1 != null) { if (lineVal1.Length > 14) { string checkanalyse = lineVal1.Substring(3, 8); if (checkanalyse != "analyse:") { Global.diskdefragdrive = lineVal1.Substring(0, 2); Global.diskdefragprogress = lineVal1.Substring(14, 2); } } Application.DoEvents(); lineVal1 = process3.StandardOutput.ReadLine(); } } catch { } log.WriteLog("Maintainer DiskDefrag defrag optimizemft end"); } }