Add i18n support [WIP]

This commit is contained in:
qianlifeng
2015-01-02 23:07:49 +08:00
parent bf87500e35
commit 203965043e
21 changed files with 257 additions and 124 deletions

View File

@@ -6,6 +6,7 @@ using System.Windows.Forms;
using ICSharpCode.SharpZipLib.Zip; using ICSharpCode.SharpZipLib.Zip;
using Newtonsoft.Json; using Newtonsoft.Json;
using Wox.Plugin; using Wox.Plugin;
using MessageBox = System.Windows.Forms.MessageBox;
namespace Wox.Core.Plugin namespace Wox.Core.Plugin
{ {
@@ -61,7 +62,7 @@ namespace Wox.Core.Plugin
plugin.Name, existingPlugin.Metadata.Version, plugin.Version, plugin.Author); 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); MessageBoxIcon.Question);
if (result == DialogResult.Yes) if (result == DialogResult.Yes)
{ {

View File

@@ -2,4 +2,6 @@
===== =====
* Handle Query * Handle Query
* Loading Plugins (including system plugin and user plugin) * Manage Plugins (including system plugin and user plugin)
* Manage Themes
* Manage i18n

View File

@@ -1,12 +1,9 @@
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
using System.Windows; using System.Windows;
using System.Windows.Media; using System.Windows.Media;
using Wox.Helper;
namespace Wox.Helper namespace Wox.Core.Theme
{ {
public static class FontHelper public static class FontHelper
{ {

View File

@@ -3,19 +3,40 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Media; using System.Windows.Media;
using Wox.Helper; using Wox.Core.UI;
using Wox.Infrastructure.Logger; using Wox.Infrastructure.Logger;
using Wox.Infrastructure.Storage.UserSettings; using Wox.Infrastructure.Storage.UserSettings;
namespace Wox namespace Wox.Core.Theme
{ {
internal class ThemeManager public class ThemeManager : IUIResource
{ {
private static List<string> themeDirectories = new List<string>(); private static List<string> themeDirectories = new List<string>();
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() static ThemeManager()
{ {
@@ -40,7 +61,7 @@ namespace Wox
{ {
Directory.CreateDirectory(pluginDirectory); Directory.CreateDirectory(pluginDirectory);
} }
catch (Exception e) catch (System.Exception e)
{ {
Log.Error(e.Message); 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); string themePath = GetThemePath(themeName);
if (string.IsNullOrEmpty(themePath)) if (string.IsNullOrEmpty(themePath))
@@ -56,7 +77,7 @@ namespace Wox
themePath = GetThemePath("Dark"); themePath = GetThemePath("Dark");
if (string.IsNullOrEmpty(themePath)) 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(); ResourceMerger.ApplyResources();
} }
internal static ResourceDictionary GetResourceDictionary() public ResourceDictionary GetResourceDictionary()
{ {
var dict = new ResourceDictionary var dict = new ResourceDictionary
{ {
@@ -100,20 +121,20 @@ namespace Wox
return dict; return dict;
} }
public static List<string> LoadAvailableThemes() public List<string> LoadAvailableThemes()
{ {
List<string> themes = new List<string>(); List<string> themes = new List<string>();
foreach (var themeDirectory in themeDirectories) foreach (var themeDirectory in themeDirectories)
{ {
themes.AddRange( themes.AddRange(
Directory.GetFiles(themeDirectory) Directory.GetFiles(themeDirectory)
.Where(filePath => filePath.EndsWith(".xaml") && !filePath.EndsWith("Default.xaml")) .Where(filePath => filePath.EndsWith(".xaml") && !filePath.EndsWith("Base.xaml"))
.ToList()); .ToList());
} }
return themes; return themes;
} }
private static string GetThemePath(string themeName) private string GetThemePath(string themeName)
{ {
foreach (string themeDirectory in themeDirectories) foreach (string themeDirectory in themeDirectories)
{ {

View File

@@ -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());
}
}
}
}

View File

@@ -40,6 +40,8 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.6.0.7\lib\net35\Newtonsoft.Json.dll</HintPath> <HintPath>..\packages\Newtonsoft.Json.6.0.7\lib\net35\Newtonsoft.Json.dll</HintPath>
</Reference> </Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
@@ -47,6 +49,7 @@
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Exception\ExceptionFormatter.cs" /> <Compile Include="Exception\ExceptionFormatter.cs" />
@@ -54,6 +57,9 @@
<Compile Include="Exception\WoxException.cs" /> <Compile Include="Exception\WoxException.cs" />
<Compile Include="Exception\WoxHttpException.cs" /> <Compile Include="Exception\WoxHttpException.cs" />
<Compile Include="Exception\WoxJsonRPCException.cs" /> <Compile Include="Exception\WoxJsonRPCException.cs" />
<Compile Include="i18n\InternationalizationManager.cs" />
<Compile Include="UI\IUIResource.cs" />
<Compile Include="UI\ResourceMerger.cs" />
<Compile Include="Plugin\PluginInstaller.cs" /> <Compile Include="Plugin\PluginInstaller.cs" />
<Compile Include="Plugin\QueryDispatcher\IQueryDispatcher.cs" /> <Compile Include="Plugin\QueryDispatcher\IQueryDispatcher.cs" />
<Compile Include="Plugin\QueryDispatcher\QueryDispatcher.cs" /> <Compile Include="Plugin\QueryDispatcher\QueryDispatcher.cs" />
@@ -68,6 +74,8 @@
<Compile Include="Plugin\PluginManager.cs" /> <Compile Include="Plugin\PluginManager.cs" />
<Compile Include="Plugin\PythonPlugin.cs" /> <Compile Include="Plugin\PythonPlugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Theme\FontHelper.cs" />
<Compile Include="Theme\ThemeManager.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="README.md" /> <None Include="README.md" />

View File

@@ -3,20 +3,40 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text;
using System.Windows; using System.Windows;
using System.Windows.Controls; using Wox.Core.UI;
using Wox.Helper;
using Wox.Infrastructure.Logger; using Wox.Infrastructure.Logger;
using Wox.Infrastructure.Storage.UserSettings; using Wox.Infrastructure.Storage.UserSettings;
namespace Wox namespace Wox.Core.i18n
{ {
public class LanguageManager public class InternationalizationManager : IUIResource
{ {
private static List<string> languageDirectories = new List<string>(); private static List<string> languageDirectories = new List<string>();
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")); languageDirectories.Add(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Languages"));
@@ -39,7 +59,7 @@ namespace Wox
{ {
Directory.CreateDirectory(pluginDirectory); Directory.CreateDirectory(pluginDirectory);
} }
catch (Exception e) catch (System.Exception e)
{ {
Log.Error(e.Message); 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); string path = GetLanguagePath(name);
if (string.IsNullOrEmpty(path)) if (string.IsNullOrEmpty(path))
@@ -55,7 +75,7 @@ namespace Wox
path = GetLanguagePath("English"); path = GetLanguagePath("English");
if (string.IsNullOrEmpty(path)) 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(); ResourceMerger.ApplyResources();
} }
internal static ResourceDictionary GetResourceDictionary() public ResourceDictionary GetResourceDictionary()
{ {
return new ResourceDictionary return new ResourceDictionary
{ {
@@ -72,7 +92,7 @@ namespace Wox
}; };
} }
public static List<string> LoadAvailableLanguages() public List<string> LoadAvailableLanguages()
{ {
List<string> themes = new List<string>(); List<string> themes = new List<string>();
foreach (var directory in languageDirectories) foreach (var directory in languageDirectories)
@@ -86,7 +106,7 @@ namespace Wox
return themes; return themes;
} }
public static string GetTranslation(string key) public string GetTranslation(string key)
{ {
try try
{ {
@@ -104,7 +124,7 @@ namespace Wox
} }
private static string GetLanguagePath(string name) private string GetLanguagePath(string name)
{ {
foreach (string directory in languageDirectories) foreach (string directory in languageDirectories)
{ {

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Wox.Infrastructure
{
interface ISingleton<T>
{
T Instance { get; }
}
}

View File

@@ -57,6 +57,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Http\HttpProxy.cs" /> <Compile Include="Http\HttpProxy.cs" />
<Compile Include="ISingleton.cs" />
<Compile Include="Logger\Log.cs" /> <Compile Include="Logger\Log.cs" />
<Compile Include="PeHeaderReader.cs" /> <Compile Include="PeHeaderReader.cs" />
<Compile Include="Storage\BinaryStorage.cs" /> <Compile Include="Storage\BinaryStorage.cs" />

View File

@@ -17,18 +17,18 @@
<ColumnDefinition Width="200"></ColumnDefinition> <ColumnDefinition Width="200"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition> <ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBlock Margin="10" FontSize="14" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right">Old ActionKeyword:</TextBlock> <TextBlock Margin="10" FontSize="14" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right" Text="{DynamicResource oldActionKeyword}"></TextBlock>
<TextBlock x:Name="tbOldActionKeyword" Margin="10" FontSize="14" Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left">Old ActionKeyword:</TextBlock> <TextBlock x:Name="tbOldActionKeyword" Margin="10" FontSize="14" Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left">Old ActionKeyword:</TextBlock>
<TextBlock Margin="10" FontSize="14" Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right">New ActionKeyword:</TextBlock> <TextBlock Margin="10" FontSize="14" Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right" Text="{DynamicResource newActionKeyword}"></TextBlock>
<StackPanel Grid.Row="1" Orientation="Horizontal" Grid.Column="1" > <StackPanel Grid.Row="1" Orientation="Horizontal" Grid.Column="1" >
<TextBox x:Name="tbAction" Margin="10" Width="400" VerticalAlignment="Center" HorizontalAlignment="Left"></TextBox> <TextBox x:Name="tbAction" Margin="10" Width="400" VerticalAlignment="Center" HorizontalAlignment="Left"></TextBox>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Row="2" Grid.Column="1"> <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Row="2" Grid.Column="1">
<Button x:Name="btnCancel" Click="BtnCancel_OnClick" Margin="10 0 10 0" Width="80" Height="25">Cancel</Button> <Button x:Name="btnCancel" Click="BtnCancel_OnClick" Margin="10 0 10 0" Width="80" Height="25" Content="{DynamicResource cancel}"></Button>
<Button x:Name="btnDone" Margin="10 0 10 0" Width="80" Height="25" Click="btnDone_OnClick"> <Button x:Name="btnDone" Margin="10 0 10 0" Width="80" Height="25" Click="btnDone_OnClick">
<TextBlock x:Name="lblAdd">Done</TextBlock> <TextBlock x:Name="lblAdd" Text="{DynamicResource done}"></TextBlock>
</Button> </Button>
</StackPanel> </StackPanel>
</Grid> </Grid>

View File

@@ -11,6 +11,7 @@ using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using System.Windows.Shapes; using System.Windows.Shapes;
using Wox.Core.i18n;
using Wox.Core.Plugin; using Wox.Core.Plugin;
using Wox.Infrastructure.Storage.UserSettings; using Wox.Infrastructure.Storage.UserSettings;
using Wox.Plugin; using Wox.Plugin;
@@ -28,7 +29,7 @@ namespace Wox
PluginPair plugin = PluginManager.GetPlugin(pluginId); PluginPair plugin = PluginManager.GetPlugin(pluginId);
if (plugin == null) if (plugin == null)
{ {
MessageBox.Show("Can't find specific plugin"); MessageBox.Show(InternationalizationManager.Instance.GetTranslation("cannotFindSpecifiedPlugin"));
Close(); Close();
return; return;
} }
@@ -51,14 +52,14 @@ namespace Wox
{ {
if (string.IsNullOrEmpty(tbAction.Text)) if (string.IsNullOrEmpty(tbAction.Text))
{ {
MessageBox.Show("New ActionKeyword can't be empty"); MessageBox.Show(InternationalizationManager.Instance.GetTranslation("newActionKeywordCannotBeEmpty"));
return; return;
} }
//check new action keyword didn't used by other plugin //check new action keyword didn't used by other plugin
if (PluginManager.AllPlugins.Exists(o => o.Metadata.ActionKeyword == tbAction.Text.Trim())) 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; return;
} }
@@ -80,10 +81,8 @@ namespace Wox
customizedPluginConfig.Actionword = tbAction.Text.Trim(); customizedPluginConfig.Actionword = tbAction.Text.Trim();
} }
UserSettingStorage.Instance.Save(); UserSettingStorage.Instance.Save();
MessageBox.Show("Sucessfully applied the new action keyword"); MessageBox.Show(InternationalizationManager.Instance.GetTranslation("succeed"));
Close(); Close();
} }
} }
} }

View File

@@ -1,4 +1,4 @@
<Window x:Class="Wox.CustomPluginHotkeySetting" <Window x:Class="Wox.CustomQueryHotkeySetting"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wox="clr-namespace:Wox" xmlns:wox="clr-namespace:Wox"
@@ -16,19 +16,19 @@
<ColumnDefinition Width="150"></ColumnDefinition> <ColumnDefinition Width="150"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition> <ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBlock Margin="10" FontSize="14" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right">Hotkey:</TextBlock> <TextBlock Margin="10" FontSize="14" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right" Text="{DynamicResource hotkey}"></TextBlock>
<wox:HotkeyControl x:Name="ctlHotkey" Margin="10" Grid.Column="1" /> <wox:HotkeyControl x:Name="ctlHotkey" Margin="10" Grid.Column="1" />
<TextBlock Margin="10" FontSize="14" Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right">Action Keyword:</TextBlock> <TextBlock Margin="10" FontSize="14" Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right" Text="{DynamicResource actionKeyword}"></TextBlock>
<StackPanel Grid.Row="1" Orientation="Horizontal" Grid.Column="1" > <StackPanel Grid.Row="1" Orientation="Horizontal" Grid.Column="1" >
<TextBox x:Name="tbAction" Margin="10" Width="400" VerticalAlignment="Center" HorizontalAlignment="Left"></TextBox> <TextBox x:Name="tbAction" Margin="10" Width="400" VerticalAlignment="Center" HorizontalAlignment="Left"></TextBox>
<Button x:Name="btnTestActionKeyword" Padding="10 5 10 5" Height="30" Click="BtnTestActionKeyword_OnClick">Test</Button> <Button x:Name="btnTestActionKeyword" Padding="10 5 10 5" Height="30" Click="BtnTestActionKeyword_OnClick" Content="{DynamicResource preview}"></Button>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Row="2" Grid.Column="1"> <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Row="2" Grid.Column="1">
<Button x:Name="btnCancel" Click="BtnCancel_OnClick" Margin="10 0 10 0" Width="80" Height="25">Cancel</Button> <Button x:Name="btnCancel" Click="BtnCancel_OnClick" Margin="10 0 10 0" Width="80" Height="25" Content="{DynamicResource cancel}"></Button>
<Button x:Name="btnAdd" Margin="10 0 10 0" Width="80" Height="25" Click="btnAdd_OnClick"> <Button x:Name="btnAdd" Margin="10 0 10 0" Width="80" Height="25" Click="btnAdd_OnClick">
<TextBlock x:Name="lblAdd">Add</TextBlock> <TextBlock x:Name="lblAdd" Text="{DynamicResource done}"></TextBlock>
</Button> </Button>
</StackPanel> </StackPanel>
</Grid> </Grid>

View File

@@ -1,17 +1,18 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Windows; using System.Windows;
using Wox.Core.i18n;
using Wox.Infrastructure.Storage.UserSettings; using Wox.Infrastructure.Storage.UserSettings;
namespace Wox namespace Wox
{ {
public partial class CustomPluginHotkeySetting : Window public partial class CustomQueryHotkeySetting : Window
{ {
private SettingWindow settingWidow; private SettingWindow settingWidow;
private bool update; private bool update;
private CustomPluginHotkey updateCustomHotkey; private CustomPluginHotkey updateCustomHotkey;
public CustomPluginHotkeySetting(SettingWindow settingWidow) public CustomQueryHotkeySetting(SettingWindow settingWidow)
{ {
this.settingWidow = settingWidow; this.settingWidow = settingWidow;
InitializeComponent(); InitializeComponent();
@@ -28,7 +29,7 @@ namespace Wox
{ {
if (!ctlHotkey.CurrentHotkeyAvailable) if (!ctlHotkey.CurrentHotkeyAvailable)
{ {
MessageBox.Show("Hotkey is unavailable, please select a new hotkey"); MessageBox.Show(InternationalizationManager.Instance.GetTranslation("hotkeyIsNotUnavailable"));
return; return;
} }
@@ -48,13 +49,13 @@ namespace Wox
settingWidow.MainWindow.ChangeQuery(pluginHotkey.ActionKeyword); settingWidow.MainWindow.ChangeQuery(pluginHotkey.ActionKeyword);
settingWidow.MainWindow.ShowApp(); settingWidow.MainWindow.ShowApp();
}); });
MessageBox.Show("Add hotkey successfully!"); MessageBox.Show(InternationalizationManager.Instance.GetTranslation("succeed"));
} }
else else
{ {
if (updateCustomHotkey.Hotkey != ctlHotkey.CurrentHotkey.ToString() && !ctlHotkey.CurrentHotkeyAvailable) 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; return;
} }
var oldHotkey = updateCustomHotkey.Hotkey; var oldHotkey = updateCustomHotkey.Hotkey;
@@ -67,7 +68,7 @@ namespace Wox
settingWidow.MainWindow.ShowApp(); settingWidow.MainWindow.ShowApp();
settingWidow.MainWindow.ChangeQuery(updateCustomHotkey.ActionKeyword); settingWidow.MainWindow.ChangeQuery(updateCustomHotkey.ActionKeyword);
}); });
MessageBox.Show("Update successfully!"); MessageBox.Show(InternationalizationManager.Instance.GetTranslation("succeed"));
} }
UserSettingStorage.Instance.Save(); UserSettingStorage.Instance.Save();
@@ -80,7 +81,7 @@ namespace Wox
updateCustomHotkey = UserSettingStorage.Instance.CustomPluginHotkeys.FirstOrDefault(o => o.ActionKeyword == item.ActionKeyword && o.Hotkey == item.Hotkey); updateCustomHotkey = UserSettingStorage.Instance.CustomPluginHotkeys.FirstOrDefault(o => o.ActionKeyword == item.ActionKeyword && o.Hotkey == item.Hotkey);
if (updateCustomHotkey == null) if (updateCustomHotkey == null)
{ {
MessageBox.Show("Invalid plugin hotkey"); MessageBox.Show(InternationalizationManager.Instance.GetTranslation("invalidPluginHotkey"));
Close(); Close();
return; return;
} }
@@ -88,7 +89,7 @@ namespace Wox
tbAction.Text = updateCustomHotkey.ActionKeyword; tbAction.Text = updateCustomHotkey.ActionKeyword;
ctlHotkey.SetHotkey(updateCustomHotkey.Hotkey, false); ctlHotkey.SetHotkey(updateCustomHotkey.Hotkey, false);
update = true; update = true;
lblAdd.Text = "Update"; lblAdd.Text = InternationalizationManager.Instance.GetTranslation("update");
} }
private void BtnTestActionKeyword_OnClick(object sender, RoutedEventArgs e) private void BtnTestActionKeyword_OnClick(object sender, RoutedEventArgs e)

View File

@@ -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);
}
}
}

View File

@@ -6,6 +6,7 @@ using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using NHotkey; using NHotkey;
using NHotkey.Wpf; using NHotkey.Wpf;
using Wox.Core.i18n;
using Wox.Helper; using Wox.Helper;
using Wox.Infrastructure; using Wox.Infrastructure;
using Wox.Infrastructure.Hotkey; using Wox.Infrastructure.Hotkey;
@@ -98,12 +99,12 @@ namespace Wox
if (!CurrentHotkeyAvailable) if (!CurrentHotkeyAvailable)
{ {
tbMsg.Foreground = new SolidColorBrush(Colors.Red); tbMsg.Foreground = new SolidColorBrush(Colors.Red);
tbMsg.Text = "hotkey unavailable"; tbMsg.Text = InternationalizationManager.Instance.GetTranslation("hotkeyUnavailable");
} }
else else
{ {
tbMsg.Foreground = new SolidColorBrush(Colors.Green); tbMsg.Foreground = new SolidColorBrush(Colors.Green);
tbMsg.Text = "succeed"; tbMsg.Text = InternationalizationManager.Instance.GetTranslation("succeed");
} }
OnOnHotkeyChanged(); OnOnHotkeyChanged();
} }

View File

@@ -1,6 +1,12 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib"> xmlns:system="clr-namespace:System;assembly=mscorlib">
<!--MainWindow-->
<system:String x:Key="registerHotkeyFailed">Register hotkey: {0} failed</system:String>
<system:String x:Key="couldnotStartCmd">Could not start {0}</system:String>
<system:String x:Key="invalidWoxPluginFileFormat">Invalid wox plugin file format</system:String>
<!--Setting General--> <!--Setting General-->
<system:String x:Key="general">General</system:String> <system:String x:Key="general">General</system:String>
<system:String x:Key="startWoxOnSystemStartup">Start Wox on system startup</system:String> <system:String x:Key="startWoxOnSystemStartup">Start Wox on system startup</system:String>
@@ -49,11 +55,30 @@
<system:String x:Key="invalidPortFormat">Invalid port format</system:String> <system:String x:Key="invalidPortFormat">Invalid port format</system:String>
<system:String x:Key="saveProxySuccessfully">Save proxy successfully</system:String> <system:String x:Key="saveProxySuccessfully">Save proxy successfully</system:String>
<system:String x:Key="proxyIsCorrect">Proxy is correct</system:String> <system:String x:Key="proxyIsCorrect">Proxy is correct</system:String>
<system:String x:Key="proxyConnectFailed">Proxy connect failed</system:String>
<!--Setting About--> <!--Setting About-->
<system:String x:Key="about">About</system:String> <system:String x:Key="about">About</system:String>
<system:String x:Key="website">Website</system:String> <system:String x:Key="website">Website</system:String>
<system:String x:Key="version">Version</system:String> <system:String x:Key="version">Version</system:String>
<!--Action Keyword Setting Dialog-->
<system:String x:Key="oldActionKeyword">Old Action Keyword</system:String>
<system:String x:Key="newActionKeyword">New Action Keyword</system:String>
<system:String x:Key="cancel">Cancel</system:String>
<system:String x:Key="done">Done</system:String>
<system:String x:Key="cannotFindSpecifiedPlugin">Can't find specified plugin</system:String>
<system:String x:Key="newActionKeywordCannotBeEmpty">New Action Keyword can't be empty</system:String>
<system:String x:Key="newActionKeywordHasBeenAssigned">New ActionKeyword has been assigned to other plugin, please assign another new action keyword</system:String>
<system:String x:Key="succeed">Succeed</system:String>
<!--Custom Query Hotkey Dialog-->
<system:String x:Key="preview">Preview</system:String>
<system:String x:Key="hotkeyIsNotUnavailable">Hotkey is unavailable, please select a new hotkey</system:String>
<system:String x:Key="invalidPluginHotkey">Invalid plugin hotkey</system:String>
<system:String x:Key="update">Update</system:String>
<!--Hotkey Control-->
<system:String x:Key="hotkeyUnavailable">Hotkey unavailable</system:String>
</ResourceDictionary> </ResourceDictionary>

View File

@@ -1,6 +1,12 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib"> xmlns:system="clr-namespace:System;assembly=mscorlib">
<!--主窗体-->
<system:String x:Key="registerHotkeyFailed">注册热键:{0} 失败</system:String>
<system:String x:Key="couldnotStartCmd">启动命令 {0} 失败</system:String>
<system:String x:Key="invalidWoxPluginFileFormat">不是合法的Wox插件格式</system:String>
<!--设置,通用--> <!--设置,通用-->
<system:String x:Key="general">通用</system:String> <system:String x:Key="general">通用</system:String>
<system:String x:Key="startWoxOnSystemStartup">开机启动</system:String> <system:String x:Key="startWoxOnSystemStartup">开机启动</system:String>
@@ -32,6 +38,8 @@
<system:String x:Key="delete">删除</system:String> <system:String x:Key="delete">删除</system:String>
<system:String x:Key="edit">编辑</system:String> <system:String x:Key="edit">编辑</system:String>
<system:String x:Key="add">增加</system:String> <system:String x:Key="add">增加</system:String>
<system:String x:Key="pleaseSelectAnItem">请选择一项</system:String>
<system:String x:Key="deleteCustomHotkeyWarning">你确定要删除插件 {0} 的热键吗?</system:String>
<!--设置,代理--> <!--设置,代理-->
<system:String x:Key="proxy">代理</system:String> <system:String x:Key="proxy">代理</system:String>
@@ -42,10 +50,36 @@
<system:String x:Key="password">密码</system:String> <system:String x:Key="password">密码</system:String>
<system:String x:Key="testProxy">测试代理</system:String> <system:String x:Key="testProxy">测试代理</system:String>
<system:String x:Key="save">保存</system:String> <system:String x:Key="save">保存</system:String>
<system:String x:Key="serverCantBeEmpty">服务器不能为空</system:String>
<system:String x:Key="portCantBeEmpty">端口不能为空</system:String>
<system:String x:Key="invalidPortFormat">非法的端口格式</system:String>
<system:String x:Key="saveProxySuccessfully">保存代理设置成功</system:String>
<system:String x:Key="proxyIsCorrect">代理设置正确</system:String>
<system:String x:Key="proxyConnectFailed">代理连接失败</system:String>
<!--设置,版本--> <!--设置,版本-->
<system:String x:Key="about">关于</system:String> <system:String x:Key="about">关于</system:String>
<system:String x:Key="website">网站</system:String> <system:String x:Key="website">网站</system:String>
<system:String x:Key="version">版本</system:String> <system:String x:Key="version">版本</system:String>
<!--Action Keyword 设置对话框-->
<system:String x:Key="oldActionKeyword">旧触发关键字</system:String>
<system:String x:Key="newActionKeyword">新触发关键字</system:String>
<system:String x:Key="cancel">取消</system:String>
<system:String x:Key="done">确定</system:String>
<system:String x:Key="cannotFindSpecifiedPlugin">找不到指定的插件</system:String>
<system:String x:Key="newActionKeywordCannotBeEmpty">新触发关键字不能为空</system:String>
<system:String x:Key="newActionKeywordHasBeenAssigned">新触发关键字已经被指派给其他插件了,请重新选择一个关键字</system:String>
<system:String x:Key="succeed">成功</system:String>
<!--Custom Query Hotkey 对话框-->
<system:String x:Key="preview">预览</system:String>
<system:String x:Key="hotkeyIsNotUnavailable">热键不可用,请选择一个新的热键</system:String>
<system:String x:Key="invalidPluginHotkey">插件热键不合法</system:String>
<system:String x:Key="update">更新</system:String>
<!--Hotkey 控件-->
<system:String x:Key="hotkeyUnavailable">热键不可用</system:String>
</ResourceDictionary> </ResourceDictionary>

