Move CMD settings to CMD plugin details.

This commit is contained in:
qianlifeng 2014-07-04 15:34:31 +08:00
parent 0c75cf6055
commit f01de3a69d
6 changed files with 93 additions and 32 deletions

View File

@ -4,10 +4,11 @@ using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Windows.Forms;
using Control = System.Windows.Controls.Control;
namespace Wox.Plugin.SystemPlugins.CMD
{
public class CMD : BaseSystemPlugin
public class CMD : BaseSystemPlugin,ISettingProvider
{
private PluginInitContext context;
@ -167,5 +168,10 @@ namespace Wox.Plugin.SystemPlugins.CMD
{
get { return "Provide executing commands from Wox. Commands should start with >"; }
}
public Control CreateSettingPanel()
{
return new CMDSetting();
}
}
}

View File

@ -0,0 +1,25 @@
<UserControl x:Class="Wox.Plugin.SystemPlugins.CMD.CMDSetting"
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"
mc:Ignorable="d"
Loaded="CMDSetting_OnLoaded"
d:DesignHeight="300" d:DesignWidth="300">
<Border BorderBrush="Gray" Margin="10" BorderThickness="1">
<Grid Margin="10" VerticalAlignment="Top" >
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal">
<CheckBox x:Name="cbReplaceWinR" />
<TextBlock Text="Replace Win+R" />
</StackPanel>
<StackPanel Grid.Row="1" Orientation="Horizontal" Margin="0 10 0 0">
<CheckBox x:Name="cbLeaveCmdOpen" />
<TextBlock Text="Do not close Command Prompt after command execution" />
</StackPanel>
</Grid>
</Border>
</UserControl>

View File

@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Wox.Infrastructure.Storage.UserSettings;
namespace Wox.Plugin.SystemPlugins.CMD
{
public partial class CMDSetting : UserControl
{
public CMDSetting()
{
InitializeComponent();
}
private void CMDSetting_OnLoaded(object sender, RoutedEventArgs re)
{
cbReplaceWinR.IsChecked = UserSettingStorage.Instance.ReplaceWinR;
cbLeaveCmdOpen.IsChecked = UserSettingStorage.Instance.LeaveCmdOpen;
cbLeaveCmdOpen.Checked += (o, e) =>
{
UserSettingStorage.Instance.LeaveCmdOpen = true;
UserSettingStorage.Instance.Save();
};
cbLeaveCmdOpen.Unchecked += (o, e) =>
{
UserSettingStorage.Instance.LeaveCmdOpen = false;
UserSettingStorage.Instance.Save();
};
cbReplaceWinR.Checked += (o, e) =>
{
UserSettingStorage.Instance.ReplaceWinR = true;
UserSettingStorage.Instance.Save();
};
cbReplaceWinR.Unchecked += (o, e) =>
{
UserSettingStorage.Instance.ReplaceWinR = false;
UserSettingStorage.Instance.Save();
};
}
}
}

View File

@ -54,6 +54,9 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="CMD\CMDSetting.xaml.cs">
<DependentUpon>CMDSetting.xaml</DependentUpon>
</Compile>
<Compile Include="CMD\CMDStorage.cs" />
<Compile Include="ColorsPlugin.cs" />
<Compile Include="Folder\FolderPluginSettings.xaml.cs">
@ -102,6 +105,10 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Page Include="CMD\CMDSetting.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Folder\FolderPluginSettings.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>

View File

@ -26,14 +26,6 @@
<CheckBox x:Name="cbStartWithWindows" Unchecked="CbStartWithWindows_OnUnchecked" Checked="CbStartWithWindows_OnChecked" />
<TextBlock Text="Start Wox on system startup" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="10">
<CheckBox x:Name="cbReplaceWinR" />
<TextBlock Text="Replace Win+R" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="10">
<CheckBox x:Name="cbLeaveCmdOpen" />
<TextBlock Text="Do not close Command Prompt after command execution" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="10">
<CheckBox x:Name="cbHideWhenDeactive" />
<TextBlock Text="Hide Wox when loses focus" />

View File

@ -48,27 +48,6 @@ namespace Wox
{
ctlHotkey.OnHotkeyChanged += ctlHotkey_OnHotkeyChanged;
ctlHotkey.SetHotkey(UserSettingStorage.Instance.Hotkey, false);
cbReplaceWinR.Checked += (o, e) =>
{
UserSettingStorage.Instance.ReplaceWinR = true;
UserSettingStorage.Instance.Save();
};
cbReplaceWinR.Unchecked += (o, e) =>
{
UserSettingStorage.Instance.ReplaceWinR = false;
UserSettingStorage.Instance.Save();
};
cbLeaveCmdOpen.Checked += (o, e) => {
UserSettingStorage.Instance.LeaveCmdOpen = true;
UserSettingStorage.Instance.Save();
};
cbLeaveCmdOpen.Unchecked += (o, e) =>
{
UserSettingStorage.Instance.LeaveCmdOpen = false;
UserSettingStorage.Instance.Save();
};
cbHideWhenDeactive.Checked += (o, e) =>
{
@ -82,10 +61,8 @@ namespace Wox
UserSettingStorage.Instance.Save();
};
cbReplaceWinR.IsChecked = UserSettingStorage.Instance.ReplaceWinR;
lvCustomHotkey.ItemsSource = UserSettingStorage.Instance.CustomPluginHotkeys;
cbStartWithWindows.IsChecked = File.Exists(woxLinkPath);
cbLeaveCmdOpen.IsChecked = UserSettingStorage.Instance.LeaveCmdOpen;
cbHideWhenDeactive.IsChecked = UserSettingStorage.Instance.HideWhenDeactive;
#region Load Theme