示例#1
0
        public static bool HandleRule(SearchResult searchResult, string command = "")
        {
            if (Properties.Settings.Default.isAutoApplyRules && string.IsNullOrEmpty(command))
            {
                foreach (Rule r in LoadRules())
                {
                    bool regexCond = !string.IsNullOrEmpty(r.Expression) && Regex.IsMatch(searchResult.FullPathAndFileName, r.Expression);
                    bool typeCond  = searchResult.IsFile && r.Type != FileType.Folder || !searchResult.IsFile && r.Type != FileType.File;
                    if (regexCond && typeCond)
                    {
                        command = r.Command;
                    }
                }
            }

            if (!string.IsNullOrEmpty(command))
            {
                command = command.Replace("%file%", "\"" + searchResult.FullPathAndFileName + "\"");
                command = command.Replace("%filename%", "\"" + searchResult.FileName + "\"");
                command = command.Replace("%path%", "\"" + searchResult.Path + "\"");
                try
                {
                    ShellUtils.CreateProcessFromCommandLine(command);
                    return(true);
                }
                catch (Win32Exception)
                {
                    MessageBox.Show("Failed to run command " + command);
                }
            }

            return(false);
        }
示例#2
0
 public void OpenPath()
 {
     try
     {
         ShellUtils.CreateProcessFromCommandLine("explorer.exe /select,\"" + FullPathAndFileName + "\"");
         EverythingSearch.Instance.IncrementRunCount(FullPathAndFileName);
     }
     catch (Exception e)
     {
         ToolbarLogger.GetLogger("EverythingToolbar").Error(e, "Failed to open path.");
         MessageBox.Show("Failed to open path.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }