Removed setting UI XAML file and references

This commit is contained in:
Divyansh 2020-03-23 14:37:43 -07:00
parent 6414fe8cf8
commit 7c174b9c05
9 changed files with 0 additions and 907 deletions

View File

@ -83,11 +83,6 @@ namespace Wox.Plugin
/// <param name="iconPath">Message icon path (relative path to your plugin folder)</param>
void ShowMsg(string title, string subTitle = "", string iconPath = "", bool useMainWindowAsOwner = true);
/// <summary>
/// Open setting dialog
/// </summary>
void OpenSettingDialog();
/// <summary>
/// Show loading animation
/// </summary>

View File

@ -94,13 +94,6 @@ namespace Wox
private void AutoStartup()
{
if (_settings.StartWoxOnSystemStartup)
{
if (!SettingWindow.StartupSet())
{
SettingWindow.SetStartup();
}
}
}
//[Conditional("RELEASE")]

View File

@ -1,39 +0,0 @@
<Window x:Class="Wox.CustomQueryHotkeySetting"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wox="clr-namespace:Wox"
Icon="Images\app.png"
ResizeMode="NoResize"
WindowStartupLocation="CenterScreen"
Title="Custom Plugin Hotkey" Height="200" Width="674.766">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock Margin="10" FontSize="14" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center"
HorizontalAlignment="Right" Text="{DynamicResource hotkey}" />
<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" Text="{DynamicResource actionKeyword}" />
<StackPanel Grid.Row="1" Orientation="Horizontal" Grid.Column="1">
<TextBox x:Name="tbAction" Margin="10" Width="400" VerticalAlignment="Center" HorizontalAlignment="Left" />
<Button x:Name="btnTestActionKeyword" Padding="10 5 10 5" Height="30" Click="BtnTestActionKeyword_OnClick"
Content="{DynamicResource preview}" />
</StackPanel>
<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"
Content="{DynamicResource cancel}" />
<Button x:Name="btnAdd" Margin="10 0 10 0" Width="80" Height="25" Click="btnAdd_OnClick">
<TextBlock x:Name="lblAdd" Text="{DynamicResource done}" />
</Button>
</StackPanel>
</Grid>
</Window>

View File

