diff --git a/Plugins/Wox.Plugin.CMD/CMD.cs b/Plugins/Wox.Plugin.CMD/CMD.cs index 7b100dc6bb..786ad9ab67 100644 --- a/Plugins/Wox.Plugin.CMD/CMD.cs +++ b/Plugins/Wox.Plugin.CMD/CMD.cs @@ -176,7 +176,8 @@ namespace Wox.Plugin.CMD private void OnWinRPressed() { context.API.ShowApp(); - context.API.ChangeQuery(">"); + // todo don't hardcode action keywords. + context.API.ChangeQuery($">{Plugin.Query.TermSeperater}"); } public Control CreateSettingPanel() diff --git a/Plugins/Wox.Plugin.Everything/Everything/EverythingAPI.cs b/Plugins/Wox.Plugin.Everything/Everything/EverythingAPI.cs index 158985e077..2d7a8e01b3 100644 --- a/Plugins/Wox.Plugin.Everything/Everything/EverythingAPI.cs +++ b/Plugins/Wox.Plugin.Everything/Everything/EverythingAPI.cs @@ -227,8 +227,6 @@ namespace Wox.Plugin.Everything.Everything yield break; } - Everything_SortResultsByPath(); - const int bufferSize = 4096; StringBuilder buffer = new StringBuilder(bufferSize); for (int idx = 0; idx < Everything_GetNumResults(); ++idx) diff --git a/Plugins/Wox.Plugin.Everything/Main.cs b/Plugins/Wox.Plugin.Everything/Main.cs index 1a6ed8c6bb..cd80d35c84 100644 --- a/Plugins/Wox.Plugin.Everything/Main.cs +++ b/Plugins/Wox.Plugin.Everything/Main.cs @@ -47,12 +47,6 @@ namespace Wox.Plugin.Everything try { var searchList = api.Search(keyword, maxCount: ContextMenuStorage.Instance.MaxSearchCount).ToList(); - var fuzzyMather = FuzzyMatcher.Create(keyword); - searchList.Sort( - (x, y) => - fuzzyMather.Evaluate(Path.GetFileName(y.FullPath)).Score - - fuzzyMather.Evaluate(Path.GetFileName(x.FullPath)).Score); - foreach (var s in searchList) { var path = s.FullPath; diff --git a/Plugins/Wox.Plugin.Program/Programs.cs b/Plugins/Wox.Plugin.Program/Programs.cs index 8ec1ea9a30..347f640b8a 100644 --- a/Plugins/Wox.Plugin.Program/Programs.cs +++ b/Plugins/Wox.Plugin.Program/Programs.cs @@ -30,24 +30,24 @@ namespace Wox.Plugin.Program { var fuzzyMather = FuzzyMatcher.Create(query.Search); - List returnList = programs.Where(o => MatchProgram(o, fuzzyMather)).ToList(); - returnList.ForEach(ScoreFilter); - returnList = returnList.OrderByDescending(o => o.Score).ToList(); - - return returnList.Select(c => new Result() - { - Title = c.Title, - SubTitle = c.ExecutePath, - IcoPath = c.IcoPath, - Score = c.Score, - ContextData = c, - Action = (e) => - { - context.API.HideApp(); - context.API.ShellRun(c.ExecutePath); - return true; - } - }).ToList(); + var results = programs.Where(o => MatchProgram(o, fuzzyMather)). + Select(ScoreFilter). + OrderByDescending(o => o.Score) + .Select(c => new Result() + { + Title = c.Title, + SubTitle = c.ExecutePath, + IcoPath = c.IcoPath, + Score = c.Score, + ContextData = c, + Action = (e) => + { + context.API.HideApp(); + context.API.ShellRun(c.ExecutePath); + return true; + } + }).ToList(); + return results; } static string ResolveShortcut(string filePath) @@ -60,12 +60,10 @@ namespace Wox.Plugin.Program private bool MatchProgram(Program program, FuzzyMatcher matcher) { - if ((program.Score = matcher.Evaluate(program.Title).Score) > 0) return true; - if ((program.Score = matcher.Evaluate(program.PinyinTitle).Score) > 0) return true; - if (program.AbbrTitle != null && (program.Score = matcher.Evaluate(program.AbbrTitle).Score) > 0) return true; - if (program.ExecuteName != null && (program.Score = matcher.Evaluate(program.ExecuteName).Score) > 0) return true; - - return false; + var scores = new List { program.Title, program.PinyinTitle, program.AbbrTitle, program.ExecuteName }; + program.Score = scores.Select(s => matcher.Evaluate(s ?? string.Empty).Score).Max(); + if (program.Score > 0) return true; + else return false; } public void Init(PluginInitContext context) @@ -161,7 +159,7 @@ namespace Wox.Plugin.Program return list; } - private void ScoreFilter(Program p) + private Program ScoreFilter(Program p) { p.Score += p.Source.BonusPoints; @@ -173,6 +171,7 @@ namespace Wox.Plugin.Program if (p.Title.Contains("卸载") || p.Title.ToLower().Contains("uninstall")) p.Score -= 20; + return p; } #region ISettingProvider Members diff --git a/Plugins/Wox.Plugin.WebSearch/Images/websearch/google.png b/Plugins/Wox.Plugin.WebSearch/Images/google.png similarity index 100% rename from Plugins/Wox.Plugin.WebSearch/Images/websearch/google.png rename to Plugins/Wox.Plugin.WebSearch/Images/google.png diff --git a/Plugins/Wox.Plugin.WebSearch/Images/websearch/pictures.png b/Plugins/Wox.Plugin.WebSearch/Images/pictures.png similarity index 100% rename from Plugins/Wox.Plugin.WebSearch/Images/websearch/pictures.png rename to Plugins/Wox.Plugin.WebSearch/Images/pictures.png diff --git a/Plugins/Wox.Plugin.WebSearch/Images/websearch/wiki.png b/Plugins/Wox.Plugin.WebSearch/Images/wiki.png similarity index 100% rename from Plugins/Wox.Plugin.WebSearch/Images/websearch/wiki.png rename to Plugins/Wox.Plugin.WebSearch/Images/wiki.png diff --git a/Plugins/Wox.Plugin.WebSearch/WebSearchSetting.xaml.cs b/Plugins/Wox.Plugin.WebSearch/WebSearchSetting.xaml.cs index 1c85340f67..4d8ba23014 100644 --- a/Plugins/Wox.Plugin.WebSearch/WebSearchSetting.xaml.cs +++ b/Plugins/Wox.Plugin.WebSearch/WebSearchSetting.xaml.cs @@ -11,7 +11,8 @@ namespace Wox.Plugin.WebSearch { public partial class WebSearchSetting : Window { - private string _defaultWebSearchImageDirectory = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Images\\websearch"); + private const string _imageDirectoryName = "Images"; + private string _pluginDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); private readonly WebSearchesSetting _settingWindow; private bool _isUpdate; private WebSearch _updateWebSearch; @@ -50,7 +51,7 @@ namespace Wox.Plugin.WebSearch private void ShowIcon(string path) { - imgIcon.Source = new BitmapImage(new Uri($"{_defaultWebSearchImageDirectory}\\{path}", UriKind.Absolute)); + imgIcon.Source = new BitmapImage(new Uri(Path.Combine(_pluginDirectory, path), UriKind.Absolute)); } private void BtnCancel_OnClick(object sender, RoutedEventArgs e) @@ -126,15 +127,15 @@ namespace Wox.Plugin.WebSearch private void BtnSelectIcon_OnClick(object sender, RoutedEventArgs e) { - if (!Directory.Exists(_defaultWebSearchImageDirectory)) + if (!Directory.Exists(_pluginDirectory)) { - _defaultWebSearchImageDirectory = + _pluginDirectory = Path.GetDirectoryName(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); } var dlg = new OpenFileDialog { - InitialDirectory = _defaultWebSearchImageDirectory, + InitialDirectory = Path.Combine(_pluginDirectory, _imageDirectoryName), Filter = "Image files (*.jpg, *.jpeg, *.gif, *.png, *.bmp) |*.jpg; *.jpeg; *.gif; *.png; *.bmp" }; @@ -142,8 +143,11 @@ namespace Wox.Plugin.WebSearch if (result == true) { string filename = dlg.FileName; - tbIconPath.Text = Path.GetFileName(filename); - ShowIcon(tbIconPath.Text); + if (filename != null) + { + tbIconPath.Text = Path.Combine(_imageDirectoryName, Path.GetFileName(filename)); + ShowIcon(tbIconPath.Text); + } } } } diff --git a/Plugins/Wox.Plugin.WebSearch/WebSearchStorage.cs b/Plugins/Wox.Plugin.WebSearch/WebSearchStorage.cs index 2f6d92435a..fec8f937a4 100644 --- a/Plugins/Wox.Plugin.WebSearch/WebSearchStorage.cs +++ b/Plugins/Wox.Plugin.WebSearch/WebSearchStorage.cs @@ -41,7 +41,7 @@ namespace Wox.Plugin.WebSearch { Title = "Google", ActionKeyword = "g", - IconPath = @"google.png", + IconPath = @"Images\google.png", Url = "https://www.google.com/search?q={q}", Enabled = true }; @@ -52,7 +52,7 @@ namespace Wox.Plugin.WebSearch { Title = "Wikipedia", ActionKeyword = "wiki", - IconPath = @"wiki.png", + IconPath = @"Images\wiki.png", Url = "http://en.wikipedia.org/wiki/{q}", Enabled = true }; @@ -62,7 +62,7 @@ namespace Wox.Plugin.WebSearch { Title = "FindIcon", ActionKeyword = "findicon", - IconPath = @"pictures.png", + IconPath = @"Images\pictures.png", Url = "http://findicons.com/search/{q}", Enabled = true }; diff --git a/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj b/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj index 9a450b0107..f2a5dd05bf 100644 --- a/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj +++ b/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj @@ -66,7 +66,13 @@ - + + PreserveNewest + + + PreserveNewest + + PreserveNewest @@ -114,16 +120,6 @@ PreserveNewest - - - PreserveNewest - - - - - PreserveNewest - -