diff --git a/Plugins/Wox.Plugin.ControlPanel/ControlPanelSettingsView.xaml b/Plugins/Wox.Plugin.ControlPanel/ControlPanelSettingsView.xaml
new file mode 100644
index 0000000000..b846f68de2
--- /dev/null
+++ b/Plugins/Wox.Plugin.ControlPanel/ControlPanelSettingsView.xaml
@@ -0,0 +1,12 @@
+
+
+
+
+
diff --git a/Plugins/Wox.Plugin.ControlPanel/ControlPanelSettingsView.xaml.cs b/Plugins/Wox.Plugin.ControlPanel/ControlPanelSettingsView.xaml.cs
new file mode 100644
index 0000000000..9f09895ed8
--- /dev/null
+++ b/Plugins/Wox.Plugin.ControlPanel/ControlPanelSettingsView.xaml.cs
@@ -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
+{
+ ///
+ /// Interaction logic for ControlPanelSettingsControl.xaml
+ ///
+ public partial class ControlPanelSettingsView : UserControl
+ {
+ public ControlPanelSettingsView(ControlPanelSettingsViewModel vm)
+ {
+ InitializeComponent();
+ DataContext = vm;
+ }
+ }
+}
diff --git a/Plugins/Wox.Plugin.ControlPanel/ControlPanelSettingsViewModel.cs b/Plugins/Wox.Plugin.ControlPanel/ControlPanelSettingsViewModel.cs
new file mode 100644
index 0000000000..cdeebdee8b
--- /dev/null
+++ b/Plugins/Wox.Plugin.ControlPanel/ControlPanelSettingsViewModel.cs
@@ -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();
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Plugins/Wox.Plugin.ControlPanel/Main.cs b/Plugins/Wox.Plugin.ControlPanel/Main.cs
index 0e0a8898d6..f082d3f6a3 100644
--- a/Plugins/Wox.Plugin.ControlPanel/Main.cs
+++ b/Plugins/Wox.Plugin.ControlPanel/Main.cs
@@ -4,17 +4,28 @@ using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
+using System.Windows.Controls;
using Wox.Infrastructure;
+using Wox.Infrastructure.Storage;
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 _settingsStorage;
+
private PluginInitContext context;
private List controlPanelItems = new List();
private string iconFolder;
private string fileType;
+ public Main()
+ {
+ _settingsStorage = new PluginJsonStorage();
+ _settings = _settingsStorage.Load();
+ }
+
public void Init(PluginInitContext context)
{
this.context = context;
@@ -43,7 +54,7 @@ namespace Wox.Plugin.ControlPanel
foreach (var item in controlPanelItems)
{
- item.Score = Score(item, query.Search);
+ item.Score = Score(item, query.Search, _settings.ShouldUsePinYin);
if (item.Score > 0)
{
var result = new Result
@@ -74,20 +85,20 @@ namespace Wox.Plugin.ControlPanel
return panelItems;
}
- private int Score(ControlPanelItem item, string query)
+ private int Score(ControlPanelItem item, string query, bool shouldUsePinYin)
{
var scores = new List {0};
if (!string.IsNullOrEmpty(item.LocalizedString))
{
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(score2);
}
if (!string.IsNullOrEmpty(item.InfoTip))
{
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(score2);
}
@@ -103,5 +114,15 @@ namespace Wox.Plugin.ControlPanel
{
return context.API.GetTranslation("wox_plugin_controlpanel_plugin_description");
}
+
+ public Control CreateSettingPanel()
+ {
+ return new ControlPanelSettingsView(new ControlPanelSettingsViewModel(_settings));
+ }
+
+ public void Save()
+ {
+ _settingsStorage.Save();
+ }
}
}
\ No newline at end of file
diff --git a/Plugins/Wox.Plugin.ControlPanel/Settings.cs b/Plugins/Wox.Plugin.ControlPanel/Settings.cs
new file mode 100644
index 0000000000..7c90afdd92
--- /dev/null
+++ b/Plugins/Wox.Plugin.ControlPanel/Settings.cs
@@ -0,0 +1,7 @@
+namespace Wox.Plugin.ControlPanel
+{
+ public class Settings
+ {
+ public bool ShouldUsePinYin { get; set; } = true;
+ }
+}
\ No newline at end of file
diff --git a/Plugins/Wox.Plugin.ControlPanel/Wox.Plugin.ControlPanel.csproj b/Plugins/Wox.Plugin.ControlPanel/Wox.Plugin.ControlPanel.csproj
index 614ea5f652..e764ccce0c 100644
--- a/Plugins/Wox.Plugin.ControlPanel/Wox.Plugin.ControlPanel.csproj
+++ b/Plugins/Wox.Plugin.ControlPanel/Wox.Plugin.ControlPanel.csproj
@@ -37,19 +37,27 @@
..\..\packages\JetBrains.Annotations.10.3.0\lib\net\JetBrains.Annotations.dll
True
+
+
+
Properties\SolutionAssemblyInfo.cs
+
+ ControlPanelSettingsView.xaml
+
+
+
@@ -114,6 +122,12 @@
PreserveNewest
+
+
+ Designer
+ MSBuild:Compile
+
+