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