diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs new file mode 100644 index 000000000..3ee7848d8 --- /dev/null +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs @@ -0,0 +1,59 @@ +using Flow.Launcher.Infrastructure; +using Flow.Launcher.Plugin.SharedCommands; +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows; + +namespace Flow.Launcher.Plugin.Explorer.Search +{ + public class ResultManager + { + public Result CreateFolderResult(string title, string subtitle, string path, Query query) + { + return new Result + { + Title = title, + IcoPath = path, + SubTitle = subtitle, + TitleHighlightData = StringMatcher.FuzzySearch(query.Search, title).MatchData, + Action = c => + { + if (c.SpecialKeyState.CtrlPressed) + { + try + { + FilesFolders.OpenPath(path); + return true; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Could not start " + path); + return false; + } + } + + string changeTo = path.EndsWith("\\") ? path : path + "\\"; + Main.Context.API.ChangeQuery(string.IsNullOrEmpty(query.ActionKeyword) ? + changeTo : + query.ActionKeyword + " " + changeTo); + return false; + }, + ContextData = new SearchResult { Type = ResultType.Folder, FullPath = path } + }; + } + } + + public class SearchResult + { + public string FullPath { get; set; } + public ResultType Type { get; set; } + } + + public enum ResultType + { + Volume, + Folder, + File + } +}