This commit is contained in:
bao-qian 2016-05-21 19:04:52 +01:00
parent 014757a0f7
commit 299864a9cf
2 changed files with 137 additions and 154 deletions

View File

@ -18,38 +18,35 @@
</ListBoxItem>
<image:ImagePathConverter x:Key="ImageConverter" />
</Window.Resources>
<TabControl Height="auto" x:Name="settingTab" SelectionChanged="settingTab_SelectionChanged">
<TabControl Height="auto" x:Name="SettingTab" SelectionChanged="settingTab_SelectionChanged">
<TabItem Header="{DynamicResource general}">
<StackPanel Orientation="Vertical">
<CheckBox x:Name="cbStartWithWindows" Unchecked="CbStartWithWindows_OnUnchecked"
<CheckBox x:Name="AutoStartup" Unchecked="CbStartWithWindows_OnUnchecked"
Checked="CbStartWithWindows_OnChecked" Margin="10">
<TextBlock Text="{DynamicResource startWoxOnSystemStartup}" />
</CheckBox>
<CheckBox x:Name="cbHideOnStartup" Margin="10">
<CheckBox x:Name="HideOnStartup" Margin="10">
<TextBlock Text="{DynamicResource hideOnStartup}" />
</CheckBox>
<CheckBox x:Name="cbHideWhenDeactive" Margin="10">
<CheckBox x:Name="HideWhenDeactive" Margin="10">
<TextBlock Text="{DynamicResource hideWoxWhenLoseFocus}" />
</CheckBox>
<CheckBox x:Name="cbDontPromptUpdateMsg" Margin="10">
<TextBlock Text="{DynamicResource dontPromptUpdateMsg}" />
</CheckBox>
<CheckBox x:Name="cbRememberLastLocation" Margin="10">
<CheckBox x:Name="RememberLastLocation" Margin="10">
<TextBlock Text="{DynamicResource rememberLastLocation}" />
</CheckBox>
<CheckBox x:Name="cbIgnoreHotkeysOnFullscreen" Margin="10">
<CheckBox x:Name="IgnoreHotkeysOnFullscreen" Margin="10">
<TextBlock Text="{DynamicResource ignoreHotkeysOnFullscreen}" />
</CheckBox>
<CheckBox x:Name="AutoUpdatesCheckBox" Margin="10">
<CheckBox x:Name="AutoUpdates" Margin="10">
<TextBlock Text="{DynamicResource autoUpdates}" />
</CheckBox>
<StackPanel Margin="10" Orientation="Horizontal">
<TextBlock Text="{DynamicResource language}" />
<ComboBox Margin="10 0 0 0" Width="120" x:Name="cbLanguages" />
<ComboBox Margin="10 0 0 0" Width="120" x:Name="Languages" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="10">
<TextBlock Text="{DynamicResource maxShowResults}" />
<ComboBox Margin="10 0 0 0" Width="45" Name="comboMaxResultsToShow" />
<ComboBox Margin="10 0 0 0" Width="45" Name="MaxResults" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{DynamicResource pythonDirectory}" Margin="10"/>
@ -58,7 +55,7 @@
</StackPanel>
</StackPanel>
</TabItem>
<TabItem Header="{DynamicResource plugin}" x:Name="tabPlugin">
<TabItem Header="{DynamicResource plugin}" x:Name="PluginTab">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
@ -66,7 +63,7 @@
</Grid.ColumnDefinitions>
<DockPanel Grid.Column="0">
<TextBlock DockPanel.Dock="Top" Margin="10" HorizontalAlignment="Left" Cursor="Hand"
MouseUp="tbMorePlugins_MouseUp" x:Name="tbMorePlugins" Foreground="Blue"
MouseUp="tbMorePlugins_MouseUp" Foreground="Blue"
Text="{DynamicResource browserMorePlugins}" />
<ListBox x:Name="PluginsListBox" Margin="10, 0, 10, 10" SelectionChanged="lbPlugins_OnSelectionChanged"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
@ -101,14 +98,14 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<ContentControl x:Name="PluginInfoPanel" Grid.ColumnSpan="1" Grid.Row="0" Margin="10 10 10 0">
<ContentControl Grid.ColumnSpan="1" Grid.Row="0" Margin="10 10 10 0">
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="48" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Image Width="48" Height="48" HorizontalAlignment="Left" VerticalAlignment="Top"
x:Name="pluginIcon" />
x:Name="PluginIcon" />
<Grid Margin="10,0,0,0" Grid.Column="1" HorizontalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition />
@ -116,28 +113,29 @@
<RowDefinition />
</Grid.RowDefinitions>
<DockPanel Grid.Row="0">
<TextBlock x:Name="pluginTitle" Text="Plugin Title" Cursor="Hand"
<TextBlock x:Name="PluginTitle" Text="Plugin Title" Cursor="Hand"
MouseUp="PluginTitle_OnMouseUp"
ToolTip="{Binding Source=pluginTitle, Path=Text}" FontSize="24" />
<TextBlock Opacity="0.5" VerticalAlignment="Bottom" HorizontalAlignment="Right"
x:Name="pluginAuthor" Text="{DynamicResource author}" />
x:Name="PluginAuthor" Text="{DynamicResource author}" />
</DockPanel>
<TextBlock Grid.Row="1" x:Name="pluginSubTitle" Opacity="0.5"
<TextBlock Grid.Row="1" x:Name="PluginSubTitle" Opacity="0.5"
ToolTip="{Binding Source=pluginSubTitle, Path=Text}"/>
<DockPanel Grid.Row="2" Margin="0 10 0 8">
<CheckBox x:Name="cbDisablePlugin" Click="OnDisablePluginClicked">
<CheckBox x:Name="DisablePlugin" Click="OnDisablePluginClicked">
<TextBlock Text="{DynamicResource disable}" />
</CheckBox>
<TextBlock x:Name="pluginActionKeywordsTitle" Margin="20 0 0 0"
Text="{DynamicResource actionKeywords}" />
<TextBlock Margin="20 0 0 0"
x:Name="PluginActionKeywordsTitle"
Text="{DynamicResource actionKeywords}"/>
<TextBlock Margin="5 0 0 0" ToolTip="Change Action Keywords" Cursor="Hand"
MouseUp="PluginActionKeywords_OnMouseUp" Foreground="Blue" Text="keys"
x:Name="pluginActionKeywords" />
<TextBlock Margin="10 0 0 0" Text="Initialize time: 0ms" x:Name="pluginInitTime" />
<TextBlock Margin="10 0 0 0" Text="Query time: 0ms" x:Name="pluginQueryTime" />
x:Name="PluginActionKeywords" />
<TextBlock Margin="10 0 0 0" Text="Initialize time: 0ms" x:Name="PluginInitTime" />
<TextBlock Margin="10 0 0 0" Text="Query time: 0ms" x:Name="PluginQueryTime" />
<TextBlock HorizontalAlignment="Right" Cursor="Hand"
MouseUp="tbOpenPluginDirecoty_MouseUp" Foreground="Blue"
Text="{DynamicResource pluginDirectory}" x:Name="tbOpenPluginDirecoty" />
Text="{DynamicResource pluginDirectory}" x:Name="OpenPluginDirecoty" />
</DockPanel>
</Grid>
</Grid>
@ -148,7 +146,7 @@
</Grid>
</Grid>
</TabItem>
<TabItem Header="{DynamicResource theme}" x:Name="tabTheme">
<TabItem Header="{DynamicResource theme}" x:Name="ThemeTab">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
@ -156,9 +154,9 @@
</Grid.ColumnDefinitions>
<DockPanel Grid.Column="0">
<TextBlock DockPanel.Dock="Top" Margin="10" HorizontalAlignment="Left" Cursor="Hand"
MouseUp="tbMoreThemes_MouseUp" x:Name="tbMoreThemes" Foreground="Blue"
MouseUp="tbMoreThemes_MouseUp" Foreground="Blue"
Text="{DynamicResource browserMoreThemes}" />
<ListBox x:Name="themeComboBox" Margin="10, 0, 10, 10"
<ListBox x:Name="Theme" Margin="10, 0, 10, 10"
SelectionChanged="ThemeComboBox_OnSelectionChanged" HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" Width="180" />
</DockPanel>
@ -167,11 +165,8 @@
<RowDefinition />
<RowDefinition Height="100" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<StackPanel x:Name="PreviewPanel" Grid.Row="0" Margin="0">
<StackPanel x:Name="PreviewMainPanel" Orientation="Horizontal" Margin="10"
<StackPanel Orientation="Horizontal" Margin="10"
HorizontalAlignment="Center" VerticalAlignment="Center">
<Border Width="500" Style="{DynamicResource WindowBorderStyle}">
<Grid>
@ -190,13 +185,13 @@
<StackPanel Grid.Row="1" Margin="0 10 0 10" Orientation="Vertical">
<StackPanel Orientation="Horizontal" Margin="2">
<TextBlock Text="{DynamicResource queryBoxFont}" />
<ComboBox Margin="10 -2 5 0" x:Name="cbQueryBoxFont"
<ComboBox Margin="10 -2 5 0" x:Name="QueryBoxFont"
ItemsSource="{x:Static Fonts.SystemFontFamilies}"
SelectionChanged="CbQueryBoxFont_OnSelectionChanged" HorizontalAlignment="Left"
VerticalAlignment="Top" Width="160" />
<ComboBox Margin="0 -2 0 0"
x:Name="cbQueryBoxFontFaces"
ItemsSource="{Binding SelectedValue.FamilyTypefaces, ElementName=cbQueryBoxFont}"
x:Name="QueryBoxFontFaces"
ItemsSource="{Binding SelectedValue.FamilyTypefaces, ElementName=QueryBoxFont}"
SelectionChanged="CbQueryBoxFontFaces_OnSelectionChanged"
HorizontalAlignment="Left" VerticalAlignment="Top" Width="120">
<ComboBox.ItemTemplate>
@ -241,7 +236,7 @@
</Grid>
</Grid>
</TabItem>
<TabItem Header="{DynamicResource hotkey}" x:Name="tabHotkey">
<TabItem Header="{DynamicResource hotkey}" x:Name="HotkeyTab">
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="30" />
@ -250,7 +245,7 @@
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock VerticalAlignment="Center" Margin="0 0 10 0" Text="{DynamicResource woxHotkey}" />
<wox:HotkeyControl x:Name="ctlHotkey" />
<wox:HotkeyControl x:Name="HotkeyControl" />
</StackPanel>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
@ -259,7 +254,7 @@
</Grid.RowDefinitions>
<TextBlock VerticalAlignment="Center" Grid.Row="0" Margin="0 0 10 0"
Text="{DynamicResource customQueryHotkey}" />
<ListView x:Name="lvCustomHotkey" Margin="0 5 0 0" Grid.Row="1">
<ListView x:Name="CustomHotkies" Margin="0 5 0 0" Grid.Row="1">
<ListView.View>
<GridView>
<GridViewColumn Header="{DynamicResource hotkey}" Width="180">
@ -282,11 +277,11 @@
</Grid>
<StackPanel Grid.Row="2" HorizontalAlignment="Right" Orientation="Horizontal">
<Button x:Name="btnDeleteCustomHotkey" Click="BtnDeleteCustomHotkey_OnClick" Width="100"
<Button Click="BtnDeleteCustomHotkey_OnClick" Width="100"
Margin="10" Content="{DynamicResource delete}" />
<Button x:Name="btnEditCustomHotkey" Click="BtnEditCustomHotkey_OnClick" Width="100" Margin="10"
<Button Click="BtnEditCustomHotkey_OnClick" Width="100" Margin="10"
Content="{DynamicResource edit}" />
<Button x:Name="btnAddCustomeHotkey" Click="BtnAddCustomeHotkey_OnClick" Width="100" Margin="10"
<Button Click="BtnAddCustomeHotkey_OnClick" Width="100" Margin="10"
Content="{DynamicResource add}" />
</StackPanel>
</Grid>
@ -311,30 +306,30 @@
<TextBlock Text="{DynamicResource server}" />
</Border>
<Border Grid.Row="0" Grid.Column="1" Padding="5">
<TextBox Width="200" HorizontalAlignment="Left" x:Name="tbProxyServer" />
<TextBox Width="200" HorizontalAlignment="Left" x:Name="ProxyServer" />
</Border>
<Border Grid.Row="0" Grid.Column="2" Padding="5">
<TextBlock Text="{DynamicResource port}" />
</Border>
<Border Grid.Row="0" Grid.Column="3" Padding="5">
<TextBox Width="50" HorizontalAlignment="Left" x:Name="tbProxyPort" />
<TextBox Width="50" HorizontalAlignment="Left" x:Name="ProxyPort" />
</Border>
<Border Grid.Row="1" Grid.Column="0" Padding="5">
<TextBlock Text="{DynamicResource userName}" />
</Border>
<Border Grid.Row="1" Grid.Column="1" Padding="5">
<TextBox Width="200" HorizontalAlignment="Left" x:Name="tbProxyUserName" />
<TextBox Width="200" HorizontalAlignment="Left" x:Name="ProxyUserName" />
</Border>
<Border Grid.Row="1" Grid.Column="2" Padding="5">
<TextBlock Text="{DynamicResource password}" />
</Border>
<Border Grid.Row="1" Grid.Column="3" Padding="5">
<PasswordBox Width="200" HorizontalAlignment="Left" x:Name="tbProxyPassword" />
<PasswordBox Width="200" HorizontalAlignment="Left" x:Name="ProxyPassword" />
</Border>
</Grid>
<StackPanel Orientation="Horizontal" IsEnabled="{Binding IsChecked, ElementName=ToggleProxy}">
<Button x:Name="btnTestProxy" Width="80" HorizontalAlignment="Left" Margin="10" Click="btnTestProxy_Click" Content="{DynamicResource testProxy}"/>
<Button x:Name="btnSaveProxy" Width="80" HorizontalAlignment="Left" Margin="10" Click="btnSaveProxy_Click" Content="{DynamicResource save}"/>
<Button Width="80" HorizontalAlignment="Left" Margin="10" Click="btnTestProxy_Click" Content="{DynamicResource testProxy}"/>
<Button Width="80" HorizontalAlignment="Left" Margin="10" Click="btnSaveProxy_Click" Content="{DynamicResource save}"/>
</StackPanel>
</StackPanel>
</TabItem>
@ -369,7 +364,7 @@
<TextBlock Grid.Column="0" Grid.Row="2" Text="{DynamicResource version}" />
<TextBlock Grid.Column="1" Grid.Row="2" HorizontalAlignment="Left" x:Name="tbVersion" Text="1.0.0" />
<TextBlock Grid.Column="1" Grid.Row="2" HorizontalAlignment="Left" x:Name="Version" Text="1.0.0" />
<TextBlock Grid.Column="0" Grid.Row="3" Text="{DynamicResource releaseNotes}"></TextBlock>
<TextBlock Grid.Column="1" Grid.Row="3" HorizontalAlignment="Left" >
@ -378,8 +373,7 @@
</Hyperlink>
</TextBlock>
<Button Grid.Column="0" Grid.Row="4" Content="{DynamicResource checkUpdates}" HorizontalAlignment="Left" Margin="10 10 10 10"
Click="OnCheckUpdates"/>
<Button Grid.Column="0" Grid.Row="4" Content="{DynamicResource checkUpdates}" HorizontalAlignment="Left" Margin="10 10 10 10" Click="OnCheckUpdates"/>
<TextBlock Grid.Column="1" Grid.Row="4" Name="NewVersionTips" HorizontalAlignment="Left" Text="{DynamicResource newVersionTips}" Visibility="Hidden"/>
</Grid>

