mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 12:18:50 +02:00
added the abitliy to opt out of pinyin in control panel and in program plug in - this give a major perf boost (and I'm guessing it is not relevant for most users)
This commit is contained in:
@@ -0,0 +1,12 @@
|
|||||||
|
<UserControl x:Class="Wox.Plugin.ControlPanel.ControlPanelSettingsView"
|
||||||
|
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:local="clr-namespace:Wox.Plugin.ControlPanel"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
d:DesignHeight="450" d:DesignWidth="800">
|
||||||
|
<Grid>
|
||||||
|
<CheckBox Name="ShouldUsePinYin_checkBox" IsChecked="{Binding ShouldUsePinYin}" Content="Should Use PinYin"/>
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
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;
|
||||||
|
|
||||||
|
namespace Wox.Plugin.ControlPanel
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for ControlPanelSettingsControl.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class ControlPanelSettingsView : UserControl
|
||||||
|
{
|
||||||
|
public ControlPanelSettingsView(ControlPanelSettingsViewModel vm)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
DataContext = vm;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
namespace Wox.Plugin.ControlPanel
|
||||||
|
{
|
||||||
|
public class ControlPanelSettingsViewModel : BaseModel
|
||||||
|
{
|
||||||
|
private readonly Settings _settings;
|
||||||
|
|
||||||
|
public ControlPanelSettingsViewModel(Settings settings)
|
||||||
|
{
|
||||||
|
_settings = settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ShouldUsePinYin
|
||||||
|
{
|
||||||
|
get { return _settings.ShouldUsePinYin; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_settings.ShouldUsePinYin = value;
|
||||||
|
this.OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,17 +4,28 @@ using System.Diagnostics;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Controls;
|
||||||
using Wox.Infrastructure;
|
using Wox.Infrastructure;
|
||||||
|
using Wox.Infrastructure.Storage;
|
||||||
|
|
||||||
namespace Wox.Plugin.ControlPanel
|
namespace Wox.Plugin.ControlPanel
|
||||||
{
|
{
|
||||||
public class Main : IPlugin, IPluginI18n
|
public class Main : IPlugin, IPluginI18n, ISettingProvider, ISavable
|
||||||
{
|
{
|
||||||
|
private readonly Settings _settings = new Settings {ShouldUsePinYin = false};
|
||||||
|
private readonly PluginJsonStorage<Settings> _settingsStorage;
|
||||||
|
|
||||||
private PluginInitContext context;
|
private PluginInitContext context;
|
||||||
private List<ControlPanelItem> controlPanelItems = new List<ControlPanelItem>();
|
private List<ControlPanelItem> controlPanelItems = new List<ControlPanelItem>();
|
||||||
private string iconFolder;
|
private string iconFolder;
|
||||||
private string fileType;
|
private string fileType;
|
||||||
|
|
||||||
|
public Main()
|
||||||
|
{
|
||||||
|
_settingsStorage = new PluginJsonStorage<Settings>();
|
||||||
|
_settings = _settingsStorage.Load();
|
||||||
|
}
|
||||||
|
|
||||||
public void Init(PluginInitContext context)
|
public void Init(PluginInitContext context)
|
||||||
{
|
{
|
||||||
this.context = context;
|
this.context = context;
|
||||||
@@ -43,7 +54,7 @@ namespace Wox.Plugin.ControlPanel
|
|||||||
|
|
||||||
foreach (var item in controlPanelItems)
|
foreach (var item in controlPanelItems)
|
||||||
{
|
{
|
||||||
item.Score = Score(item, query.Search);
|
item.Score = Score(item, query.Search, _settings.ShouldUsePinYin);
|
||||||
if (item.Score > 0)
|
if (item.Score > 0)
|
||||||
{
|
{
|
||||||
var result = new Result
|
var result = new Result
|
||||||
@@ -74,20 +85,20 @@ namespace Wox.Plugin.ControlPanel
|
|||||||
return panelItems;
|
return panelItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int Score(ControlPanelItem item, string query)
|
private int Score(ControlPanelItem item, string query, bool shouldUsePinYin)
|
||||||
{
|
{
|
||||||
var scores = new List<int> {0};
|
var scores = new List<int> {0};
|
||||||
if (!string.IsNullOrEmpty(item.LocalizedString))
|
if (!string.IsNullOrEmpty(item.LocalizedString))
|
||||||
{
|
{
|
||||||
var score1 = StringMatcher.FuzzySearch(query, item.LocalizedString).ScoreAfterSearchPrecisionFilter();
|
var score1 = StringMatcher.FuzzySearch(query, item.LocalizedString).ScoreAfterSearchPrecisionFilter();
|
||||||
var score2 = StringMatcher.ScoreForPinyin(item.LocalizedString, query);
|
var score2 = shouldUsePinYin ? StringMatcher.ScoreForPinyin(item.LocalizedString, query) : 0;
|
||||||
scores.Add(score1);
|
scores.Add(score1);
|
||||||
scores.Add(score2);
|
scores.Add(score2);
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrEmpty(item.InfoTip))
|
if (!string.IsNullOrEmpty(item.InfoTip))
|
||||||
{
|
{
|
||||||
var score1 = StringMatcher.FuzzySearch(query, item.InfoTip).ScoreAfterSearchPrecisionFilter();
|
var score1 = StringMatcher.FuzzySearch(query, item.InfoTip).ScoreAfterSearchPrecisionFilter();
|
||||||
var score2 = StringMatcher.ScoreForPinyin(item.InfoTip, query);
|
var score2 = shouldUsePinYin ? StringMatcher.ScoreForPinyin(item.InfoTip, query) : 0;
|
||||||
scores.Add(score1);
|
scores.Add(score1);
|
||||||
scores.Add(score2);
|
scores.Add(score2);
|
||||||
}
|
}
|
||||||
@@ -103,5 +114,15 @@ namespace Wox.Plugin.ControlPanel
|
|||||||
{
|
{
|
||||||
return context.API.GetTranslation("wox_plugin_controlpanel_plugin_description");
|
return context.API.GetTranslation("wox_plugin_controlpanel_plugin_description");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Control CreateSettingPanel()
|
||||||
|
{
|
||||||
|
return new ControlPanelSettingsView(new ControlPanelSettingsViewModel(_settings));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Save()
|
||||||
|
{
|
||||||
|
_settingsStorage.Save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
7
Plugins/Wox.Plugin.ControlPanel/Settings.cs
Normal file
7
Plugins/Wox.Plugin.ControlPanel/Settings.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
namespace Wox.Plugin.ControlPanel
|
||||||
|
{
|
||||||
|
public class Settings
|
||||||
|
{
|
||||||
|
public bool ShouldUsePinYin { get; set; } = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -37,19 +37,27 @@
|
|||||||
<HintPath>..\..\packages\JetBrains.Annotations.10.3.0\lib\net\JetBrains.Annotations.dll</HintPath>
|
<HintPath>..\..\packages\JetBrains.Annotations.10.3.0\lib\net\JetBrains.Annotations.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="PresentationCore" />
|
||||||
<Reference Include="PresentationFramework" />
|
<Reference Include="PresentationFramework" />
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Drawing" />
|
<Reference Include="System.Drawing" />
|
||||||
|
<Reference Include="System.Xaml" />
|
||||||
|
<Reference Include="WindowsBase" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="..\..\SolutionAssemblyInfo.cs">
|
<Compile Include="..\..\SolutionAssemblyInfo.cs">
|
||||||
<Link>Properties\SolutionAssemblyInfo.cs</Link>
|
<Link>Properties\SolutionAssemblyInfo.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="ControlPanelSettingsView.xaml.cs">
|
||||||
|
<DependentUpon>ControlPanelSettingsView.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="ControlPanelSettingsViewModel.cs" />
|
||||||
<Compile Include="Main.cs" />
|
<Compile Include="Main.cs" />
|
||||||
<Compile Include="ControlPanelItem.cs" />
|
<Compile Include="ControlPanelItem.cs" />
|
||||||
<Compile Include="ControlPanelList.cs" />
|
<Compile Include="ControlPanelList.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="Settings.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
@@ -114,6 +122,12 @@
|
|||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Page Include="ControlPanelSettingsView.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
<system:String x:Key="wox_plugin_program_index_registry">Indexierungsspeicher</system:String>
|
<system:String x:Key="wox_plugin_program_index_registry">Indexierungsspeicher</system:String>
|
||||||
<system:String x:Key="wox_plugin_program_suffixes_header">Endungen</system:String>
|
<system:String x:Key="wox_plugin_program_suffixes_header">Endungen</system:String>
|
||||||
<system:String x:Key="wox_plugin_program_max_depth_header">Maximale Tiefe</system:String>
|
<system:String x:Key="wox_plugin_program_max_depth_header">Maximale Tiefe</system:String>
|
||||||
|
<system:String x:Key="wox_plugin_program_use_pinyin">Should Use Pinyin (waiting for translation)</system:String>
|
||||||
|
|
||||||
<system:String x:Key="wox_plugin_program_directory">Verzeichnis:</system:String>
|
<system:String x:Key="wox_plugin_program_directory">Verzeichnis:</system:String>
|
||||||
<system:String x:Key="wox_plugin_program_browse">Durchsuchen</system:String>
|
<system:String x:Key="wox_plugin_program_browse">Durchsuchen</system:String>
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
<system:String x:Key="wox_plugin_program_index_registry">Index Registry</system:String>
|
<system:String x:Key="wox_plugin_program_index_registry">Index Registry</system:String>
|
||||||
<system:String x:Key="wox_plugin_program_suffixes_header">Suffixes</system:String>
|
<system:String x:Key="wox_plugin_program_suffixes_header">Suffixes</system:String>
|
||||||
<system:String x:Key="wox_plugin_program_max_depth_header">Max Depth</system:String>
|
<system:String x:Key="wox_plugin_program_max_depth_header">Max Depth</system:String>
|
||||||
|
<system:String x:Key="wox_plugin_program_use_pinyin">Should Use Pinyin</system:String>
|
||||||
|
|
||||||
|
|
||||||
<system:String x:Key="wox_plugin_program_directory">Directory:</system:String>
|
<system:String x:Key="wox_plugin_program_directory">Directory:</system:String>
|
||||||
<system:String x:Key="wox_plugin_program_browse">Browse</system:String>
|
<system:String x:Key="wox_plugin_program_browse">Browse</system:String>
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
<system:String x:Key="wox_plugin_program_index_registry">Indeksuj rejestr</system:String>
|
<system:String x:Key="wox_plugin_program_index_registry">Indeksuj rejestr</system:String>
|
||||||
<system:String x:Key="wox_plugin_program_suffixes_header">Rozszerzenia</system:String>
|
<system:String x:Key="wox_plugin_program_suffixes_header">Rozszerzenia</system:String>
|
||||||
<system:String x:Key="wox_plugin_program_max_depth_header">Maksymalna głębokość</system:String>
|
<system:String x:Key="wox_plugin_program_max_depth_header">Maksymalna głębokość</system:String>
|
||||||
|
<system:String x:Key="wox_plugin_program_use_pinyin">Should Use Pinyin (waiting for translation)</system:String>
|
||||||
|
|
||||||
<system:String x:Key="wox_plugin_program_directory">Katalog:</system:String>
|
<system:String x:Key="wox_plugin_program_directory">Katalog:</system:String>
|
||||||
<system:String x:Key="wox_plugin_program_browse">Przeglądaj</system:String>
|
<system:String x:Key="wox_plugin_program_browse">Przeglądaj</system:String>
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
<system:String x:Key="wox_plugin_program_index_registry">Registry'i İndeksle</system:String>
|
<system:String x:Key="wox_plugin_program_index_registry">Registry'i İndeksle</system:String>
|
||||||
<system:String x:Key="wox_plugin_program_suffixes_header">Uzantılar</system:String>
|
<system:String x:Key="wox_plugin_program_suffixes_header">Uzantılar</system:String>
|
||||||
<system:String x:Key="wox_plugin_program_max_depth_header">Derinlik</system:String>
|
<system:String x:Key="wox_plugin_program_max_depth_header">Derinlik</system:String>
|
||||||
|
<system:String x:Key="wox_plugin_program_use_pinyin">Should Use Pinyin (waiting for translation)</system:String>
|
||||||
|
|
||||||
<system:String x:Key="wox_plugin_program_directory">Dizin:</system:String>
|
<system:String x:Key="wox_plugin_program_directory">Dizin:</system:String>
|
||||||
<system:String x:Key="wox_plugin_program_browse">Gözat</system:String>
|
<system:String x:Key="wox_plugin_program_browse">Gözat</system:String>
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
<system:String x:Key="wox_plugin_program_index_registry">索引注册表</system:String>
|
<system:String x:Key="wox_plugin_program_index_registry">索引注册表</system:String>
|
||||||
<system:String x:Key="wox_plugin_program_suffixes_header">后缀</system:String>
|
<system:String x:Key="wox_plugin_program_suffixes_header">后缀</system:String>
|
||||||
<system:String x:Key="wox_plugin_program_max_depth_header">最大深度</system:String>
|
<system:String x:Key="wox_plugin_program_max_depth_header">最大深度</system:String>
|
||||||
|
<system:String x:Key="wox_plugin_program_use_pinyin">Should Use Pinyin (waiting for translation)</system:String>
|
||||||
|
|
||||||
<system:String x:Key="wox_plugin_program_directory">目录</system:String>
|
<system:String x:Key="wox_plugin_program_directory">目录</system:String>
|
||||||
<system:String x:Key="wox_plugin_program_browse">浏览</system:String>
|
<system:String x:Key="wox_plugin_program_browse">浏览</system:String>
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
<system:String x:Key="wox_plugin_program_index_registry">替登錄檔建立索引</system:String>
|
<system:String x:Key="wox_plugin_program_index_registry">替登錄檔建立索引</system:String>
|
||||||
<system:String x:Key="wox_plugin_program_suffixes_header">副檔名</system:String>
|
<system:String x:Key="wox_plugin_program_suffixes_header">副檔名</system:String>
|
||||||
<system:String x:Key="wox_plugin_program_max_depth_header">最大深度</system:String>
|
<system:String x:Key="wox_plugin_program_max_depth_header">最大深度</system:String>
|
||||||
|
<system:String x:Key="wox_plugin_program_use_pinyin">Should Use Pinyin (waiting for translation)</system:String>
|
||||||
|
|
||||||
<system:String x:Key="wox_plugin_program_directory">目錄</system:String>
|
<system:String x:Key="wox_plugin_program_directory">目錄</system:String>
|
||||||
<system:String x:Key="wox_plugin_program_browse">瀏覽</system:String>
|
<system:String x:Key="wox_plugin_program_browse">瀏覽</system:String>
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace Wox.Plugin.Program
|
|||||||
|
|
||||||
private static BinaryStorage<Win32[]> _win32Storage;
|
private static BinaryStorage<Win32[]> _win32Storage;
|
||||||
|
|
||||||
private static Settings _settings;
|
private readonly Settings _settings;
|
||||||
private readonly PluginJsonStorage<Settings> _settingsStorage;
|
private readonly PluginJsonStorage<Settings> _settingsStorage;
|
||||||
|
|
||||||
public Main()
|
public Main()
|
||||||
@@ -66,9 +66,9 @@ namespace Wox.Plugin.Program
|
|||||||
{
|
{
|
||||||
lock (IndexLock)
|
lock (IndexLock)
|
||||||
{
|
{
|
||||||
var results1 = _win32s.AsParallel().Select(p => p.Result(query.Search, _context.API));
|
var results1 = _win32s.AsParallel().Select(p => p.Result(query.Search, _context.API, _settings));
|
||||||
#if !IGNORE_UWP
|
#if !IGNORE_UWP
|
||||||
var results2 = _uwps.AsParallel().Select(p => p.Result(query.Search, _context.API));
|
var results2 = _uwps.AsParallel().Select(p => p.Result(query.Search, _context.API, _settings));
|
||||||
#endif
|
#endif
|
||||||
var result = results1
|
var result = results1
|
||||||
#if !IGNORE_UWP
|
#if !IGNORE_UWP
|
||||||
@@ -84,7 +84,7 @@ namespace Wox.Plugin.Program
|
|||||||
_context = context;
|
_context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void IndexPrograms()
|
public void IndexPrograms()
|
||||||
{
|
{
|
||||||
Win32[] w = { };
|
Win32[] w = { };
|
||||||
#if !IGNORE_UWP
|
#if !IGNORE_UWP
|
||||||
@@ -121,7 +121,7 @@ namespace Wox.Plugin.Program
|
|||||||
|
|
||||||
public Control CreateSettingPanel()
|
public Control CreateSettingPanel()
|
||||||
{
|
{
|
||||||
return new ProgramSetting(_context, _settings);
|
return new ProgramSetting(_context, _settings, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetTranslatedPluginTitle()
|
public string GetTranslatedPluginTitle()
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
d:DesignHeight="300" d:DesignWidth="600">
|
d:DesignHeight="300" d:DesignWidth="600">
|
||||||
<Grid Margin="10">
|
<Grid Margin="10">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="50"/>
|
<RowDefinition Height="80"/>
|
||||||
<RowDefinition Height="*"/>
|
<RowDefinition Height="*"/>
|
||||||
<RowDefinition Height="50"/>
|
<RowDefinition Height="50"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
<StackPanel Orientation="Vertical" Width="310">
|
<StackPanel Orientation="Vertical" Width="310">
|
||||||
<CheckBox Name="StartMenuEnabled" Click="StartMenuEnabled_Click" Margin="5" Content="{DynamicResource wox_plugin_program_index_start}" />
|
<CheckBox Name="StartMenuEnabled" Click="StartMenuEnabled_Click" Margin="5" Content="{DynamicResource wox_plugin_program_index_start}" />
|
||||||
<CheckBox Name="RegistryEnabled" Click="RegistryEnabled_Click" Margin="5" Content="{DynamicResource wox_plugin_program_index_registry}" />
|
<CheckBox Name="RegistryEnabled" Click="RegistryEnabled_Click" Margin="5" Content="{DynamicResource wox_plugin_program_index_registry}" />
|
||||||
|
<CheckBox Name="ShouldUsePinYin" Click="ShouldUsePinYin_Click" Margin="5" Content="{DynamicResource wox_plugin_program_use_pinyin}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<Button Height="30" HorizontalAlignment="Right" x:Name="btnProgramSuffixes" Width="130" Click="BtnProgramSuffixes_OnClick" Content="{DynamicResource wox_plugin_program_suffixes}" />
|
<Button Height="30" HorizontalAlignment="Right" x:Name="btnProgramSuffixes" Width="130" Click="BtnProgramSuffixes_OnClick" Content="{DynamicResource wox_plugin_program_suffixes}" />
|
||||||
<Button Height="30" HorizontalAlignment="Right" Margin="10 0 0 0" x:Name="btnReindex" Width="100" Click="btnReindex_Click" Content="{DynamicResource wox_plugin_program_reindex}" />
|
<Button Height="30" HorizontalAlignment="Right" Margin="10 0 0 0" x:Name="btnReindex" Width="100" Click="btnReindex_Click" Content="{DynamicResource wox_plugin_program_reindex}" />
|
||||||
|
|||||||
@@ -11,15 +11,17 @@ namespace Wox.Plugin.Program
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class ProgramSetting : UserControl
|
public partial class ProgramSetting : UserControl
|
||||||
{
|
{
|
||||||
private PluginInitContext context;
|
private readonly PluginInitContext context;
|
||||||
private Settings _settings;
|
private readonly Settings _settings;
|
||||||
|
private readonly Main _main;
|
||||||
|
|
||||||
public ProgramSetting(PluginInitContext context, Settings settings)
|
public ProgramSetting(PluginInitContext context, Settings settings, Main main)
|
||||||
{
|
{
|
||||||
this.context = context;
|
this.context = context;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
Loaded += Setting_Loaded;
|
Loaded += Setting_Loaded;
|
||||||
_settings = settings;
|
_settings = settings;
|
||||||
|
_main = main;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Setting_Loaded(object sender, RoutedEventArgs e)
|
private void Setting_Loaded(object sender, RoutedEventArgs e)
|
||||||
@@ -27,6 +29,7 @@ namespace Wox.Plugin.Program
|
|||||||
programSourceView.ItemsSource = _settings.ProgramSources;
|
programSourceView.ItemsSource = _settings.ProgramSources;
|
||||||
StartMenuEnabled.IsChecked = _settings.EnableStartMenuSource;
|
StartMenuEnabled.IsChecked = _settings.EnableStartMenuSource;
|
||||||
RegistryEnabled.IsChecked = _settings.EnableRegistrySource;
|
RegistryEnabled.IsChecked = _settings.EnableRegistrySource;
|
||||||
|
ShouldUsePinYin.IsChecked = _settings.ShouldUsePinYin;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReIndexing()
|
private void ReIndexing()
|
||||||
@@ -35,7 +38,7 @@ namespace Wox.Plugin.Program
|
|||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
Dispatcher.Invoke(() => { indexingPanel.Visibility = Visibility.Visible; });
|
Dispatcher.Invoke(() => { indexingPanel.Visibility = Visibility.Visible; });
|
||||||
Main.IndexPrograms();
|
_main.IndexPrograms();
|
||||||
Dispatcher.Invoke(() => { indexingPanel.Visibility = Visibility.Hidden; });
|
Dispatcher.Invoke(() => { indexingPanel.Visibility = Visibility.Hidden; });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -145,5 +148,10 @@ namespace Wox.Plugin.Program
|
|||||||
_settings.EnableRegistrySource = RegistryEnabled.IsChecked ?? false;
|
_settings.EnableRegistrySource = RegistryEnabled.IsChecked ?? false;
|
||||||
ReIndexing();
|
ReIndexing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ShouldUsePinYin_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
_settings.ShouldUsePinYin = ShouldUsePinYin.IsChecked ?? false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,6 @@ namespace Wox.Plugin.Program.Programs
|
|||||||
public interface IProgram
|
public interface IProgram
|
||||||
{
|
{
|
||||||
List<Result> ContextMenus(IPublicAPI api);
|
List<Result> ContextMenus(IPublicAPI api);
|
||||||
Result Result(string query, IPublicAPI api);
|
Result Result(string query, IPublicAPI api, Settings settings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -239,23 +239,23 @@ namespace Wox.Plugin.Program.Programs
|
|||||||
public string LogoPath { get; set; }
|
public string LogoPath { get; set; }
|
||||||
public UWP Package { get; set; }
|
public UWP Package { get; set; }
|
||||||
|
|
||||||
private int Score(string query)
|
private int Score(string query, bool shouldUsePinYin)
|
||||||
{
|
{
|
||||||
var score1 = StringMatcher.FuzzySearch(query, DisplayName).ScoreAfterSearchPrecisionFilter();
|
var score1 = StringMatcher.FuzzySearch(query, DisplayName).ScoreAfterSearchPrecisionFilter();
|
||||||
var score2 = StringMatcher.ScoreForPinyin(DisplayName, query);
|
var score2 = shouldUsePinYin ? StringMatcher.ScoreForPinyin(DisplayName, query) : 0;
|
||||||
var score3 = StringMatcher.FuzzySearch(query, Description).ScoreAfterSearchPrecisionFilter();
|
var score3 = StringMatcher.FuzzySearch(query, Description).ScoreAfterSearchPrecisionFilter();
|
||||||
var score4 = StringMatcher.ScoreForPinyin(Description, query);
|
var score4 = shouldUsePinYin ? StringMatcher.ScoreForPinyin(Description, query) : 0;
|
||||||
var score = new[] { score1, score2, score3, score4 }.Max();
|
var score = new[] { score1, score2, score3, score4 }.Max();
|
||||||
return score;
|
return score;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Result Result(string query, IPublicAPI api)
|
public Result Result(string query, IPublicAPI api, Settings settings)
|
||||||
{
|
{
|
||||||
var result = new Result
|
var result = new Result
|
||||||
{
|
{
|
||||||
SubTitle = Package.Location,
|
SubTitle = Package.Location,
|
||||||
Icon = Logo,
|
Icon = Logo,
|
||||||
Score = Score(query),
|
Score = Score(query, settings.ShouldUsePinYin),
|
||||||
ContextData = this,
|
ContextData = this,
|
||||||
Action = e =>
|
Action = e =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,25 +29,25 @@ namespace Wox.Plugin.Program.Programs
|
|||||||
private const string ApplicationReferenceExtension = "appref-ms";
|
private const string ApplicationReferenceExtension = "appref-ms";
|
||||||
private const string ExeExtension = "exe";
|
private const string ExeExtension = "exe";
|
||||||
|
|
||||||
private int Score(string query)
|
private int Score(string query, bool shouldUsePinYin)
|
||||||
{
|
{
|
||||||
var score1 = StringMatcher.FuzzySearch(query, Name).ScoreAfterSearchPrecisionFilter();
|
var score1 = StringMatcher.FuzzySearch(query, Name).ScoreAfterSearchPrecisionFilter();
|
||||||
var score2 = StringMatcher.ScoreForPinyin(Name, query);
|
var score2 = shouldUsePinYin ? StringMatcher.ScoreForPinyin(Name, query) : 0;
|
||||||
var score3 = StringMatcher.FuzzySearch(query, Description).ScoreAfterSearchPrecisionFilter();
|
var score3 = StringMatcher.FuzzySearch(query, Description).ScoreAfterSearchPrecisionFilter();
|
||||||
var score4 = StringMatcher.ScoreForPinyin(Description, query);
|
var score4 = shouldUsePinYin ? StringMatcher.ScoreForPinyin(Description, query) : 0;
|
||||||
var score5 = StringMatcher.FuzzySearch(query, ExecutableName).ScoreAfterSearchPrecisionFilter();
|
var score5 = StringMatcher.FuzzySearch(query, ExecutableName).ScoreAfterSearchPrecisionFilter();
|
||||||
var score = new[] { score1, score2, score3, score4, score5 }.Max();
|
var score = new[] { score1, score2, score3, score4, score5 }.Max();
|
||||||
return score;
|
return score;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Result Result(string query, IPublicAPI api)
|
public Result Result(string query, IPublicAPI api, Settings settings)
|
||||||
{
|
{
|
||||||
var result = new Result
|
var result = new Result
|
||||||
{
|
{
|
||||||
SubTitle = FullPath,
|
SubTitle = FullPath,
|
||||||
IcoPath = IcoPath,
|
IcoPath = IcoPath,
|
||||||
Score = Score(query),
|
Score = Score(query, settings.ShouldUsePinYin),
|
||||||
ContextData = this,
|
ContextData = this,
|
||||||
Action = e =>
|
Action = e =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ namespace Wox.Plugin.Program
|
|||||||
|
|
||||||
public bool EnableRegistrySource { get; set; } = true;
|
public bool EnableRegistrySource { get; set; } = true;
|
||||||
|
|
||||||
|
public bool ShouldUsePinYin { get; set; } = true;
|
||||||
|
|
||||||
internal const char SuffixSeperator = ';';
|
internal const char SuffixSeperator = ';';
|
||||||
|
|
||||||
public class ProgramSource
|
public class ProgramSource
|
||||||
|
|||||||
Reference in New Issue
Block a user