示例#1
0
        public void Add(SearchedFile searchedFile)
        {
            var results = searchedFile.Matches.Select(m => new SearchResultNode(m)).ToList();

            resultNodes.AddRange(results);
            this.fileNodes.Add(new SearchFileNode(searchedFile.FileName, results));
            InvalidateText();
        }
示例#2
0
        private void SearchInRegistry(RegistryKey key, RegistryKey baseKey)
        {
            //Thread.Sleep(1000);
            SearchInDirectory?.Invoke(key.Name);
            RegistryKey startupApprovedKey;

            try
            {
                if (key.Name.Contains("Wow6432Node"))
                {
                    startupApprovedKey = baseKey.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\Run32", true);
                }
                else
                {
                    startupApprovedKey = baseKey.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\Run", true);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                //return;
                startupApprovedKey = null;
            }

            foreach (var item in key.GetValueNames())
            {
                if (item == "")
                {
                    continue;
                }
                StartupFile file     = new StartupFile();
                PathParse   PathInfo = new PathParse(key.GetValue(item).ToString());
                file.Name            = item;
                file.FileName        = PathInfo.Name;
                file.FilePath        = PathInfo.Path;
                file.Params          = PathInfo.Params;
                file.Path            = key.Name;
                file.Icon            = GetIcon(file.FilePath + file.FileName);
                file.ApprovedKeyPath = startupApprovedKey;
                if (startupApprovedKey != null)
                {
                    file.Enabled = GetEnabled(item, startupApprovedKey);
                }

                SearchedFile?.Invoke(file);
                ResultCount++;
            }
            // FilesParse(paths, names, key.Name);
        }
示例#3
0
        private void SearchInStartMenu(string pathStartup, RegistryKey startupApprovedKey)
        {
            //Thread.Sleep(1000);
            SearchInDirectory?.Invoke(pathStartup);
            string[] paths;
            try
            {
                paths = Directory.GetFiles(pathStartup).Where(f => !f.ToLower().EndsWith(".ini")).ToArray();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            IWshShell wsh = new WshShell();

            foreach (var item in paths)
            {
                StartupFile file     = new StartupFile();
                PathParse   PathInfo = new PathParse(item);

                if (item.EndsWith("lnk"))
                {
                    var lnk     = (IWshShortcut)wsh.CreateShortcut(item);
                    var lnkInfo = new PathParse(lnk.TargetPath);
                    file.FileName = lnkInfo.Name;
                    file.Params   = lnk.Arguments;
                    file.FilePath = lnkInfo.Path;
                }
                else
                {
                    file.FileName = PathInfo.Name;
                    file.Params   = PathInfo.Params;
                    file.FilePath = PathInfo.Path;
                }
                file.Name            = PathInfo.Name;
                file.Path            = pathStartup;
                file.Icon            = GetIcon(file.FilePath + file.FileName);
                file.ApprovedKeyPath = startupApprovedKey;
                if (startupApprovedKey != null)
                {
                    file.Enabled = GetEnabled(file.Name, startupApprovedKey);
                }

                SearchedFile?.Invoke(file);
                ResultCount++;
            }
        }
        public void Add(SearchedFile searchedFile)
        {
            var results = searchedFile.Matches.Select(m => new SearchResultNode(m)).ToList();

            resultNodes.AddRange(results);
            this.fileNodes.Add(new SearchFileNode(searchedFile.FileName, results));
            foreach (var g in results.GroupBy(r => SD.ProjectService.FindProjectContainingFile(r.FileName)))
            {
                var p  = projectNodes.FirstOrDefault(n => n.Project == g.Key);
                var p2 = projectAndFileNodes.FirstOrDefault(n => n.Project == g.Key);
                if (p == null)
                {
                    projectNodes.Add(new SearchProjectNode(g.Key, g.OfType <SearchNode>().ToList()));
                }
                else
                {
                    p.Children = new List <SearchNode>(p.Children.Concat(g.AsEnumerable()));
                }
                if (p2 == null)
                {
                    projectAndFileNodes.Add(new SearchProjectNode(g.Key, g.GroupBy(r => r.FileName).Select(g2 => new SearchFileNode(g2.Key, g2.ToList())).OfType <SearchNode>().ToList()));
                }
                else
                {
                    var f = p2.Children.OfType <SearchFileNode>().FirstOrDefault(n => n.FileName == searchedFile.FileName);
                    if (f == null)
                    {
                        var list = new List <SearchNode>(p2.Children);
                        list.Add(new SearchFileNode(searchedFile.FileName, g.ToList()));
                        p2.Children = list;
                    }
                    else
                    {
                        f.Children = new List <SearchNode>(f.Children.Concat(g.AsEnumerable()));
                    }
                }
            }
            InvalidateText();
        }