diff --git a/Plugins/HelloWorldPython/plugin.json b/Plugins/HelloWorldPython/plugin.json index 889f3c8848..a928a5ae5b 100644 --- a/Plugins/HelloWorldPython/plugin.json +++ b/Plugins/HelloWorldPython/plugin.json @@ -6,7 +6,7 @@ "Author":"happlebao", "Version":"1.0", "Language":"python", - "Website":"https://github.com/Wox-launche/Wox", + "Website":"https://github.com/Wox-launcher/Wox", "IcoPath":"Images\\app.png", "ExecuteFileName":"main.py" } diff --git a/Plugins/Wox.Plugin.BrowserBookmark/Commands/Bookmarks.cs b/Plugins/Wox.Plugin.BrowserBookmark/Commands/Bookmarks.cs new file mode 100644 index 0000000000..778e0ee65b --- /dev/null +++ b/Plugins/Wox.Plugin.BrowserBookmark/Commands/Bookmarks.cs @@ -0,0 +1,35 @@ +using System.Collections.Generic; +using System.Linq; +using Wox.Infrastructure; + +namespace Wox.Plugin.BrowserBookmark.Commands +{ + internal static class Bookmarks + { + internal static bool MatchProgram(Bookmark bookmark, string queryString) + { + if (StringMatcher.FuzzySearch(queryString, bookmark.Name, new MatchOption()).IsSearchPrecisionScoreMet()) return true; + if (StringMatcher.FuzzySearch(queryString, bookmark.PinyinName, new MatchOption()).IsSearchPrecisionScoreMet()) return true; + if (StringMatcher.FuzzySearch(queryString, bookmark.Url, new MatchOption()).IsSearchPrecisionScoreMet()) return true; + + return false; + } + + internal static List LoadAllBookmarks() + { + var allbookmarks = new List(); + + var chromeBookmarks = new ChromeBookmarks(); + var mozBookmarks = new FirefoxBookmarks(); + + //TODO: Let the user select which browser's bookmarks are displayed + // Add Firefox bookmarks + mozBookmarks.GetBookmarks().ForEach(x => allbookmarks.Add(x)); + + // Add Chrome bookmarks + chromeBookmarks.GetBookmarks().ForEach(x => allbookmarks.Add(x)); + + return allbookmarks.Distinct().ToList(); + } + } +} diff --git a/Plugins/Wox.Plugin.BrowserBookmark/FirefoxBookmarks.cs b/Plugins/Wox.Plugin.BrowserBookmark/FirefoxBookmarks.cs index fec331a76e..7686501cd7 100644 --- a/Plugins/Wox.Plugin.BrowserBookmark/FirefoxBookmarks.cs +++ b/Plugins/Wox.Plugin.BrowserBookmark/FirefoxBookmarks.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Data.SQLite; using System.IO; @@ -27,20 +27,25 @@ namespace Wox.Plugin.BrowserBookmark if (string.IsNullOrEmpty(PlacesPath) || !File.Exists(PlacesPath)) return new List(); + var bookmarList = new List(); + // create the connection string and init the connection - string dbPath = string.Format(dbPathFormat, PlacesPath); - var dbConnection = new SQLiteConnection(dbPath); - - // Open connection to the database file and execute the query - dbConnection.Open(); - var reader = new SQLiteCommand(queryAllBookmarks, dbConnection).ExecuteReader(); - - // return results in List format - return reader.Select(x => new Bookmark() + string dbPath = string.Format(dbPathFormat, PlacesPath); + using (var dbConnection = new SQLiteConnection(dbPath)) { - Name = (x["title"] is DBNull) ? string.Empty : x["title"].ToString(), - Url = x["url"].ToString() - }).ToList(); + // Open connection to the database file and execute the query + dbConnection.Open(); + var reader = new SQLiteCommand(queryAllBookmarks, dbConnection).ExecuteReader(); + + // return results in List format + bookmarList = reader.Select(x => new Bookmark() + { + Name = (x["title"] is DBNull) ? string.Empty : x["title"].ToString(), + Url = x["url"].ToString() + }).ToList(); + } + + return bookmarList; } /// @@ -61,17 +66,52 @@ namespace Wox.Plugin.BrowserBookmark using (var sReader = new StreamReader(profileIni)) { ini = sReader.ReadToEnd(); } + + /* + Current profiles.ini structure example as of Firefox version 69.0.1 + + [Install736426B0AF4A39CB] + Default=Profiles/7789f565.default-release <== this is the default profile this plugin will get the bookmarks from. When opened Firefox will load the default profile + Locked=1 + + [Profile2] + Name=newblahprofile + IsRelative=0 + Path=C:\t6h2yuq8.newblahprofile <== Note this is a custom location path for the profile user can set, we need to cater for this in code. + + [Profile1] + Name=default + IsRelative=1 + Path=Profiles/cydum7q4.default + Default=1 + + [Profile0] + Name=default-release + IsRelative=1 + Path=Profiles/7789f565.default-release + + [General] + StartWithLastProfile=1 + Version=2 + */ + var lines = ini.Split(new string[] { "\r\n" }, StringSplitOptions.None).ToList(); - var index = lines.IndexOf("Default=1"); - if (index > 3) { - var relative = lines[index - 2].Split('=')[1]; - var profiePath = lines[index - 1].Split('=')[1]; - return relative == "0" - ? profiePath + @"\places.sqlite" - : Path.Combine(profileFolderPath, profiePath) + @"\places.sqlite"; - } - return string.Empty; + var defaultProfileFolderNameRaw = lines.Where(x => x.Contains("Default=") && x != "Default=1").FirstOrDefault() ?? string.Empty; + + if (string.IsNullOrEmpty(defaultProfileFolderNameRaw)) + return string.Empty; + + var defaultProfileFolderName = defaultProfileFolderNameRaw.Split('=').Last(); + + var indexOfDefaultProfileAtttributePath = lines.IndexOf("Path="+ defaultProfileFolderName); + + // Seen in the example above, the IsRelative attribute is always above the Path attribute + var relativeAttribute = lines[indexOfDefaultProfileAtttributePath - 1]; + + return relativeAttribute == "0" // See above, the profile is located in a custom location, path is not relative, so IsRelative=0 + ? defaultProfileFolderName + @"\places.sqlite" + : Path.Combine(profileFolderPath, defaultProfileFolderName) + @"\places.sqlite"; } } } diff --git a/Plugins/Wox.Plugin.BrowserBookmark/Languages/en.xaml b/Plugins/Wox.Plugin.BrowserBookmark/Languages/en.xaml new file mode 100644 index 0000000000..7db78333be --- /dev/null +++ b/Plugins/Wox.Plugin.BrowserBookmark/Languages/en.xaml @@ -0,0 +1,9 @@ + + + + Browser Bookmarks + Search your browser bookmarks + + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.BrowserBookmark/Languages/tr.xaml b/Plugins/Wox.Plugin.BrowserBookmark/Languages/tr.xaml new file mode 100644 index 0000000000..847d28c7bb --- /dev/null +++ b/Plugins/Wox.Plugin.BrowserBookmark/Languages/tr.xaml @@ -0,0 +1,9 @@ + + + + Yer İşaretleri + Tarayıcılarınızdaki yer işaretlerini arayın. + + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.BrowserBookmark/Main.cs b/Plugins/Wox.Plugin.BrowserBookmark/Main.cs index 23f1135a6f..cb1f0d654b 100644 --- a/Plugins/Wox.Plugin.BrowserBookmark/Main.cs +++ b/Plugins/Wox.Plugin.BrowserBookmark/Main.cs @@ -1,32 +1,21 @@ using System.Collections.Generic; using System.Linq; -using Wox.Infrastructure; +using Wox.Plugin.BrowserBookmark.Commands; using Wox.Plugin.SharedCommands; namespace Wox.Plugin.BrowserBookmark { - public class Main : IPlugin + public class Main : IPlugin, IReloadable, IPluginI18n { private PluginInitContext context; - - // TODO: periodically refresh the Cache? + private List cachedBookmarks = new List(); public void Init(PluginInitContext context) { this.context = context; - // Cache all bookmarks - var chromeBookmarks = new ChromeBookmarks(); - var mozBookmarks = new FirefoxBookmarks(); - - //TODO: Let the user select which browser's bookmarks are displayed - // Add Firefox bookmarks - cachedBookmarks.AddRange(mozBookmarks.GetBookmarks()); - // Add Chrome bookmarks - cachedBookmarks.AddRange(chromeBookmarks.GetBookmarks()); - - cachedBookmarks = cachedBookmarks.Distinct().ToList(); + cachedBookmarks = Bookmarks.LoadAllBookmarks(); } public List Query(Query query) @@ -40,16 +29,15 @@ namespace Wox.Plugin.BrowserBookmark if (!topResults) { - // Since we mixed chrome and firefox bookmarks, we should order them again - var fuzzyMatcher = FuzzyMatcher.Create(param); - returnList = cachedBookmarks.Where(o => MatchProgram(o, fuzzyMatcher)).ToList(); + // Since we mixed chrome and firefox bookmarks, we should order them again + returnList = cachedBookmarks.Where(o => Bookmarks.MatchProgram(o, param)).ToList(); returnList = returnList.OrderByDescending(o => o.Score).ToList(); } return returnList.Select(c => new Result() { Title = c.Name, - SubTitle = "Bookmark: " + c.Url, + SubTitle = c.Url, IcoPath = @"Images\bookmark.png", Score = 5, Action = (e) => @@ -61,13 +49,22 @@ namespace Wox.Plugin.BrowserBookmark }).ToList(); } - private bool MatchProgram(Bookmark bookmark, FuzzyMatcher matcher) + public void ReloadData() { - if ((bookmark.Score = matcher.Evaluate(bookmark.Name).Score) > 0) return true; - if ((bookmark.Score = matcher.Evaluate(bookmark.PinyinName).Score) > 0) return true; - if ((bookmark.Score = matcher.Evaluate(bookmark.Url).Score / 10) > 0) return true; + cachedBookmarks.Clear(); - return false; + cachedBookmarks = Bookmarks.LoadAllBookmarks(); } + + public string GetTranslatedPluginTitle() + { + return context.API.GetTranslation("wox_plugin_browserbookmark_plugin_name"); + } + + public string GetTranslatedPluginDescription() + { + return context.API.GetTranslation("wox_plugin_browserbookmark_plugin_description"); + } + } } diff --git a/Plugins/Wox.Plugin.BrowserBookmark/Wox.Plugin.BrowserBookmark.csproj b/Plugins/Wox.Plugin.BrowserBookmark/Wox.Plugin.BrowserBookmark.csproj index f0a36fb65f..0be10b913a 100644 --- a/Plugins/Wox.Plugin.BrowserBookmark/Wox.Plugin.BrowserBookmark.csproj +++ b/Plugins/Wox.Plugin.BrowserBookmark/Wox.Plugin.BrowserBookmark.csproj @@ -1,4 +1,4 @@ - + @@ -14,6 +14,8 @@ ..\..\ true + + true @@ -35,14 +37,26 @@ false + + ..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll + + + ..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll + + - - ..\..\packages\System.Data.SQLite.Core.1.0.93.0\lib\net20\System.Data.SQLite.dll - True - + + ..\..\packages\System.Data.SQLite.Core.1.0.111.0\lib\net451\System.Data.SQLite.dll + + + ..\..\packages\System.Data.SQLite.EF6.1.0.111.0\lib\net451\System.Data.SQLite.EF6.dll + + + ..\..\packages\System.Data.SQLite.Linq.1.0.111.0\lib\net451\System.Data.SQLite.Linq.dll + ..\..\packages\UnidecodeSharp.1.0.0.0\lib\net35\UnidecodeSharp.dll True @@ -52,6 +66,7 @@ + @@ -67,6 +82,11 @@ Always + + Designer + MSBuild:Compile + PreserveNewest + Always @@ -84,8 +104,22 @@ Wox.Plugin + + + MSBuild:Compile + Designer + PreserveNewest + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + +
+ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.BrowserBookmark/packages.config b/Plugins/Wox.Plugin.BrowserBookmark/packages.config index 5abe85e328..fc01b224e7 100644 --- a/Plugins/Wox.Plugin.BrowserBookmark/packages.config +++ b/Plugins/Wox.Plugin.BrowserBookmark/packages.config @@ -1,7 +1,9 @@  - - - + + + + + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Calculator/Languages/tr.xaml b/Plugins/Wox.Plugin.Calculator/Languages/tr.xaml new file mode 100644 index 0000000000..51c5b9b2b9 --- /dev/null +++ b/Plugins/Wox.Plugin.Calculator/Languages/tr.xaml @@ -0,0 +1,10 @@ + + + Hesap Makinesi + Matematiksel hesaplamalar yapmaya yarar. (5*3-2 yazmayı deneyin) + Sayı değil (NaN) + İfade hatalı ya da eksik. (Parantez koymayı mı unuttunuz?) + Bu sayıyı panoya kopyala + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Calculator/Wox.Plugin.Calculator.csproj b/Plugins/Wox.Plugin.Calculator/Wox.Plugin.Calculator.csproj index 8fd3169a84..cf7ce1241f 100644 --- a/Plugins/Wox.Plugin.Calculator/Wox.Plugin.Calculator.csproj +++ b/Plugins/Wox.Plugin.Calculator/Wox.Plugin.Calculator.csproj @@ -111,6 +111,13 @@ PreserveNewest + + + MSBuild:Compile + Designer + PreserveNewest + + diff --git a/Plugins/Wox.Plugin.Color/Languages/tr.xaml b/Plugins/Wox.Plugin.Color/Languages/tr.xaml new file mode 100644 index 0000000000..c3224f517a --- /dev/null +++ b/Plugins/Wox.Plugin.Color/Languages/tr.xaml @@ -0,0 +1,8 @@ + + + Renkler + Hex kodunu girdiğiniz renkleri görüntülemeye yarar.(#000 yazmayı deneyin) + + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Color/Wox.Plugin.Color.csproj b/Plugins/Wox.Plugin.Color/Wox.Plugin.Color.csproj index 0b0dc560d8..f5b1ff1607 100644 --- a/Plugins/Wox.Plugin.Color/Wox.Plugin.Color.csproj +++ b/Plugins/Wox.Plugin.Color/Wox.Plugin.Color.csproj @@ -105,6 +105,13 @@ PreserveNewest + + + MSBuild:Compile + Designer + PreserveNewest + + + Sil + Düzenle + Ekle + Konum + İndekslenecek Uzantılar + Yeniden İndeksle + İndeksleniyor + Başlat Menüsünü İndeksle + Registry'i İndeksle + Uzantılar + Derinlik + + Dizin: + Gözat + Dosya Uzantıları: + Maksimum Arama Derinliği (Limitsiz için -1): + + İşlem yapmak istediğiniz klasörü seçin. + {0} klasörünü silmek istediğinize emin misiniz? + + Güncelle + Wox yalnızca aşağıdaki uzantılara sahip dosyaları indeksleyecektir: + (Her uzantıyı ; işareti ile ayırın) + Dosya uzantıları başarıyla güncellendi + Dosya uzantıları boş olamaz + + Yönetici Olarak Çalıştır + İçeren Klasörü Aç + + Program + Programları Wox'tan arayın + + Geçersiz Konum + + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Program/Main.cs b/Plugins/Wox.Plugin.Program/Main.cs index 7cdb3507b0..a6a891265a 100644 --- a/Plugins/Wox.Plugin.Program/Main.cs +++ b/Plugins/Wox.Plugin.Program/Main.cs @@ -13,7 +13,7 @@ using Stopwatch = Wox.Infrastructure.Stopwatch; namespace Wox.Plugin.Program { - public class Main : ISettingProvider, IPlugin, IPluginI18n, IContextMenu, ISavable + public class Main : ISettingProvider, IPlugin, IPluginI18n, IContextMenu, ISavable, IReloadable { private static readonly object IndexLock = new object(); private static Win32[] _win32s; @@ -145,5 +145,10 @@ namespace Wox.Plugin.Program } return hide; } + + public void ReloadData() + { + IndexPrograms(); + } } } \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Program/Programs/UWP.cs b/Plugins/Wox.Plugin.Program/Programs/UWP.cs index bad8fece95..d5f72683f0 100644 --- a/Plugins/Wox.Plugin.Program/Programs/UWP.cs +++ b/Plugins/Wox.Plugin.Program/Programs/UWP.cs @@ -240,9 +240,9 @@ namespace Wox.Plugin.Program.Programs private int Score(string query) { - var score1 = StringMatcher.Score(DisplayName, query); + var score1 = StringMatcher.FuzzySearch(query, DisplayName).ScoreAfterSearchPrecisionFilter(); var score2 = StringMatcher.ScoreForPinyin(DisplayName, query); - var score3 = StringMatcher.Score(Description, query); + var score3 = StringMatcher.FuzzySearch(query, Description).ScoreAfterSearchPrecisionFilter(); var score4 = StringMatcher.ScoreForPinyin(Description, query); var score = new[] { score1, score2, score3, score4 }.Max(); return score; diff --git a/Plugins/Wox.Plugin.Program/Programs/Win32.cs b/Plugins/Wox.Plugin.Program/Programs/Win32.cs index 6ac53fa922..7b9b3a52f5 100644 --- a/Plugins/Wox.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Wox.Plugin.Program/Programs/Win32.cs @@ -31,11 +31,11 @@ namespace Wox.Plugin.Program.Programs private int Score(string query) { - var score1 = StringMatcher.Score(Name, query); + var score1 = StringMatcher.FuzzySearch(query, Name).ScoreAfterSearchPrecisionFilter(); var score2 = StringMatcher.ScoreForPinyin(Name, query); - var score3 = StringMatcher.Score(Description, query); + var score3 = StringMatcher.FuzzySearch(query, Description).ScoreAfterSearchPrecisionFilter(); var score4 = StringMatcher.ScoreForPinyin(Description, query); - var score5 = StringMatcher.Score(ExecutableName, query); + var score5 = StringMatcher.FuzzySearch(query, ExecutableName).ScoreAfterSearchPrecisionFilter(); var score = new[] { score1, score2, score3, score4, score5 }.Max(); return score; } diff --git a/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj b/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj index ae0a83c54f..322a873508 100644 --- a/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj +++ b/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj @@ -130,6 +130,11 @@ Designer PreserveNewest + + MSBuild:Compile + Designer + PreserveNewest + MSBuild:Compile Designer diff --git a/Plugins/Wox.Plugin.Shell/Languages/tr.xaml b/Plugins/Wox.Plugin.Shell/Languages/tr.xaml new file mode 100644 index 0000000000..268b882533 --- /dev/null +++ b/Plugins/Wox.Plugin.Shell/Languages/tr.xaml @@ -0,0 +1,12 @@ + + + Win+R kısayolunu kullan + Çalıştırma sona erdikten sonra komut istemini kapatma + Kabuk + Wox üzerinden komut istemini kullanmanızı sağlar. Komutlar > işareti ile başlamalıdır. + Bu komut {0} kez çalıştırıldı + Komut isteminde çalıştır + Yönetici Olarak Çalıştır + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Shell/Wox.Plugin.Shell.csproj b/Plugins/Wox.Plugin.Shell/Wox.Plugin.Shell.csproj index 3ba77d86da..2291f78bb8 100644 --- a/Plugins/Wox.Plugin.Shell/Wox.Plugin.Shell.csproj +++ b/Plugins/Wox.Plugin.Shell/Wox.Plugin.Shell.csproj @@ -118,6 +118,11 @@ Designer PreserveNewest + + MSBuild:Compile + Designer + PreserveNewest + MSBuild:Compile Designer diff --git a/Plugins/Wox.Plugin.Sys/Languages/en.xaml b/Plugins/Wox.Plugin.Sys/Languages/en.xaml index 0d3fb8e61f..f4b8bbfba5 100644 --- a/Plugins/Wox.Plugin.Sys/Languages/en.xaml +++ b/Plugins/Wox.Plugin.Sys/Languages/en.xaml @@ -2,6 +2,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib"> + Command Description @@ -14,6 +15,16 @@ Tweak this app Put computer to sleep Empty recycle bin + Hibernate computer + Save all Wox settings + Reloads plugin data with new content added after Wox started. Plugins need to have this feature already added. + + + Success + All Wox settings saved + Reloaded all applicable plugin data + Are you sure you want to shut the computer down? + Are you sure you want to restart the computer? System Commands Provides System related commands. e.g. shutdown, lock, settings etc. diff --git a/Plugins/Wox.Plugin.Sys/Languages/tr.xaml b/Plugins/Wox.Plugin.Sys/Languages/tr.xaml new file mode 100644 index 0000000000..5111aa7785 --- /dev/null +++ b/Plugins/Wox.Plugin.Sys/Languages/tr.xaml @@ -0,0 +1,32 @@ + + + + Komut + Açıklama + + Bilgisayarı Kapat + Yeniden Başlat + Oturumu Kapat + Bilgisayarı Kilitle + Wox'u Kapat + Wox'u Yeniden Başlat + Wox Ayarlarını Aç + Bilgisayarı Uyku Moduna Al + Geri Dönüşüm Kutusunu Boşalt + Bilgisayarı Askıya Al + Tüm Wox Ayarlarını Kaydet + Eklentilerin verilerini Wox'un açılışından sonra yapılan değişiklikleri için günceller. Eklentilerin bu özelliği zaten eklemiş olması gerekir. + + + Başarılı + Tüm Wox ayarları kaydedildi. + Bilgisayarı kapatmak istediğinize emin misiniz? + Bilgisayarı yeniden başlatmak istediğinize emin misiniz? + + + Sistem Komutları + Sistem ile ilgili komutlara erişim sağlar. ör. shutdown, lock, settings vb. + + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Sys/Main.cs b/Plugins/Wox.Plugin.Sys/Main.cs index 1334034a3b..32e888514d 100644 --- a/Plugins/Wox.Plugin.Sys/Main.cs +++ b/Plugins/Wox.Plugin.Sys/Main.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Diagnostics; using System.Runtime.InteropServices; @@ -56,8 +56,8 @@ namespace Wox.Plugin.Sys var results = new List(); foreach (var c in commands) { - var titleScore = StringMatcher.Score(c.Title, query.Search); - var subTitleScore = StringMatcher.Score(c.SubTitle, query.Search); + var titleScore = StringMatcher.FuzzySearch(query.Search, c.Title).ScoreAfterSearchPrecisionFilter(); + var subTitleScore = StringMatcher.FuzzySearch(query.Search, c.SubTitle).ScoreAfterSearchPrecisionFilter(); var score = Math.Max(titleScore, subTitleScore); if (score > 0) { @@ -85,8 +85,9 @@ namespace Wox.Plugin.Sys IcoPath = "Images\\shutdown.png", Action = c => { - var reuslt = MessageBox.Show("Are you sure you want to shut the computer down?", - "Shutdown Computer?", MessageBoxButton.YesNo, MessageBoxImage.Warning); + var reuslt = MessageBox.Show(context.API.GetTranslation("wox_plugin_sys_dlgtext_shutdown_computer"), + context.API.GetTranslation("wox_plugin_sys_shutdown_computer"), + MessageBoxButton.YesNo, MessageBoxImage.Warning); if (reuslt == MessageBoxResult.Yes) { Process.Start("shutdown", "/s /t 0"); @@ -101,8 +102,9 @@ namespace Wox.Plugin.Sys IcoPath = "Images\\restart.png", Action = c => { - var result = MessageBox.Show("Are you sure you want to restart the computer?", - "Restart Computer?", MessageBoxButton.YesNo, MessageBoxImage.Warning); + var result = MessageBox.Show(context.API.GetTranslation("wox_plugin_sys_dlgtext_restart_computer"), + context.API.GetTranslation("wox_plugin_sys_restart_computer"), + MessageBoxButton.YesNo, MessageBoxImage.Warning); if (result == MessageBoxResult.Yes) { Process.Start("shutdown", "/r /t 0"); @@ -112,7 +114,7 @@ namespace Wox.Plugin.Sys }, new Result { - Title = "Log off", + Title = "Log Off", SubTitle = context.API.GetTranslation("wox_plugin_sys_log_off"), IcoPath = "Images\\logoff.png", Action = c => ExitWindowsEx(EWX_LOGOFF, 0) @@ -136,6 +138,13 @@ namespace Wox.Plugin.Sys Action = c => FormsApplication.SetSuspendState(PowerState.Suspend, false, false) }, new Result + { + Title = "Hibernate", + SubTitle = context.API.GetTranslation("wox_plugin_sys_hibernate"), + IcoPath = "Images\\sleep.png", // Icon change needed + Action = c => FormsApplication.SetSuspendState(PowerState.Hibernate, false, false) + }, + new Result { Title = "Empty Recycle Bin", SubTitle = context.API.GetTranslation("wox_plugin_sys_emptyrecyclebin"), @@ -168,6 +177,19 @@ namespace Wox.Plugin.Sys } }, new Result + { + Title = "Save Settings", + SubTitle = context.API.GetTranslation("wox_plugin_sys_save_all_settings"), + IcoPath = "Images\\app.png", + Action = c => + { + context.API.SaveAppAllSettings(); + context.API.ShowMsg(context.API.GetTranslation("wox_plugin_sys_dlgtitle_success"), + context.API.GetTranslation("wox_plugin_sys_dlgtext_all_settings_saved")); + return true; + } + }, + new Result { Title = "Restart Wox", SubTitle = context.API.GetTranslation("wox_plugin_sys_restart"), @@ -188,6 +210,21 @@ namespace Wox.Plugin.Sys context.API.OpenSettingDialog(); return true; } + }, + new Result + { + Title = "Reload Plugin Data", + SubTitle = context.API.GetTranslation("wox_plugin_sys_reload_plugin_data"), + IcoPath = "Images\\app.png", + Action = c => + { + // Hide the window first then show msg after done because sometimes the reload could take a while, so not to make user think it's frozen. + Application.Current.MainWindow.Hide(); + context.API.ReloadAllPluginData(); + context.API.ShowMsg(context.API.GetTranslation("wox_plugin_sys_dlgtitle_success"), + context.API.GetTranslation("wox_plugin_sys_dlgtext_all_applicableplugins_reloaded")); + return true; + } } }); return results; diff --git a/Plugins/Wox.Plugin.Sys/Wox.Plugin.Sys.csproj b/Plugins/Wox.Plugin.Sys/Wox.Plugin.Sys.csproj index eeccb363e5..e1a334bb3a 100644 --- a/Plugins/Wox.Plugin.Sys/Wox.Plugin.Sys.csproj +++ b/Plugins/Wox.Plugin.Sys/Wox.Plugin.Sys.csproj @@ -102,6 +102,11 @@ Designer PreserveNewest + + MSBuild:Compile + Designer + PreserveNewest + MSBuild:Compile Designer diff --git a/Plugins/Wox.Plugin.Url/Languages/tr.xaml b/Plugins/Wox.Plugin.Url/Languages/tr.xaml new file mode 100644 index 0000000000..a82b55ff29 --- /dev/null +++ b/Plugins/Wox.Plugin.Url/Languages/tr.xaml @@ -0,0 +1,15 @@ + + + URL'yi Aç: {0} + URL Açılamıyor: {0} + + URL + Wox'a yazılan URL'leri açar + + Tarayıcınızın konumunu ayarlayın: + Seç + Uygula + Programlar (*.exe)|*.exe|Tüm Dosyalar|*.* + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Url/Wox.Plugin.Url.csproj b/Plugins/Wox.Plugin.Url/Wox.Plugin.Url.csproj index ee0e09c18f..515d240b72 100644 --- a/Plugins/Wox.Plugin.Url/Wox.Plugin.Url.csproj +++ b/Plugins/Wox.Plugin.Url/Wox.Plugin.Url.csproj @@ -112,6 +112,11 @@ + + MSBuild:Compile + Designer + PreserveNewest + Designer MSBuild:Compile diff --git a/Plugins/Wox.Plugin.WebSearch/Languages/tr.xaml b/Plugins/Wox.Plugin.WebSearch/Languages/tr.xaml new file mode 100644 index 0000000000..1a3951faf7 --- /dev/null +++ b/Plugins/Wox.Plugin.WebSearch/Languages/tr.xaml @@ -0,0 +1,32 @@ + + + Sil + Düzenle + Ekle + Onayla + Anahtar Kelime + URL + Ara: + Arama önerilerini etkinleştir + Lütfen bir web araması seçin + {0} aramasını silmek istediğinize emin misiniz? + + + Başlık + Etkin + Simge Seç + Simge + İptal + Geçersiz web araması + Lütfen bir başlık giriniz + Lütfen anahtar kelime giriniz + Lütfen bir URL giriniz + Anahtar kelime zaten mevcut. Lütfen yeni bir tane seçiniz. + Başarılı + + Web Araması + Web üzerinde arama yapmanızı sağlar + + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.WebSearch/Main.cs b/Plugins/Wox.Plugin.WebSearch/Main.cs index ea7720329f..ec4033ac33 100644 --- a/Plugins/Wox.Plugin.WebSearch/Main.cs +++ b/Plugins/Wox.Plugin.WebSearch/Main.cs @@ -49,10 +49,11 @@ namespace Wox.Plugin.WebSearch { foreach (SearchSource searchSource in searchSourceList) { - string keyword = query.Search; - string title = keyword; - string subtitle = _context.API.GetTranslation("wox_plugin_websearch_search") + " " + - searchSource.Title; + string keyword = string.Empty; + keyword = searchSource.ActionKeyword == SearchSourceGlobalPluginWildCardSign ? query.ToString() : query.Search; + var title = keyword; + string subtitle = _context.API.GetTranslation("wox_plugin_websearch_search") + " " + searchSource.Title; + if (string.IsNullOrEmpty(keyword)) { var result = new Result @@ -78,7 +79,14 @@ namespace Wox.Plugin.WebSearch return true; } }; + results.Add(result); + ResultsUpdated?.Invoke(this, new ResultUpdatedEventArgs + { + Results = results, + Query = query + }); + UpdateResultsFromSuggestion(results, keyword, subtitle, searchSource, query); } } diff --git a/Plugins/Wox.Plugin.WebSearch/SearchSourceSetting.xaml.cs b/Plugins/Wox.Plugin.WebSearch/SearchSourceSetting.xaml.cs index 539b6d2c26..9bc31dd03f 100644 --- a/Plugins/Wox.Plugin.WebSearch/SearchSourceSetting.xaml.cs +++ b/Plugins/Wox.Plugin.WebSearch/SearchSourceSetting.xaml.cs @@ -83,7 +83,7 @@ namespace Wox.Plugin.WebSearch _searchSources.Add(_searchSource); - var info = _api.GetTranslation("succeed"); + var info = _api.GetTranslation("success"); MessageBox.Show(info); Close(); } @@ -106,7 +106,7 @@ namespace Wox.Plugin.WebSearch var index = _searchSources.IndexOf(_oldSearchSource); _searchSources[index] = _searchSource; - var info = _api.GetTranslation("succeed"); + var info = _api.GetTranslation("success"); MessageBox.Show(info); Close(); } diff --git a/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj b/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj index 858b6fd433..e2237dab1a 100644 --- a/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj +++ b/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj @@ -154,6 +154,11 @@ Designer PreserveNewest + + MSBuild:Compile + Designer + PreserveNewest + MSBuild:Compile Designer diff --git a/README.md b/README.md index 22a1a45d47..36628d4c00 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,10 @@ WoX === +![Maintenance](https://img.shields.io/maintenance/yes/2019) +[![GitHub release (latest by date)](https://img.shields.io/github/v/release/jjw24/wox)](https://github.com/jjw24/Wox/releases/latest) +![GitHub Release Date](https://img.shields.io/github/release-date/jjw24/wox) +![GitHub commits since latest release](https://img.shields.io/github/commits-since/jjw24/wox/v1.3.524) [![Build status](https://ci.appveyor.com/api/projects/status/bfktntbivg32e103/branch/master?svg=true)](https://ci.appveyor.com/project/happlebao/wox/branch/master) [![Github All Releases](https://img.shields.io/github/downloads/Wox-launcher/Wox/total.svg)](https://github.com/Wox-launcher/Wox/releases) [![RamenBless](https://cdn.rawgit.com/LunaGao/BlessYourCodeTag/master/tags/ramen.svg)](https://github.com/LunaGao/BlessYourCodeTag) @@ -24,6 +28,10 @@ Features Installation ------------ +To install this fork's version of Wox, you can **download** it [here](https://github.com/jjw24/Wox/releases/latest). + +To install the upstream version: + Download `Wox-xxx.exe` from [releases](https://github.com/Wox-launcher/Wox/releases). Latest as of now is [`1.3.524`](https://github.com/Wox-launcher/Wox/releases/download/v1.3.524/Wox-1.3.524.exe) ([`1.3.578`](https://github.com/Wox-launcher/Wox/releases/download/v1.3.578/Wox-1.3.578.exe) for preview channel) Windows may complain about security due to code not being signed. This will be fixed later. diff --git a/Wox.Core/Plugin/PluginManager.cs b/Wox.Core/Plugin/PluginManager.cs index 6ca826fd9b..e42cf02e80 100644 --- a/Wox.Core/Plugin/PluginManager.cs +++ b/Wox.Core/Plugin/PluginManager.cs @@ -3,9 +3,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading.Tasks; -using Wox.Core.Resource; using Wox.Infrastructure; -using Wox.Infrastructure.Exception; using Wox.Infrastructure.Logger; using Wox.Infrastructure.Storage; using Wox.Infrastructure.UserSettings; @@ -66,6 +64,15 @@ namespace Wox.Core.Plugin } } + public static void ReloadData() + { + foreach(var plugin in AllPlugins) + { + var reloadablePlugin = plugin.Plugin as IReloadable; + reloadablePlugin?.ReloadData(); + } + } + static PluginManager() { ValidateUserDirectory(); diff --git a/Wox.Core/Resource/AvailableLanguages.cs b/Wox.Core/Resource/AvailableLanguages.cs index d650723db2..e6c1e07f26 100644 --- a/Wox.Core/Resource/AvailableLanguages.cs +++ b/Wox.Core/Resource/AvailableLanguages.cs @@ -21,6 +21,7 @@ namespace Wox.Core.Resource public static Language Italian = new Language("it", "Italiano"); public static Language Norwegian_Bokmal = new Language("nb-NO", "Norsk Bokmål"); public static Language Slovak = new Language("sk", "Slovenský"); + public static Language Turkish = new Language("tr", "Türkçe"); public static List GetAvailableLanguages() { @@ -42,7 +43,8 @@ namespace Wox.Core.Resource Portuguese_BR, Italian, Norwegian_Bokmal, - Slovak + Slovak, + Turkish }; return languages; } diff --git a/Wox.Core/Updater.cs b/Wox.Core/Updater.cs index 050ccceb81..d2461baf4a 100644 --- a/Wox.Core/Updater.cs +++ b/Wox.Core/Updater.cs @@ -69,7 +69,7 @@ namespace Wox.Core var newVersionTips = Translater.GetTranslation("newVersionTips"); newVersionTips = string.Format(newVersionTips, fr.Version); MessageBox.Show(newVersionTips); - Log.Info($"|Updater.UpdateApp|Update succeed:{newVersionTips}"); + Log.Info($"|Updater.UpdateApp|Update success:{newVersionTips}"); } // always dispose UpdateManager diff --git a/Wox.Infrastructure/FuzzyMatcher.cs b/Wox.Infrastructure/FuzzyMatcher.cs index c2d7e02e94..cb1e735f5c 100644 --- a/Wox.Infrastructure/FuzzyMatcher.cs +++ b/Wox.Infrastructure/FuzzyMatcher.cs @@ -1,10 +1,8 @@ -using System.Text; +using System; namespace Wox.Infrastructure { - /// - /// refer to https://github.com/mattyork/fuzzy - /// + [Obsolete("This class is obsolete and should not be used. Please use the static function StringMatcher.FuzzySearch")] public class FuzzyMatcher { private string query; @@ -28,99 +26,7 @@ namespace Wox.Infrastructure public MatchResult Evaluate(string str) { - if (string.IsNullOrEmpty(str) || string.IsNullOrEmpty(query)) return new MatchResult { Success = false }; - - var len = str.Length; - var compareString = opt.IgnoreCase ? str.ToLower() : str; - var pattern = opt.IgnoreCase ? query.ToLower() : query; - - var sb = new StringBuilder(str.Length + (query.Length * (opt.Prefix.Length + opt.Suffix.Length))); - var patternIdx = 0; - var firstMatchIndex = -1; - var lastMatchIndex = 0; - char ch; - for (var idx = 0; idx < len; idx++) - { - ch = str[idx]; - if (compareString[idx] == pattern[patternIdx]) - { - if (firstMatchIndex < 0) - firstMatchIndex = idx; - lastMatchIndex = idx + 1; - - sb.Append(opt.Prefix + ch + opt.Suffix); - patternIdx += 1; - } - else - { - sb.Append(ch); - } - - // match success, append remain char - if (patternIdx == pattern.Length && (idx + 1) != compareString.Length) - { - sb.Append(str.Substring(idx + 1)); - break; - } - } - - // return rendered string if we have a match for every char - if (patternIdx == pattern.Length) - { - return new MatchResult - { - Success = true, - Value = sb.ToString(), - Score = CalScore(str, firstMatchIndex, lastMatchIndex - firstMatchIndex) - }; - } - - return new MatchResult { Success = false }; + return StringMatcher.FuzzySearch(query, str, opt); } - - private int CalScore(string str, int firstIndex, int matchLen) - { - //a match found near the beginning of a string is scored more than a match found near the end - //a match is scored more if the characters in the patterns are closer to each other, while the score is lower if they are more spread out - var score = 100 * (query.Length + 1) / ((1 + firstIndex) + (matchLen + 1)); - //a match with less characters assigning more weights - if (str.Length - query.Length < 5) - score = score + 20; - else if (str.Length - query.Length < 10) - score = score + 10; - - return score; - } - } - - public class MatchResult - { - public bool Success { get; set; } - public int Score { get; set; } - /// - /// hightlight string - /// - public string Value { get; set; } - } - - public class MatchOption - { - public MatchOption() - { - Prefix = ""; - Suffix = ""; - IgnoreCase = true; - } - - /// - /// prefix of match char, use for hightlight - /// - public string Prefix { get; set; } - /// - /// suffix of match char, use for hightlight - /// - public string Suffix { get; set; } - - public bool IgnoreCase { get; set; } } } diff --git a/Wox.Infrastructure/Logger/Log.cs b/Wox.Infrastructure/Logger/Log.cs index f7ea74b31c..dfa05c7154 100644 --- a/Wox.Infrastructure/Logger/Log.cs +++ b/Wox.Infrastructure/Logger/Log.cs @@ -1,4 +1,4 @@ -using System.Diagnostics; +using System.Diagnostics; using System.IO; using System.Runtime.CompilerServices; using NLog; @@ -22,8 +22,7 @@ namespace Wox.Infrastructure.Logger var configuration = new LoggingConfiguration(); var target = new FileTarget(); configuration.AddTarget("file", target); - target.FileName = "${specialfolder:folder=ApplicationData}/" + Constant.Wox + "/" + DirectoryName + "/" + - Constant.Version + "/${shortdate}.txt"; + target.FileName = path.Replace(@"\", "/") + "/${shortdate}.txt"; #if DEBUG var rule = new LoggingRule("*", LogLevel.Debug, target); #else diff --git a/Wox.Infrastructure/StringMatcher.cs b/Wox.Infrastructure/StringMatcher.cs index 0ef4f14265..0f2657a49a 100644 --- a/Wox.Infrastructure/StringMatcher.cs +++ b/Wox.Infrastructure/StringMatcher.cs @@ -1,20 +1,21 @@ using System; -using System.Collections.Generic; using System.Linq; -using Wox.Infrastructure; +using System.Text; using Wox.Infrastructure.Logger; +using Wox.Infrastructure.UserSettings; namespace Wox.Infrastructure { public static class StringMatcher { + public static string UserSettingSearchPrecision { get; set; } + + [Obsolete("This method is obsolete and should not be used. Please use the static function StringMatcher.FuzzySearch")] public static int Score(string source, string target) { if (!string.IsNullOrEmpty(source) && !string.IsNullOrEmpty(target)) { - FuzzyMatcher matcher = FuzzyMatcher.Create(target); - var score = matcher.Evaluate(source).Score; - return score; + return FuzzySearch(target, source, new MatchOption()).Score; } else { @@ -22,6 +23,108 @@ namespace Wox.Infrastructure } } + [Obsolete("This method is obsolete and should not be used. Please use the static function StringMatcher.FuzzySearch")] + public static bool IsMatch(string source, string target) + { + return FuzzySearch(target, source, new MatchOption()).Score > 0; + } + + public static MatchResult FuzzySearch(string query, string stringToCompare) + { + return FuzzySearch(query, stringToCompare, new MatchOption()); + } + + /// + /// refer to https://github.com/mattyork/fuzzy + /// + public static MatchResult FuzzySearch(string query, string stringToCompare, MatchOption opt) + { + if (string.IsNullOrEmpty(stringToCompare) || string.IsNullOrEmpty(query)) return new MatchResult { Success = false }; + + query.Trim(); + + var len = stringToCompare.Length; + var compareString = opt.IgnoreCase ? stringToCompare.ToLower() : stringToCompare; + var pattern = opt.IgnoreCase ? query.ToLower() : query; + + var sb = new StringBuilder(stringToCompare.Length + (query.Length * (opt.Prefix.Length + opt.Suffix.Length))); + var patternIdx = 0; + var firstMatchIndex = -1; + var lastMatchIndex = 0; + char ch; + for (var idx = 0; idx < len; idx++) + { + ch = stringToCompare[idx]; + if (compareString[idx] == pattern[patternIdx]) + { + if (firstMatchIndex < 0) + firstMatchIndex = idx; + lastMatchIndex = idx + 1; + + sb.Append(opt.Prefix + ch + opt.Suffix); + patternIdx += 1; + } + else + { + sb.Append(ch); + } + + // match success, append remain char + if (patternIdx == pattern.Length && (idx + 1) != compareString.Length) + { + sb.Append(stringToCompare.Substring(idx + 1)); + break; + } + } + + // return rendered string if we have a match for every char + if (patternIdx == pattern.Length) + { + return new MatchResult + { + Success = true, + Value = sb.ToString(), + Score = CalScore(query, stringToCompare, firstMatchIndex, lastMatchIndex - firstMatchIndex) + }; + } + + return new MatchResult { Success = false }; + } + + private static int CalScore(string query, string stringToCompare, int firstIndex, int matchLen) + { + //a match found near the beginning of a string is scored more than a match found near the end + //a match is scored more if the characters in the patterns are closer to each other, while the score is lower if they are more spread out + var score = 100 * (query.Length + 1) / ((1 + firstIndex) + (matchLen + 1)); + //a match with less characters assigning more weights + if (stringToCompare.Length - query.Length < 5) + score = score + 20; + else if (stringToCompare.Length - query.Length < 10) + score = score + 10; + + return score; + } + + public enum SearchPrecisionScore + { + Regular = 50, + Low = 20, + None = 0 + } + + public static bool IsSearchPrecisionScoreMet(this MatchResult matchResult) + { + var precisionScore = (SearchPrecisionScore)Enum.Parse(typeof(SearchPrecisionScore), + UserSettingSearchPrecision ?? SearchPrecisionScore.Regular.ToString()); + return matchResult.Score >= (int)precisionScore; + } + + public static int ScoreAfterSearchPrecisionFilter(this MatchResult matchResult) + { + return matchResult.IsSearchPrecisionScoreMet() ? matchResult.Score : 0; + + } + public static int ScoreForPinyin(string source, string target) { if (!string.IsNullOrEmpty(source) && !string.IsNullOrEmpty(target)) @@ -34,12 +137,12 @@ namespace Wox.Infrastructure if (Alphabet.ContainsChinese(source)) { - FuzzyMatcher matcher = FuzzyMatcher.Create(target); - var combination = Alphabet.PinyinComination(source); - var pinyinScore = combination.Select(pinyin => matcher.Evaluate(string.Join("", pinyin)).Score) + var combination = Alphabet.PinyinComination(source); + var pinyinScore = combination + .Select(pinyin => FuzzySearch(target, string.Join("", pinyin), new MatchOption()).Score) .Max(); - var acronymScore = combination.Select(Alphabet.Acronym) - .Select(pinyin => matcher.Evaluate(pinyin).Score) + var acronymScore = combination.Select(Alphabet.Acronym) + .Select(pinyin => FuzzySearch(target, pinyin, new MatchOption()).Score) .Max(); var score = Math.Max(pinyinScore, acronymScore); return score; @@ -53,11 +156,37 @@ namespace Wox.Infrastructure { return 0; } + } + } + + public class MatchResult + { + public bool Success { get; set; } + public int Score { get; set; } + /// + /// hightlight string + /// + public string Value { get; set; } + } + + public class MatchOption + { + public MatchOption() + { + Prefix = ""; + Suffix = ""; + IgnoreCase = true; } - public static bool IsMatch(string source, string target) - { - return Score(source, target) > 0; - } + /// + /// prefix of match char, use for hightlight + /// + public string Prefix { get; set; } + /// + /// suffix of match char, use for hightlight + /// + public string Suffix { get; set; } + + public bool IgnoreCase { get; set; } } } diff --git a/Wox.Infrastructure/UserSettings/Settings.cs b/Wox.Infrastructure/UserSettings/Settings.cs index 8e72a24875..5e22ca4936 100644 --- a/Wox.Infrastructure/UserSettings/Settings.cs +++ b/Wox.Infrastructure/UserSettings/Settings.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.ObjectModel; using System.Drawing; using Newtonsoft.Json; @@ -21,7 +21,18 @@ namespace Wox.Infrastructure.UserSettings public string ResultFontWeight { get; set; } public string ResultFontStretch { get; set; } - public bool AutoUpdates { get; set; } = true; + private string _querySearchPrecision { get; set; } = StringMatcher.SearchPrecisionScore.Regular.ToString(); + public string QuerySearchPrecision + { + get { return _querySearchPrecision; } + set + { + _querySearchPrecision = value; + StringMatcher.UserSettingSearchPrecision = value; + } + } + + public bool AutoUpdates { get; set; } = false; public double WindowLeft { get; set; } public double WindowTop { get; set; } @@ -63,7 +74,6 @@ namespace Wox.Infrastructure.UserSettings [JsonConverter(typeof(StringEnumConverter))] public LastQueryMode LastQueryMode { get; set; } = LastQueryMode.Selected; - } public enum LastQueryMode diff --git a/Wox.Infrastructure/Wox.cs b/Wox.Infrastructure/Wox.cs index 50107737b4..fbab671edc 100644 --- a/Wox.Infrastructure/Wox.cs +++ b/Wox.Infrastructure/Wox.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Diagnostics; using System.IO; using System.Reflection; @@ -7,13 +7,26 @@ namespace Wox.Infrastructure { public static class Constant { + public static string DetermineDataDirectory() + { + string portableDataPath = Path.Combine(ProgramDirectory, "UserData"); + if (Directory.Exists(portableDataPath)) + { + return portableDataPath; + } + else + { + return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Wox); + } + } + public const string Wox = "Wox"; public const string Plugins = "Plugins"; private static readonly Assembly Assembly = Assembly.GetExecutingAssembly(); public static readonly string ProgramDirectory = Directory.GetParent(Assembly.Location.NonNull()).ToString(); public static readonly string ExecutablePath = Path.Combine(ProgramDirectory, Wox + ".exe"); - public static readonly string DataDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Wox); + public static readonly string DataDirectory = DetermineDataDirectory(); public static readonly string PluginsDirectory = Path.Combine(DataDirectory, Plugins); public static readonly string PreinstalledDirectory = Path.Combine(ProgramDirectory, Plugins); public const string Repository = "https://github.com/Wox-launcher/Wox"; diff --git a/Wox.Plugin/IPublicAPI.cs b/Wox.Plugin/IPublicAPI.cs index c726c962a6..eb3f18fa70 100644 --- a/Wox.Plugin/IPublicAPI.cs +++ b/Wox.Plugin/IPublicAPI.cs @@ -57,6 +57,19 @@ namespace Wox.Plugin [Obsolete] void ShowApp(); + /// + /// Save all Wox settings + /// + void SaveAppAllSettings(); + + /// + /// Reloads any Plugins that have the + /// IReloadable implemented. It refeshes + /// Plugin's in memory data with new content + /// added by user. + /// + void ReloadAllPluginData(); + /// /// Show message box /// diff --git a/Wox.Plugin/Interfaces/IReloadable.cs b/Wox.Plugin/Interfaces/IReloadable.cs new file mode 100644 index 0000000000..86f75ee3e9 --- /dev/null +++ b/Wox.Plugin/Interfaces/IReloadable.cs @@ -0,0 +1,18 @@ +namespace Wox.Plugin +{ + /// + /// This interface is to indicate and allow plugins to reload their + /// in memory data cache or other mediums when user makes a new change + /// that is not immediately captured. For example, for BrowserBookmark and Program + /// plugin does not automatically detect when a user added a new bookmark or program, + /// so this interface's function is exposed to allow user manually do the reloading after + /// those new additions. + /// + /// The command that allows user to manual reload is exposed via Plugin.Sys, and + /// it will call the plugins that have implemented this interface. + /// + public interface IReloadable + { + void ReloadData(); + } +} diff --git a/Wox.Plugin/README.md b/Wox.Plugin/README.md index 1d5c7394da..27024c2530 100644 --- a/Wox.Plugin/README.md +++ b/Wox.Plugin/README.md @@ -1,5 +1,6 @@ What does Wox.Plugin do? ==== -* Define base objects and interfaces for plugins -* Plugin Author who making C# plugin should reference this DLL via nuget \ No newline at end of file +* Defines base objects and interfaces for plugins +* Plugin authors making C# plugins should reference this DLL via nuget +* Contains base commands used by all plugins diff --git a/Wox.Plugin/Result.cs b/Wox.Plugin/Result.cs index cdeabbdc24..88b8679f24 100644 --- a/Wox.Plugin/Result.cs +++ b/Wox.Plugin/Result.cs @@ -65,17 +65,13 @@ namespace Wox.Plugin public override bool Equals(object obj) { - Result r = obj as Result; - if (r != null) - { - var equality = string.Equals(r.Title, Title) && - string.Equals(r.SubTitle, SubTitle); - return equality; - } - else - { - return false; - } + var r = obj as Result; + + var equality = string.Equals(r?.Title, Title) && + string.Equals(r?.SubTitle, SubTitle) && + string.Equals(r?.IcoPath, IcoPath); + + return equality; } public override int GetHashCode() diff --git a/Wox.Plugin/Wox.Plugin.csproj b/Wox.Plugin/Wox.Plugin.csproj index 8b1e9f0ca7..843cc7d8bf 100644 --- a/Wox.Plugin/Wox.Plugin.csproj +++ b/Wox.Plugin/Wox.Plugin.csproj @@ -66,6 +66,7 @@ + diff --git a/Wox.Test/FuzzyMatcherTest.cs b/Wox.Test/FuzzyMatcherTest.cs index 2856a0fdeb..9aeca05348 100644 --- a/Wox.Test/FuzzyMatcherTest.cs +++ b/Wox.Test/FuzzyMatcherTest.cs @@ -1,4 +1,6 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using NUnit.Framework; using Wox.Infrastructure; @@ -9,6 +11,31 @@ namespace Wox.Test [TestFixture] public class FuzzyMatcherTest { + public List GetSearchStrings() + => new List + { + "Chrome", + "Choose which programs you want Windows to use for activities like web browsing, editing photos, sending e-mail, and playing music.", + "Help cure hope raise on mind entity Chrome ", + "Candy Crush Saga from King", + "Uninstall or change programs on your computer", + "Add, change, and manage fonts on your computer", + "Last is chrome", + "1111" + }; + + public List GetPrecisionScores() + { + var listToReturn = new List(); + + Enum.GetValues(typeof(StringMatcher.SearchPrecisionScore)) + .Cast() + .ToList() + .ForEach(x => listToReturn.Add((int)x)); + + return listToReturn; + } + [Test] public void MatchTest() { @@ -28,7 +55,7 @@ namespace Wox.Test results.Add(new Result { Title = str, - Score = FuzzyMatcher.Create("inst").Evaluate(str).Score + Score = StringMatcher.FuzzySearch("inst", str, new MatchOption()).Score }); } @@ -39,5 +66,124 @@ namespace Wox.Test Assert.IsTrue(results[1].Title == "Install Package"); Assert.IsTrue(results[2].Title == "file open in browser-test"); } + + [TestCase("Chrome")] + public void WhenGivenNotAllCharactersFoundInSearchStringThenShouldReturnZeroScore(string searchString) + { + var compareString = "Can have rum only in my glass"; + + var scoreResult = StringMatcher.FuzzySearch(searchString, compareString, new MatchOption()).Score; + + Assert.True(scoreResult == 0); + } + + [TestCase("chr")] + [TestCase("chrom")] + [TestCase("chrome")] + [TestCase("cand")] + [TestCase("cpywa")] + [TestCase("ccs")] + public void WhenGivenStringsAndAppliedPrecisionFilteringThenShouldReturnGreaterThanPrecisionScoreResults(string searchTerm) + { + var results = new List(); + + foreach (var str in GetSearchStrings()) + { + results.Add(new Result + { + Title = str, + Score = StringMatcher.FuzzySearch(searchTerm, str, new MatchOption()).Score + }); + } + + foreach (var precisionScore in GetPrecisionScores()) + { + var filteredResult = results.Where(result => result.Score >= precisionScore).Select(result => result).OrderByDescending(x => x.Score).ToList(); + + Debug.WriteLine(""); + Debug.WriteLine("###############################################"); + Debug.WriteLine("SEARCHTERM: " + searchTerm + ", GreaterThanSearchPrecisionScore: " + precisionScore); + foreach (var item in filteredResult) + { + Debug.WriteLine("SCORE: " + item.Score.ToString() + ", FoundString: " + item.Title); + } + Debug.WriteLine("###############################################"); + Debug.WriteLine(""); + + Assert.IsFalse(filteredResult.Any(x => x.Score < precisionScore)); + } + } + + [TestCase("chrome")] + public void WhenGivenStringsForCalScoreMethodThenShouldReturnCurrentScoring(string searchTerm) + { + var searchStrings = new List + { + "Chrome",//SCORE: 107 + "Last is chrome",//SCORE: 53 + "Help cure hope raise on mind entity Chrome",//SCORE: 21 + "Uninstall or change programs on your computer", //SCORE: 15 + "Candy Crush Saga from King"//SCORE: 0 + } + .OrderByDescending(x => x) + .ToList(); + + var results = new List(); + + foreach (var str in searchStrings) + { + results.Add(new Result + { + Title = str, + Score = StringMatcher.FuzzySearch(searchTerm, str, new MatchOption()).Score + }); + } + + var orderedResults = results.OrderByDescending(x => x.Title).ToList(); + + Debug.WriteLine(""); + Debug.WriteLine("###############################################"); + Debug.WriteLine("SEARCHTERM: " + searchTerm); + foreach (var item in orderedResults) + { + Debug.WriteLine("SCORE: " + item.Score.ToString() + ", FoundString: " + item.Title); + } + Debug.WriteLine("###############################################"); + Debug.WriteLine(""); + + Assert.IsTrue(orderedResults[0].Score == 15 && orderedResults[0].Title == searchStrings[0]); + Assert.IsTrue(orderedResults[1].Score == 53 && orderedResults[1].Title == searchStrings[1]); + Assert.IsTrue(orderedResults[2].Score == 21 && orderedResults[2].Title == searchStrings[2]); + Assert.IsTrue(orderedResults[3].Score == 107 && orderedResults[3].Title == searchStrings[3]); + Assert.IsTrue(orderedResults[4].Score == 0 && orderedResults[4].Title == searchStrings[4]); + } + + [TestCase("goo", "Google Chrome", (int)StringMatcher.SearchPrecisionScore.Regular, true)] + [TestCase("chr", "Google Chrome", (int)StringMatcher.SearchPrecisionScore.Low, true)] + [TestCase("chr", "Chrome", (int)StringMatcher.SearchPrecisionScore.Regular, true)] + [TestCase("chr", "Help cure hope raise on mind entity Chrome", (int)StringMatcher.SearchPrecisionScore.Regular, false)] + [TestCase("chr", "Help cure hope raise on mind entity Chrome", (int)StringMatcher.SearchPrecisionScore.Low, true)] + [TestCase("chr", "Candy Crush Saga from King", (int)StringMatcher.SearchPrecisionScore.Regular, false)] + [TestCase("chr", "Candy Crush Saga from King", (int)StringMatcher.SearchPrecisionScore.None, true)] + [TestCase("ccs", "Candy Crush Saga from King", (int)StringMatcher.SearchPrecisionScore.Low, true)] + [TestCase("cand", "Candy Crush Saga from King", (int)StringMatcher.SearchPrecisionScore.Regular, true)] + [TestCase("cand", "Help cure hope raise on mind entity Chrome", (int)StringMatcher.SearchPrecisionScore.Regular, false)] + public void WhenGivenDesiredPrecisionThenShouldReturnAllResultsGreaterOrEqual(string queryString, string compareString, + int expectedPrecisionScore, bool expectedPrecisionResult) + { + var expectedPrecisionString = (StringMatcher.SearchPrecisionScore)expectedPrecisionScore; + StringMatcher.UserSettingSearchPrecision = expectedPrecisionString.ToString(); + var matchResult = StringMatcher.FuzzySearch(queryString, compareString, new MatchOption()); + + Debug.WriteLine(""); + Debug.WriteLine("###############################################"); + Debug.WriteLine($"SearchTerm: {queryString} PrecisionLevelSetAt: {expectedPrecisionString} ({expectedPrecisionScore})"); + Debug.WriteLine($"SCORE: {matchResult.Score.ToString()}, ComparedString: {compareString}"); + Debug.WriteLine("###############################################"); + Debug.WriteLine(""); + + var matchPrecisionResult = matchResult.IsSearchPrecisionScoreMet(); + Assert.IsTrue(matchPrecisionResult == expectedPrecisionResult); + } } } diff --git a/Wox.Test/Wox.Test.csproj b/Wox.Test/Wox.Test.csproj index 0827bde5ad..385fe023e5 100644 --- a/Wox.Test/Wox.Test.csproj +++ b/Wox.Test/Wox.Test.csproj @@ -1,5 +1,7 @@  + + Debug @@ -13,6 +15,8 @@ 512 ..\ + + true @@ -38,10 +42,10 @@ ..\packages\Moq.4.2.1409.1722\lib\net40\Moq.dll True - - ..\packages\NUnit.2.6.4\lib\nunit.framework.dll - True + + ..\packages\NUnit.3.12.0\lib\net45\nunit.framework.dll + @@ -76,6 +80,13 @@ + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + diff --git a/Wox/Languages/de.xaml b/Wox/Languages/de.xaml index 270084ab29..3efa653e63 100644 --- a/Wox/Languages/de.xaml +++ b/Wox/Languages/de.xaml @@ -91,7 +91,7 @@ Kann das angegebene Plugin nicht finden Neues Aktionsschlüsselwort darf nicht leer sein Aktionsschlüsselwort ist schon bei einem anderen Plugin in verwendung. Bitte stellen Sie ein anderes Aktionsschlüsselwort ein. - Erfolgreich + Erfolgreich Benutzen Sie * wenn Sie ein Aktionsschlüsselwort definieren wollen. diff --git a/Wox/Languages/en.xaml b/Wox/Languages/en.xaml index 37f944d871..ae8041121c 100644 --- a/Wox/Languages/en.xaml +++ b/Wox/Languages/en.xaml @@ -33,6 +33,7 @@ Select Hide Wox on startup Hide tray icon + Query Search Precision Plugin @@ -103,7 +104,7 @@ Can't find specified plugin New Action Keyword can't be empty New Action Keywords have been assigned to another plugin, please assign other new action keyword - Succeed + Success Use * if you don't want to specify an action keyword diff --git a/Wox/Languages/fr.xaml b/Wox/Languages/fr.xaml index 1e05ba6175..2f8ebc8fc7 100644 --- a/Wox/Languages/fr.xaml +++ b/Wox/Languages/fr.xaml @@ -97,7 +97,7 @@ Impossible de trouver le module spécifié Le nouveau mot-clé d'action doit être spécifié Le nouveau mot-clé d'action a été assigné à un autre module, veuillez en choisir un autre - Ajouté + Ajouté Saisissez * si vous ne souhaitez pas utiliser de mot-clé spécifique diff --git a/Wox/Languages/it.xaml b/Wox/Languages/it.xaml index a8c823aaeb..7696e9dc9e 100644 --- a/Wox/Languages/it.xaml +++ b/Wox/Languages/it.xaml @@ -100,7 +100,7 @@ Impossibile trovare il plugin specificato La nuova parola chiave d'azione non può essere vuota La nuova parola chiave d'azione è stata assegnata ad un altro plugin, per favore sceglierne una differente - Successo + Successo Usa * se non vuoi specificare una parola chiave d'azione diff --git a/Wox/Languages/ja.xaml b/Wox/Languages/ja.xaml index c5bd5a8858..d9a203a241 100644 --- a/Wox/Languages/ja.xaml +++ b/Wox/Languages/ja.xaml @@ -103,7 +103,7 @@ プラグインが見つかりません 新しいアクションキーボードを空にすることはできません 新しいアクションキーボードは他のプラグインに割り当てられています。他のアクションキーボードを指定してください - 成功しました + 成功しました アクションキーボードを指定しない場合、* を使用してください diff --git a/Wox/Languages/ko.xaml b/Wox/Languages/ko.xaml index 5a206622df..7810beec78 100644 --- a/Wox/Languages/ko.xaml +++ b/Wox/Languages/ko.xaml @@ -95,7 +95,7 @@ 플러그인을 찾을 수 없습니다. 새 액션 키워드를 입력하세요. 새 액션 키워드가 할당된 플러그인이 이미 있습니다. 다른 액션 키워드를 입력하세요. - 성공 + 성공 액션 키워드를 지정하지 않으려면 *를 사용하세요. diff --git a/Wox/Languages/nb-NO.xaml b/Wox/Languages/nb-NO.xaml index 778cb7db19..c7f294d932 100644 --- a/Wox/Languages/nb-NO.xaml +++ b/Wox/Languages/nb-NO.xaml @@ -100,7 +100,7 @@ Kan ikke finne den angitte utvidelsen Nytt handlingsnøkkelord kan ikke være tomt De nye handlingsnøkkelordene er tildelt en annen utvidelse, vennligst velg et annet nøkkelord - Vellykket + Vellykket Bruk * hvis du ikke ønsker å angi et handlingsnøkkelord diff --git a/Wox/Languages/nl.xaml b/Wox/Languages/nl.xaml index e81cdd585c..ffb77a7933 100644 --- a/Wox/Languages/nl.xaml +++ b/Wox/Languages/nl.xaml @@ -91,7 +91,7 @@ Kan plugin niet vinden Nieuwe actie sneltoets moet ingevuld worden Nieuwe actie sneltoets is toegewezen aan een andere plugin, wijs een nieuwe actie sneltoets aan - Succesvol + Succesvol Gebruik * wanneer je geen nieuwe actie sneltoets wilt specificeren diff --git a/Wox/Languages/pl.xaml b/Wox/Languages/pl.xaml index 6d1c226686..f6d638fbc8 100644 --- a/Wox/Languages/pl.xaml +++ b/Wox/Languages/pl.xaml @@ -91,7 +91,7 @@ Nie można odnaleźć podanej wtyczki Nowy wyzwalacz nie może być pusty Ten wyzwalacz został już przypisany do innej wtyczki, musisz podać inny wyzwalacz. - Sukces + Sukces Użyj * jeżeli nie chcesz podawać wyzwalacza diff --git a/Wox/Languages/pt-br.xaml b/Wox/Languages/pt-br.xaml index b1b2d0192c..bd4e70f242 100644 --- a/Wox/Languages/pt-br.xaml +++ b/Wox/Languages/pt-br.xaml @@ -100,7 +100,7 @@ Não foi possível encontrar o plugin especificado A nova palavra-chave da ação não pode ser vazia A nova palavra-chave da ação já foi atribuída a outro plugin, por favor tente outra - Sucesso + Sucesso Use * se não quiser especificar uma palavra-chave de ação diff --git a/Wox/Languages/ru.xaml b/Wox/Languages/ru.xaml index 32bee83f0d..945162b425 100644 --- a/Wox/Languages/ru.xaml +++ b/Wox/Languages/ru.xaml @@ -91,7 +91,7 @@ Не удалось найти заданный плагин Новая горячая клавиша не может быть пустой Новая горячая клавиша уже используется другим плагином. Пожалуйста, задайте новую - Сохранено + Сохранено Используйте * в случае, если вы не хотите задавать конкретную горячую клавишу diff --git a/Wox/Languages/sk.xaml b/Wox/Languages/sk.xaml index 08b84f2e25..7a7f083cac 100644 --- a/Wox/Languages/sk.xaml +++ b/Wox/Languages/sk.xaml @@ -101,7 +101,7 @@ Nepodarilo sa nájsť zadaný plugin Nová skratka pre akciu nemôže byť prázdna Nová skratka pre akciu bola priradená pre iný plugin, prosím, zvoľte inú skratku - Úspešné + Úspešné Použite * ak nechcete určiť skratku pre akciu diff --git a/Wox/Languages/sr.xaml b/Wox/Languages/sr.xaml index aa730d7740..dd8826e1c7 100644 --- a/Wox/Languages/sr.xaml +++ b/Wox/Languages/sr.xaml @@ -100,7 +100,7 @@ Navedeni plugin nije moguće pronaći Prečica za novu radnju ne može da bude prazna Prečica za novu radnju je dodeljena drugom plugin-u, molim Vas dodelite drugu prečicu - Uspešno + Uspešno Koristite * ako ne želite da navedete prečicu za radnju diff --git a/Wox/Languages/tr.xaml b/Wox/Languages/tr.xaml new file mode 100644 index 0000000000..82445e2ac7 --- /dev/null +++ b/Wox/Languages/tr.xaml @@ -0,0 +1,145 @@ + + + Kısayol tuşu ataması başarısız oldu: {0} + {0} başlatılamıyor + Geçersiz Wox eklenti dosyası formatı + Bu sorgu için başa sabitle + Sabitlemeyi kaldır + Sorguyu çalıştır: {0} + Son çalıştırma zamanı: {0} + + Ayarlar + Hakkında + Çıkış + + + Wox Ayarları + Genel + Wox'u başlangıçta başlat + Odak pencereden ayrıldığında Wox'u gizle + Güncelleme bildirimlerini gösterme + Pencere konumunu hatırla + Dil + Pencere açıldığında + Son sorguyu sakla + Son sorguyu sakla ve tümünü seç + Sorgu kutusunu temizle + Maksimum sonuç sayısı + Tam ekran modunda kısayol tuşunu gözardı et + Python Konumu + Otomatik Güncelle + Seç + Başlangıçta Wox'u gizle + Sistem çekmecesi simgesini gizle + Sorgu Arama Hassasiyeti + + + Eklentiler + Daha fazla eklenti bul + Devre Dışı + Anahtar Kelimeler + Eklenti Klasörü + Yapımcı + Açılış Süresi: {0}ms + Sorgu Süresi: {0}ms + + + Temalar + Daha fazla tema bul + Merhaba Wox + Pencere Yazı Tipi + Sonuç Yazı Tipi + Pencere Modu + Saydamlık + {0} isimli tema bulunamadı, varsayılan temaya dönülüyor. + {0} isimli tema yüklenirken hata oluştu, varsayılan temaya dönülüyor. + + + Kısayol Tuşu + Wox Kısayolu + Özel Sorgu Kısayolları + Sil + Düzenle + Ekle + Lütfen bir öğe seçin + {0} eklentisi için olan kısayolu silmek istediğinize emin misiniz? + + + Vekil Sunucu + HTTP vekil sunucuyu etkinleştir. + Sunucu Adresi + Port + Kullanıcı Adı + Parola + Ayarları Sına + Kaydet + Sunucu adresi boş olamaz + Port boş olamaz + Port biçimi geçersiz + Vekil sunucu ayarları başarıyla kaydedildi + Vekil sunucu doğru olarak ayarlandı + Vekil sunucuya bağlanılırken hata oluştu + + + Hakkında + Web Sitesi + Sürüm + Şu ana kadar Wox'u {0} kez aktifleştirdiniz. + Güncellemeleri Kontrol Et + Uygulamanın yeni sürümü ({0}) mevcut, Lütfen Wox'u yeniden başlatın. + Güncelleme kontrolü başarısız oldu. Lütfen bağlantınız ve vekil sunucu ayarlarınızın api.github.com adresine ulaşabilir olduğunu kontrol edin. + + Güncellemenin yüklenmesi başarısız oldu. Lütfen bağlantınız ve vekil sunucu ayarlarınızın github-cloud.s3.amazonaws.com + adresine ulaşabilir olduğunu kontrol edin ya da https://github.com/Wox-launcher/Wox/releases adresinden güncellemeyi elle indirin. + + Sürüm Notları: + + + Eski Anahtar Kelime + Yeni Anahtar Kelime + İptal + Tamam + Belirtilen eklenti bulunamadı + Yeni anahtar kelime boş olamaz + Yeni anahtar kelime başka bir eklentiye atanmış durumda. Lütfen başka bir anahtar kelime seçin + Başarılı + Anahtar kelime belirlemek istemiyorsanız * kullanın + + + Önizleme + Kısayol tuşu kullanılabilir değil, lütfen başka bir kısayol tuşu seçin + Geçersiz eklenti kısayol tuşu + Güncelle + + + Kısayol tuşu kullanılabilir değil + + + Sürüm + Tarih + Sorunu çözebilmemiz için lütfen uygulamanın ne yaparken çöktüğünü belirtin. + Raporu Gönder + İptal + Genel + Özel Durumlar + Özel Durum Tipi + Kaynak + Yığın İzleme + Gönderiliyor + Hata raporu başarıyla gönderildi + Hata raporu gönderimi başarısız oldu + Wox'ta bir hata oluştu + + + Wox'un yeni bir sürümü ({0}) mevcut + Güncellemelerin kurulması sırasında bir hata oluştu + Güncelle + İptal + Bu güncelleme Wox'u yeniden başlatacaktır + Aşağıdaki dosyalar güncelleştirilecektir + Güncellenecek dosyalar + Güncelleme açıklaması + + \ No newline at end of file diff --git a/Wox/Languages/uk-UA.xaml b/Wox/Languages/uk-UA.xaml index 2e4d71f773..e114c2706d 100644 --- a/Wox/Languages/uk-UA.xaml +++ b/Wox/Languages/uk-UA.xaml @@ -91,7 +91,7 @@ Не вдалося знайти вказаний плагін Нова гаряча клавіша не може бути порожньою Нова гаряча клавіша вже використовується іншим плагіном. Будь ласка, вкажіть нову - Збережено + Збережено Використовуйте * у разі, якщо ви не хочете ставити конкретну гарячу клавішу diff --git a/Wox/Languages/zh-cn.xaml b/Wox/Languages/zh-cn.xaml index 5e9570d543..679040928c 100644 --- a/Wox/Languages/zh-cn.xaml +++ b/Wox/Languages/zh-cn.xaml @@ -98,7 +98,7 @@ 找不到指定的插件 新触发关键字不能为空 新触发关键字已经被指派给其他插件了,请重新选择一个关键字 - 成功 + 成功 如果你不想设置触发关键字,可以使用*代替 diff --git a/Wox/Languages/zh-tw.xaml b/Wox/Languages/zh-tw.xaml index b32c925cc1..9b26b0d067 100644 --- a/Wox/Languages/zh-tw.xaml +++ b/Wox/Languages/zh-tw.xaml @@ -91,7 +91,7 @@ 找不到指定的外掛 新觸發關鍵字不能為空白 新觸發關鍵字已經被指派給另一外掛,請設定其他關鍵字。 - 成功 + 成功 如果不想設定觸發關鍵字,可以使用*代替 diff --git a/Wox/PublicAPIInstance.cs b/Wox/PublicAPIInstance.cs index 748c7aac65..4bcc825309 100644 --- a/Wox/PublicAPIInstance.cs +++ b/Wox/PublicAPIInstance.cs @@ -59,13 +59,23 @@ namespace Wox // we must manually save // UpdateManager.RestartApp() will call Environment.Exit(0) // which will cause ungraceful exit + SaveAppAllSettings(); + + UpdateManager.RestartApp(); + } + + public void SaveAppAllSettings() + { _mainVM.Save(); _settingsVM.Save(); PluginManager.Save(); ImageLoader.Save(); Alphabet.Save(); + } - UpdateManager.RestartApp(); + public void ReloadAllPluginData() + { + PluginManager.ReloadData(); } [Obsolete] diff --git a/Wox/SettingWindow.xaml b/Wox/SettingWindow.xaml index bf25e3e600..86d6a345a9 100644 --- a/Wox/SettingWindow.xaml +++ b/Wox/SettingWindow.xaml @@ -55,6 +55,12 @@ Checked="OnAutoStartupChecked" Unchecked="OnAutoStartupUncheck"> + + + + StringMatcher.IsMatch(r.Title, query) || - StringMatcher.IsMatch(r.SubTitle, query) + r => StringMatcher.FuzzySearch(query, r.Title).IsSearchPrecisionScoreMet() + || StringMatcher.FuzzySearch(query, r.SubTitle).IsSearchPrecisionScoreMet() ).ToList(); ContextMenu.AddResults(filtered, id); } @@ -348,8 +348,8 @@ namespace Wox.ViewModel { var filtered = results.Where ( - r => StringMatcher.IsMatch(r.Title, query) || - StringMatcher.IsMatch(r.SubTitle, query) + r => StringMatcher.FuzzySearch(query, r.Title).IsSearchPrecisionScoreMet() || + StringMatcher.FuzzySearch(query, r.SubTitle).IsSearchPrecisionScoreMet() ).ToList(); History.AddResults(filtered, id); } @@ -440,7 +440,7 @@ namespace Wox.ViewModel Action = _ => { _topMostRecord.Remove(result); - App.API.ShowMsg("Succeed"); + App.API.ShowMsg("Success"); return false; } }; @@ -455,7 +455,7 @@ namespace Wox.ViewModel Action = _ => { _topMostRecord.AddOrUpdate(result); - App.API.ShowMsg("Succeed"); + App.API.ShowMsg("Success"); return false; } }; diff --git a/Wox/ViewModel/ResultsViewModel.cs b/Wox/ViewModel/ResultsViewModel.cs index a92b84930f..674923228e 100644 --- a/Wox/ViewModel/ResultsViewModel.cs +++ b/Wox/ViewModel/ResultsViewModel.cs @@ -148,25 +148,28 @@ namespace Wox.ViewModel private List NewResults(List newRawResults, string resultId) { - var newResults = newRawResults.Select(r => new ResultViewModel(r)).ToList(); var results = Results.ToList(); + var newResults = newRawResults.Select(r => new ResultViewModel(r)).ToList(); var oldResults = results.Where(r => r.Result.PluginID == resultId).ToList(); - // intersection of A (old results) and B (new newResults) - var intersection = oldResults.Intersect(newResults).ToList(); - + // Find the same results in A (old results) and B (new newResults) + var sameResults = oldResults + .Where(t1 => newResults.Any(x => x.Result.Equals(t1.Result))) + .Select(t1 => t1) + .ToList(); + // remove result of relative complement of B in A - foreach (var result in oldResults.Except(intersection)) + foreach (var result in oldResults.Except(sameResults)) { results.Remove(result); } - // update index for result in intersection of A and B - foreach (var commonResult in intersection) + // update result with B's score and index position + foreach (var sameResult in sameResults) { - int oldIndex = results.IndexOf(commonResult); + int oldIndex = results.IndexOf(sameResult); int oldScore = results[oldIndex].Result.Score; - var newResult = newResults[newResults.IndexOf(commonResult)]; + var newResult = newResults[newResults.IndexOf(sameResult)]; int newScore = newResult.Result.Score; if (newScore != oldScore) { @@ -182,7 +185,7 @@ namespace Wox.ViewModel } // insert result in relative complement of A in B - foreach (var result in newResults.Except(intersection)) + foreach (var result in newResults.Except(sameResults)) { int newIndex = InsertIndexOf(result.Result.Score, results); results.Insert(newIndex, result); diff --git a/Wox/ViewModel/SettingWindowViewModel.cs b/Wox/ViewModel/SettingWindowViewModel.cs index 7c4f5ad807..67b8d7af06 100644 --- a/Wox/ViewModel/SettingWindowViewModel.cs +++ b/Wox/ViewModel/SettingWindowViewModel.cs @@ -70,6 +70,20 @@ namespace Wox.ViewModel } } + public List QuerySearchPrecisionStrings + { + get + { + var precisionStrings = new List(); + + var enumList = Enum.GetValues(typeof(StringMatcher.SearchPrecisionScore)).Cast().ToList(); + + enumList.ForEach(x => precisionStrings.Add(x.ToString())); + + return precisionStrings; + } + } + private Internationalization _translater => InternationalizationManager.Instance; public List Languages => _translater.LoadAvailableLanguages(); public IEnumerable MaxResultsRange => Enumerable.Range(2, 16); diff --git a/Wox/Wox.csproj b/Wox/Wox.csproj index faa10af787..ef77148291 100644 --- a/Wox/Wox.csproj +++ b/Wox/Wox.csproj @@ -313,6 +313,11 @@ Designer PreserveNewest + + MSBuild:Compile + Designer + PreserveNewest + MSBuild:Compile Designer @@ -377,7 +382,7 @@ MSBuild:Compile Designer - PreserveNewest + PreserveNewest MSBuild:Compile