View File

@@ -14,7 +14,9 @@ using WindowsInput;
using WindowsInput.Native; using WindowsInput.Native;
using NHotkey; using NHotkey;
using NHotkey.Wpf; using NHotkey.Wpf;
using Wox.Core.i18n;
using Wox.Core.Plugin; using Wox.Core.Plugin;
using Wox.Core.Theme;
using Wox.Helper; using Wox.Helper;
using Wox.Infrastructure; using Wox.Infrastructure;
using Wox.Infrastructure.Hotkey; using Wox.Infrastructure.Hotkey;
@@ -128,7 +130,7 @@ namespace Wox
public void ReloadPlugins() public void ReloadPlugins()
{ {
Dispatcher.Invoke(new Action(()=> PluginManager.Init(this))); Dispatcher.Invoke(new Action(() => PluginManager.Init(this)));
} }
public List<PluginPair> GetAllPlugins() public List<PluginPair> GetAllPlugins()
@@ -173,8 +175,8 @@ namespace Wox
pnlResult.RightMouseClickEvent += pnlResult_RightMouseClickEvent; pnlResult.RightMouseClickEvent += pnlResult_RightMouseClickEvent;
ThreadPool.SetMaxThreads(30, 10); ThreadPool.SetMaxThreads(30, 10);
ThemeManager.ChangeTheme(UserSettingStorage.Instance.Theme); ThemeManager.Instance.ChangeTheme(UserSettingStorage.Instance.Theme);
LanguageManager.ChangeLanguage(UserSettingStorage.Instance.Language); InternationalizationManager.Instance.ChangeLanguage(UserSettingStorage.Instance.Language);
SetHotkey(UserSettingStorage.Instance.Hotkey, OnHotkey); SetHotkey(UserSettingStorage.Instance.Hotkey, OnHotkey);
SetCustomPluginHotkey(); SetCustomPluginHotkey();
@@ -266,7 +268,8 @@ namespace Wox
} }
catch (Exception) 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; break;
case Key.F1: case Key.F1:
Process.Start("https://github.com/qianlifeng/Wox/wiki/Wox-Function-Guide"); Process.Start("http://doc.getwox.com");
break; break;
case Key.Enter: case Key.Enter:
@@ -568,7 +571,7 @@ namespace Wox
} }
else else
{ {
SelectResult(activeResult); SelectResult(activeResult);
} }
e.Handled = true; e.Handled = true;
break; break;
@@ -590,7 +593,7 @@ namespace Wox
{ {
return pnlResult.GetActiveResult(); return pnlResult.GetActiveResult();
} }
} }
private void SelectPrevItem() private void SelectPrevItem()
{ {
@@ -683,7 +686,8 @@ namespace Wox
} }
catch (Exception ex) 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; return false;
} }
@@ -700,7 +704,7 @@ namespace Wox
} }
else else
{ {
MessageBox.Show("incorrect wox plugin file."); MessageBox.Show(InternationalizationManager.Instance.GetTranslation("invalidWoxPluginFileFormat"));
} }
} }
} }

