Exemple #1
0
        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;
                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();
        }
Exemple #2
0
        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");
        }