public static void clean(TreeView treeView1, Label label1, TextBox textBox1) { log.WriteLog("Maintainer Diskclean clean start"); string series = null; if (treeView1.Nodes.Count == 0) { DiskCleaner.read_cleaners(treeView1, "blb\\Bleachbit.ini"); } for (int x = 0; x < treeView1.Nodes.Count; x++) { for (int y = 0; y < treeView1.Nodes[x].Nodes.Count; y++) { if (treeView1.Nodes[x].Nodes[y].Checked) { series = series + " " + treeView1.Nodes[x].Nodes[y].Tag; } } } ProcessStartInfo startInfo1 = new ProcessStartInfo("blb\\bleachbit_console.exe"); startInfo1.UseShellExecute = false; startInfo1.RedirectStandardInput = true; startInfo1.RedirectStandardOutput = true; startInfo1.Arguments = "--clean " + series; startInfo1.CreateNoWindow = true; startInfo1.WindowStyle = ProcessWindowStyle.Hidden; Process process1 = new Process(); process1.StartInfo = startInfo1; process1.Start(); List <string> output1 = new List <string>(); string lineVal1 = process1.StandardOutput.ReadLine(); string rem = null; string saved = ""; while (lineVal1 != null) { rem = rem + "\r\n" + lineVal1; output1.Add(lineVal1); lineVal1 = process1.StandardOutput.ReadLine(); Application.DoEvents(); } if (output1.Count > 4) { for (int s = 4; s > 1; s--) { if (output1[output1.Count - s].Length > 22) { if (output1[output1.Count - s].Substring(0, 22) == "Disk space recovered: ") { saved = output1[output1.Count - s].Substring(22); } } } } Global.cleanupsize = saved; log.WriteLog("Maintainer Diskclean clean end"); }
public DiskCleanList() { InitializeComponent(); DiskCleaner.read_cleaners(treeView1, "blb\\Bleachbit.ini"); }
public static void analyse(TreeView treeView1, Label label1, TextBox textBox1, TextBox textBox2) { log.WriteLog("Maintainer Diskclean analysis start"); string series = null; if (treeView1.Nodes.Count == 0) { DiskCleaner.read_cleaners(treeView1, "blb\\Bleachbit.ini"); List <string> searchstring = new List <string>(); if (_fieldsTreeCache.Nodes.Count == 0) { foreach (TreeNode node in treeView1.Nodes) { _fieldsTreeCache.Nodes.Add((TreeNode)node.Clone()); } } treeView1.BeginUpdate(); treeView1.Nodes.Clear(); textBox2.Text = Global.cleanertext; Global.cleanertext = string.Empty; if (textBox2.Text != string.Empty) { for (int x = 0; x < _fieldsTreeCache.Nodes.Count; x++) { Match m1 = Regex.Match(_fieldsTreeCache.Nodes[x].Text, textBox2.Text, RegexOptions.IgnoreCase); if (m1.Success) { for (int y = 0; y < _fieldsTreeCache.Nodes[x].Nodes.Count; y++) { searchstring.Add(_fieldsTreeCache.Nodes[x].Nodes[y].Tag.ToString()); } } else { for (int y = 0; y < _fieldsTreeCache.Nodes[x].Nodes.Count; y++) { Match m = Regex.Match(_fieldsTreeCache.Nodes[x].Nodes[y].Tag.ToString(), textBox2.Text, RegexOptions.IgnoreCase); Match m2 = Regex.Match(_fieldsTreeCache.Nodes[x].Nodes[y].Text, textBox2.Text, RegexOptions.IgnoreCase); if (m.Success) { searchstring.Add(_fieldsTreeCache.Nodes[x].Nodes[y].Tag.ToString()); } else if (m2.Success) { searchstring.Add(_fieldsTreeCache.Nodes[x].Nodes[y].Tag.ToString()); } else { } } } } DiskCleaner.search_cleaners(treeView1, "blb\\Bleachbit.ini", searchstring); searchstring.Clear(); treeView1.ExpandAll(); } else { foreach (TreeNode _node in _fieldsTreeCache.Nodes) { treeView1.Nodes.Add((TreeNode)_node.Clone()); } treeView1.CheckBoxes = true; } //enables redrawing tree after all objects have been added treeView1.EndUpdate(); } for (int x = 0; x < treeView1.Nodes.Count; x++) { for (int y = 0; y < treeView1.Nodes[x].Nodes.Count; y++) { if (treeView1.Nodes[x].Nodes[y].Checked) { series = series + " " + treeView1.Nodes[x].Nodes[y].Tag; } } } try { ProcessStartInfo startInfo1 = new ProcessStartInfo("blb\\bleachbit_console.exe"); startInfo1.UseShellExecute = false; startInfo1.RedirectStandardInput = true; startInfo1.RedirectStandardOutput = true; startInfo1.Arguments = "--preview " + series; startInfo1.CreateNoWindow = true; startInfo1.WindowStyle = ProcessWindowStyle.Hidden; Process process1 = new Process(); process1.StartInfo = startInfo1; process1.Start(); List <string> output1 = new List <string>(); string lineVal1 = process1.StandardOutput.ReadLine(); string rem = null; string saved = ""; while (lineVal1 != null) { rem = rem + "\r\n" + lineVal1; output1.Add(lineVal1); lineVal1 = process1.StandardOutput.ReadLine(); Application.DoEvents(); } if (output1.Count > 4) { for (int s = 4; s > 1; s--) { if (output1[output1.Count - s].Length > 28) { if (output1[output1.Count - s].Substring(0, 28) == "Disk space to be recovered: ") { saved = output1[output1.Count - s].Substring(28); } } } } label1.Text = "Recoverable Size: " + saved; Global.cleanupsize = saved; textBox1.Text = rem; textBox1.SelectionStart = textBox1.Text.Length; textBox1.ScrollToCaret(); } catch { } log.WriteLog("Maintainer Diskclean analysis end"); }
public void filter_cleaners(TreeView treeView1, List <string> searchstring, TextBox textBox1, PictureBox pictureBox1) { //blocks repainting tree till all objects loaded treeView1.BeginUpdate(); treeView1.Nodes.Clear(); if (textBox1.Text != string.Empty) { pictureBox1.Image = global::pcsm.Properties.Resources.x; for (int x = 0; x < DiskCleaner._fieldsTreeCache.Nodes.Count; x++) { Match m1 = Regex.Match(DiskCleaner._fieldsTreeCache.Nodes[x].Text, textBox1.Text, RegexOptions.IgnoreCase); if (m1.Success) { for (int y = 0; y < DiskCleaner._fieldsTreeCache.Nodes[x].Nodes.Count; y++) { searchstring.Add(DiskCleaner._fieldsTreeCache.Nodes[x].Nodes[y].Tag.ToString()); } } else { for (int y = 0; y < DiskCleaner._fieldsTreeCache.Nodes[x].Nodes.Count; y++) { Match m = Regex.Match(DiskCleaner._fieldsTreeCache.Nodes[x].Nodes[y].Tag.ToString(), textBox1.Text, RegexOptions.IgnoreCase); Match m2 = Regex.Match(DiskCleaner._fieldsTreeCache.Nodes[x].Nodes[y].Text, textBox1.Text, RegexOptions.IgnoreCase); if (m.Success) { searchstring.Add(DiskCleaner._fieldsTreeCache.Nodes[x].Nodes[y].Tag.ToString()); } else if (m2.Success) { searchstring.Add(DiskCleaner._fieldsTreeCache.Nodes[x].Nodes[y].Tag.ToString()); } else { } } } } DiskCleaner.search_cleaners(treeView1, "blb\\Bleachbit.ini", searchstring); searchstring.Clear(); treeView1.ExpandAll(); } else { pictureBox1.Image = global::pcsm.Properties.Resources.q; DiskCleaner._fieldsTreeCache.Nodes.Clear(); DiskCleaner.read_cleaners(DiskCleaner._fieldsTreeCache, "blb\\Bleachbit.ini"); foreach (TreeNode _node in DiskCleaner._fieldsTreeCache.Nodes) { treeView1.Nodes.Add((TreeNode)_node.Clone()); } DiskCleaner.selectionload(treeView1, "blb\\Bleachbit.ini"); } //enables redrawing tree after all objects have been added treeView1.EndUpdate(); }