Exemplo n.º 1
0
        private void lbxFolders_Drop(object sender, System.Windows.DragEventArgs e)
        {
            string[] files = (string[])e.Data.GetData(System.Windows.DataFormats.FileDrop);

            if (files != null && files.Count() > 0)
            {
                if (FolderStorage.Instance.FolderLinks == null)
                {
                    FolderStorage.Instance.FolderLinks = new List <FolderLink>();
                }

                foreach (string s in files)
                {
                    if (System.IO.Directory.Exists(s) == true)
                    {
                        var newFolder = new FolderLink()
                        {
                            Path = s
                        };

                        FolderStorage.Instance.FolderLinks.Add(newFolder);
                        FolderStorage.Instance.Save();
                    }

                    lbxFolders.Items.Refresh();
                }
            }
        }
Exemplo n.º 2
0
        private void lbxFolders_Drop(object sender, DragEventArgs e)
        {
            string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);

            if (files != null && files.Count() > 0)
            {
                if (_settings.FolderLinks == null)
                {
                    _settings.FolderLinks = new List <FolderLink>();
                }

                foreach (string s in files)
                {
                    if (Directory.Exists(s))
                    {
                        var newFolder = new FolderLink
                        {
                            Path = s
                        };

                        _settings.FolderLinks.Add(newFolder);
                    }

                    lbxFolders.Items.Refresh();
                }
            }
        }
Exemplo n.º 3
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            var folderBrowserDialog = new FolderBrowserDialog();
            if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
            {
                var newFolder = new FolderLink
                {
                    Path = folderBrowserDialog.SelectedPath
                };

                if (_settings.FolderLinks == null)
                {
                    _settings.FolderLinks = new List<FolderLink>();
                }

                _settings.FolderLinks.Add(newFolder);
            }

            lbxFolders.Items.Refresh();
        }
Exemplo n.º 4
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            var folderBrowserDialog = new VistaFolderBrowserDialog();

            if (folderBrowserDialog.ShowDialog() == true)
            {
                var newFolder = new FolderLink
                {
                    Path = folderBrowserDialog.SelectedPath
                };

                if (_settings.FolderLinks == null)
                {
                    _settings.FolderLinks = new List <FolderLink>();
                }

                _settings.FolderLinks.Add(newFolder);
            }

            lbxFolders.Items.Refresh();
        }
Exemplo n.º 5
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            var folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog();
            if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                var newFolder = new FolderLink()
                {
                    Path = folderBrowserDialog.SelectedPath
                };

                if (FolderStorage.Instance.FolderLinks == null)
                {
                    FolderStorage.Instance.FolderLinks = new List<FolderLink>();
                }

                FolderStorage.Instance.FolderLinks.Add(newFolder);
                FolderStorage.Instance.Save();
            }

            lbxFolders.Items.Refresh();
        }
Exemplo n.º 6
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            var folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog();

            if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                var newFolder = new FolderLink()
                {
                    Path = folderBrowserDialog.SelectedPath
                };

                if (FolderStorage.Instance.FolderLinks == null)
                {
                    FolderStorage.Instance.FolderLinks = new List <FolderLink>();
                }

                FolderStorage.Instance.FolderLinks.Add(newFolder);
                FolderStorage.Instance.Save();
            }

            lbxFolders.Items.Refresh();
        }
Exemplo n.º 7
0
        private void lbxFolders_Drop(object sender, System.Windows.DragEventArgs e)
        {
            string[] files = (string[])e.Data.GetData(System.Windows.DataFormats.FileDrop);

            if (files != null && files.Count() > 0)
            {
                if (FolderStorage.Instance.FolderLinks == null)
                {
                    FolderStorage.Instance.FolderLinks = new List<FolderLink>();
                }

                foreach (string s in files)
                {
                    if (System.IO.Directory.Exists(s) == true)
                    {
                        var newFolder = new FolderLink()
                        {
                            Path = s
                        };

                        FolderStorage.Instance.FolderLinks.Add(newFolder);
                        FolderStorage.Instance.Save();
                    }

                    lbxFolders.Items.Refresh();
                }
            }
        }
Exemplo n.º 8
0
        private void lbxFolders_Drop(object sender, DragEventArgs e)
        {
            string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);

            if (files != null && files.Count() > 0)
            {
                if (_settings.FolderLinks == null)
                {
                    _settings.FolderLinks = new List<FolderLink>();
                }

                foreach (string s in files)
                {
                    if (Directory.Exists(s))
                    {
                        var newFolder = new FolderLink
                        {
                            Path = s
                        };

                        _settings.FolderLinks.Add(newFolder);
                    }

                    lbxFolders.Items.Refresh();
                }
            }
        }
Exemplo n.º 9
0
        private List<Result> QueryInternal_Directory_Exists(Query query)
        {
            var search = query.Search.ToLower();
            var results = new List<Result>();

            string incompleteName = "";
            if (!Directory.Exists(search + "\\"))
            {
                //if the last component of the path is incomplete,
                //then make auto complete for it.
                int index = search.LastIndexOf('\\');
                if (index > 0 && index < (search.Length - 1))
                {
                    incompleteName = search.Substring(index + 1);
                    incompleteName = incompleteName.ToLower();
                    search = search.Substring(0, index + 1);
                    if (!Directory.Exists(search))
                        return results;
                }
                else
                    return results;
            }
            else
            {
                if (!search.EndsWith("\\"))
                    search += "\\";
            }

            string firstResult = "Open current directory";
            if (incompleteName.Length > 0)
                firstResult = "Open " + search;
            results.Add(new Result
            {
                Title = firstResult,
                IcoPath = search,
                Score = 10000,
                Action = c =>
                {
                    Process.Start(search);
                    return true;
                }
            });

            // the string that matches the result's title
            string searchNickname = new FolderLink { Path = query.Search }.Nickname;

            //Add children directories
            DirectoryInfo[] dirs = new DirectoryInfo(search).GetDirectories();
            foreach (DirectoryInfo dir in dirs)
            {
                if ((dir.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) continue;

                if (incompleteName.Length != 0 && !dir.Name.ToLower().StartsWith(incompleteName))
                    continue;
                DirectoryInfo dirCopy = dir;
                var result = new Result
                {
                    Title = dir.Name,
                    IcoPath = dir.FullName,
                    SubTitle = "Ctrl + Enter to open the directory",
                    TitleHighlightData = StringMatcher.Match(dir.Name, searchNickname).MatchData,
                    Action = c =>
                    {
                        if (c.SpecialKeyState.CtrlPressed)
                        {
                            try
                            {
                                Process.Start(dirCopy.FullName);
                                return true;
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message, "Could not start " + dirCopy.FullName);
                                return false;
                            }
                        }
                        _context.API.ChangeQuery($"{query.ActionKeyword} {dirCopy.FullName}\\");
                        return false;
                    }
                };

                results.Add(result);
            }

            //Add children files
            FileInfo[] files = new DirectoryInfo(search).GetFiles();
            foreach (FileInfo file in files)
            {
                if ((file.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) continue;
                if (incompleteName.Length != 0 && !file.Name.ToLower().StartsWith(incompleteName))
                    continue;
                string filePath = file.FullName;
                var result = new Result
                {
                    Title = Path.GetFileName(filePath),
                    IcoPath = filePath,
                    TitleHighlightData = StringMatcher.Match(file.Name, searchNickname).MatchData,
                    Action = c =>
                    {
                        try
                        {
                            Process.Start(filePath);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message, "Could not start " + filePath);
                        }

                        return true;
                    }
                };

                results.Add(result);
            }

            return results;
        }