Ejemplo n.º 1
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();
            }
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
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;
        }
Ejemplo n.º 4
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);
            }
        }
Ejemplo n.º 5
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;
        }