diff --git a/Wox.Core/Plugin/PluginInstaller.cs b/Wox.Core/Plugin/PluginInstaller.cs index 25e7d3b3c1..c6a53606ed 100644 --- a/Wox.Core/Plugin/PluginInstaller.cs +++ b/Wox.Core/Plugin/PluginInstaller.cs @@ -6,6 +6,7 @@ using System.Windows.Forms; using ICSharpCode.SharpZipLib.Zip; using Newtonsoft.Json; using Wox.Plugin; +using MessageBox = System.Windows.Forms.MessageBox; namespace Wox.Core.Plugin { @@ -61,7 +62,7 @@ namespace Wox.Core.Plugin plugin.Name, existingPlugin.Metadata.Version, plugin.Version, plugin.Author); } - DialogResult result = MessageBox.Show(content, "Install plugin", MessageBoxButtons.YesNo, + DialogResult result = System.Windows.Forms.MessageBox.Show(content, "Install plugin", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { diff --git a/Wox.Core/README.md b/Wox.Core/README.md index 2c191d0856..337b0a463d 100644 --- a/Wox.Core/README.md +++ b/Wox.Core/README.md @@ -2,4 +2,6 @@ ===== * Handle Query -* Loading Plugins (including system plugin and user plugin) \ No newline at end of file +* Manage Plugins (including system plugin and user plugin) +* Manage Themes +* Manage i18n \ No newline at end of file diff --git a/Wox/Helper/FontHelper.cs b/Wox.Core/Theme/FontHelper.cs similarity index 96% rename from Wox/Helper/FontHelper.cs rename to Wox.Core/Theme/FontHelper.cs index cdc30f1fb9..8aca0b4363 100644 --- a/Wox/Helper/FontHelper.cs +++ b/Wox.Core/Theme/FontHelper.cs @@ -1,12 +1,9 @@ using System; -using System.Collections.Generic; using System.Linq; -using System.Text; using System.Windows; using System.Windows.Media; -using Wox.Helper; -namespace Wox.Helper +namespace Wox.Core.Theme { public static class FontHelper { diff --git a/Wox/Helper/ThemeManager.cs b/Wox.Core/Theme/ThemeManager.cs similarity index 82% rename from Wox/Helper/ThemeManager.cs rename to Wox.Core/Theme/ThemeManager.cs index 43260a2743..baf59c37aa 100644 --- a/Wox/Helper/ThemeManager.cs +++ b/Wox.Core/Theme/ThemeManager.cs @@ -3,19 +3,40 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; -using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Media; -using Wox.Helper; +using Wox.Core.UI; using Wox.Infrastructure.Logger; using Wox.Infrastructure.Storage.UserSettings; -namespace Wox +namespace Wox.Core.Theme { - internal class ThemeManager + public class ThemeManager : IUIResource { private static List themeDirectories = new List(); + private static ThemeManager instance; + private static object syncObject = new object(); + + private ThemeManager() { } + + public static ThemeManager Instance + { + get + { + if (instance == null) + { + lock (syncObject) + { + if (instance == null) + { + instance = new ThemeManager(); + } + } + } + return instance; + } + } static ThemeManager() { @@ -40,7 +61,7 @@ namespace Wox { Directory.CreateDirectory(pluginDirectory); } - catch (Exception e) + catch (System.Exception e) { Log.Error(e.Message); } @@ -48,7 +69,7 @@ namespace Wox } } - public static void ChangeTheme(string themeName) + public void ChangeTheme(string themeName) { string themePath = GetThemePath(themeName); if (string.IsNullOrEmpty(themePath)) @@ -56,7 +77,7 @@ namespace Wox themePath = GetThemePath("Dark"); if (string.IsNullOrEmpty(themePath)) { - throw new Exception("Change theme failed"); + throw new System.Exception("Change theme failed"); } } @@ -66,7 +87,7 @@ namespace Wox ResourceMerger.ApplyResources(); } - internal static ResourceDictionary GetResourceDictionary() + public ResourceDictionary GetResourceDictionary() { var dict = new ResourceDictionary { @@ -100,20 +121,20 @@ namespace Wox return dict; } - public static List LoadAvailableThemes() + public List LoadAvailableThemes() { List themes = new List(); foreach (var themeDirectory in themeDirectories) { themes.AddRange( Directory.GetFiles(themeDirectory) - .Where(filePath => filePath.EndsWith(".xaml") && !filePath.EndsWith("Default.xaml")) + .Where(filePath => filePath.EndsWith(".xaml") && !filePath.EndsWith("Base.xaml")) .ToList()); } return themes; } - private static string GetThemePath(string themeName) + private string GetThemePath(string themeName) { foreach (string themeDirectory in themeDirectories) { diff --git a/Wox.Core/UI/ResourceMerger.cs b/Wox.Core/UI/ResourceMerger.cs new file mode 100644 index 0000000000..5f6ee7e60c --- /dev/null +++ b/Wox.Core/UI/ResourceMerger.cs @@ -0,0 +1,27 @@ +using System; +using System.Linq; +using System.Windows; +using Wox.Core.i18n; +using Wox.Core.Theme; + +namespace Wox.Core.UI +{ + public class ResourceMerger + { + public static void ApplyResources() + { + var UIResourceType = typeof(IUIResource); + var UIResources = AppDomain.CurrentDomain.GetAssemblies() + .SelectMany(s => s.GetTypes()) + .Where(p => p.IsClass && !p.IsAbstract && UIResourceType.IsAssignableFrom(p)); + + Application.Current.Resources.MergedDictionaries.Clear(); + + foreach (var uiResource in UIResources) + { + Application.Current.Resources.MergedDictionaries.Add( + ((IUIResource)Activator.CreateInstance(uiResource)).GetResourceDictionary()); + } + } + } +} diff --git a/Wox.Core/Wox.Core.csproj b/Wox.Core/Wox.Core.csproj index 310f255fd7..61037d42b8 100644 --- a/Wox.Core/Wox.Core.csproj +++ b/Wox.Core/Wox.Core.csproj @@ -40,6 +40,8 @@ False ..\packages\Newtonsoft.Json.6.0.7\lib\net35\Newtonsoft.Json.dll + + @@ -47,6 +49,7 @@ + @@ -54,6 +57,9 @@ + + + @@ -68,6 +74,8 @@ + + diff --git a/Wox/Helper/LanguageManager.cs b/Wox.Core/i18n/InternationalizationManager.cs similarity index 72% rename from Wox/Helper/LanguageManager.cs rename to Wox.Core/i18n/InternationalizationManager.cs index eb46559c5f..6750ab32d9 100644 --- a/Wox/Helper/LanguageManager.cs +++ b/Wox.Core/i18n/InternationalizationManager.cs @@ -3,20 +3,40 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; -using System.Text; using System.Windows; -using System.Windows.Controls; -using Wox.Helper; +using Wox.Core.UI; using Wox.Infrastructure.Logger; using Wox.Infrastructure.Storage.UserSettings; -namespace Wox +namespace Wox.Core.i18n { - public class LanguageManager + public class InternationalizationManager : IUIResource { private static List languageDirectories = new List(); + private static InternationalizationManager instance; + private static object syncObject = new object(); - static LanguageManager() + private InternationalizationManager() { } + + public static InternationalizationManager Instance + { + get + { + if (instance == null) + { + lock (syncObject) + { + if (instance == null) + { + instance = new InternationalizationManager(); + } + } + } + return instance; + } + } + + static InternationalizationManager() { languageDirectories.Add(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Languages")); @@ -39,7 +59,7 @@ namespace Wox { Directory.CreateDirectory(pluginDirectory); } - catch (Exception e) + catch (System.Exception e) { Log.Error(e.Message); } @@ -47,7 +67,7 @@ namespace Wox } } - public static void ChangeLanguage(string name) + public void ChangeLanguage(string name) { string path = GetLanguagePath(name); if (string.IsNullOrEmpty(path)) @@ -55,7 +75,7 @@ namespace Wox path = GetLanguagePath("English"); if (string.IsNullOrEmpty(path)) { - throw new Exception("Change Language failed"); + throw new System.Exception("Change Language failed"); } } @@ -64,7 +84,7 @@ namespace Wox ResourceMerger.ApplyResources(); } - internal static ResourceDictionary GetResourceDictionary() + public ResourceDictionary GetResourceDictionary() { return new ResourceDictionary { @@ -72,7 +92,7 @@ namespace Wox }; } - public static List LoadAvailableLanguages() + public List LoadAvailableLanguages() { List themes = new List(); foreach (var directory in languageDirectories) @@ -86,7 +106,7 @@ namespace Wox return themes; } - public static string GetTranslation(string key) + public string GetTranslation(string key) { try { @@ -104,7 +124,7 @@ namespace Wox } - private static string GetLanguagePath(string name) + private string GetLanguagePath(string name) { foreach (string directory in languageDirectories) { diff --git a/Wox.Infrastructure/ISingleton.cs b/Wox.Infrastructure/ISingleton.cs new file mode 100644 index 0000000000..32555980f6 --- /dev/null +++ b/Wox.Infrastructure/ISingleton.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Wox.Infrastructure +{ + interface ISingleton + { + T Instance { get; } + } +} diff --git a/Wox.Infrastructure/Wox.Infrastructure.csproj b/Wox.Infrastructure/Wox.Infrastructure.csproj index d862f7774a..ed897bbd58 100644 --- a/Wox.Infrastructure/Wox.Infrastructure.csproj +++ b/Wox.Infrastructure/Wox.Infrastructure.csproj @@ -57,6 +57,7 @@ + diff --git a/Wox/ActionKeyword.xaml b/Wox/ActionKeyword.xaml index 20288b6d15..27ed9ad171 100644 --- a/Wox/ActionKeyword.xaml +++ b/Wox/ActionKeyword.xaml @@ -17,18 +17,18 @@ - Old ActionKeyword: + Old ActionKeyword: - New ActionKeyword: + - + diff --git a/Wox/ActionKeyword.xaml.cs b/Wox/ActionKeyword.xaml.cs index 4851a979b6..23f2952bb4 100644 --- a/Wox/ActionKeyword.xaml.cs +++ b/Wox/ActionKeyword.xaml.cs @@ -11,6 +11,7 @@ using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; +using Wox.Core.i18n; using Wox.Core.Plugin; using Wox.Infrastructure.Storage.UserSettings; using Wox.Plugin; @@ -28,7 +29,7 @@ namespace Wox PluginPair plugin = PluginManager.GetPlugin(pluginId); if (plugin == null) { - MessageBox.Show("Can't find specific plugin"); + MessageBox.Show(InternationalizationManager.Instance.GetTranslation("cannotFindSpecifiedPlugin")); Close(); return; } @@ -51,14 +52,14 @@ namespace Wox { if (string.IsNullOrEmpty(tbAction.Text)) { - MessageBox.Show("New ActionKeyword can't be empty"); + MessageBox.Show(InternationalizationManager.Instance.GetTranslation("newActionKeywordCannotBeEmpty")); return; } //check new action keyword didn't used by other plugin if (PluginManager.AllPlugins.Exists(o => o.Metadata.ActionKeyword == tbAction.Text.Trim())) { - MessageBox.Show("New ActionKeyword has been assigned to other plugin, please assign another new action keyword"); + MessageBox.Show(InternationalizationManager.Instance.GetTranslation("newActionKeywordHasBeenAssigned")); return; } @@ -80,10 +81,8 @@ namespace Wox customizedPluginConfig.Actionword = tbAction.Text.Trim(); } UserSettingStorage.Instance.Save(); - MessageBox.Show("Sucessfully applied the new action keyword"); + MessageBox.Show(InternationalizationManager.Instance.GetTranslation("succeed")); Close(); } - - } } diff --git a/Wox/CustomPluginHotkeySetting.xaml b/Wox/CustomQueryHotkeySetting.xaml similarity index 79% rename from Wox/CustomPluginHotkeySetting.xaml rename to Wox/CustomQueryHotkeySetting.xaml index ac3bc9f632..fc714d1b0d 100644 --- a/Wox/CustomPluginHotkeySetting.xaml +++ b/Wox/CustomQueryHotkeySetting.xaml @@ -1,4 +1,4 @@ - - Hotkey: + - Action Keyword: + - + - + diff --git a/Wox/CustomPluginHotkeySetting.xaml.cs b/Wox/CustomQueryHotkeySetting.xaml.cs similarity index 80% rename from Wox/CustomPluginHotkeySetting.xaml.cs rename to Wox/CustomQueryHotkeySetting.xaml.cs index 3cdb33dc8a..9c5b4a8a0c 100644 --- a/Wox/CustomPluginHotkeySetting.xaml.cs +++ b/Wox/CustomQueryHotkeySetting.xaml.cs @@ -1,17 +1,18 @@ using System.Collections.Generic; using System.Linq; using System.Windows; +using Wox.Core.i18n; using Wox.Infrastructure.Storage.UserSettings; namespace Wox { - public partial class CustomPluginHotkeySetting : Window + public partial class CustomQueryHotkeySetting : Window { private SettingWindow settingWidow; private bool update; private CustomPluginHotkey updateCustomHotkey; - public CustomPluginHotkeySetting(SettingWindow settingWidow) + public CustomQueryHotkeySetting(SettingWindow settingWidow) { this.settingWidow = settingWidow; InitializeComponent(); @@ -28,7 +29,7 @@ namespace Wox { if (!ctlHotkey.CurrentHotkeyAvailable) { - MessageBox.Show("Hotkey is unavailable, please select a new hotkey"); + MessageBox.Show(InternationalizationManager.Instance.GetTranslation("hotkeyIsNotUnavailable")); return; } @@ -48,13 +49,13 @@ namespace Wox settingWidow.MainWindow.ChangeQuery(pluginHotkey.ActionKeyword); settingWidow.MainWindow.ShowApp(); }); - MessageBox.Show("Add hotkey successfully!"); + MessageBox.Show(InternationalizationManager.Instance.GetTranslation("succeed")); } else { if (updateCustomHotkey.Hotkey != ctlHotkey.CurrentHotkey.ToString() && !ctlHotkey.CurrentHotkeyAvailable) { - MessageBox.Show("Hotkey is unavailable, please select a new hotkey"); + MessageBox.Show(InternationalizationManager.Instance.GetTranslation("hotkeyIsNotUnavailable")); return; } var oldHotkey = updateCustomHotkey.Hotkey; @@ -67,7 +68,7 @@ namespace Wox settingWidow.MainWindow.ShowApp(); settingWidow.MainWindow.ChangeQuery(updateCustomHotkey.ActionKeyword); }); - MessageBox.Show("Update successfully!"); + MessageBox.Show(InternationalizationManager.Instance.GetTranslation("succeed")); } UserSettingStorage.Instance.Save(); @@ -80,7 +81,7 @@ namespace Wox updateCustomHotkey = UserSettingStorage.Instance.CustomPluginHotkeys.FirstOrDefault(o => o.ActionKeyword == item.ActionKeyword && o.Hotkey == item.Hotkey); if (updateCustomHotkey == null) { - MessageBox.Show("Invalid plugin hotkey"); + MessageBox.Show(InternationalizationManager.Instance.GetTranslation("invalidPluginHotkey")); Close(); return; } @@ -88,7 +89,7 @@ namespace Wox tbAction.Text = updateCustomHotkey.ActionKeyword; ctlHotkey.SetHotkey(updateCustomHotkey.Hotkey, false); update = true; - lblAdd.Text = "Update"; + lblAdd.Text = InternationalizationManager.Instance.GetTranslation("update"); } private void BtnTestActionKeyword_OnClick(object sender, RoutedEventArgs e) diff --git a/Wox/Helper/ResourceMerger.cs b/Wox/Helper/ResourceMerger.cs deleted file mode 100644 index f57cbb4e92..0000000000 --- a/Wox/Helper/ResourceMerger.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows; - -namespace Wox.Helper -{ - public class ResourceMerger - { - public static void ApplyResources() - { - var languageResource = LanguageManager.GetResourceDictionary(); - var themeResource = ThemeManager.GetResourceDictionary(); - - Application.Current.Resources.MergedDictionaries.Clear(); - Application.Current.Resources.MergedDictionaries.Add(languageResource); - Application.Current.Resources.MergedDictionaries.Add(themeResource); - } - } -} diff --git a/Wox/HotkeyControl.xaml.cs b/Wox/HotkeyControl.xaml.cs index 83b3bb3bea..77cd95ea3b 100644 --- a/Wox/HotkeyControl.xaml.cs +++ b/Wox/HotkeyControl.xaml.cs @@ -6,6 +6,7 @@ using System.Windows.Input; using System.Windows.Media; using NHotkey; using NHotkey.Wpf; +using Wox.Core.i18n; using Wox.Helper; using Wox.Infrastructure; using Wox.Infrastructure.Hotkey; @@ -98,12 +99,12 @@ namespace Wox if (!CurrentHotkeyAvailable) { tbMsg.Foreground = new SolidColorBrush(Colors.Red); - tbMsg.Text = "hotkey unavailable"; + tbMsg.Text = InternationalizationManager.Instance.GetTranslation("hotkeyUnavailable"); } else { tbMsg.Foreground = new SolidColorBrush(Colors.Green); - tbMsg.Text = "succeed"; + tbMsg.Text = InternationalizationManager.Instance.GetTranslation("succeed"); } OnOnHotkeyChanged(); } diff --git a/Wox/Languages/English.xaml b/Wox/Languages/English.xaml index a91e3a2d9b..ee7c18c2ae 100644 --- a/Wox/Languages/English.xaml +++ b/Wox/Languages/English.xaml @@ -1,6 +1,12 @@  + + Register hotkey: {0} failed + Could not start {0} + Invalid wox plugin file format + + General Start Wox on system startup @@ -49,11 +55,30 @@ Invalid port format Save proxy successfully Proxy is correct - + Proxy connect failed About Website Version + + + Old Action Keyword + New Action Keyword + Cancel + Done + Can't find specified plugin + New Action Keyword can't be empty + New ActionKeyword has been assigned to other plugin, please assign another new action keyword + Succeed + + + Preview + Hotkey is unavailable, please select a new hotkey + Invalid plugin hotkey + Update + + + Hotkey unavailable \ No newline at end of file diff --git a/Wox/Languages/中文.xaml b/Wox/Languages/中文.xaml index 243352f307..b13726eb4b 100644 --- a/Wox/Languages/中文.xaml +++ b/Wox/Languages/中文.xaml @@ -1,6 +1,12 @@  + + 注册热键:{0} 失败 + 启动命令 {0} 失败 + 不是合法的Wox插件格式 + + 通用 开机启动 @@ -32,6 +38,8 @@ 删除 编辑 增加 + 请选择一项 + 你确定要删除插件 {0} 的热键吗? 代理 @@ -42,10 +50,36 @@ 密码 测试代理 保存 - + 服务器不能为空 + 端口不能为空 + 非法的端口格式 + 保存代理设置成功 + 代理设置正确 + 代理连接失败 + 关于 网站 版本 + + + 旧触发关键字 + 新触发关键字 + 取消 + 确定 + 找不到指定的插件 + 新触发关键字不能为空 + 新触发关键字已经被指派给其他插件了,请重新选择一个关键字 + 成功 + + + 预览 + 热键不可用,请选择一个新的热键 + 插件热键不合法 + 更新 + + + 热键不可用 + \ No newline at end of file diff --git a/Wox/MainWindow.xaml.cs b/Wox/MainWindow.xaml.cs index 261a549253..9feba7a30c 100644 --- a/Wox/MainWindow.xaml.cs +++ b/Wox/MainWindow.xaml.cs @@ -14,7 +14,9 @@ using WindowsInput; using WindowsInput.Native; using NHotkey; using NHotkey.Wpf; +using Wox.Core.i18n; using Wox.Core.Plugin; +using Wox.Core.Theme; using Wox.Helper; using Wox.Infrastructure; using Wox.Infrastructure.Hotkey; @@ -128,7 +130,7 @@ namespace Wox public void ReloadPlugins() { - Dispatcher.Invoke(new Action(()=> PluginManager.Init(this))); + Dispatcher.Invoke(new Action(() => PluginManager.Init(this))); } public List GetAllPlugins() @@ -173,8 +175,8 @@ namespace Wox pnlResult.RightMouseClickEvent += pnlResult_RightMouseClickEvent; ThreadPool.SetMaxThreads(30, 10); - ThemeManager.ChangeTheme(UserSettingStorage.Instance.Theme); - LanguageManager.ChangeLanguage(UserSettingStorage.Instance.Language); + ThemeManager.Instance.ChangeTheme(UserSettingStorage.Instance.Theme); + InternationalizationManager.Instance.ChangeLanguage(UserSettingStorage.Instance.Language); SetHotkey(UserSettingStorage.Instance.Hotkey, OnHotkey); SetCustomPluginHotkey(); @@ -266,7 +268,8 @@ namespace Wox } catch (Exception) { - MessageBox.Show("Register hotkey: " + hotkeyStr + " failed."); + string errorMsg = string.Format(InternationalizationManager.Instance.GetTranslation("registerHotkeyFailed"), hotkeyStr); + MessageBox.Show(errorMsg); } } @@ -557,7 +560,7 @@ namespace Wox break; case Key.F1: - Process.Start("https://github.com/qianlifeng/Wox/wiki/Wox-Function-Guide"); + Process.Start("http://doc.getwox.com"); break; case Key.Enter: @@ -568,7 +571,7 @@ namespace Wox } else { - SelectResult(activeResult); + SelectResult(activeResult); } e.Handled = true; break; @@ -590,7 +593,7 @@ namespace Wox { return pnlResult.GetActiveResult(); } - } + } private void SelectPrevItem() { @@ -683,7 +686,8 @@ namespace Wox } catch (Exception ex) { - ShowMsg("Could not start " + cmd, ex.Message, null); + string errorMsg = string.Format(InternationalizationManager.Instance.GetTranslation("couldnotStartCmd"), cmd); + ShowMsg(errorMsg, ex.Message, null); } return false; } @@ -700,7 +704,7 @@ namespace Wox } else { - MessageBox.Show("incorrect wox plugin file."); + MessageBox.Show(InternationalizationManager.Instance.GetTranslation("invalidWoxPluginFileFormat")); } } } diff --git a/Wox/SettingWindow.xaml b/Wox/SettingWindow.xaml index 8e213dbbd6..966416430d 100644 --- a/Wox/SettingWindow.xaml +++ b/Wox/SettingWindow.xaml @@ -20,7 +20,7 @@ - + @@ -33,7 +33,7 @@ - + diff --git a/Wox/SettingWindow.xaml.cs b/Wox/SettingWindow.xaml.cs index c25849c461..8445f2c098 100644 --- a/Wox/SettingWindow.xaml.cs +++ b/Wox/SettingWindow.xaml.cs @@ -21,6 +21,8 @@ using Application = System.Windows.Forms.Application; using File = System.IO.File; using MessageBox = System.Windows.MessageBox; using System.Windows.Data; +using Wox.Core.i18n; +using Wox.Core.Theme; namespace Wox { @@ -150,7 +152,7 @@ namespace Wox } }); - foreach (string theme in ThemeManager.LoadAvailableThemes()) + foreach (string theme in ThemeManager.Instance.LoadAvailableThemes()) { string themeName = System.IO.Path.GetFileNameWithoutExtension(theme); themeComboBox.Items.Add(themeName); @@ -174,7 +176,7 @@ namespace Wox } //PreviewPanel - ThemeManager.ChangeTheme(UserSettingStorage.Instance.Theme); + ThemeManager.Instance.ChangeTheme(UserSettingStorage.Instance.Theme); #endregion #region Plugin @@ -244,7 +246,7 @@ namespace Wox private void LoadLanguages() { - cbLanguages.ItemsSource = LanguageManager.LoadAvailableLanguages(); + cbLanguages.ItemsSource = InternationalizationManager.Instance.LoadAvailableLanguages(); cbLanguages.SelectedValue = UserSettingStorage.Instance.Language; cbLanguages.SelectionChanged += cbLanguages_SelectionChanged; } @@ -252,7 +254,7 @@ namespace Wox void cbLanguages_SelectionChanged(object sender, SelectionChangedEventArgs e) { string language = cbLanguages.SelectedValue.ToString(); - LanguageManager.ChangeLanguage(language); + InternationalizationManager.Instance.ChangeLanguage(language); } private void EnableProxy() @@ -330,12 +332,12 @@ namespace Wox CustomPluginHotkey item = lvCustomHotkey.SelectedItem as CustomPluginHotkey; if (item == null) { - MessageBox.Show(LanguageManager.GetTranslation("pleaseSelectAnItem")); + MessageBox.Show(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem")); return; } - string deleteWarning = string.Format(LanguageManager.GetTranslation("deleteCustomHotkeyWarning"), item.Hotkey); - if (MessageBox.Show(deleteWarning, LanguageManager.GetTranslation("delete"), MessageBoxButton.YesNo) == MessageBoxResult.Yes) + string deleteWarning = string.Format(InternationalizationManager.Instance.GetTranslation("deleteCustomHotkeyWarning"), item.Hotkey); + if (MessageBox.Show(deleteWarning, InternationalizationManager.Instance.GetTranslation("delete"), MessageBoxButton.YesNo) == MessageBoxResult.Yes) { UserSettingStorage.Instance.CustomPluginHotkeys.Remove(item); lvCustomHotkey.Items.Refresh(); @@ -349,19 +351,19 @@ namespace Wox CustomPluginHotkey item = lvCustomHotkey.SelectedItem as CustomPluginHotkey; if (item != null) { - CustomPluginHotkeySetting window = new CustomPluginHotkeySetting(this); + CustomQueryHotkeySetting window = new CustomQueryHotkeySetting(this); window.UpdateItem(item); window.ShowDialog(); } else { - MessageBox.Show(LanguageManager.GetTranslation("pleaseSelectAnItem")); + MessageBox.Show(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem")); } } private void BtnAddCustomeHotkey_OnClick(object sender, RoutedEventArgs e) { - new CustomPluginHotkeySetting(this).ShowDialog(); + new CustomQueryHotkeySetting(this).ShowDialog(); } public void ReloadCustomPluginHotkeyView() @@ -375,7 +377,7 @@ namespace Wox private void ThemeComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) { string themeName = themeComboBox.SelectedItem.ToString(); - ThemeManager.ChangeTheme(themeName); + ThemeManager.Instance.ChangeTheme(themeName); UserSettingStorage.Instance.Theme = themeName; UserSettingStorage.Instance.Save(); } @@ -388,7 +390,7 @@ namespace Wox this.cbQueryBoxFontFaces.SelectedItem = ((FontFamily)cbQueryBoxFont.SelectedItem).ChooseRegularFamilyTypeface(); UserSettingStorage.Instance.Save(); - ThemeManager.ChangeTheme(UserSettingStorage.Instance.Theme); + ThemeManager.Instance.ChangeTheme(UserSettingStorage.Instance.Theme); } private void CbQueryBoxFontFaces_OnSelectionChanged(object sender, SelectionChangedEventArgs e) @@ -408,7 +410,7 @@ namespace Wox UserSettingStorage.Instance.QueryBoxFontWeight = typeface.Weight.ToString(); UserSettingStorage.Instance.QueryBoxFontStyle = typeface.Style.ToString(); UserSettingStorage.Instance.Save(); - ThemeManager.ChangeTheme(UserSettingStorage.Instance.Theme); + ThemeManager.Instance.ChangeTheme(UserSettingStorage.Instance.Theme); } } @@ -420,7 +422,7 @@ namespace Wox this.cbResultItemFontFaces.SelectedItem = ((FontFamily)cbResultItemFont.SelectedItem).ChooseRegularFamilyTypeface(); UserSettingStorage.Instance.Save(); - ThemeManager.ChangeTheme(UserSettingStorage.Instance.Theme); + ThemeManager.Instance.ChangeTheme(UserSettingStorage.Instance.Theme); } private void CbResultItemFontFaces_OnSelectionChanged(object sender, SelectionChangedEventArgs e) @@ -438,21 +440,24 @@ namespace Wox UserSettingStorage.Instance.ResultItemFontWeight = typeface.Weight.ToString(); UserSettingStorage.Instance.ResultItemFontStyle = typeface.Style.ToString(); UserSettingStorage.Instance.Save(); - ThemeManager.ChangeTheme(UserSettingStorage.Instance.Theme); + ThemeManager.Instance.ChangeTheme(UserSettingStorage.Instance.Theme); } } private void slOpacity_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) { UserSettingStorage.Instance.Opacity = slOpacity.Value; - UserSettingStorage.Instance.Save(); if (UserSettingStorage.Instance.OpacityMode == OpacityMode.LayeredWindow) PreviewMainPanel.Opacity = UserSettingStorage.Instance.Opacity; else PreviewMainPanel.Opacity = 1; - ThemeManager.ChangeTheme(UserSettingStorage.Instance.Theme); + ThemeManager.Instance.ChangeTheme(UserSettingStorage.Instance.Theme); + Dispatcher.DelayInvoke("delaySaveUserSetting", o => + { + UserSettingStorage.Instance.Save(); + }, TimeSpan.FromMilliseconds(1000)); } #endregion @@ -650,17 +655,17 @@ namespace Wox { if (string.IsNullOrEmpty(tbProxyServer.Text)) { - MessageBox.Show(LanguageManager.GetTranslation("serverCantBeEmpty")); + MessageBox.Show(InternationalizationManager.Instance.GetTranslation("serverCantBeEmpty")); return; } if (string.IsNullOrEmpty(tbProxyPort.Text)) { - MessageBox.Show(LanguageManager.GetTranslation("portCantBeEmpty")); + MessageBox.Show(InternationalizationManager.Instance.GetTranslation("portCantBeEmpty")); return; } if (!int.TryParse(tbProxyPort.Text, out port)) { - MessageBox.Show(LanguageManager.GetTranslation("invalidPortFormat")); + MessageBox.Show(InternationalizationManager.Instance.GetTranslation("invalidPortFormat")); return; } } @@ -671,25 +676,25 @@ namespace Wox UserSettingStorage.Instance.ProxyPassword = tbProxyPassword.Password; UserSettingStorage.Instance.Save(); - MessageBox.Show(LanguageManager.GetTranslation("saveProxySuccessfully")); + MessageBox.Show(InternationalizationManager.Instance.GetTranslation("saveProxySuccessfully")); } private void btnTestProxy_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(tbProxyServer.Text)) { - MessageBox.Show(LanguageManager.GetTranslation("serverCantBeEmpty")); + MessageBox.Show(InternationalizationManager.Instance.GetTranslation("serverCantBeEmpty")); return; } if (string.IsNullOrEmpty(tbProxyPort.Text)) { - MessageBox.Show(LanguageManager.GetTranslation("portCantBeEmpty")); + MessageBox.Show(InternationalizationManager.Instance.GetTranslation("portCantBeEmpty")); return; } int port; if (!int.TryParse(tbProxyPort.Text, out port)) { - MessageBox.Show(LanguageManager.GetTranslation("invalidPortFormat")); + MessageBox.Show(InternationalizationManager.Instance.GetTranslation("invalidPortFormat")); return; } @@ -710,16 +715,16 @@ namespace Wox HttpWebResponse response = (HttpWebResponse)request.GetResponse(); if (response.StatusCode == HttpStatusCode.OK) { - MessageBox.Show(LanguageManager.GetTranslation("proxyIsCorrect")); + MessageBox.Show(InternationalizationManager.Instance.GetTranslation("proxyIsCorrect")); } else { - MessageBox.Show("Proxy connect failed."); + MessageBox.Show(InternationalizationManager.Instance.GetTranslation("proxyConnectFailed")); } } catch { - MessageBox.Show("Proxy connect failed."); + MessageBox.Show(InternationalizationManager.Instance.GetTranslation("proxyConnectFailed")); } } diff --git a/Wox/Wox.csproj b/Wox/Wox.csproj index 9f6414f8d5..4a595ff105 100644 --- a/Wox/Wox.csproj +++ b/Wox/Wox.csproj @@ -113,12 +113,9 @@ - - - NewVersionWindow.xaml @@ -144,7 +141,6 @@ WPFErrorReportingDialog.xaml - @@ -152,8 +148,8 @@ - - CustomPluginHotkeySetting.xaml + + CustomQueryHotkeySetting.xaml @@ -181,7 +177,7 @@ Designer MSBuild:Compile - + Designer MSBuild:Compile