Exemple #1
0
 internal void Remove(Result result)
 {
     if (records.ContainsKey(result.OriginQuery.RawQuery))
     {
         records.Remove(result.OriginQuery.RawQuery);
     }
 }
Exemple #2
0
 internal bool IsTopMost(Result result)
 {
     return records.Any(o => o.Value.Title == result.Title
         && o.Value.SubTitle == result.SubTitle
         && o.Value.PluginID == result.PluginID
         && o.Key == result.OriginQuery.RawQuery);
 }
Exemple #3
0
 public ResultViewModel(Result result)
 {
     if (result != null)
     {
         Result = result;
     }
 }
Exemple #4
0
 public int GetSelectedCount(Result result)
 {
     if (records.ContainsKey(result.ToString()))
     {
         return records[result.ToString()];
     }
     return 0;
 }
Exemple #5
0
 public void Add(Result result)
 {
     if (records.ContainsKey(result.ToString()))
     {
         records[result.ToString()] += 1;
     }
     else
     {
         records.Add(result.ToString(), 1);
     }
 }
Exemple #6
0
        public Wox.Plugin.Result Create(IPublicAPI contextApi)
        {
            var result = new Wox.Plugin.Result(StringMatcher.FuzzySearch(Search, Path.GetFileName(FilePath)).MatchData)
            {
                Title       = Title,
                SubTitle    = string.Format(CultureInfo.CurrentCulture, Properties.Resources.wox_plugin_folder_select_file_result_subtitle, FilePath),
                IcoPath     = FilePath,
                Action      = c => ShellAction.Execute(FilePath, contextApi),
                ContextData = new SearchResult {
                    Type = ResultType.File, FullPath = FilePath
                },
            };

            return(result);
        }
Exemple #7
0
        public Wox.Plugin.Result Create(IPublicAPI contextApi)
        {
            var result = new Wox.Plugin.Result
            {
                Title              = Title,
                SubTitle           = "Folder: " + FilePath,
                IcoPath            = FilePath,
                TitleHighlightData = StringMatcher.FuzzySearch(Search, Path.GetFileName(FilePath)).MatchData,
                Action             = c => ExplorerAction.Execute(FilePath, contextApi),
                ContextData        = new SearchResult {
                    Type = ResultType.File, FullPath = FilePath
                },
            };

            return(result);
        }
Exemple #8
0
 internal void AddOrUpdate(Result result)
 {
     if (records.ContainsKey(result.OriginQuery.RawQuery))
     {
         records[result.OriginQuery.RawQuery].Title = result.Title;
         records[result.OriginQuery.RawQuery].SubTitle = result.SubTitle;
         records[result.OriginQuery.RawQuery].PluginID = result.PluginID;
     }
     else
     {
         records.Add(result.OriginQuery.RawQuery, new Record
         {
             PluginID = result.PluginID,
             Title = result.Title,
             SubTitle = result.SubTitle
         });
     }
 }
Exemple #9
0
        public ResultViewModel(Result result)
        {
            if (result != null)
            {
                RawResult = result;

                OpenResultListBoxItemCommand = new RelayCommand(_ =>
                {

                    bool hideWindow = result.Action(new ActionContext
                    {
                        SpecialKeyState = GlobalHotkey.Instance.CheckModifiers()
                    });

                    if (hideWindow)
                    {
                        App.API.HideApp();
                        UserSelectedRecordStorage.Instance.Add(RawResult);
                        QueryHistoryStorage.Instance.Add(RawResult.OriginQuery.RawQuery);
                    }
                });

                OpenContextMenuItemCommand = new RelayCommand(_ =>
                {

                    var actions = PluginManager.GetContextMenusForPlugin(result);

                    var pluginMetaData = PluginManager.GetPluginForId(result.PluginID).Metadata;
                    actions.ForEach(o =>
                    {
                        o.PluginDirectory = pluginMetaData.PluginDirectory;
                        o.PluginID = result.PluginID;
                        o.OriginQuery = result.OriginQuery;
                    });

                    actions.Add(GetTopMostContextMenu(result));

                    App.API.ShowContextMenu(pluginMetaData, actions);

                });
            }
        }
Exemple #10
0
 private Result GetTopMostContextMenu(Result result)
 {
     if (TopMostRecordStorage.Instance.IsTopMost(result))
     {
         return new Result(InternationalizationManager.Instance.GetTranslation("cancelTopMostInThisQuery"), "Images\\down.png")
         {
             PluginDirectory = WoxDirectroy.Executable,
             Action = _ =>
             {
                 TopMostRecordStorage.Instance.Remove(result);
                 App.API.ShowMsg("Succeed", "", "");
                 return false;
             }
         };
     }
     else
     {
         return new Result(InternationalizationManager.Instance.GetTranslation("setAsTopMostInThisQuery"), "Images\\up.png")
         {
             PluginDirectory = WoxDirectroy.Executable,
             Action = _ =>
             {
                 TopMostRecordStorage.Instance.AddOrUpdate(result);
                 App.API.ShowMsg("Succeed", "", "");
                 return false;
             }
         };
     }
 }
Exemple #11
0
 private bool CheckExisted(Result result)
 {
     return pnlContainer.Children.Cast<ResultItem>().Any(child => child.Result.Equals(result));
 }