@ -1,129 +0,0 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
using NHotkey;
using NHotkey.Wpf;
using Wox.Core.Resource;
using Wox.Infrastructure.Hotkey;
using Wox.Infrastructure.UserSettings;
namespace Wox
{
public partial class CustomQueryHotkeySetting : Window
{
private SettingWindow _settingWidow;
private bool update;
private CustomPluginHotkey updateCustomHotkey;
private Settings _settings;
public CustomQueryHotkeySetting(SettingWindow settingWidow, Settings settings)
{
_settingWidow = settingWidow;
InitializeComponent();
_settings = settings;
}
private void BtnCancel_OnClick(object sender, RoutedEventArgs e)
{
Close();
}
private void btnAdd_OnClick(object sender, RoutedEventArgs e)
{
if (!update)
{
if (!ctlHotkey.CurrentHotkeyAvailable)
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("hotkeyIsNotUnavailable"));
return;
}
if (_settings.CustomPluginHotkeys == null)
{
_settings.CustomPluginHotkeys = new ObservableCollection<CustomPluginHotkey>();
}
var pluginHotkey = new CustomPluginHotkey
{
Hotkey = ctlHotkey.CurrentHotkey.ToString(),
ActionKeyword = tbAction.Text
};
_settings.CustomPluginHotkeys.Add(pluginHotkey);
SetHotkey(ctlHotkey.CurrentHotkey, delegate
{
App.API.ChangeQuery(pluginHotkey.ActionKeyword);
Application.Current.MainWindow.Visibility = Visibility.Visible;
});
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("success"));
}
else
{
if (updateCustomHotkey.Hotkey != ctlHotkey.CurrentHotkey.ToString() && !ctlHotkey.CurrentHotkeyAvailable)
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("hotkeyIsNotUnavailable"));
return;
}
var oldHotkey = updateCustomHotkey.Hotkey;
updateCustomHotkey.ActionKeyword = tbAction.Text;
updateCustomHotkey.Hotkey = ctlHotkey.CurrentHotkey.ToString();
//remove origin hotkey
RemoveHotkey(oldHotkey);
SetHotkey(new HotkeyModel(updateCustomHotkey.Hotkey), delegate
{
App.API.ChangeQuery(updateCustomHotkey.ActionKeyword);
Application.Current.MainWindow.Visibility = Visibility.Visible;
});
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("success"));
}
Close();
}
public void UpdateItem(CustomPluginHotkey item)
{
updateCustomHotkey = _settings.CustomPluginHotkeys.FirstOrDefault(o => o.ActionKeyword == item.ActionKeyword && o.Hotkey == item.Hotkey);
if (updateCustomHotkey == null)
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("invalidPluginHotkey"));
Close();
return;
}
tbAction.Text = updateCustomHotkey.ActionKeyword;
ctlHotkey.SetHotkey(updateCustomHotkey.Hotkey, false);
update = true;
lblAdd.Text = InternationalizationManager.Instance.GetTranslation("update");
}
private void BtnTestActionKeyword_OnClick(object sender, RoutedEventArgs e)
{
App.API.ChangeQuery(tbAction.Text);
Application.Current.MainWindow.Visibility = Visibility.Visible;
}
private void RemoveHotkey(string hotkeyStr)
{
if (!string.IsNullOrEmpty(hotkeyStr))
{
HotkeyManager.Current.Remove(hotkeyStr);
}
}
private void SetHotkey(HotkeyModel hotkey, EventHandler<HotkeyEventArgs> action)
{
string hotkeyStr = hotkey.ToString();
try
{
HotkeyManager.Current.AddOrReplace(hotkeyStr, hotkey.CharKey, hotkey.ModifierKeys, action);
}
catch (Exception)
{
string errorMsg = string.Format(InternationalizationManager.Instance.GetTranslation("registerHotkeyFailed"), hotkeyStr);
MessageBox.Show(errorMsg);
}
}
}
}

View File

