Exemplo n.º 1
0
 private void btnAddCurrentScan_Click(object sender, EventArgs e)
 {
     if (VSCleanLib.AddCurrentScan())
     {
         LoadSetting();
     }
 }
Exemplo n.º 2
0
        private void btnClean_Click(object sender, EventArgs e)
        {
            if (GetText(btnClean) == "Start")
            {
                VSCleanSetting obj = VSCleanLib.GetCurrentSetting();
                if (obj == null || obj.ExcludePaths == null)
                {
                    return;
                }

                if (obj.ScanPaths == null || obj.ScanPaths.Count == 0)
                {
                    MessageBoxShow("No path to start, add <project>\\bin or <project>\\obj to start");
                    return;
                }
                Stop();
                SetText(btnClean, "Stop");
                Lib        = new VSCleanLib();
                Lib.Report = new Action <List <string>, List <string> >(Report);
                ParameterizedThreadStart ts = new ParameterizedThreadStart(Lib.Clean);
                MainThread = new Thread(ts);
                MainThread.Start(obj);
                Lib.IsRunning = true;
            }
            else if (GetText(btnClean) == "Stop")
            {
                SetText(btnClean, "Start");
                Stop();
            }
        }
Exemplo n.º 3
0
        private void btnScan_Click(object sender, EventArgs e)
        {
            if (Lib != null && Lib.IsRunningScan)
            {
                MessageBoxShow("Scanning is in progress");
                return;
            }
            if (Lib == null)
            {
                Lib = new VSCleanLib();
            }

            Lib.IsRunningScan = true;
            Lib.ScanCompleted = delegate
            {
                MainThread2 = null;
                LoadSetting();
                MessageBoxShow("Scan VS successfully");
            };

            ThreadStart ts = new ThreadStart(Lib.ScanVS);

            MainThread2 = new Thread(ts);
            MainThread2.Start();
        }
Exemplo n.º 4
0
        private void Include(ListView listView, string s)
        {
            if (s == CurrentDirectory)
            {
                s = "";
            }
            VSCleanSetting obj = VSCleanLib.GetCurrentSetting();

            if (VSCleanLib.AddScan(obj, VSCleanLib.GetFilenameAbsolute(s)))
            {
                VSCleanLib.RemoveExclude(obj, VSCleanLib.GetFilenameAbsolute(s));
                VSCleanLib.SaveCurrentSetting(obj);
            }
        }
Exemplo n.º 5
0
        public void ListViewDelete(ListView listView, bool isExclude)
        {
            if (listView.SelectedItems == null || listView.SelectedItems.Count == 0)
            {
                return;
            }
            VSCleanSetting obj = VSCleanLib.GetCurrentSetting();

            for (int i = listView.SelectedItems.Count - 1; i >= 0; i--)
            {
                string strx = listView.SelectedItems[i].Text;
                if (strx == CurrentDirectory)
                {
                    strx = "";
                }

                string str = VSCleanLib.GetFilenameAbsolute(strx);
                if (isExclude)
                {
                    if (VSCleanLib.ContainsExclude(obj, str))
                    {
                        VSCleanLib.RemoveExclude(obj, str);
                    }
                }
                else
                {
                    if (VSCleanLib.ContainsScan(obj, str))
                    {
                        VSCleanLib.RemoveScan(obj, str);
                    }
                }
            }
            if (VSCleanLib.SaveCurrentSetting(obj))
            {
                LoadSetting();
                return;
            }
            MessageBoxShow("Fail removing Path(s)");
            return;
        }
Exemplo n.º 6
0
        private void Menu_Click(object sender, EventArgs e)
        {
            MenuItem mi = (MenuItem)sender;

            object[]      objs     = (object[])mi.Tag;
            ListView      listView = (ListView)objs[0];
            List <string> selected = (List <string>)objs[1];

            if (mi.Text == "Copy")
            {
                List <string> transform = new List <string>();
                foreach (string s in selected)
                {
                    string s2 = s;
                    if (s2 == CurrentDirectory)
                    {
                        s2 = "";
                    }
                    transform.Add(VSCleanLib.GetFilenameAbsolute(s2));
                }
                Clipboard.SetText(string.Join("\r\n", transform));
            }
            else if (mi.Text == "Exclude")
            {
                foreach (string s in selected)
                {
                    Exclude(listView, s);
                }
                LoadSetting();
            }
            else if (mi.Text == "Include")
            {
                foreach (string s in selected)
                {
                    Include(listView, s);
                }
                LoadSetting();
            }
        }