View File

@ -55,88 +55,77 @@ namespace Wox
{
#region General
cbHideOnStartup.Checked += (o, e) =>
HideOnStartup.Checked += (o, e) =>
{
_settings.HideOnStartup = true;
};
cbHideOnStartup.Unchecked += (o, e) =>
HideOnStartup.Unchecked += (o, e) =>
{
_settings.HideOnStartup = false;
};
cbHideWhenDeactive.Checked += (o, e) =>
HideWhenDeactive.Checked += (o, e) =>
{
_settings.HideWhenDeactive = true;
};
cbHideWhenDeactive.Unchecked += (o, e) =>
HideWhenDeactive.Unchecked += (o, e) =>
{
_settings.HideWhenDeactive = false;
};
cbRememberLastLocation.Checked += (o, e) =>
RememberLastLocation.Checked += (o, e) =>
{
_settings.RememberLastLaunchLocation = true;
};
cbRememberLastLocation.Unchecked += (o, e) =>
RememberLastLocation.Unchecked += (o, e) =>
{
_settings.RememberLastLaunchLocation = false;
};
cbDontPromptUpdateMsg.Checked += (o, e) =>
{
_settings.DontPromptUpdateMsg = true;
};
cbDontPromptUpdateMsg.Unchecked += (o, e) =>
{
_settings.DontPromptUpdateMsg = false;
};
cbIgnoreHotkeysOnFullscreen.Checked += (o, e) =>
IgnoreHotkeysOnFullscreen.Checked += (o, e) =>
{
_settings.IgnoreHotkeysOnFullscreen = true;
};
cbIgnoreHotkeysOnFullscreen.Unchecked += (o, e) =>
IgnoreHotkeysOnFullscreen.Unchecked += (o, e) =>
{
_settings.IgnoreHotkeysOnFullscreen = false;
};
AutoUpdatesCheckBox.Checked += (o, e) =>
AutoUpdates.Checked += (o, e) =>
{
_settings.AutoUpdates = true;
};
AutoUpdatesCheckBox.Unchecked += (o, e) =>
AutoUpdates.Unchecked += (o, e) =>
{
_settings.AutoUpdates = false;
};
cbStartWithWindows.IsChecked = _settings.StartWoxOnSystemStartup;
comboMaxResultsToShow.SelectionChanged += (o, e) =>
AutoStartup.IsChecked = _settings.StartWoxOnSystemStartup;
MaxResults.SelectionChanged += (o, e) =>
{
_settings.MaxResultsToShow = (int)comboMaxResultsToShow.SelectedItem;
_settings.MaxResultsToShow = (int)MaxResults.SelectedItem;
//MainWindow.pnlResult.lbResults.GetBindingExpression(MaxHeightProperty).UpdateTarget();
};
cbHideOnStartup.IsChecked = _settings.HideOnStartup;
cbHideWhenDeactive.IsChecked = _settings.HideWhenDeactive;
cbDontPromptUpdateMsg.IsChecked = _settings.DontPromptUpdateMsg;
cbRememberLastLocation.IsChecked = _settings.RememberLastLaunchLocation;
cbIgnoreHotkeysOnFullscreen.IsChecked = _settings.IgnoreHotkeysOnFullscreen;
AutoUpdatesCheckBox.IsChecked = _settings.AutoUpdates;
HideOnStartup.IsChecked = _settings.HideOnStartup;
HideWhenDeactive.IsChecked = _settings.HideWhenDeactive;
RememberLastLocation.IsChecked = _settings.RememberLastLaunchLocation;
IgnoreHotkeysOnFullscreen.IsChecked = _settings.IgnoreHotkeysOnFullscreen;
AutoUpdates.IsChecked = _settings.AutoUpdates;
LoadLanguages();
comboMaxResultsToShow.ItemsSource = Enumerable.Range(2, 16);
MaxResults.ItemsSource = Enumerable.Range(2, 16);
var maxResults = _settings.MaxResultsToShow;
comboMaxResultsToShow.SelectedItem = maxResults == 0 ? 6 : maxResults;
MaxResults.SelectedItem = maxResults == 0 ? 6 : maxResults;
PythonDirectory.Text = _settings.PluginSettings.PythonDirectory;
@ -145,13 +134,13 @@ namespace Wox
#region Proxy
ToggleProxy.IsChecked = _settings.ProxyEnabled;
tbProxyServer.Text = _settings.ProxyServer;
ProxyServer.Text = _settings.ProxyServer;
if (_settings.ProxyPort != 0)
{
tbProxyPort.Text = _settings.ProxyPort.ToString();
ProxyPort.Text = _settings.ProxyPort.ToString();
}
tbProxyUserName.Text = _settings.ProxyUserName;
tbProxyPassword.Password = _settings.ProxyPassword;
ProxyUserName.Text = _settings.ProxyUserName;
ProxyPassword.Password = _settings.ProxyPassword;
#endregion
@ -160,7 +149,7 @@ namespace Wox
string activateTimes = string.Format(
InternationalizationManager.Instance.GetTranslation("about_activate_times"), _settings.ActivateTimes);
ActivatedTimes.Text = activateTimes;
tbVersion.Text = Infrastructure.Constant.Version;
Version.Text = Infrastructure.Constant.Version;
#endregion
@ -172,22 +161,22 @@ namespace Wox
switch (tabName)
{
case "general":
settingTab.SelectedIndex = 0;
SettingTab.SelectedIndex = 0;
break;
case "plugin":
settingTab.SelectedIndex = 1;
SettingTab.SelectedIndex = 1;
break;
case "theme":
settingTab.SelectedIndex = 2;
SettingTab.SelectedIndex = 2;
break;
case "hotkey":
settingTab.SelectedIndex = 3;
SettingTab.SelectedIndex = 3;
break;
case "proxy":
settingTab.SelectedIndex = 4;
SettingTab.SelectedIndex = 4;
break;
case "about":
settingTab.SelectedIndex = 5;
SettingTab.SelectedIndex = 5;
break;
}
}
@ -195,17 +184,17 @@ namespace Wox
private void settingTab_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
// Update controls inside the selected tab
if (e.OriginalSource != settingTab) return;
if (e.OriginalSource != SettingTab) return;
if (tabPlugin.IsSelected)
if (PluginTab.IsSelected)
{
OnPluginTabSelected();
}
else if (tabTheme.IsSelected)
else if (ThemeTab.IsSelected)
{
OnThemeTabSelected();
}
else if (tabHotkey.IsSelected)
else if (HotkeyTab.IsSelected)
{
OnHotkeyTabSelected();
}
@ -215,16 +204,16 @@ namespace Wox
private void LoadLanguages()
{
cbLanguages.ItemsSource = InternationalizationManager.Instance.LoadAvailableLanguages();
cbLanguages.DisplayMemberPath = "Display";
cbLanguages.SelectedValuePath = "LanguageCode";
cbLanguages.SelectedValue = _settings.Language;
cbLanguages.SelectionChanged += cbLanguages_SelectionChanged;
Languages.ItemsSource = InternationalizationManager.Instance.LoadAvailableLanguages();
Languages.DisplayMemberPath = "Display";
Languages.SelectedValuePath = "LanguageCode";
Languages.SelectedValue = _settings.Language;
Languages.SelectionChanged += cbLanguages_SelectionChanged;
}
void cbLanguages_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
InternationalizationManager.Instance.ChangeLanguage(cbLanguages.SelectedItem as Language);
InternationalizationManager.Instance.ChangeLanguage(Languages.SelectedItem as Language);
}
private void CbStartWithWindows_OnChecked(object sender, RoutedEventArgs e)
@ -305,9 +294,9 @@ namespace Wox
void ctlHotkey_OnHotkeyChanged(object sender, EventArgs e)
{
if (ctlHotkey.CurrentHotkeyAvailable)
if (HotkeyControl.CurrentHotkeyAvailable)
{
SetHotkey(ctlHotkey.CurrentHotkey, delegate
SetHotkey(HotkeyControl.CurrentHotkey, delegate
{
if (!System.Windows.Application.Current.MainWindow.IsVisible)
{
@ -319,7 +308,7 @@ namespace Wox
}
});
RemoveHotkey(_settings.Hotkey);
_settings.Hotkey = ctlHotkey.CurrentHotkey.ToString();
_settings.Hotkey = HotkeyControl.CurrentHotkey.ToString();
}
}
@ -348,14 +337,14 @@ namespace Wox
private void OnHotkeyTabSelected()
{
ctlHotkey.HotkeyChanged += ctlHotkey_OnHotkeyChanged;
ctlHotkey.SetHotkey(_settings.Hotkey, false);
lvCustomHotkey.ItemsSource = _settings.CustomPluginHotkeys;
HotkeyControl.HotkeyChanged += ctlHotkey_OnHotkeyChanged;
HotkeyControl.SetHotkey(_settings.Hotkey, false);
CustomHotkies.ItemsSource = _settings.CustomPluginHotkeys;
}
private void BtnDeleteCustomHotkey_OnClick(object sender, RoutedEventArgs e)
{
CustomPluginHotkey item = lvCustomHotkey.SelectedItem as CustomPluginHotkey;
CustomPluginHotkey item = CustomHotkies.SelectedItem as CustomPluginHotkey;
if (item == null)
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem"));
@ -370,14 +359,14 @@ namespace Wox
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
{
_settings.CustomPluginHotkeys.Remove(item);
lvCustomHotkey.Items.Refresh();
CustomHotkies.Items.Refresh();
RemoveHotkey(item.Hotkey);
}
}
private void BtnEditCustomHotkey_OnClick(object sender, RoutedEventArgs e)
{
CustomPluginHotkey item = lvCustomHotkey.SelectedItem as CustomPluginHotkey;
CustomPluginHotkey item = CustomHotkies.SelectedItem as CustomPluginHotkey;
if (item != null)
{
CustomQueryHotkeySetting window = new CustomQueryHotkeySetting(this, _settings);
@ -397,7 +386,7 @@ namespace Wox
public void ReloadCustomPluginHotkeyView()
{
lvCustomHotkey.Items.Refresh();
CustomHotkies.Items.Refresh();
}
#endregion
@ -422,11 +411,11 @@ namespace Wox
if (!string.IsNullOrEmpty(_settings.QueryBoxFont) &&
Fonts.SystemFontFamilies.Count(o => o.FamilyNames.Values.Contains(_settings.QueryBoxFont)) > 0)
{
cbQueryBoxFont.Text = _settings.QueryBoxFont;
QueryBoxFont.Text = _settings.QueryBoxFont;
cbQueryBoxFontFaces.SelectedItem =
QueryBoxFontFaces.SelectedItem =
SyntaxSugars.CallOrRescueDefault(
() => ((FontFamily)cbQueryBoxFont.SelectedItem).ConvertFromInvariantStringsOrNormal(
() => ((FontFamily)QueryBoxFont.SelectedItem).ConvertFromInvariantStringsOrNormal(
_settings.QueryBoxFontStyle,
_settings.QueryBoxFontWeight,
_settings.QueryBoxFontStretch
@ -501,10 +490,10 @@ namespace Wox
foreach (string theme in ThemeManager.Instance.LoadAvailableThemes())
{
string themeName = Path.GetFileNameWithoutExtension(theme);
themeComboBox.Items.Add(themeName);
Theme.Items.Add(themeName);
}
themeComboBox.SelectedItem = _settings.Theme;
Theme.SelectedItem = _settings.Theme;
var wallpaper = WallpaperPathRetrieval.GetWallpaperPath();
if (wallpaper != null && File.Exists(wallpaper))
@ -528,27 +517,27 @@ namespace Wox
private void ThemeComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
string themeName = themeComboBox.SelectedItem.ToString();
string themeName = Theme.SelectedItem.ToString();
ThemeManager.Instance.ChangeTheme(themeName);
}
private void CbQueryBoxFont_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (!settingsLoaded) return;
string queryBoxFontName = cbQueryBoxFont.SelectedItem.ToString();
string queryBoxFontName = QueryBoxFont.SelectedItem.ToString();
_settings.QueryBoxFont = queryBoxFontName;
cbQueryBoxFontFaces.SelectedItem = ((FontFamily)cbQueryBoxFont.SelectedItem).ChooseRegularFamilyTypeface();
QueryBoxFontFaces.SelectedItem = ((FontFamily)QueryBoxFont.SelectedItem).ChooseRegularFamilyTypeface();
ThemeManager.Instance.ChangeTheme(_settings.Theme);
}
private void CbQueryBoxFontFaces_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (!settingsLoaded) return;
FamilyTypeface typeface = (FamilyTypeface)cbQueryBoxFontFaces.SelectedItem;
FamilyTypeface typeface = (FamilyTypeface)QueryBoxFontFaces.SelectedItem;
if (typeface == null)
{
if (cbQueryBoxFontFaces.Items.Count > 0)
cbQueryBoxFontFaces.SelectedIndex = 0;
if (QueryBoxFontFaces.Items.Count > 0)
QueryBoxFontFaces.SelectedIndex = 0;
}
else
{
@ -599,34 +588,34 @@ namespace Wox
List<string> actionKeywords = null;
if (pair == null) return;
actionKeywords = pair.Metadata.ActionKeywords;
pluginAuthor.Visibility = Visibility.Visible;
pluginInitTime.Text =
PluginAuthor.Visibility = Visibility.Visible;
PluginInitTime.Text =
string.Format(InternationalizationManager.Instance.GetTranslation("plugin_init_time"), pair.InitTime);
pluginQueryTime.Text =
PluginQueryTime.Text =
string.Format(InternationalizationManager.Instance.GetTranslation("plugin_query_time"),
pair.AvgQueryTime);
if (actionKeywords.Count > 1)
{
pluginActionKeywordsTitle.Visibility = Visibility.Collapsed;
pluginActionKeywords.Visibility = Visibility.Collapsed;
PluginActionKeywordsTitle.Visibility = Visibility.Collapsed;
PluginActionKeywords.Visibility = Visibility.Collapsed;
}
else
{
pluginActionKeywordsTitle.Visibility = Visibility.Visible;
pluginActionKeywords.Visibility = Visibility.Visible;
PluginActionKeywordsTitle.Visibility = Visibility.Visible;
PluginActionKeywords.Visibility = Visibility.Visible;
}
tbOpenPluginDirecoty.Visibility = Visibility.Visible;
pluginTitle.Text = pair.Metadata.Name;
pluginTitle.Cursor = Cursors.Hand;
pluginActionKeywords.Text = string.Join(Query.ActionKeywordSeperater, actionKeywords.ToArray());
pluginAuthor.Text = InternationalizationManager.Instance.GetTranslation("author") + ": " +
OpenPluginDirecoty.Visibility = Visibility.Visible;
PluginTitle.Text = pair.Metadata.Name;
PluginTitle.Cursor = Cursors.Hand;
PluginActionKeywords.Text = string.Join(Query.ActionKeywordSeperater, actionKeywords.ToArray());
PluginAuthor.Text = InternationalizationManager.Instance.GetTranslation("author") + ": " +
pair.Metadata.Author;
pluginSubTitle.Text = pair.Metadata.Description;
PluginSubTitle.Text = pair.Metadata.Description;
pluginId = pair.Metadata.ID;
pluginIcon.Source = ImageLoader.Load(pair.Metadata.IcoPath);
PluginIcon.Source = ImageLoader.Load(pair.Metadata.IcoPath);
var customizedPluginConfig = _settings.PluginSettings.Plugins[pluginId];
cbDisablePlugin.IsChecked = customizedPluginConfig != null && customizedPluginConfig.Disabled;
DisablePlugin.IsChecked = customizedPluginConfig != null && customizedPluginConfig.Disabled;
PluginContentPanel.Content = null;
var settingProvider = pair.Plugin as ISettingProvider;
@ -688,7 +677,7 @@ namespace Wox
changeKeywordsWindow.ShowDialog();
PluginPair plugin = PluginManager.GetPluginForId(id);
if (plugin != null)
pluginActionKeywords.Text = string.Join(Query.ActionKeywordSeperater,
PluginActionKeywords.Text = string.Join(Query.ActionKeywordSeperater,
pair.Metadata.ActionKeywords.ToArray());
}
}
@ -775,45 +764,45 @@ namespace Wox
int port = 80;
if (_settings.ProxyEnabled)
{
if (string.IsNullOrEmpty(tbProxyServer.Text))
if (string.IsNullOrEmpty(ProxyServer.Text))
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("serverCantBeEmpty"));
return;
}
if (string.IsNullOrEmpty(tbProxyPort.Text))
if (string.IsNullOrEmpty(ProxyPort.Text))
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("portCantBeEmpty"));
return;
}
if (!int.TryParse(tbProxyPort.Text, out port))
if (!int.TryParse(ProxyPort.Text, out port))
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("invalidPortFormat"));
return;
}
}
_settings.ProxyServer = tbProxyServer.Text;
_settings.ProxyServer = ProxyServer.Text;
_settings.ProxyPort = port;
_settings.ProxyUserName = tbProxyUserName.Text;
_settings.ProxyPassword = tbProxyPassword.Password;
_settings.ProxyUserName = ProxyUserName.Text;
_settings.ProxyPassword = ProxyPassword.Password;
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("saveProxySuccessfully"));
}
private void btnTestProxy_Click(object sender, RoutedEventArgs e)
{
if (string.IsNullOrEmpty(tbProxyServer.Text))
if (string.IsNullOrEmpty(ProxyServer.Text))
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("serverCantBeEmpty"));
return;
}
if (string.IsNullOrEmpty(tbProxyPort.Text))
if (string.IsNullOrEmpty(ProxyPort.Text))
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("portCantBeEmpty"));
return;
}
int port;
if (!int.TryParse(tbProxyPort.Text, out port))
if (!int.TryParse(ProxyPort.Text, out port))
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("invalidPortFormat"));
return;
@ -822,14 +811,14 @@ namespace Wox
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.baidu.com");
request.Timeout = 1000 * 5;
request.ReadWriteTimeout = 1000 * 5;
if (string.IsNullOrEmpty(tbProxyUserName.Text))
if (string.IsNullOrEmpty(ProxyUserName.Text))
{
request.Proxy = new WebProxy(tbProxyServer.Text, port);
request.Proxy = new WebProxy(ProxyServer.Text, port);
}
else
{
request.Proxy = new WebProxy(tbProxyServer.Text, port);
request.Proxy.Credentials = new NetworkCredential(tbProxyUserName.Text, tbProxyPassword.Password);
request.Proxy = new WebProxy(ProxyServer.Text, port);
request.Proxy.Credentials = new NetworkCredential(ProxyUserName.Text, ProxyPassword.Password);
}
try
{
@ -854,7 +843,7 @@ namespace Wox
private void Window_PreviewKeyDown(object sender, KeyEventArgs e)
{
// Hide window with ESC, but make sure it is not pressed as a hotkey
if (e.Key == Key.Escape && !ctlHotkey.IsFocused)
if (e.Key == Key.Escape && !HotkeyControl.IsFocused)
{
Close();
}