mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-14 19:49:15 +08:00
parent
2256183422
commit
cb56b98222
@ -1,7 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using PropertyChanged;
|
||||||
|
|
||||||
namespace Wox.Core.UserSettings
|
namespace Wox.Core.UserSettings
|
||||||
{
|
{
|
||||||
|
[ImplementPropertyChanged]
|
||||||
public class CustomPluginHotkey
|
public class CustomPluginHotkey
|
||||||
{
|
{
|
||||||
public string Hotkey { get; set; }
|
public string Hotkey { get; set; }
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using PropertyChanged;
|
||||||
using Wox.Core.Plugin;
|
using Wox.Core.Plugin;
|
||||||
using Wox.Plugin;
|
using Wox.Plugin;
|
||||||
|
|
||||||
namespace Wox.Core.UserSettings
|
namespace Wox.Core.UserSettings
|
||||||
{
|
{
|
||||||
|
[ImplementPropertyChanged]
|
||||||
public class PluginsSettings
|
public class PluginsSettings
|
||||||
{
|
{
|
||||||
public string PythonDirectory { get; set; }
|
public string PythonDirectory { get; set; }
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using PropertyChanged;
|
using PropertyChanged;
|
||||||
@ -31,7 +32,7 @@ namespace Wox.Core.UserSettings
|
|||||||
// Order defaults to 0 or -1, so 1 will let this property appear last
|
// Order defaults to 0 or -1, so 1 will let this property appear last
|
||||||
[JsonProperty(Order = 1)]
|
[JsonProperty(Order = 1)]
|
||||||
public PluginsSettings PluginSettings { get; set; } = new PluginsSettings();
|
public PluginsSettings PluginSettings { get; set; } = new PluginsSettings();
|
||||||
public List<CustomPluginHotkey> CustomPluginHotkeys { get; set; } = new List<CustomPluginHotkey>();
|
public ObservableCollection<CustomPluginHotkey> CustomPluginHotkeys { get; set; } = new ObservableCollection<CustomPluginHotkey>();
|
||||||
|
|
||||||
[Obsolete]
|
[Obsolete]
|
||||||
public double Opacity { get; set; } = 1;
|
public double Opacity { get; set; } = 1;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using NHotkey;
|
using NHotkey;
|
||||||
@ -41,7 +42,7 @@ namespace Wox
|
|||||||
|
|
||||||
if (_settings.CustomPluginHotkeys == null)
|
if (_settings.CustomPluginHotkeys == null)
|
||||||
{
|
{
|
||||||
_settings.CustomPluginHotkeys = new List<CustomPluginHotkey>();
|
_settings.CustomPluginHotkeys = new ObservableCollection<CustomPluginHotkey>();
|
||||||
}
|
}
|
||||||
|
|
||||||
var pluginHotkey = new CustomPluginHotkey
|
var pluginHotkey = new CustomPluginHotkey
|
||||||
@ -78,7 +79,6 @@ namespace Wox
|
|||||||
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("succeed"));
|
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("succeed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
_settingWidow.ReloadCustomPluginHotkeyView();
|
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:wox="clr-namespace:Wox"
|
xmlns:wox="clr-namespace:Wox"
|
||||||
|
xmlns:s="clr-namespace:Wox.Core.UserSettings;assembly=Wox.Core"
|
||||||
xmlns:vm="clr-namespace:Wox.ViewModel"
|
xmlns:vm="clr-namespace:Wox.ViewModel"
|
||||||
x:Class="Wox.SettingWindow"
|
x:Class="Wox.SettingWindow"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
@ -237,56 +238,51 @@
|
|||||||
</ComboBox>
|
</ComboBox>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem Header="{DynamicResource hotkey}" Selector.Selected="OnHotkeyTabSelected">
|
<TabItem Header="{DynamicResource hotkey}">
|
||||||
<Grid Margin="10">
|
<Grid Margin="10">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="30" />
|
<RowDefinition Height="35" />
|
||||||
<RowDefinition />
|
<RowDefinition Height="20"/>
|
||||||
<RowDefinition Height="50" />
|
<RowDefinition Height="400"/>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<StackPanel Grid.Row="0" Orientation="Horizontal" VerticalAlignment="Center">
|
<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}" />
|
<TextBlock VerticalAlignment="Center" Margin="0 0 10 0" Text="{DynamicResource woxHotkey}" />
|
||||||
<wox:HotkeyControl x:Name="HotkeyControl" />
|
<wox:HotkeyControl x:Name="HotkeyControl" HotkeyChanged="OnHotkeyChanged" Loaded="OnHotkeyControlLoaded" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<Grid Grid.Row="1">
|
<TextBlock VerticalAlignment="Center" Grid.Row="1" Margin="0,3,10,2"
|
||||||
<Grid.RowDefinitions>
|
Text="{DynamicResource customQueryHotkey}"/>
|
||||||
<RowDefinition Height="20" />
|
<ListView ItemsSource="{Binding Settings.CustomPluginHotkeys}"
|
||||||
<RowDefinition />
|
SelectedItem="{Binding SelectedCustomPluginHotkey}"
|
||||||
</Grid.RowDefinitions>
|
Margin="0 5 0 0" Grid.Row="2">
|
||||||
<TextBlock VerticalAlignment="Center" Grid.Row="0" Margin="0 0 10 0"
|
|
||||||
Text="{DynamicResource customQueryHotkey}" />
|
|
||||||
<ListView x:Name="CustomHotkies" Margin="0 5 0 0" Grid.Row="1">
|
|
||||||
<ListView.View>
|
<ListView.View>
|
||||||
<GridView>
|
<GridView>
|
||||||
<GridViewColumn Header="{DynamicResource hotkey}" Width="180">
|
<GridViewColumn Header="{DynamicResource hotkey}" Width="180">
|
||||||
<GridViewColumn.CellTemplate>
|
<GridViewColumn.CellTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate DataType="s:CustomPluginHotkey">
|
||||||
<TextBlock Text="{Binding Hotkey}" />
|
<TextBlock Text="{Binding Hotkey}"/>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</GridViewColumn.CellTemplate>
|
</GridViewColumn.CellTemplate>
|
||||||
</GridViewColumn>
|
</GridViewColumn>
|
||||||
<GridViewColumn Header="{DynamicResource actionKeywords}" Width="500">
|
<GridViewColumn Header="{DynamicResource actionKeywords}" Width="500">
|
||||||
<GridViewColumn.CellTemplate>
|
<GridViewColumn.CellTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate DataType="s:CustomPluginHotkey">
|
||||||
<TextBlock Text="{Binding ActionKeywords}" />
|
<TextBlock Text="{Binding ActionKeyword}" />
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</GridViewColumn.CellTemplate>
|
</GridViewColumn.CellTemplate>
|
||||||
</GridViewColumn>
|
</GridViewColumn>
|
||||||
</GridView>
|
</GridView>
|
||||||
</ListView.View>
|
</ListView.View>
|
||||||
</ListView>
|
</ListView>
|
||||||
|
<StackPanel Grid.Row="3" HorizontalAlignment="Right" VerticalAlignment="Bottom" Orientation="Horizontal" Height="40" Width="360">
|
||||||
</Grid>
|
<Button Click="OnDeleteCustomHotkeyClick" Width="100"
|
||||||
<StackPanel Grid.Row="2" HorizontalAlignment="Right" Orientation="Horizontal">
|
|
||||||
<Button Click="BtnDeleteCustomHotkey_OnClick" Width="100"
|
|
||||||
Margin="10" Content="{DynamicResource delete}" />
|
Margin="10" Content="{DynamicResource delete}" />
|
||||||
<Button Click="BtnEditCustomHotkey_OnClick" Width="100" Margin="10"
|
<Button Click="OnnEditCustomHotkeyClick" Width="100" Margin="10"
|
||||||
Content="{DynamicResource edit}" />
|
Content="{DynamicResource edit}" />
|
||||||
<Button Click="BtnAddCustomeHotkey_OnClick" Width="100" Margin="10"
|
<Button Click="OnAddCustomeHotkeyClick" Width="100" Margin="10"
|
||||||
Content="{DynamicResource add}" />
|
Content="{DynamicResource add}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
@ -154,13 +154,18 @@ namespace Wox
|
|||||||
|
|
||||||
#region Hotkey
|
#region Hotkey
|
||||||
|
|
||||||
void ctlHotkey_OnHotkeyChanged(object sender, EventArgs e)
|
private void OnHotkeyControlLoaded(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
HotkeyControl.SetHotkey(_viewModel.Settings.Hotkey, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnHotkeyChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (HotkeyControl.CurrentHotkeyAvailable)
|
if (HotkeyControl.CurrentHotkeyAvailable)
|
||||||
{
|
{
|
||||||
SetHotkey(HotkeyControl.CurrentHotkey, delegate
|
SetHotkey(HotkeyControl.CurrentHotkey, delegate
|
||||||
{
|
{
|
||||||
if (!System.Windows.Application.Current.MainWindow.IsVisible)
|
if (!Application.Current.MainWindow.IsVisible)
|
||||||
{
|
{
|
||||||
_api.ShowApp();
|
_api.ShowApp();
|
||||||
}
|
}
|
||||||
@ -197,16 +202,9 @@ namespace Wox
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnHotkeyTabSelected(object sender, RoutedEventArgs e)
|
private void OnDeleteCustomHotkeyClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
HotkeyControl.HotkeyChanged += ctlHotkey_OnHotkeyChanged;
|
var item = _viewModel.SelectedCustomPluginHotkey;
|
||||||
HotkeyControl.SetHotkey(_settings.Hotkey, false);
|
|
||||||
CustomHotkies.ItemsSource = _settings.CustomPluginHotkeys;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void BtnDeleteCustomHotkey_OnClick(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
CustomPluginHotkey item = CustomHotkies.SelectedItem as CustomPluginHotkey;
|
|
||||||
if (item == null)
|
if (item == null)
|
||||||
{
|
{
|
||||||
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem"));
|
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem"));
|
||||||
@ -221,14 +219,13 @@ namespace Wox
|
|||||||
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
||||||
{
|
{
|
||||||
_settings.CustomPluginHotkeys.Remove(item);
|
_settings.CustomPluginHotkeys.Remove(item);
|
||||||
CustomHotkies.Items.Refresh();
|
|
||||||
RemoveHotkey(item.Hotkey);
|
RemoveHotkey(item.Hotkey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BtnEditCustomHotkey_OnClick(object sender, RoutedEventArgs e)
|
private void OnnEditCustomHotkeyClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
CustomPluginHotkey item = CustomHotkies.SelectedItem as CustomPluginHotkey;
|
var item = _viewModel.SelectedCustomPluginHotkey;
|
||||||
if (item != null)
|
if (item != null)
|
||||||
{
|
{
|
||||||
CustomQueryHotkeySetting window = new CustomQueryHotkeySetting(this, _settings);
|
CustomQueryHotkeySetting window = new CustomQueryHotkeySetting(this, _settings);
|
||||||
@ -241,16 +238,11 @@ namespace Wox
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BtnAddCustomeHotkey_OnClick(object sender, RoutedEventArgs e)
|
private void OnAddCustomeHotkeyClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
new CustomQueryHotkeySetting(this, _settings).ShowDialog();
|
new CustomQueryHotkeySetting(this, _settings).ShowDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ReloadCustomPluginHotkeyView()
|
|
||||||
{
|
|
||||||
CustomHotkies.Items.Refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Theme
|
#region Theme
|
||||||
@ -433,5 +425,6 @@ namespace Wox
|
|||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -276,6 +276,10 @@ namespace Wox.ViewModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
#region hotkey
|
||||||
|
|
||||||
|
public CustomPluginHotkey SelectedCustomPluginHotkey {get;set;}
|
||||||
#endregion
|
#endregion
|
||||||
public SettingWindowViewModel()
|
public SettingWindowViewModel()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user