Exemplo n.º 7
0
        private void LoadSetting()
        {
            if (InvokeRequired)
            {
                Invoke(new Action(LoadSetting), null);
                return;
            }
            listView1.Items.Clear();
            VSCleanSetting obj = VSCleanLib.GetCurrentSetting();

            if (obj == null || obj.ExcludePaths == null)
            {
                return;
            }
            foreach (string str in obj.ExcludePaths)
            {
                string f = str;
                if (string.IsNullOrEmpty(f))
                {
                    f = CurrentDirectory;
                }
                listView1.Items.Add(f);
            }

            listView2.Items.Clear();
            if (obj == null || obj.ScanPaths == null)
            {
                return;
            }
            foreach (string str in obj.ScanPaths)
            {
                string f = str;
                if (string.IsNullOrEmpty(f))
                {
                    f = CurrentDirectory;
                }
                listView2.Items.Add(f);
            }
        }
Exemplo n.º 8
0
        public void ListViewMouseDown(ListView listView, MouseEventArgs e)
        {
            bool match = false;

            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                MenuItem[]    mi       = null;
                MenuItem      addNext  = null;
                List <string> selected = new List <string>();
                if (listView.SelectedItems != null)
                {
                    foreach (ListViewItem item in listView.SelectedItems)
                    {
                        selected.Add(item.Text);
                        if (addNext != null)
                        {
                            continue;
                        }

                        if (listView == listView2)
                        {
                            addNext = new MenuItem("Exclude");
                        }
                        else
                        {
                            string s = item.Text;
                            if (s == CurrentDirectory)
                            {
                                s = "";
                            }
                            string path = VSCleanLib.GetFilenameAbsolute(s);
                            if (Directory.Exists(path))
                            {
                                addNext = new MenuItem("Include");
                            }
                        }
                    }
                    if (addNext != null)
                    {
                        mi = new MenuItem[] { new MenuItem("Copy"), addNext }
                    }
                    ;
                    else
                    {
                        mi = new MenuItem[] { new MenuItem("Copy") }
                    };

                    mi[0].Click += Menu_Click;
                    mi[0].Tag    = new object[] { listView, selected };
                    if (mi.Length >= 2)
                    {
                        mi[1].Click += Menu_Click;
                        mi[1].Tag    = new object[] { listView, selected };
                    }
                    listView.ContextMenu = new ContextMenu(mi);
                    match = true;

                    if (match)
                    {
                        listView.ContextMenu.Show(listView, new Point(e.X, e.Y));
                    }
                }
            }
        }
Exemplo n.º 9
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            VSCleanSetting obj = VSCleanLib.GetCurrentSetting();

            if (string.IsNullOrEmpty(txtSubPath.Text))
            {
                return;
            }
            if (obj == null)
            {
                MessageBox.Show("Error reading " + VSCleanLib.SettingFilename);
                return;
            }
            string path      = txtSubPath.Text;
            string checkPath = path.TrimEnd(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar;

            if (checkPath.StartsWith(VSCleanLib.GetWorkingDirectory(), StringComparison.CurrentCultureIgnoreCase) == false)
            {
                MessageBox.Show("Path must be Sub Path from VSClean.exe");
                return;
            }
            if (File.Exists(VSCleanLib.GetFilenameAbsolute(path)) == false && Directory.Exists(VSCleanLib.GetFilenameAbsolute(path)))
            {
                path = path.TrimEnd(new char[] { '\\' }) + "\\";
            }
            if (Exclude == false && Directory.Exists(VSCleanLib.GetFilenameAbsolute(path)) == false)
            {
                MessageBox.Show("Path must be Directory");
                return;
            }

            bool contains = false;

            if (Exclude)
            {
                contains = VSCleanLib.ContainsExclude(obj, path);
            }
            else
            {
                contains = VSCleanLib.ContainsScan(obj, path);
            }
            if (contains)
            {
                MessageBox.Show("Path/File already exist in list");
                return;
            }
            if (Exclude)
            {
                obj.ExcludePaths.Add(VSCleanLib.GetFilenameRelative(path));
            }
            else
            {
                obj.ScanPaths.Add(VSCleanLib.GetFilenameRelative(path));
            }

            if (VSCleanLib.SaveCurrentSetting(obj))
            {
                Close();
                return;
            }
            MessageBox.Show("Fail adding Path to " + VSCleanLib.SettingFilename);
            return;
        }