Example #1
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);
            }
        }
Example #2
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;
        }
        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;
        }