mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 18:57:19 +02:00
Add multiple language. [WIP]
This commit is contained in:
@@ -4,6 +4,10 @@
|
||||
>
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="Themes/Dark.xaml" />
|
||||
<ResourceDictionary Source="Languages/English.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
|
||||
121
Wox/Helper/LanguageManager.cs
Normal file
121
Wox/Helper/LanguageManager.cs
Normal file
@@ -0,0 +1,121 @@
|
||||
using System;
|
||||
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.Infrastructure.Logger;
|
||||
using Wox.Infrastructure.Storage.UserSettings;
|
||||
|
||||
namespace Wox
|
||||
{
|
||||
public class LanguageManager
|
||||
{
|
||||
private static List<string> languageDirectories = new List<string>();
|
||||
|
||||
static LanguageManager()
|
||||
{
|
||||
languageDirectories.Add(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Languages"));
|
||||
|
||||
string userProfilePath = Environment.GetEnvironmentVariable("USERPROFILE");
|
||||
if (userProfilePath != null)
|
||||
{
|
||||
languageDirectories.Add(Path.Combine(Path.Combine(userProfilePath, ".Wox"), "Languages"));
|
||||
}
|
||||
|
||||
MakesureThemeDirectoriesExist();
|
||||
}
|
||||
|
||||
private static void MakesureThemeDirectoriesExist()
|
||||
{
|
||||
foreach (string pluginDirectory in languageDirectories)
|
||||
{
|
||||
if (!Directory.Exists(pluginDirectory))
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(pluginDirectory);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error(e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void ChangeLanguage(string name)
|
||||
{
|
||||
string path = GetLanguagePath(name);
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
path = GetLanguagePath("English");
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
throw new Exception("Change Language failed");
|
||||
}
|
||||
}
|
||||
|
||||
UserSettingStorage.Instance.Language = name;
|
||||
UserSettingStorage.Instance.Save();
|
||||
ResourceMerger.ApplyResources();
|
||||
}
|
||||
|
||||
internal static ResourceDictionary GetResourceDictionary()
|
||||
{
|
||||
return new ResourceDictionary
|
||||
{
|
||||
Source = new Uri(GetLanguagePath(UserSettingStorage.Instance.Language), UriKind.Absolute)
|
||||
};
|
||||
}
|
||||
|
||||
public static List<string> LoadAvailableLanguages()
|
||||
{
|
||||
List<string> themes = new List<string>();
|
||||
foreach (var directory in languageDirectories)
|
||||
{
|
||||
themes.AddRange(
|
||||
Directory.GetFiles(directory)
|
||||
.Where(filePath => filePath.EndsWith(".xaml"))
|
||||
.Select(Path.GetFileNameWithoutExtension)
|
||||
.ToList());
|
||||
}
|
||||
return themes;
|
||||
}
|
||||
|
||||
public static string GetTranslation(string key)
|
||||
{
|
||||
try
|
||||
{
|
||||
object translation = Application.Current.FindResource(key);
|
||||
if (translation == null)
|
||||
{
|
||||
return "NoTranslation";
|
||||
}
|
||||
return translation.ToString();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "NoTranslation";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static string GetLanguagePath(string name)
|
||||
{
|
||||
foreach (string directory in languageDirectories)
|
||||
{
|
||||
string path = Path.Combine(directory, name + ".xaml");
|
||||
if (File.Exists(path))
|
||||
{
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
21
Wox/Helper/ResourceMerger.cs
Normal file
21
Wox/Helper/ResourceMerger.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@ namespace Wox
|
||||
{
|
||||
Directory.CreateDirectory(pluginDirectory);
|
||||
}
|
||||
catch(Exception e)
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error(e.Message);
|
||||
}
|
||||
@@ -60,9 +60,17 @@ namespace Wox
|
||||
}
|
||||
}
|
||||
|
||||
UserSettingStorage.Instance.Theme = themeName;
|
||||
UserSettingStorage.Instance.Save();
|
||||
|
||||
ResourceMerger.ApplyResources();
|
||||
}
|
||||
|
||||
internal static ResourceDictionary GetResourceDictionary()
|
||||
{
|
||||
var dict = new ResourceDictionary
|
||||
{
|
||||
Source = new Uri(themePath, UriKind.Absolute)
|
||||
Source = new Uri(GetThemePath(UserSettingStorage.Instance.Theme), UriKind.Absolute)
|
||||
};
|
||||
|
||||
Style queryBoxStyle = dict["QueryBoxStyle"] as Style;
|
||||
@@ -89,9 +97,20 @@ namespace Wox
|
||||
Array.ForEach(new Style[] { resultItemStyle, resultSubItemStyle, resultItemSelectedStyle, resultSubItemSelectedStyle }, o => Array.ForEach(setters, p => o.Setters.Add(p)));
|
||||
}
|
||||
|
||||
Application.Current.Resources.MergedDictionaries.Clear();
|
||||
Application.Current.Resources.MergedDictionaries.Add(dict);
|
||||
return dict;
|
||||
}
|
||||
|
||||
public static List<string> LoadAvailableThemes()
|
||||
{
|
||||
List<string> themes = new List<string>();
|
||||
foreach (var themeDirectory in themeDirectories)
|
||||
{
|
||||
themes.AddRange(
|
||||
Directory.GetFiles(themeDirectory)
|
||||
.Where(filePath => filePath.EndsWith(".xaml") && !filePath.EndsWith("Default.xaml"))
|
||||
.ToList());
|
||||
}
|
||||
return themes;
|
||||
}
|
||||
|
||||
private static string GetThemePath(string themeName)
|
||||
59
Wox/Languages/English.xaml
Normal file
59
Wox/Languages/English.xaml
Normal file
@@ -0,0 +1,59 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
<!--Setting General-->
|
||||
<system:String x:Key="general">General</system:String>
|
||||
<system:String x:Key="startWoxOnSystemStartup">Start Wox on system startup</system:String>
|
||||
<system:String x:Key="hideWoxWhenLoseFocus">Hide Wox when loses focus</system:String>
|
||||
<system:String x:Key="dontPromptUpdateMsg">Don't show upgrade msg if new version available</system:String>
|
||||
<system:String x:Key="language">Language</system:String>
|
||||
|
||||
<!--Setting Plugin-->
|
||||
<system:String x:Key="plugin">Plugin</system:String>
|
||||
<system:String x:Key="browserMorePlugins">Browse more plugins</system:String>
|
||||
<system:String x:Key="disable">Disable</system:String>
|
||||
<system:String x:Key="actionKeyword">Action keyword</system:String>
|
||||
<system:String x:Key="pluginDirectory">Plugin Directory</system:String>
|
||||
<system:String x:Key="author">Author</system:String>
|
||||
|
||||
<!--Setting Theme-->
|
||||
<system:String x:Key="theme">Theme</system:String>
|
||||
<system:String x:Key="browserMoreThemes">Browse more themes</system:String>
|
||||
<system:String x:Key="helloWox">Hello Wox</system:String>
|
||||
<system:String x:Key="queryBoxFont">Query Box Font</system:String>
|
||||
<system:String x:Key="resultItemFont">Result Item Font</system:String>
|
||||
<system:String x:Key="windowMode">Window Mode</system:String>
|
||||
<system:String x:Key="opacity">Opacity</system:String>
|
||||
|
||||
<!--Setting Hotkey-->
|
||||
<system:String x:Key="hotkey">Hotkey</system:String>
|
||||
<system:String x:Key="woxHotkey">Wox Hotkey</system:String>
|
||||
<system:String x:Key="customQueryHotkey">Custom Query Hotkey</system:String>
|
||||
<system:String x:Key="delete">Delete</system:String>
|
||||
<system:String x:Key="edit">Edit</system:String>
|
||||
<system:String x:Key="add">Add</system:String>
|
||||
<system:String x:Key="pleaseSelectAnItem">Please select an item</system:String>
|
||||
<system:String x:Key="deleteCustomHotkeyWarning">Are your sure to delete {0} plugin hotkey?</system:String>
|
||||
|
||||
<!--Setting Proxy-->
|
||||
<system:String x:Key="proxy">Proxy</system:String>
|
||||
<system:String x:Key="enableProxy">Enable Proxy</system:String>
|
||||
<system:String x:Key="server">Server</system:String>
|
||||
<system:String x:Key="port">Port</system:String>
|
||||
<system:String x:Key="userName">User Name</system:String>
|
||||
<system:String x:Key="password">Password</system:String>
|
||||
<system:String x:Key="testProxy">Test Proxy</system:String>
|
||||
<system:String x:Key="save">Save</system:String>
|
||||
<system:String x:Key="serverCantBeEmpty">Server can't be empty</system:String>
|
||||
<system:String x:Key="portCantBeEmpty">Server port can't be empty</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="proxyIsCorrect">Proxy is correct</system:String>
|
||||
|
||||
|
||||
<!--Setting About-->
|
||||
<system:String x:Key="about">About</system:String>
|
||||
<system:String x:Key="website">Website</system:String>
|
||||
<system:String x:Key="version">Version</system:String>
|
||||
|
||||
</ResourceDictionary>
|
||||
51
Wox/Languages/中文.xaml
Normal file
51
Wox/Languages/中文.xaml
Normal file
@@ -0,0 +1,51 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
<!--设置,通用-->
|
||||
<system:String x:Key="general">通用</system:String>
|
||||
<system:String x:Key="startWoxOnSystemStartup">开机启动</system:String>
|
||||
<system:String x:Key="hideWoxWhenLoseFocus">失去焦点时自动隐藏Wox</system:String>
|
||||
<system:String x:Key="dontPromptUpdateMsg">不显示新版本提示</system:String>
|
||||
<system:String x:Key="language">语言</system:String>
|
||||
|
||||
<!--设置,插件-->
|
||||
<system:String x:Key="plugin">插件</system:String>
|
||||
<system:String x:Key="browserMorePlugins">浏览更多插件</system:String>
|
||||
<system:String x:Key="disable">禁用</system:String>
|
||||
<system:String x:Key="actionKeyword">触发关键字</system:String>
|
||||
<system:String x:Key="pluginDirectory">插件目录</system:String>
|
||||
<system:String x:Key="author">作者</system:String>
|
||||
|
||||
<!--设置,主题-->
|
||||
<system:String x:Key="theme">主题</system:String>
|
||||
<system:String x:Key="browserMoreThemes">浏览更多主题</system:String>
|
||||
<system:String x:Key="helloWox">你好,Wox</system:String>
|
||||
<system:String x:Key="queryBoxFont">查询框字体</system:String>
|
||||
<system:String x:Key="resultItemFont">结果项字体</system:String>
|
||||
<system:String x:Key="windowMode">窗口模式</system:String>
|
||||
<system:String x:Key="opacity">透明度</system:String>
|
||||
|
||||
<!--设置,热键-->
|
||||
<system:String x:Key="hotkey">热键</system:String>
|
||||
<system:String x:Key="woxHotkey">Wox激活热键</system:String>
|
||||
<system:String x:Key="customQueryHotkey">自定义查询热键</system:String>
|
||||
<system:String x:Key="delete">删除</system:String>
|
||||
<system:String x:Key="edit">编辑</system:String>
|
||||
<system:String x:Key="add">增加</system:String>
|
||||
|
||||
<!--设置,代理-->
|
||||
<system:String x:Key="proxy">代理</system:String>
|
||||
<system:String x:Key="enableProxy">启用代理</system:String>
|
||||
<system:String x:Key="server">服务器</system:String>
|
||||
<system:String x:Key="port">端口</system:String>
|
||||
<system:String x:Key="userName">用户名</system:String>
|
||||
<system:String x:Key="password">密码</system:String>
|
||||
<system:String x:Key="testProxy">测试代理</system:String>
|
||||
<system:String x:Key="save">保存</system:String>
|
||||
|
||||
<!--设置,版本-->
|
||||
<system:String x:Key="about">关于</system:String>
|
||||
<system:String x:Key="website">网站</system:String>
|
||||
<system:String x:Key="version">版本</system:String>
|
||||
|
||||
</ResourceDictionary>
|
||||
@@ -174,7 +174,7 @@ namespace Wox
|
||||
|
||||
ThreadPool.SetMaxThreads(30, 10);
|
||||
ThemeManager.ChangeTheme(UserSettingStorage.Instance.Theme);
|
||||
|
||||
LanguageManager.ChangeLanguage(UserSettingStorage.Instance.Language);
|
||||
|
||||
SetHotkey(UserSettingStorage.Instance.Hotkey, OnHotkey);
|
||||
SetCustomPluginHotkey();
|
||||
|
||||
@@ -20,27 +20,31 @@
|
||||
<converters:ImagePathConverter x:Key="ImageConverter" />
|
||||
</Window.Resources>
|
||||
<TabControl Height="auto" >
|
||||
<TabItem Header="General">
|
||||
<TabItem Header="{DynamicResource general}" Height="23" VerticalAlignment="Top">
|
||||
<StackPanel Orientation="Vertical" Margin="10">
|
||||
<CheckBox x:Name="cbStartWithWindows" Unchecked="CbStartWithWindows_OnUnchecked" Checked="CbStartWithWindows_OnChecked" Margin="10">
|
||||
Start Wox on system startup
|
||||
<CheckBox x:Name="cbStartWithWindows" Unchecked="CbStartWithWindows_OnUnchecked" Checked="CbStartWithWindows_OnChecked" Margin="10">
|
||||
<TextBlock Text="{DynamicResource startWoxOnSystemStartup}" ></TextBlock>
|
||||
</CheckBox>
|
||||
<CheckBox x:Name="cbHideWhenDeactive" Margin="10">
|
||||
Hide Wox when loses focus
|
||||
<TextBlock Text="{DynamicResource hideWoxWhenLoseFocus}" ></TextBlock>
|
||||
</CheckBox>
|
||||
<CheckBox x:Name="cbDontPromptUpdateMsg" Margin="10">
|
||||
Don't show upgrade msg if new version available
|
||||
<TextBlock Text="{DynamicResource dontPromptUpdateMsg}" ></TextBlock>
|
||||
</CheckBox>
|
||||
<StackPanel Margin="10" Orientation="Horizontal">
|
||||
<TextBlock Text="{DynamicResource language}"></TextBlock>
|
||||
<ComboBox Margin="10 0 0 0" Width="200" x:Name="cbLanguages" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</TabItem>
|
||||
<TabItem Header="Plugin">
|
||||
<TabItem Header="{DynamicResource plugin}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="200"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<DockPanel Grid.Column="0" >
|
||||
<TextBlock DockPanel.Dock="Top" Margin="6" HorizontalAlignment="Left" Cursor="Hand" MouseUp="tbMorePlugins_MouseUp" x:Name="tbMorePlugins" Foreground="Blue" Text="Browse more plugins"></TextBlock>
|
||||
<TextBlock DockPanel.Dock="Top" Margin="6" HorizontalAlignment="Left" Cursor="Hand" MouseUp="tbMorePlugins_MouseUp" x:Name="tbMorePlugins" Foreground="Blue" Text="{DynamicResource browserMorePlugins}"></TextBlock>
|
||||
<ListBox x:Name="lbPlugins" Margin="0" SelectionChanged="lbPlugins_OnSelectionChanged" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ScrollViewer.HorizontalScrollBarVisibility="Disabled" Grid.IsSharedSizeScope="True" >
|
||||
<ListBox.Resources>
|
||||
<DataTemplate DataType="{x:Type system:BaseSystemPlugin}">
|
||||
@@ -102,14 +106,18 @@
|
||||
</Grid.RowDefinitions>
|
||||
<DockPanel Grid.Row="0">
|
||||
<TextBlock x:Name="pluginTitle" Text="Plugin Title" Cursor="Hand" MouseUp="PluginTitle_OnMouseUp" ToolTip="{Binding Source=pluginTitle, Path=Text}" FontSize="24"></TextBlock>
|
||||
<TextBlock Opacity="0.5" VerticalAlignment="Bottom" HorizontalAlignment="Right" x:Name="pluginAuthor" Text="Author"></TextBlock>
|
||||
<TextBlock Opacity="0.5" VerticalAlignment="Bottom" HorizontalAlignment="Right" x:Name="pluginAuthor" Text="{DynamicResource author}"></TextBlock>
|
||||
</DockPanel>
|
||||
<TextBlock Grid.Row="1" x:Name="pluginSubTitle" Opacity="0.5" ToolTip="{Binding Source=pluginSubTitle, Path=Text}" Visibility="{Binding Source=pluginSubTitle, Path=Text, Converter={converters:StringNullOrEmptyToVisibilityConverter}}" ></TextBlock>
|
||||
<DockPanel Grid.Row="2" Margin="0 8 0 0">
|
||||
<CheckBox x:Name="cbDisablePlugin" Click="CbDisablePlugin_OnClick">Disable</CheckBox>
|
||||
<TextBlock x:Name="pluginActionKeywordTitle" Margin="50 -2 0 0">ActionKeyword:</TextBlock>
|
||||
<CheckBox x:Name="cbDisablePlugin" Click="CbDisablePlugin_OnClick">
|
||||
<TextBlock Text="{DynamicResource disable}"></TextBlock>
|
||||
</CheckBox>
|
||||
<TextBlock x:Name="pluginActionKeywordTitle" Margin="50 -2 0 0">
|
||||
<TextBlock Text="{DynamicResource actionKeyword}"></TextBlock>
|
||||
</TextBlock>
|
||||
<TextBlock Margin="5 -2 0 0" ToolTip="Change Action Keyword" Cursor="Hand" MouseUp="PluginActionKeyword_OnMouseUp" Foreground="Blue" Text="key" x:Name="pluginActionKeyword"></TextBlock>
|
||||
<TextBlock HorizontalAlignment="Right" Cursor="Hand" MouseUp="tbOpenPluginDirecoty_MouseUp" Foreground="Blue" Text="Plugin Directory" x:Name="tbOpenPluginDirecoty"></TextBlock>
|
||||
<TextBlock HorizontalAlignment="Right" Cursor="Hand" MouseUp="tbOpenPluginDirecoty_MouseUp" Foreground="Blue" Text="{DynamicResource pluginDirectory}" x:Name="tbOpenPluginDirecoty"></TextBlock>
|
||||
</DockPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
@@ -121,14 +129,14 @@
|
||||
</Grid>
|
||||
</Grid>
|
||||
</TabItem>
|
||||
<TabItem Header="Theme">
|
||||
<TabItem Header="{DynamicResource theme}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="200"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<DockPanel Grid.Column="0" >
|
||||
<TextBlock DockPanel.Dock="Top" Margin="6" HorizontalAlignment="Left" Cursor="Hand" MouseUp="tbMoreThemes_MouseUp" x:Name="tbMoreThemes" Foreground="Blue" Text="Browse more themes"></TextBlock>
|
||||
<TextBlock DockPanel.Dock="Top" Margin="6" HorizontalAlignment="Left" Cursor="Hand" MouseUp="tbMoreThemes_MouseUp" x:Name="tbMoreThemes" Foreground="Blue" Text="{DynamicResource browserMoreThemes}"></TextBlock>
|
||||
<ListBox x:Name="themeComboBox" Margin="0" SelectionChanged="ThemeComboBox_OnSelectionChanged" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="180"/>
|
||||
</DockPanel>
|
||||
<Grid Margin="0" Grid.Column="1">
|
||||
@@ -150,7 +158,7 @@
|
||||
<RowDefinition Height="50" />
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBox Text="Hello Wox" IsReadOnly="True" Style="{DynamicResource QueryBoxStyle}" Grid.Row="0"/>
|
||||
<TextBox Text="{DynamicResource helloWox}" IsReadOnly="True" Style="{DynamicResource QueryBoxStyle}" Grid.Row="0"/>
|
||||
<wox:ResultPanel Grid.Row="1" x:Name="resultPanelPreview"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
@@ -159,7 +167,7 @@
|
||||
|
||||
<StackPanel Grid.Row="1" Margin="0 10 0 10" Orientation="Vertical">
|
||||
<StackPanel Orientation="Horizontal" Margin="2">
|
||||
<TextBlock Text="Query Box Font:" />
|
||||
<TextBlock Text="{DynamicResource queryBoxFont}" />
|
||||
<ComboBox Margin="10 -2 5 0" x:Name="cbQueryBoxFont" ItemsSource="{x:Static Fonts.SystemFontFamilies}" SelectionChanged="CbQueryBoxFont_OnSelectionChanged" HorizontalAlignment="Left" VerticalAlignment="Top" Width="160"/>
|
||||
<ComboBox Margin="0 -2 0 0"
|
||||
x:Name="cbQueryBoxFontFaces"
|
||||
@@ -178,7 +186,7 @@
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" Margin="2">
|
||||
<TextBlock Text="Result Item Font:" />
|
||||
<TextBlock Text="{DynamicResource resultItemFont}" />
|
||||
<ComboBox Margin="5 -2 5 0" x:Name="cbResultItemFont" ItemsSource="{x:Static Fonts.SystemFontFamilies}" SelectionChanged="CbResultItemFont_OnSelectionChanged" HorizontalAlignment="Left" VerticalAlignment="Top" Width="160"/>
|
||||
<ComboBox Margin="0 -2 0 0"
|
||||
x:Name="cbResultItemFontFaces"
|
||||
@@ -197,7 +205,7 @@
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" Margin="2">
|
||||
<TextBlock Text="Window Mode:" />
|
||||
<TextBlock Text="{DynamicResource windowMode}" />
|
||||
<ComboBox Name="CbOpacityMode" Margin="14 0 0 0" SelectionChanged="CbOpacityMode_OnSelectionChanged" Width="160">
|
||||
<UserSettings:OpacityMode>Normal</UserSettings:OpacityMode>
|
||||
<UserSettings:OpacityMode>LayeredWindow</UserSettings:OpacityMode>
|
||||
@@ -209,7 +217,7 @@
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
<StackPanel Orientation="Horizontal" Margin="5 0 0 0" x:Name="spOpacity">
|
||||
<TextBlock Text="Opacity:" HorizontalAlignment="Center" />
|
||||
<TextBlock Text="{DynamicResource opacity}" HorizontalAlignment="Center" />
|
||||
<Slider x:Name="slOpacity" Maximum="1" Minimum="0" SmallChange="1" LargeChange="0.1" TickPlacement="BottomRight" TickFrequency="0.1" ValueChanged="slOpacity_ValueChanged" Width="100"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
@@ -218,7 +226,7 @@
|
||||
</Grid>
|
||||
</Grid>
|
||||
</TabItem>
|
||||
<TabItem Header="Hotkey">
|
||||
<TabItem Header="{DynamicResource hotkey}">
|
||||
<Grid Margin="10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"/>
|
||||
@@ -226,7 +234,7 @@
|
||||
<RowDefinition Height="50"/>
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Grid.Row="0" Orientation="Horizontal" VerticalAlignment="Center">
|
||||
<TextBlock VerticalAlignment="Center" Margin="0 0 10 0"><Run Text="Wox Hotkey:"/></TextBlock>
|
||||
<TextBlock VerticalAlignment="Center" Margin="0 0 10 0" Text="{DynamicResource woxHotkey}"></TextBlock>
|
||||
<wox:HotkeyControl x:Name="ctlHotkey"/>
|
||||
</StackPanel>
|
||||
<Grid Grid.Row="1">
|
||||
@@ -234,18 +242,18 @@
|
||||
<RowDefinition Height="20"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock VerticalAlignment="Center" Grid.Row="0" Margin="0 0 10 0"><Run Text="Custom Plugin Hotkey:"/></TextBlock>
|
||||
<TextBlock VerticalAlignment="Center" Grid.Row="0" Margin="0 0 10 0" Text="{DynamicResource customQueryHotkey}"></TextBlock>
|
||||
<ListView x:Name="lvCustomHotkey" Margin="0 5 0 0" Grid.Row="1">
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridViewColumn Header="Hotkey" Width="180">
|
||||
<GridViewColumn Header="{DynamicResource hotkey}" Width="180">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Hotkey}"/>
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
<GridViewColumn Header="Action Keyword" Width="500">
|
||||
<GridViewColumn Header="{DynamicResource actionKeyword}" Width="500">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding ActionKeyword}"/>
|
||||
@@ -258,15 +266,17 @@
|
||||
|
||||
</Grid>
|
||||
<StackPanel Grid.Row="2" HorizontalAlignment="Right" Orientation="Horizontal">
|
||||
<Button x:Name="btnDeleteCustomHotkey" Click="BtnDeleteCustomHotkey_OnClick" Width="100" Margin="10" Content="Delete"/>
|
||||
<Button x:Name="btnEditCustomHotkey" Click="BtnEditCustomHotkey_OnClick" Width="100" Margin="10" Content="Edit"/>
|
||||
<Button x:Name="btnAddCustomeHotkey" Click="BtnAddCustomeHotkey_OnClick" Width="100" Margin="10" Content="Add"/>
|
||||
<Button x:Name="btnDeleteCustomHotkey" Click="BtnDeleteCustomHotkey_OnClick" Width="100" Margin="10" Content="{DynamicResource delete}"/>
|
||||
<Button x:Name="btnEditCustomHotkey" Click="BtnEditCustomHotkey_OnClick" Width="100" Margin="10" Content="{DynamicResource edit}"/>
|
||||
<Button x:Name="btnAddCustomeHotkey" Click="BtnAddCustomeHotkey_OnClick" Width="100" Margin="10" Content="{DynamicResource add}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</TabItem>
|
||||
<TabItem Header="Proxy">
|
||||
<TabItem Header="{DynamicResource proxy}">
|
||||
<StackPanel>
|
||||
<CheckBox x:Name="cbEnableProxy" Margin="10">Enable Proxy</CheckBox>
|
||||
<CheckBox x:Name="cbEnableProxy" Margin="10">
|
||||
<TextBlock Text="{DynamicResource enableProxy}"></TextBlock>
|
||||
</CheckBox>
|
||||
<Grid Margin="10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition ></RowDefinition>
|
||||
@@ -279,37 +289,37 @@
|
||||
<ColumnDefinition></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border Grid.Row="0" Grid.Column="0" Padding="5">
|
||||
<TextBlock >Server</TextBlock>
|
||||
<TextBlock Text="{DynamicResource server}"></TextBlock>
|
||||
</Border>
|
||||
<Border Grid.Row="0" Grid.Column="1" Padding="5">
|
||||
<TextBox Width="200" HorizontalAlignment="Left" x:Name="tbProxyServer"></TextBox>
|
||||
</Border>
|
||||
<Border Grid.Row="0" Grid.Column="2" Padding="5">
|
||||
<TextBlock>Port</TextBlock>
|
||||
<TextBlock Text="{DynamicResource port}"></TextBlock>
|
||||
</Border>
|
||||
<Border Grid.Row="0" Grid.Column="3" Padding="5">
|
||||
<TextBox Width="50" HorizontalAlignment="Left" x:Name="tbProxyPort"></TextBox>
|
||||
</Border>
|
||||
<Border Grid.Row="1" Grid.Column="0" Padding="5">
|
||||
<TextBlock >UserName</TextBlock>
|
||||
<TextBlock Text="{DynamicResource userName}"></TextBlock>
|
||||
</Border>
|
||||
<Border Grid.Row="1" Grid.Column="1" Padding="5">
|
||||
<TextBox Width="200" HorizontalAlignment="Left" x:Name="tbProxyUserName"></TextBox>
|
||||
</Border>
|
||||
<Border Grid.Row="1" Grid.Column="2" Padding="5">
|
||||
<TextBlock>Password</TextBlock>
|
||||
<TextBlock Text="{DynamicResource password}"></TextBlock>
|
||||
</Border>
|
||||
<Border Grid.Row="1" Grid.Column="3" Padding="5">
|
||||
<PasswordBox Width="200" HorizontalAlignment="Left" x:Name="tbProxyPassword" />
|
||||
</Border>
|
||||
</Grid>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Button x:Name="btnTestProxy" Width="80" HorizontalAlignment="Left" Margin="10" Click="btnTestProxy_Click">Test Proxy</Button>
|
||||
<Button x:Name="btnSaveProxy" Width="80" HorizontalAlignment="Left" Margin="10" Click="btnSaveProxy_Click">Save</Button>
|
||||
<Button x:Name="btnTestProxy" Width="80" HorizontalAlignment="Left" Margin="10" Click="btnTestProxy_Click" Content="{DynamicResource testProxy}"></Button>
|
||||
<Button x:Name="btnSaveProxy" Width="80" HorizontalAlignment="Left" Margin="10" Click="btnSaveProxy_Click" Content="{DynamicResource save}"></Button>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</TabItem>
|
||||
<TabItem Header="About">
|
||||
<TabItem Header="{DynamicResource about}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="80"></ColumnDefinition>
|
||||
@@ -320,10 +330,10 @@
|
||||
<RowDefinition Height="30"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Grid.Column="0" Grid.Row="0" Margin="6">Website:</TextBlock>
|
||||
<TextBlock Grid.Column="0" Grid.Row="0" Margin="6" Text="{DynamicResource website}"></TextBlock>
|
||||
<TextBlock Grid.Column="1" Grid.Row="0" Margin="6" HorizontalAlignment="Left" Cursor="Hand" MouseUp="tbWebsite_MouseUp" x:Name="tbWebsite" Foreground="Blue" Text="http://www.getwox.com"></TextBlock>
|
||||
|
||||
<TextBlock Grid.Column="0" Grid.Row="1" Margin="6">Version:</TextBlock>
|
||||
<TextBlock Grid.Column="0" Grid.Row="1" Margin="6" Text="{DynamicResource version}"></TextBlock>
|
||||
<StackPanel Grid.Column="1" Grid.Row="1" Orientation="Horizontal">
|
||||
<TextBlock Margin="6" HorizontalAlignment="Left" x:Name="tbVersion" Text="1.0.0"></TextBlock>
|
||||
<TextBlock Margin="6" HorizontalAlignment="Left" Cursor="Hand" MouseUp="tbNewVersionAvailable_MouseUp" x:Name="tbNewVersionAvailable" Foreground="Blue" Text="1.1.0 Available"></TextBlock>
|
||||
|
||||
@@ -70,6 +70,8 @@ namespace Wox
|
||||
cbHideWhenDeactive.IsChecked = UserSettingStorage.Instance.HideWhenDeactive;
|
||||
cbDontPromptUpdateMsg.IsChecked = UserSettingStorage.Instance.DontPromptUpdateMsg;
|
||||
|
||||
LoadLanguages();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Theme
|
||||
@@ -148,7 +150,7 @@ namespace Wox
|
||||
}
|
||||
});
|
||||
|
||||
foreach (string theme in LoadAvailableThemes())
|
||||
foreach (string theme in ThemeManager.LoadAvailableThemes())
|
||||
{
|
||||
string themeName = System.IO.Path.GetFileNameWithoutExtension(theme);
|
||||
themeComboBox.Items.Add(themeName);
|
||||
@@ -240,6 +242,19 @@ namespace Wox
|
||||
settingsLoaded = true;
|
||||
}
|
||||
|
||||
private void LoadLanguages()
|
||||
{
|
||||
cbLanguages.ItemsSource = LanguageManager.LoadAvailableLanguages();
|
||||
cbLanguages.SelectedValue = UserSettingStorage.Instance.Language;
|
||||
cbLanguages.SelectionChanged += cbLanguages_SelectionChanged;
|
||||
}
|
||||
|
||||
void cbLanguages_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
string language = cbLanguages.SelectedValue.ToString();
|
||||
LanguageManager.ChangeLanguage(language);
|
||||
}
|
||||
|
||||
private void EnableProxy()
|
||||
{
|
||||
tbProxyPassword.IsEnabled = true;
|
||||
@@ -256,12 +271,6 @@ namespace Wox
|
||||
tbProxyPort.IsEnabled = false;
|
||||
}
|
||||
|
||||
private List<string> LoadAvailableThemes()
|
||||
{
|
||||
string themePath = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "Themes");
|
||||
return Directory.GetFiles(themePath).Where(filePath => filePath.EndsWith(".xaml") && !filePath.EndsWith("Default.xaml")).ToList();
|
||||
}
|
||||
|
||||
private void CbStartWithWindows_OnChecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CreateStartupFolderShortcut();
|
||||
@@ -319,19 +328,20 @@ namespace Wox
|
||||
private void BtnDeleteCustomHotkey_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CustomPluginHotkey item = lvCustomHotkey.SelectedItem as CustomPluginHotkey;
|
||||
if (item != null &&
|
||||
MessageBox.Show("Are your sure to delete " + item.Hotkey + " plugin hotkey?", "Delete Custom Plugin Hotkey",
|
||||
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
||||
if (item == null)
|
||||
{
|
||||
MessageBox.Show(LanguageManager.GetTranslation("pleaseSelectAnItem"));
|
||||
return;
|
||||
}
|
||||
|
||||
string deleteWarning = string.Format(LanguageManager.GetTranslation("deleteCustomHotkeyWarning"), item.Hotkey);
|
||||
if (MessageBox.Show(deleteWarning, LanguageManager.GetTranslation("delete"), MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
||||
{
|
||||
UserSettingStorage.Instance.CustomPluginHotkeys.Remove(item);
|
||||
lvCustomHotkey.Items.Refresh();
|
||||
UserSettingStorage.Instance.Save();
|
||||
MainWindow.RemoveHotkey(item.Hotkey);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Please select an item");
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnEditCustomHotkey_OnClick(object sender, RoutedEventArgs e)
|
||||
@@ -345,7 +355,7 @@ namespace Wox
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Please select an item");
|
||||
MessageBox.Show(LanguageManager.GetTranslation("pleaseSelectAnItem"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -640,17 +650,17 @@ namespace Wox
|
||||
{
|
||||
if (string.IsNullOrEmpty(tbProxyServer.Text))
|
||||
{
|
||||
MessageBox.Show("Server can't be empty");
|
||||
MessageBox.Show(LanguageManager.GetTranslation("serverCantBeEmpty"));
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(tbProxyPort.Text))
|
||||
{
|
||||
MessageBox.Show("Server port can't be empty");
|
||||
MessageBox.Show(LanguageManager.GetTranslation("portCantBeEmpty"));
|
||||
return;
|
||||
}
|
||||
if (!int.TryParse(tbProxyPort.Text, out port))
|
||||
{
|
||||
MessageBox.Show("Invalid port format");
|
||||
MessageBox.Show(LanguageManager.GetTranslation("invalidPortFormat"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -661,25 +671,25 @@ namespace Wox
|
||||
UserSettingStorage.Instance.ProxyPassword = tbProxyPassword.Password;
|
||||
UserSettingStorage.Instance.Save();
|
||||
|
||||
MessageBox.Show("Save Proxy Successfully");
|
||||
MessageBox.Show(LanguageManager.GetTranslation("saveProxySuccessfully"));
|
||||
}
|
||||
|
||||
private void btnTestProxy_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(tbProxyServer.Text))
|
||||
{
|
||||
MessageBox.Show("Server can't be empty");
|
||||
MessageBox.Show(LanguageManager.GetTranslation("serverCantBeEmpty"));
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(tbProxyPort.Text))
|
||||
{
|
||||
MessageBox.Show("Server port can't be empty");
|
||||
MessageBox.Show(LanguageManager.GetTranslation("portCantBeEmpty"));
|
||||
return;
|
||||
}
|
||||
int port;
|
||||
if (!int.TryParse(tbProxyPort.Text, out port))
|
||||
{
|
||||
MessageBox.Show("Invalid port format");
|
||||
MessageBox.Show(LanguageManager.GetTranslation("invalidPortFormat"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -697,10 +707,10 @@ namespace Wox
|
||||
}
|
||||
try
|
||||
{
|
||||
HttpWebResponse response = (HttpWebResponse) request.GetResponse();
|
||||
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
||||
if (response.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
MessageBox.Show("Proxy is ok");
|
||||
MessageBox.Show(LanguageManager.GetTranslation("proxyIsCorrect"));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="Default.xaml" />
|
||||
<ResourceDictionary Source="Base.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style x:Key="QueryBoxStyle" BasedOn="{StaticResource BaseQueryBoxStyle}" TargetType="{x:Type TextBox}">
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="Default.xaml"></ResourceDictionary>
|
||||
<ResourceDictionary Source="Base.xaml"></ResourceDictionary>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style x:Key="QueryBoxStyle" BasedOn="{StaticResource BaseQueryBoxStyle}" TargetType="{x:Type TextBox}">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="Default.xaml"></ResourceDictionary>
|
||||
<ResourceDictionary Source="Base.xaml"></ResourceDictionary>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<Style x:Key="QueryBoxStyle" BasedOn="{StaticResource BaseQueryBoxStyle}" TargetType="{x:Type TextBox}">
|
||||
<Setter Property="Background" Value="#ffffff"/>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="Default.xaml"></ResourceDictionary>
|
||||
<ResourceDictionary Source="Base.xaml"></ResourceDictionary>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<Style x:Key="QueryBoxStyle" BasedOn="{StaticResource BaseQueryBoxStyle}" TargetType="{x:Type TextBox}">
|
||||
<Setter Property="Background" Value="#1f1d1f"/>
|
||||
|
||||
@@ -113,10 +113,12 @@
|
||||
<Reference Include="WPFToolkit, Version=3.5.40128.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Helper\ResourceMerger.cs" />
|
||||
<Compile Include="Helper\WoxLogPathConverter.cs" />
|
||||
<Compile Include="ImageLoader\ImageCacheStroage.cs" />
|
||||
<Compile Include="Helper\LanguageManager.cs" />
|
||||
<Compile Include="Storage\UserSelectedRecordStorage.cs" />
|
||||
<Compile Include="ThemeManager.cs" />
|
||||
<Compile Include="Helper\ThemeManager.cs" />
|
||||
<Compile Include="Update\NewVersionWindow.xaml.cs">
|
||||
<DependentUpon>NewVersionWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -187,6 +189,16 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<None Include="Languages\中文.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<Content Include="Languages\English.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Page Include="MainWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
@@ -216,11 +228,11 @@
|
||||
<SubType>Designer</SubType>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Themes\Default.xaml">
|
||||
<Content Include="Themes\Base.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</Content>
|
||||
<None Include="Themes\Pink.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
@@ -231,10 +243,11 @@
|
||||
<SubType>Designer</SubType>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<Page Include="Themes\Dark.xaml">
|
||||
<Content Include="Themes\Dark.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Page Include="Update\NewVersionWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
||||
Reference in New Issue
Block a user