예제 #1
0
        private void StardLifeSearch()
        {
            SuitFiles = new List <string>();
            ProgramsView.Items.Clear();
            try
            {
                for (int i = 0; i < Files.Count; i++)
                {
                    if (Regex.IsMatch(Files[i].Name, Sourcer.ArrayToString(Regex.Replace(CommandBox.Text, "(^|^\\s+)-\\s+", "").Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries), ' '), RegexOptions.IgnoreCase))
                    {
                        var some      = new FileToImageIconConverter(Files[i].FullName);
                        var imgSource = some.Icon;

                        var stItem = new StackPanel()
                        {
                            Orientation = Orientation.Horizontal
                        };

                        stItem.Children.Add(new Image()
                        {
                            Source = imgSource,
                            Margin = new Thickness(20, 5, 20, 5),
                            Width  = 20,
                            Height = 20
                        });

                        stItem.Children.Add(new TextBlock()
                        {
                            Text       = Files[i].Name,
                            FontFamily = new FontFamily("Bahnschrift"),
                            Margin     = new Thickness(20, 5, 20, 5)
                        });

                        ProgramsView.Items.Add(stItem);
                        SuitFiles.Add(Files[i].FullName);
                    }
                }
            }
            catch { }
        }
예제 #2
0
        private void StartSearch()
        {
            SuitFiles = new List <string>();

            ProgramsView.Items.Clear();

            try
            {
                int startIndex = 0, endIndex = 0;
                var expression = Regex.Replace(CommandBox.Text, "^\\s*(search|find)", "");
                var tokens     = expression.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                for (int i = 0; i < tokens.Length; i++)
                {
                    if (tokens[i] != tokens[i].Replace(":\\", ""))
                    {
                        startIndex = i;
                    }
                    if (Regex.IsMatch(tokens[i], ":$"))
                    {
                        endIndex = i;
                    }
                }

                var folder = tokens[startIndex];
                for (int i = startIndex + 1; i <= endIndex; i++)
                {
                    folder += " " + tokens[i];
                }

                var pattern = tokens[endIndex + 1];
                for (int i = endIndex + 2; i < tokens.Length; i++)
                {
                    pattern += " " + tokens[i];
                }

                folder = Regex.Replace(folder, ":$", "");
                var files = FileSearcher.GetFilesFast(folder, pattern);

                for (int i = 0; i < files.Count; i++)
                {
                    var some      = new FileToImageIconConverter(files[i].FullName);
                    var imgSource = some.Icon;

                    var stItem = new StackPanel()
                    {
                        Orientation = Orientation.Horizontal
                    };

                    stItem.Children.Add(new Image()
                    {
                        Source = imgSource,
                        Margin = new Thickness(20, 5, 20, 5),
                        Width  = 20,
                        Height = 20
                    });

                    stItem.Children.Add(new TextBlock()
                    {
                        Text       = files[i].Name,
                        FontFamily = new FontFamily("Bahnschrift"),
                        Margin     = new Thickness(20, 5, 20, 5)
                    });

                    ProgramsView.Items.Add(stItem);
                    SuitFiles.Add(files[i].FullName);
                }
            }
            catch
            {
            }
        }