View File

@@ -20,7 +20,7 @@
<converters:ImagePathConverter x:Key="ImageConverter" /> <converters:ImagePathConverter x:Key="ImageConverter" />
</Window.Resources> </Window.Resources>
<TabControl Height="auto" > <TabControl Height="auto" >
<TabItem Header="{DynamicResource general}" Height="23" VerticalAlignment="Top"> <TabItem Header="{DynamicResource general}">
<StackPanel Orientation="Vertical" Margin="10"> <StackPanel Orientation="Vertical" Margin="10">
<CheckBox x:Name="cbStartWithWindows" Unchecked="CbStartWithWindows_OnUnchecked" Checked="CbStartWithWindows_OnChecked" Margin="10"> <CheckBox x:Name="cbStartWithWindows" Unchecked="CbStartWithWindows_OnUnchecked" Checked="CbStartWithWindows_OnChecked" Margin="10">
<TextBlock Text="{DynamicResource startWoxOnSystemStartup}" ></TextBlock> <TextBlock Text="{DynamicResource startWoxOnSystemStartup}" ></TextBlock>
@@ -33,7 +33,7 @@
</CheckBox> </CheckBox>
<StackPanel Margin="10" Orientation="Horizontal"> <StackPanel Margin="10" Orientation="Horizontal">
<TextBlock Text="{DynamicResource language}"></TextBlock> <TextBlock Text="{DynamicResource language}"></TextBlock>
<ComboBox Margin="10 0 0 0" Width="200" x:Name="cbLanguages" /> <ComboBox Margin="10 0 0 0" Width="100" x:Name="cbLanguages" />
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
</TabItem> </TabItem>