@ -16,7 +16,6 @@ using DataFormats = System.Windows.DataFormats;
using DragEventArgs = System.Windows.DragEventArgs;
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
using MessageBox = System.Windows.MessageBox;
using NotifyIcon = System.Windows.Forms.NotifyIcon;
namespace Wox
{
@ -48,10 +47,6 @@ namespace Wox
_viewModel.Save();
}
private void OnInitialized(object sender, EventArgs e)
{
}
private void OnLoaded(object sender, RoutedEventArgs _)
{
// todo is there a way to set blur only once?
@ -156,11 +151,6 @@ namespace Wox
e.Handled = true;
}
private void OnContextMenusForSettingsClick(object sender, RoutedEventArgs e)
{
App.API.OpenSettingDialog();
}
private void OnDeactivated(object sender, EventArgs e)
{

View File

@ -106,14 +106,6 @@ namespace Wox
});
}
public void OpenSettingDialog()
{
Application.Current.Dispatcher.Invoke(() =>
{
SettingWindow sw = SingletonWindowOpener.Open<SettingWindow>(this, _settingsVM);
});
}
public void StartLoadingBar()
{
_mainVM.ProgressBarVisibility = Visibility.Visible;

View File

@ -1,402 +0,0 @@
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:wox="clr-namespace:Wox"
xmlns:vm="clr-namespace:Wox.ViewModel"
xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
xmlns:userSettings="clr-namespace:Wox.Infrastructure.UserSettings;assembly=Wox.Infrastructure"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
x:Class="Wox.SettingWindow"
mc:Ignorable="d"
Icon="Images\app.png"
Title="{DynamicResource wox_settings}"
ResizeMode="NoResize"
WindowStartupLocation="CenterScreen"
Height="600" Width="800"
Closed="OnClosed"
d:DataContext="{d:DesignInstance vm:SettingWindowViewModel}">
<Window.InputBindings>
<KeyBinding Key="Escape" Command="Close"/>
</Window.InputBindings>
<Window.CommandBindings>
<CommandBinding Command="Close" Executed="OnCloseExecuted"/>
</Window.CommandBindings>
<Window.Resources>
<CollectionViewSource Source="{Binding Source={x:Static Fonts.SystemFontFamilies}}" x:Key="SortedFonts">
<CollectionViewSource.SortDescriptions>
<scm:SortDescription PropertyName="Source"/>
</CollectionViewSource.SortDescriptions>
</CollectionViewSource>
</Window.Resources>
<TabControl Height="auto" SelectedIndex="0">
<TabItem Header="{DynamicResource general}">
<StackPanel Orientation="Vertical">
<CheckBox Margin="10" IsChecked="{Binding Settings.StartWoxOnSystemStartup}"
Checked="OnAutoStartupChecked" Unchecked="OnAutoStartupUncheck">
<TextBlock Text="{DynamicResource startWoxOnSystemStartup}" />
</CheckBox>
<CheckBox Margin="10" IsChecked="{Binding Settings.HideOnStartup}">
<TextBlock Text="{DynamicResource hideOnStartup}" />
</CheckBox>
<CheckBox Margin="10" IsChecked="{Binding Settings.HideWhenDeactive}">
<TextBlock Text="{DynamicResource hideWoxWhenLoseFocus}" />
</CheckBox>
<CheckBox Margin="10" IsChecked="{Binding Settings.HideNotifyIcon}">
<TextBlock Text="{DynamicResource hideNotifyIcon}" />
</CheckBox>
<CheckBox Margin="10" IsChecked="{Binding Settings.RememberLastLaunchLocation}">
<TextBlock Text="{DynamicResource rememberLastLocation}" />
</CheckBox>
<CheckBox Margin="10" IsChecked="{Binding Settings.IgnoreHotkeysOnFullscreen}">
<TextBlock Text="{DynamicResource ignoreHotkeysOnFullscreen}" />
</CheckBox>
<CheckBox Margin="10" IsChecked="{Binding Settings.AutoUpdates}">
<TextBlock Text="{DynamicResource autoUpdates}" />
</CheckBox>
<CheckBox Margin="10" IsChecked="{Binding Settings.ShouldUsePinyin}">
<TextBlock Text="{DynamicResource ShouldUsePinyin}" />
</CheckBox>
<StackPanel Margin="10" Orientation="Horizontal">
<TextBlock Text="{DynamicResource querySearchPrecision}" />
<ComboBox Margin="10 0 0 0" Width="120"
ItemsSource="{Binding QuerySearchPrecisionStrings}"
SelectedItem="{Binding Settings.QuerySearchPrecisionString}" />
</StackPanel>
<StackPanel Margin="10" Orientation="Horizontal">
<TextBlock Text="{DynamicResource lastQueryMode}" />
<ComboBox Margin="10 0 0 0" Width="120"
ItemsSource="{Binding LastQueryModes}" SelectedValue="{Binding Settings.LastQueryMode}"
DisplayMemberPath="Display" SelectedValuePath="Value" />
</StackPanel>
<StackPanel Margin="10" Orientation="Horizontal">
<TextBlock Text="{DynamicResource language}" />
<ComboBox Margin="10 0 0 0" Width="120" SelectionChanged="OnLanguageChanged"
ItemsSource="{Binding Languages}" SelectedValue="{Binding Settings.Language}"
DisplayMemberPath="Display" SelectedValuePath="LanguageCode" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="10">
<TextBlock Text="{DynamicResource maxShowResults}" />
<ComboBox Margin="10 0 0 0" Width="45" ItemsSource="{Binding MaxResultsRange}"
SelectedItem="{Binding Settings.MaxResultsToShow}" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Margin="10" Text="{DynamicResource pythonDirectory}" />
<TextBox Width="300" Margin="10" Text="{Binding Settings.PluginSettings.PythonDirectory}" />
<Button Margin="10" Click="OnSelectPythonDirectoryClick"
Content="{DynamicResource selectPythonDirectory}" />
</StackPanel>
</StackPanel>
</TabItem>
<TabItem Header="{DynamicResource plugin}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<DockPanel Grid.Column="0">
<TextBlock DockPanel.Dock="Top" Margin="10">
<Hyperlink NavigateUri="{Binding Plugin, Mode=OneWay}" RequestNavigate="OnRequestNavigate">
<Run Text="{DynamicResource browserMorePlugins}" />
</Hyperlink>
</TextBlock>
<ListBox SelectedIndex="0" SelectedItem="{Binding SelectedPlugin}"
ItemsSource="{Binding PluginViewModels}"
Margin="10, 0, 10, 10" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="3">
<Image Source="{Binding Image, IsAsync=True}"
Width="32" Height="32" />
<StackPanel Margin="3 0 3 0">
<TextBlock Text="{Binding PluginPair.Metadata.Name}"
ToolTip="{Binding PluginPair.Metadata.Name}" />
<TextBlock Text="{Binding PluginPair.Metadata.Description}"
ToolTip="{Binding PluginPair.Metadata.Description}"
Opacity="0.5" />
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</DockPanel>
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<ContentControl DataContext="{Binding Path=SelectedPlugin}"
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 Source="{Binding Image, IsAsync=True}"
Width="48" Height="48" HorizontalAlignment="Left" VerticalAlignment="Top" />
<Grid Margin="10,0,0,0" Grid.Column="1" HorizontalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding PluginPair.Metadata.Name}"
ToolTip="{Binding PluginPair.Metadata.Name}"
Grid.Column="0"
Cursor="Hand" MouseUp="OnPluginNameClick" FontSize="24"
HorizontalAlignment="Left" />
<StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right"
VerticalAlignment="Bottom" Opacity="0.5">
<TextBlock Text="{DynamicResource author}" />
<TextBlock Text=": " />
<TextBlock Text="{Binding PluginPair.Metadata.Author}" ToolTip="{Binding PluginPair.Metadata.Author}" />
</StackPanel>
</Grid>
<TextBlock Text="{Binding PluginPair.Metadata.Description}"
ToolTip="{Binding PluginPair.Metadata.Description}"
Grid.Row="1" Opacity="0.5" />
<DockPanel Grid.Row="2" Margin="0 10 0 8">
<CheckBox IsChecked="{Binding PluginPair.Metadata.Disabled}" Checked="OnPluginToggled"
Unchecked="OnPluginToggled">
<TextBlock Text="{DynamicResource disable}" />
</CheckBox>
<TextBlock Text="{DynamicResource actionKeywords}"
Visibility="{Binding ActionKeywordsVisibility}"
Margin="20 0 0 0" />
<TextBlock Text="{Binding ActionKeywordsText}"
Visibility="{Binding ActionKeywordsVisibility}"
ToolTip="Change Action Keywords"
Margin="5 0 0 0" Cursor="Hand" Foreground="Blue"
MouseUp="OnPluginActionKeywordsClick" />
<TextBlock Text="{Binding InitilizaTime}" Margin="10 0 0 0" />
<TextBlock Text="{Binding QueryTime}" Margin="10 0 0 0" />
<TextBlock Text="{DynamicResource pluginDirectory}"
HorizontalAlignment="Right" Cursor="Hand"
MouseUp="OnPluginDirecotyClick" Foreground="Blue" />
</DockPanel>
</Grid>
</Grid>
</ContentControl>
<ContentControl Content="{Binding SettingProvider}"
Grid.ColumnSpan="1" Grid.Row="1"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
</Grid>
</Grid>
</TabItem>
<TabItem Header="{DynamicResource theme}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<DockPanel Grid.Column="0">
<TextBlock DockPanel.Dock="Top" Margin="10" HorizontalAlignment="Left">
<Hyperlink NavigateUri="{Binding Theme, Mode=OneWay}" RequestNavigate="OnRequestNavigate">
<Run Text="{DynamicResource browserMoreThemes}" />
</Hyperlink>
</TextBlock>
<ListBox SelectedItem="{Binding SelectedTheme}" ItemsSource="{Binding Themes}"
Margin="10, 0, 10, 10" Width="180"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
</DockPanel>
<Grid Margin="0" Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="100" />
</Grid.RowDefinitions>
<StackPanel Background="{Binding PreviewBackground}" Grid.Row="0" Margin="0">
<StackPanel Orientation="Horizontal" Margin="10"
HorizontalAlignment="Center" VerticalAlignment="Center">
<Border Width="500" Style="{DynamicResource WindowBorderStyle}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition />
</Grid.RowDefinitions>
<TextBox Text="{DynamicResource helloWox}" IsReadOnly="True"
Style="{DynamicResource QueryBoxStyle}" Grid.Row="0" />
<ContentControl Visibility="Visible" Grid.Row="1">
<wox:ResultListBox DataContext="{Binding PreviewResults}" />
</ContentControl>
</Grid>
</Border>
</StackPanel>
</StackPanel>
<StackPanel Grid.Row="1" Margin="0 10 0 10" Orientation="Vertical">
<StackPanel Orientation="Horizontal" Margin="2">
<TextBlock Text="{DynamicResource queryBoxFont}" />
<ComboBox ItemsSource="{Binding Source={StaticResource SortedFonts}}"
SelectedItem="{Binding SelectedQueryBoxFont}"
HorizontalAlignment="Left" VerticalAlignment="Top" Width="160" Margin="10 -2 5 0" />
<ComboBox ItemsSource="{Binding SelectedQueryBoxFont.FamilyTypefaces}"
SelectedItem="{Binding SelectedQueryBoxFontFaces}"
HorizontalAlignment="Left" VerticalAlignment="Top"
Width="120" Margin="0 -2 0 0">
<ComboBox.ItemTemplate>
<DataTemplate>
<ItemsControl ItemsSource="{Binding AdjustedFaceNames}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Value}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="2">
<TextBlock Text="{DynamicResource resultItemFont}" />
<ComboBox ItemsSource="{Binding Source={StaticResource SortedFonts}}"
SelectedItem="{Binding SelectedResultFont}"
HorizontalAlignment="Left" VerticalAlignment="Top"
Width="160" Margin="5 -2 5 0" />
<ComboBox ItemsSource="{Binding SelectedResultFont.FamilyTypefaces}"
SelectedItem="{Binding SelectedResultFontFaces}"
HorizontalAlignment="Left" VerticalAlignment="Top"
Width="120" Margin="0 -2 0 0">
<ComboBox.ItemTemplate>
<DataTemplate>
<ItemsControl ItemsSource="{Binding AdjustedFaceNames}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Value}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</StackPanel>
</StackPanel>
</Grid>
</Grid>
</TabItem>
<TabItem Header="{DynamicResource hotkey}">
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="35" />
<RowDefinition Height="20" />
<RowDefinition Height="400" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal" VerticalAlignment="Center" Height="24"
Margin="0,4,0,3">
<TextBlock VerticalAlignment="Center" Margin="0 0 10 0" Text="{DynamicResource woxHotkey}" />
<wox:HotkeyControl x:Name="HotkeyControl" HotkeyChanged="OnHotkeyChanged"
Loaded="OnHotkeyControlLoaded" />
</StackPanel>
<TextBlock VerticalAlignment="Center" Grid.Row="1" Margin="0,3,10,2"
Text="{DynamicResource customQueryHotkey}" />
<ListView ItemsSource="{Binding Settings.CustomPluginHotkeys}"
SelectedItem="{Binding SelectedCustomPluginHotkey}"
Margin="0 5 0 0" Grid.Row="2">
<ListView.View>
<GridView>
<GridViewColumn Header="{DynamicResource hotkey}" Width="180">
<GridViewColumn.CellTemplate>
<DataTemplate DataType="userSettings:CustomPluginHotkey">
<TextBlock Text="{Binding Hotkey}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="{DynamicResource actionKeywords}" Width="500">
<GridViewColumn.CellTemplate>
<DataTemplate DataType="userSettings:CustomPluginHotkey">
<TextBlock Text="{Binding ActionKeyword}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
<StackPanel Grid.Row="3" HorizontalAlignment="Right" VerticalAlignment="Bottom"
Orientation="Horizontal" Height="40" Width="360">
<Button Click="OnDeleteCustomHotkeyClick" Width="100"
Margin="10" Content="{DynamicResource delete}" />
<Button Click="OnnEditCustomHotkeyClick" Width="100" Margin="10"
Content="{DynamicResource edit}" />
<Button Click="OnAddCustomeHotkeyClick" Width="100" Margin="10"
Content="{DynamicResource add}" />
</StackPanel>
</Grid>
</TabItem>
<TabItem Header="{DynamicResource proxy}">
<StackPanel>
<CheckBox Margin="10" IsChecked="{Binding Settings.Proxy.Enabled}">
<TextBlock Text="{DynamicResource enableProxy}" />
</CheckBox>
<Grid Margin="10" IsEnabled="{Binding Settings.Proxy.Enabled}">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="200" />
<ColumnDefinition Width="100" />
<ColumnDefinition Width="200" />
</Grid.ColumnDefinitions>
<TextBlock Text="{DynamicResource server}" Grid.Row="0" Grid.Column="0" Padding="5" />
<TextBox Text="{Binding Settings.Proxy.Server}" Grid.Row="0" Grid.Column="1" Padding="5" />
<TextBlock Text="{DynamicResource port}" Grid.Row="0" Grid.Column="2" Padding="5" />
<TextBox Text="{Binding Settings.Proxy.Port, TargetNullValue={x:Static sys:String.Empty} }" Grid.Row="0" Grid.Column="3" Padding="5" />
<TextBlock Text="{DynamicResource userName}" Grid.Row="1" Grid.Column="0" Padding="5" />
<TextBox Text="{Binding Settings.Proxy.UserName}" Grid.Row="1" Grid.Column="1" Padding="5" />
<TextBlock Text="{DynamicResource password}" Grid.Row="1" Grid.Column="2" Padding="5" />
<TextBox Text="{Binding Settings.Proxy.Password}" Grid.Row="1" Grid.Column="3" Padding="5" />
</Grid>
<Button Content="{DynamicResource testProxy}" IsEnabled="{Binding Settings.Proxy.Enabled}"
Width="80" HorizontalAlignment="Left" Margin="10" Click="OnTestProxyClick" />
</StackPanel>
</TabItem>
<TabItem Header="{DynamicResource about}">
<Grid>
<Grid.Resources>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="Margin" Value="10, 10, 0, 0" />
</Style>
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.ColumnSpan="2" Text="{Binding ActivatedTimes, Mode=OneWay}" />
<TextBlock Grid.Row="1" Grid.Column="0" Text="{DynamicResource website}" />
<TextBlock Grid.Row="1" Grid.Column="1" HorizontalAlignment="Left">
<Hyperlink NavigateUri="{Binding Github, Mode=OneWay}" RequestNavigate="OnRequestNavigate">
<Run Text="{Binding Github, Mode=OneWay}" />
</Hyperlink>
</TextBlock>
<TextBlock Grid.Row="2" Grid.Column="0" Text="{DynamicResource version}" />
<TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding Version}" />
<TextBlock Grid.Row="3" Grid.Column="0" Text="{DynamicResource releaseNotes}" />
<TextBlock Grid.Row="3" Grid.Column="1">
<Hyperlink NavigateUri="{Binding ReleaseNotes, Mode=OneWay}"
RequestNavigate="OnRequestNavigate">
<Run Text="{Binding ReleaseNotes, Mode=OneWay}" />
</Hyperlink>
</TextBlock>
<Button Grid.Row="4" Grid.Column="0"
Content="{DynamicResource checkUpdates}" Click="OnCheckUpdates"
HorizontalAlignment="Left" Margin="10 10 10 10" />
</Grid>
</TabItem>
</TabControl>
</Window>