View File

@@ -21,6 +21,8 @@ using Application = System.Windows.Forms.Application;
using File = System.IO.File; using File = System.IO.File;
using MessageBox = System.Windows.MessageBox; using MessageBox = System.Windows.MessageBox;
using System.Windows.Data; using System.Windows.Data;
using Wox.Core.i18n;
using Wox.Core.Theme;
namespace Wox 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); string themeName = System.IO.Path.GetFileNameWithoutExtension(theme);
themeComboBox.Items.Add(themeName); themeComboBox.Items.Add(themeName);
@@ -174,7 +176,7 @@ namespace Wox
} }
//PreviewPanel //PreviewPanel
ThemeManager.ChangeTheme(UserSettingStorage.Instance.Theme); ThemeManager.Instance.ChangeTheme(UserSettingStorage.Instance.Theme);
#endregion #endregion
#region Plugin #region Plugin
@@ -244,7 +246,7 @@ namespace Wox
private void LoadLanguages() private void LoadLanguages()
{ {
cbLanguages.ItemsSource = LanguageManager.LoadAvailableLanguages(); cbLanguages.ItemsSource = InternationalizationManager.Instance.LoadAvailableLanguages();
cbLanguages.SelectedValue = UserSettingStorage.Instance.Language; cbLanguages.SelectedValue = UserSettingStorage.Instance.Language;
cbLanguages.SelectionChanged += cbLanguages_SelectionChanged; cbLanguages.SelectionChanged += cbLanguages_SelectionChanged;
} }
@@ -252,7 +254,7 @@ namespace Wox
void cbLanguages_SelectionChanged(object sender, SelectionChangedEventArgs e) void cbLanguages_SelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
string language = cbLanguages.SelectedValue.ToString(); string language = cbLanguages.SelectedValue.ToString();
LanguageManager.ChangeLanguage(language); InternationalizationManager.Instance.ChangeLanguage(language);
} }
private void EnableProxy() private void EnableProxy()
@@ -330,12 +332,12 @@ namespace Wox
CustomPluginHotkey item = lvCustomHotkey.SelectedItem as CustomPluginHotkey; CustomPluginHotkey item = lvCustomHotkey.SelectedItem as CustomPluginHotkey;
if (item == null) if (item == null)
{ {
MessageBox.Show(LanguageManager.GetTranslation("pleaseSelectAnItem")); MessageBox.Show(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem"));
return; return;
} }
string deleteWarning = string.Format(LanguageManager.GetTranslation("deleteCustomHotkeyWarning"), item.Hotkey); string deleteWarning = string.Format(InternationalizationManager.Instance.GetTranslation("deleteCustomHotkeyWarning"), item.Hotkey);
if (MessageBox.Show(deleteWarning, LanguageManager.GetTranslation("delete"), MessageBoxButton.YesNo) == MessageBoxResult.Yes) if (MessageBox.Show(deleteWarning, InternationalizationManager.Instance.GetTranslation("delete"), MessageBoxButton.YesNo) == MessageBoxResult.Yes)
{ {
UserSettingStorage.Instance.CustomPluginHotkeys.Remove(item); UserSettingStorage.Instance.CustomPluginHotkeys.Remove(item);
lvCustomHotkey.Items.Refresh(); lvCustomHotkey.Items.Refresh();
@@ -349,19 +351,19 @@ namespace Wox
CustomPluginHotkey item = lvCustomHotkey.SelectedItem as CustomPluginHotkey; CustomPluginHotkey item = lvCustomHotkey.SelectedItem as CustomPluginHotkey;
if (item != null) if (item != null)
{ {
CustomPluginHotkeySetting window = new CustomPluginHotkeySetting(this); CustomQueryHotkeySetting window = new CustomQueryHotkeySetting(this);
window.UpdateItem(item); window.UpdateItem(item);
window.ShowDialog(); window.ShowDialog();
} }
else else
{ {
MessageBox.Show(LanguageManager.GetTranslation("pleaseSelectAnItem")); MessageBox.Show(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem"));
} }
} }
private void BtnAddCustomeHotkey_OnClick(object sender, RoutedEventArgs e) private void BtnAddCustomeHotkey_OnClick(object sender, RoutedEventArgs e)
{ {
new CustomPluginHotkeySetting(this).ShowDialog(); new CustomQueryHotkeySetting(this).ShowDialog();
} }
public void ReloadCustomPluginHotkeyView() public void ReloadCustomPluginHotkeyView()
@@ -375,7 +377,7 @@ namespace Wox
private void ThemeComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) private void ThemeComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
string themeName = themeComboBox.SelectedItem.ToString(); string themeName = themeComboBox.SelectedItem.ToString();
ThemeManager.ChangeTheme(themeName); ThemeManager.Instance.ChangeTheme(themeName);
UserSettingStorage.Instance.Theme = themeName; UserSettingStorage.Instance.Theme = themeName;
UserSettingStorage.Instance.Save(); UserSettingStorage.Instance.Save();
} }
@@ -388,7 +390,7 @@ namespace Wox
this.cbQueryBoxFontFaces.SelectedItem = ((FontFamily)cbQueryBoxFont.SelectedItem).ChooseRegularFamilyTypeface(); this.cbQueryBoxFontFaces.SelectedItem = ((FontFamily)cbQueryBoxFont.SelectedItem).ChooseRegularFamilyTypeface();
UserSettingStorage.Instance.Save(); UserSettingStorage.Instance.Save();
ThemeManager.ChangeTheme(UserSettingStorage.Instance.Theme); ThemeManager.Instance.ChangeTheme(UserSettingStorage.Instance.Theme);
} }
private void CbQueryBoxFontFaces_OnSelectionChanged(object sender, SelectionChangedEventArgs e) private void CbQueryBoxFontFaces_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
@@ -408,7 +410,7 @@ namespace Wox
UserSettingStorage.Instance.QueryBoxFontWeight = typeface.Weight.ToString(); UserSettingStorage.Instance.QueryBoxFontWeight = typeface.Weight.ToString();
UserSettingStorage.Instance.QueryBoxFontStyle = typeface.Style.ToString(); UserSettingStorage.Instance.QueryBoxFontStyle = typeface.Style.ToString();
UserSettingStorage.Instance.Save(); 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(); this.cbResultItemFontFaces.SelectedItem = ((FontFamily)cbResultItemFont.SelectedItem).ChooseRegularFamilyTypeface();
UserSettingStorage.Instance.Save(); UserSettingStorage.Instance.Save();
ThemeManager.ChangeTheme(UserSettingStorage.Instance.Theme); ThemeManager.Instance.ChangeTheme(UserSettingStorage.Instance.Theme);
} }
private void CbResultItemFontFaces_OnSelectionChanged(object sender, SelectionChangedEventArgs e) private void CbResultItemFontFaces_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
@@ -438,21 +440,24 @@ namespace Wox
UserSettingStorage.Instance.ResultItemFontWeight = typeface.Weight.ToString(); UserSettingStorage.Instance.ResultItemFontWeight = typeface.Weight.ToString();
UserSettingStorage.Instance.ResultItemFontStyle = typeface.Style.ToString(); UserSettingStorage.Instance.ResultItemFontStyle = typeface.Style.ToString();
UserSettingStorage.Instance.Save(); UserSettingStorage.Instance.Save();
ThemeManager.ChangeTheme(UserSettingStorage.Instance.Theme); ThemeManager.Instance.ChangeTheme(UserSettingStorage.Instance.Theme);
} }
} }
private void slOpacity_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) private void slOpacity_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{ {
UserSettingStorage.Instance.Opacity = slOpacity.Value; UserSettingStorage.Instance.Opacity = slOpacity.Value;
UserSettingStorage.Instance.Save();
if (UserSettingStorage.Instance.OpacityMode == OpacityMode.LayeredWindow) if (UserSettingStorage.Instance.OpacityMode == OpacityMode.LayeredWindow)
PreviewMainPanel.Opacity = UserSettingStorage.Instance.Opacity; PreviewMainPanel.Opacity = UserSettingStorage.Instance.Opacity;
else else
PreviewMainPanel.Opacity = 1; 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 #endregion
@@ -650,17 +655,17 @@ namespace Wox
{ {
if (string.IsNullOrEmpty(tbProxyServer.Text)) if (string.IsNullOrEmpty(tbProxyServer.Text))
{ {
MessageBox.Show(LanguageManager.GetTranslation("serverCantBeEmpty")); MessageBox.Show(InternationalizationManager.Instance.GetTranslation("serverCantBeEmpty"));
return; return;
} }
if (string.IsNullOrEmpty(tbProxyPort.Text)) if (string.IsNullOrEmpty(tbProxyPort.Text))
{ {
MessageBox.Show(LanguageManager.GetTranslation("portCantBeEmpty")); MessageBox.Show(InternationalizationManager.Instance.GetTranslation("portCantBeEmpty"));
return; return;
} }
if (!int.TryParse(tbProxyPort.Text, out port)) if (!int.TryParse(tbProxyPort.Text, out port))
{ {
MessageBox.Show(LanguageManager.GetTranslation("invalidPortFormat")); MessageBox.Show(InternationalizationManager.Instance.GetTranslation("invalidPortFormat"));
return; return;
} }
} }
@@ -671,25 +676,25 @@ namespace Wox
UserSettingStorage.Instance.ProxyPassword = tbProxyPassword.Password; UserSettingStorage.Instance.ProxyPassword = tbProxyPassword.Password;
UserSettingStorage.Instance.Save(); UserSettingStorage.Instance.Save();
MessageBox.Show(LanguageManager.GetTranslation("saveProxySuccessfully")); MessageBox.Show(InternationalizationManager.Instance.GetTranslation("saveProxySuccessfully"));
} }
private void btnTestProxy_Click(object sender, RoutedEventArgs e) private void btnTestProxy_Click(object sender, RoutedEventArgs e)
{ {
if (string.IsNullOrEmpty(tbProxyServer.Text)) if (string.IsNullOrEmpty(tbProxyServer.Text))
{ {
MessageBox.Show(LanguageManager.GetTranslation("serverCantBeEmpty")); MessageBox.Show(InternationalizationManager.Instance.GetTranslation("serverCantBeEmpty"));
return; return;
} }
if (string.IsNullOrEmpty(tbProxyPort.Text)) if (string.IsNullOrEmpty(tbProxyPort.Text))
{ {
MessageBox.Show(LanguageManager.GetTranslation("portCantBeEmpty")); MessageBox.Show(InternationalizationManager.Instance.GetTranslation("portCantBeEmpty"));
return; return;
} }
int port; int port;
if (!int.TryParse(tbProxyPort.Text, out port)) if (!int.TryParse(tbProxyPort.Text, out port))
{ {
MessageBox.Show(LanguageManager.GetTranslation("invalidPortFormat")); MessageBox.Show(InternationalizationManager.Instance.GetTranslation("invalidPortFormat"));
return; return;
} }
@@ -710,16 +715,16 @@ namespace Wox
HttpWebResponse response = (HttpWebResponse)request.GetResponse(); HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK) if (response.StatusCode == HttpStatusCode.OK)
{ {
MessageBox.Show(LanguageManager.GetTranslation("proxyIsCorrect")); MessageBox.Show(InternationalizationManager.Instance.GetTranslation("proxyIsCorrect"));
} }
else else
{ {
MessageBox.Show("Proxy connect failed."); MessageBox.Show(InternationalizationManager.Instance.GetTranslation("proxyConnectFailed"));
} }
} }
catch catch
{ {
MessageBox.Show("Proxy connect failed."); MessageBox.Show(InternationalizationManager.Instance.GetTranslation("proxyConnectFailed"));
} }
} }

View File

@@ -113,12 +113,9 @@
<Reference Include="WPFToolkit, Version=3.5.40128.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" /> <Reference Include="WPFToolkit, Version=3.5.40128.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Helper\ResourceMerger.cs" />
<Compile Include="Helper\WoxLogPathConverter.cs" /> <Compile Include="Helper\WoxLogPathConverter.cs" />
<Compile Include="ImageLoader\ImageCacheStroage.cs" /> <Compile Include="ImageLoader\ImageCacheStroage.cs" />
<Compile Include="Helper\LanguageManager.cs" />
<Compile Include="Storage\UserSelectedRecordStorage.cs" /> <Compile Include="Storage\UserSelectedRecordStorage.cs" />
<Compile Include="Helper\ThemeManager.cs" />
<Compile Include="Update\NewVersionWindow.xaml.cs"> <Compile Include="Update\NewVersionWindow.xaml.cs">
<DependentUpon>NewVersionWindow.xaml</DependentUpon> <DependentUpon>NewVersionWindow.xaml</DependentUpon>
</Compile> </Compile>
@@ -144,7 +141,6 @@
<Compile Include="Helper\ErrorReporting\WPFErrorReportingDialog.xaml.cs"> <Compile Include="Helper\ErrorReporting\WPFErrorReportingDialog.xaml.cs">
<DependentUpon>WPFErrorReportingDialog.xaml</DependentUpon> <DependentUpon>WPFErrorReportingDialog.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Helper\FontHelper.cs" />
<Compile Include="ImageLoader\ImageLoader.cs" /> <Compile Include="ImageLoader\ImageLoader.cs" />
<Compile Include="Helper\SingleInstance.cs" /> <Compile Include="Helper\SingleInstance.cs" />
<Compile Include="Helper\SyntaxSugars.cs" /> <Compile Include="Helper\SyntaxSugars.cs" />
@@ -152,8 +148,8 @@
<Compile Include="Helper\WindowIntelopHelper.cs" /> <Compile Include="Helper\WindowIntelopHelper.cs" />
<Compile Include="Helper\WindowOpener.cs" /> <Compile Include="Helper\WindowOpener.cs" />
<Compile Include="Converters\OpacityModeConverter.cs" /> <Compile Include="Converters\OpacityModeConverter.cs" />
<Compile Include="CustomPluginHotkeySetting.xaml.cs"> <Compile Include="CustomQueryHotkeySetting.xaml.cs">
<DependentUpon>CustomPluginHotkeySetting.xaml</DependentUpon> <DependentUpon>CustomQueryHotkeySetting.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Helper\DispatcherExtensions.cs" /> <Compile Include="Helper\DispatcherExtensions.cs" />
<Compile Include="Helper\DWMDropShadow.cs" /> <Compile Include="Helper\DWMDropShadow.cs" />
@@ -181,7 +177,7 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="CustomPluginHotkeySetting.xaml"> <Page Include="CustomQueryHotkeySetting.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>