View File

@ -1,293 +0,0 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Navigation;
using Microsoft.Win32;
using NHotkey;
using NHotkey.Wpf;
using Wox.Core;
using Wox.Core.Plugin;
using Wox.Core.Resource;
using Wox.Infrastructure.Hotkey;
using Wox.Infrastructure.UserSettings;
using Wox.Plugin;
using Wox.ViewModel;
namespace Wox
{
public partial class SettingWindow
{
private const string StartupPath = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";
public readonly IPublicAPI _api;
private Settings _settings;
private SettingWindowViewModel _viewModel;
public SettingWindow(IPublicAPI api, SettingWindowViewModel viewModel)
{
InitializeComponent();
_settings = viewModel.Settings;
DataContext = viewModel;
_viewModel = viewModel;
_api = api;
}
#region General
void OnLanguageChanged(object sender, SelectionChangedEventArgs e)
{
var language = (Language)e.AddedItems[0];
InternationalizationManager.Instance.ChangeLanguage(language);
}
private void OnAutoStartupChecked(object sender, RoutedEventArgs e)
{
SetStartup();
}
private void OnAutoStartupUncheck(object sender, RoutedEventArgs e)
{
RemoveStartup();
}
public static void SetStartup()
{
using (var key = Registry.CurrentUser.OpenSubKey(StartupPath, true))
{
key?.SetValue(Infrastructure.Constant.Wox, Infrastructure.Constant.ExecutablePath);
}
}
private void RemoveStartup()
{
using (var key = Registry.CurrentUser.OpenSubKey(StartupPath, true))
{
key?.DeleteValue(Infrastructure.Constant.Wox, false);
}
}
public static bool StartupSet()
{
using (var key = Registry.CurrentUser.OpenSubKey(StartupPath, true))
{
var path = key?.GetValue(Infrastructure.Constant.Wox) as string;
if (path != null)
{
return path == Infrastructure.Constant.ExecutablePath;
}
else
{
return false;
}
}
}
private void OnSelectPythonDirectoryClick(object sender, RoutedEventArgs e)
{
var dlg = new System.Windows.Forms.FolderBrowserDialog
{
SelectedPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)
};
var result = dlg.ShowDialog();
if (result == System.Windows.Forms.DialogResult.OK)
{
string pythonDirectory = dlg.SelectedPath;
if (!string.IsNullOrEmpty(pythonDirectory))
{
var pythonPath = Path.Combine(pythonDirectory, PluginsLoader.PythonExecutable);
if (File.Exists(pythonPath))
{
_settings.PluginSettings.PythonDirectory = pythonDirectory;
MessageBox.Show("Remember to restart Wox use new Python path");
}
else
{
MessageBox.Show("Can't find python in given directory");
}
}
}
}
#endregion
#region Hotkey
private void OnHotkeyControlLoaded(object sender, RoutedEventArgs e)
{
HotkeyControl.SetHotkey(_viewModel.Settings.Hotkey, false);
}
void OnHotkeyChanged(object sender, EventArgs e)
{
if (HotkeyControl.CurrentHotkeyAvailable)
{
SetHotkey(HotkeyControl.CurrentHotkey, (o, args) =>
{
if (!Application.Current.MainWindow.IsVisible)
{
Application.Current.MainWindow.Visibility = Visibility.Visible;
}
else
{
Application.Current.MainWindow.Visibility = Visibility.Hidden;
}
});
RemoveHotkey(_settings.Hotkey);
_settings.Hotkey = HotkeyControl.CurrentHotkey.ToString();
}
}
void SetHotkey(HotkeyModel hotkey, EventHandler<HotkeyEventArgs> action)
{
string hotkeyStr = hotkey.ToString();
try
{
HotkeyManager.Current.AddOrReplace(hotkeyStr, hotkey.CharKey, hotkey.ModifierKeys, action);
}
catch (Exception)
{
string errorMsg =
string.Format(InternationalizationManager.Instance.GetTranslation("registerHotkeyFailed"), hotkeyStr);
MessageBox.Show(errorMsg);
}
}
void RemoveHotkey(string hotkeyStr)
{
if (!string.IsNullOrEmpty(hotkeyStr))
{
HotkeyManager.Current.Remove(hotkeyStr);
}
}
private void OnDeleteCustomHotkeyClick(object sender, RoutedEventArgs e)
{
var item = _viewModel.SelectedCustomPluginHotkey;
if (item == null)
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem"));
return;
}
string deleteWarning =
string.Format(InternationalizationManager.Instance.GetTranslation("deleteCustomHotkeyWarning"),
item.Hotkey);
if (
MessageBox.Show(deleteWarning, InternationalizationManager.Instance.GetTranslation("delete"),
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
{
_settings.CustomPluginHotkeys.Remove(item);
RemoveHotkey(item.Hotkey);
}
}
private void OnnEditCustomHotkeyClick(object sender, RoutedEventArgs e)
{
var item = _viewModel.SelectedCustomPluginHotkey;
if (item != null)
{
CustomQueryHotkeySetting window = new CustomQueryHotkeySetting(this, _settings);
window.UpdateItem(item);
window.ShowDialog();
}
else
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem"));
}
}
private void OnAddCustomeHotkeyClick(object sender, RoutedEventArgs e)
{
new CustomQueryHotkeySetting(this, _settings).ShowDialog();
}
#endregion
#region Plugin
private void OnPluginToggled(object sender, RoutedEventArgs e)
{
var id = _viewModel.SelectedPlugin.PluginPair.Metadata.ID;
// used to sync the current status from the plugin manager into the setting to keep consistency after save
_settings.PluginSettings.Plugins[id].Disabled = _viewModel.SelectedPlugin.PluginPair.Metadata.Disabled;
}
private void OnPluginActionKeywordsClick(object sender, MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.Left)
{
var id = _viewModel.SelectedPlugin.PluginPair.Metadata.ID;
ActionKeywords changeKeywordsWindow = new ActionKeywords(id, _settings);
changeKeywordsWindow.ShowDialog();
}
}
private void OnPluginNameClick(object sender, MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.Left)
{
var website = _viewModel.SelectedPlugin.PluginPair.Metadata.Website;
if (!string.IsNullOrEmpty(website))
{
var uri = new Uri(website);
if (Uri.CheckSchemeName(uri.Scheme))
{
Process.Start(website);
}
}
}
}
private void OnPluginDirecotyClick(object sender, MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.Left)
{
var directory = _viewModel.SelectedPlugin.PluginPair.Metadata.PluginDirectory;
if (!string.IsNullOrEmpty(directory) && Directory.Exists(directory))
{
Process.Start(directory);
}
}
}
#endregion
#region Proxy
private void OnTestProxyClick(object sender, RoutedEventArgs e)
{ // TODO: change to command
var msg = _viewModel.TestProxy();
MessageBox.Show(msg); // TODO: add message box service
}
#endregion
private async void OnCheckUpdates(object sender, RoutedEventArgs e)
{
_viewModel.UpdateApp(); // TODO: change to command
}
private void OnRequestNavigate(object sender, RequestNavigateEventArgs e)
{
Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri));
e.Handled = true;
}
private void OnClosed(object sender, EventArgs e)
{
_viewModel.Save();
PluginManager.Save();
}
private void OnCloseExecuted(object sender, ExecutedRoutedEventArgs e)
{
Close();
}
}
}

View File

@ -122,9 +122,6 @@
<Compile Include="Helper\SyntaxSugars.cs" />
<Compile Include="Helper\WallpaperPathRetrieval.cs" />
<Compile Include="Helper\WindowsInteropHelper.cs" />
<Compile Include="CustomQueryHotkeySetting.xaml.cs">
<DependentUpon>CustomQueryHotkeySetting.xaml</DependentUpon>
</Compile>
<Compile Include="Helper\DWMDropShadow.cs" />
<Compile Include="HotkeyControl.xaml.cs">
<DependentUpon>HotkeyControl.xaml</DependentUpon>
@ -132,17 +129,10 @@
<Compile Include="Msg.xaml.cs">
<DependentUpon>Msg.xaml</DependentUpon>
</Compile>
<Compile Include="SettingWindow.xaml.cs">
<DependentUpon>SettingWindow.xaml</DependentUpon>
</Compile>
<Page Include="ActionKeywords.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="CustomQueryHotkeySetting.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="HotkeyControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@ -277,10 +267,6 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="SettingWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<None Include="Themes\Light.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>