mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-11 05:52:19 +02:00
Refactoring.
This commit is contained in:
@@ -197,7 +197,7 @@ namespace Wox.Plugin.PluginManagement
|
||||
private List<Result> ListUnInstalledPlugins(Query query)
|
||||
{
|
||||
List<Result> results = new List<Result>();
|
||||
List<PluginMetadata> allInstalledPlugins = ParseThirdPartyPlugins();
|
||||
List<PluginMetadata> allInstalledPlugins = ParseUserPlugins();
|
||||
if (query.ActionParameters.Count > 1)
|
||||
{
|
||||
string pluginName = query.ActionParameters[1];
|
||||
@@ -235,7 +235,7 @@ namespace Wox.Plugin.PluginManagement
|
||||
private List<Result> ListInstalledPlugins()
|
||||
{
|
||||
List<Result> results = new List<Result>();
|
||||
foreach (PluginMetadata plugin in ParseThirdPartyPlugins())
|
||||
foreach (PluginMetadata plugin in ParseUserPlugins())
|
||||
{
|
||||
results.Add(new Result()
|
||||
{
|
||||
@@ -247,7 +247,7 @@ namespace Wox.Plugin.PluginManagement
|
||||
return results;
|
||||
}
|
||||
|
||||
private static List<PluginMetadata> ParseThirdPartyPlugins()
|
||||
private static List<PluginMetadata> ParseUserPlugins()
|
||||
{
|
||||
List<PluginMetadata> pluginMetadatas = new List<PluginMetadata>();
|
||||
if (!Directory.Exists(PluginPath))
|
||||
@@ -276,7 +276,7 @@ namespace Wox.Plugin.PluginManagement
|
||||
try
|
||||
{
|
||||
metadata = JsonConvert.DeserializeObject<PluginMetadata>(File.ReadAllText(configPath));
|
||||
metadata.PluginType = PluginType.ThirdParty;
|
||||
metadata.PluginType = PluginType.User;
|
||||
metadata.PluginDirectory = pluginDirectory;
|
||||
}
|
||||
catch (Exception)
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using Newtonsoft.Json;
|
||||
using Wox.Infrastructure.Exceptions;
|
||||
using Wox.Infrastructure.Logger;
|
||||
@@ -74,7 +75,6 @@ namespace Wox.Core.Plugin
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
ErrorReporting.TryShowErrorMessageBox(e.Message, e);
|
||||
Log.Error(e.Message);
|
||||
}
|
||||
}
|
||||
@@ -83,12 +83,12 @@ namespace Wox.Core.Plugin
|
||||
|
||||
private void ExecuteWoxAPI(string method, object[] parameters)
|
||||
{
|
||||
MethodInfo methodInfo = App.Window.GetType().GetMethod(method);
|
||||
MethodInfo methodInfo = PluginManager.API.GetType().GetMethod(method);
|
||||
if (methodInfo != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
methodInfo.Invoke(App.Window, parameters);
|
||||
methodInfo.Invoke(PluginManager.API, parameters);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -132,7 +132,7 @@ namespace Wox.Core.Plugin
|
||||
string result = reader.ReadToEnd();
|
||||
if (result.StartsWith("DEBUG:"))
|
||||
{
|
||||
System.Windows.Forms.MessageBox.Show(new Form { TopMost = true }, result.Substring(6));
|
||||
MessageBox.Show(new Form { TopMost = true }, result.Substring(6));
|
||||
return "";
|
||||
}
|
||||
if (string.IsNullOrEmpty(result))
|
||||
@@ -142,7 +142,8 @@ namespace Wox.Core.Plugin
|
||||
string error = errorReader.ReadToEnd();
|
||||
if (!string.IsNullOrEmpty(error))
|
||||
{
|
||||
ErrorReporting.TryShowErrorMessageBox(error, new WoxJsonRPCException(error));
|
||||
//todo:
|
||||
// ErrorReporting.TryShowErrorMessageBox(error, new WoxJsonRPCException(error));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Wox.Core.Plugin
|
||||
ParseSystemPlugins();
|
||||
foreach (string pluginDirectory in pluginDirectories)
|
||||
{
|
||||
ParseThirdPartyPlugins(pluginDirectory);
|
||||
ParseUserPlugins(pluginDirectory);
|
||||
}
|
||||
|
||||
if (PluginManager.DebuggerMode != null)
|
||||
@@ -56,7 +56,7 @@ namespace Wox.Core.Plugin
|
||||
});
|
||||
}
|
||||
|
||||
private static void ParseThirdPartyPlugins(string pluginDirectory)
|
||||
private static void ParseUserPlugins(string pluginDirectory)
|
||||
{
|
||||
|
||||
string[] directories = Directory.GetDirectories(pluginDirectory);
|
||||
@@ -88,7 +88,7 @@ namespace Wox.Core.Plugin
|
||||
try
|
||||
{
|
||||
metadata = JsonConvert.DeserializeObject<PluginMetadata>(File.ReadAllText(configPath));
|
||||
metadata.PluginType = PluginType.ThirdParty;
|
||||
metadata.PluginType = PluginType.User;
|
||||
metadata.PluginDirectory = pluginDirectory;
|
||||
}
|
||||
catch (Exception)
|
||||
|
||||
@@ -15,6 +15,8 @@ namespace Wox.Core.Plugin
|
||||
public static class PluginManager
|
||||
{
|
||||
public static String DebuggerMode { get; private set; }
|
||||
public static IPublicAPI API { get; private set; }
|
||||
|
||||
private static List<PluginPair> plugins = new List<PluginPair>();
|
||||
|
||||
/// <summary>
|
||||
@@ -26,8 +28,12 @@ namespace Wox.Core.Plugin
|
||||
{
|
||||
pluginDirectories.Add(
|
||||
Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Plugins"));
|
||||
pluginDirectories.Add(
|
||||
Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), ".Wox"),"Plugins"));
|
||||
|
||||
string userProfilePath = Environment.GetEnvironmentVariable("USERPROFILE");
|
||||
if (userProfilePath != null)
|
||||
{
|
||||
pluginDirectories.Add(Path.Combine(Path.Combine(userProfilePath, ".Wox"), "Plugins"));
|
||||
}
|
||||
|
||||
MakesurePluginDirectoriesExist();
|
||||
}
|
||||
@@ -46,8 +52,9 @@ namespace Wox.Core.Plugin
|
||||
/// <summary>
|
||||
/// Load and init all Wox plugins
|
||||
/// </summary>
|
||||
public static void Init()
|
||||
public static void Init(IPublicAPI api)
|
||||
{
|
||||
API = api;
|
||||
plugins.Clear();
|
||||
|
||||
List<PluginMetadata> pluginMetadatas = PluginConfig.Parse(pluginDirectories);
|
||||
@@ -61,11 +68,16 @@ namespace Wox.Core.Plugin
|
||||
{
|
||||
CurrentPluginMetadata = pair.Metadata,
|
||||
Proxy = HttpProxy.Instance,
|
||||
API = App.Window
|
||||
API = API
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
public static void Query(Query query)
|
||||
{
|
||||
QueryDispatcher.QueryDispatcher.Dispatch(query);
|
||||
}
|
||||
|
||||
public static List<PluginPair> AllPlugins
|
||||
{
|
||||
get
|
||||
@@ -74,11 +86,11 @@ namespace Wox.Core.Plugin
|
||||
}
|
||||
}
|
||||
|
||||
public static bool HitThirdpartyKeyword(Query query)
|
||||
public static bool IsUserPluginQuery(Query query)
|
||||
{
|
||||
if (string.IsNullOrEmpty(query.ActionName)) return false;
|
||||
|
||||
return plugins.Any(o => o.Metadata.PluginType == PluginType.ThirdParty && o.Metadata.ActionKeyword == query.ActionName);
|
||||
return plugins.Any(o => o.Metadata.PluginType == PluginType.User && o.Metadata.ActionKeyword == query.ActionName);
|
||||
}
|
||||
|
||||
public static void ActivatePluginDebugger(string path)
|
||||
|
||||
7
Wox.Core/Plugin/QueryDispatcher/IQueryDispatcher.cs
Normal file
7
Wox.Core/Plugin/QueryDispatcher/IQueryDispatcher.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace Wox.Core.Plugin.QueryDispatcher
|
||||
{
|
||||
internal interface IQueryDispatcher
|
||||
{
|
||||
void Dispatch(Wox.Plugin.Query query);
|
||||
}
|
||||
}
|
||||
21
Wox.Core/Plugin/QueryDispatcher/QueryDispatcher.cs
Normal file
21
Wox.Core/Plugin/QueryDispatcher/QueryDispatcher.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
namespace Wox.Core.Plugin.QueryDispatcher
|
||||
{
|
||||
internal static class QueryDispatcher
|
||||
{
|
||||
private static IQueryDispatcher pluginCmd = new UserPluginQueryDispatcher();
|
||||
private static IQueryDispatcher systemCmd = new SystemPluginQueryDispatcher();
|
||||
|
||||
public static void Dispatch(Wox.Plugin.Query query)
|
||||
{
|
||||
if (PluginManager.IsUserPluginQuery(query))
|
||||
{
|
||||
pluginCmd.Dispatch(query);
|
||||
}
|
||||
else
|
||||
{
|
||||
systemCmd.Dispatch(query);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using Wox.Core.Plugin;
|
||||
using Wox.Infrastructure.Storage.UserSettings;
|
||||
using Wox.Plugin;
|
||||
using Wox.Plugin.SystemPlugins;
|
||||
|
||||
namespace Wox.Commands
|
||||
namespace Wox.Core.Plugin.QueryDispatcher
|
||||
{
|
||||
public class SystemCommand : BaseCommand
|
||||
public class SystemPluginQueryDispatcher : IQueryDispatcher
|
||||
{
|
||||
private IEnumerable<PluginPair> allSytemPlugins = PluginManager.AllPlugins.Where(o => o.Metadata.PluginType == PluginType.System);
|
||||
|
||||
public override void Dispatch(Query query)
|
||||
public void Dispatch(Query query)
|
||||
{
|
||||
var queryPlugins = allSytemPlugins;
|
||||
if (UserSettingStorage.Instance.WebSearches.Exists(o => o.ActionWord == query.ActionName && o.Enabled))
|
||||
@@ -34,7 +31,7 @@ namespace Wox.Commands
|
||||
List<Result> results = pair1.Plugin.Query(query);
|
||||
results.ForEach(o => { o.AutoAjustScore = true; });
|
||||
|
||||
App.Window.PushResults(query, pair1.Metadata, results);
|
||||
PluginManager.API.PushResults(query, pair1.Metadata, results);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -2,26 +2,24 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Wox.Core.Plugin;
|
||||
using Wox.Helper;
|
||||
using Wox.Infrastructure.Logger;
|
||||
using Wox.Infrastructure.Storage.UserSettings;
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Wox.Commands
|
||||
namespace Wox.Core.Plugin.QueryDispatcher
|
||||
{
|
||||
public class PluginCommand : BaseCommand
|
||||
public class UserPluginQueryDispatcher : IQueryDispatcher
|
||||
{
|
||||
public override void Dispatch(Query query)
|
||||
public void Dispatch(Query query)
|
||||
{
|
||||
PluginPair thirdPlugin = PluginManager.AllPlugins.FirstOrDefault(o => o.Metadata.ActionKeyword == query.ActionName);
|
||||
if (thirdPlugin != null && !string.IsNullOrEmpty(thirdPlugin.Metadata.ActionKeyword))
|
||||
PluginPair userPlugin = PluginManager.AllPlugins.FirstOrDefault(o => o.Metadata.ActionKeyword == query.ActionName);
|
||||
if (userPlugin != null && !string.IsNullOrEmpty(userPlugin.Metadata.ActionKeyword))
|
||||
{
|
||||
var customizedPluginConfig = UserSettingStorage.Instance.CustomizedPluginConfigs.FirstOrDefault(o => o.ID == thirdPlugin.Metadata.ID);
|
||||
var customizedPluginConfig = UserSettingStorage.Instance.CustomizedPluginConfigs.FirstOrDefault(o => o.ID == userPlugin.Metadata.ID);
|
||||
if (customizedPluginConfig != null && customizedPluginConfig.Disabled)
|
||||
{
|
||||
//need to stop the loading animation
|
||||
UpdateResultView(null);
|
||||
PluginManager.API.StopLoadingBar();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -29,12 +27,12 @@ namespace Wox.Commands
|
||||
{
|
||||
try
|
||||
{
|
||||
List<Result> results = thirdPlugin.Plugin.Query(query) ?? new List<Result>();
|
||||
App.Window.PushResults(query,thirdPlugin.Metadata,results);
|
||||
List<Result> results = userPlugin.Plugin.Query(query) ?? new List<Result>();
|
||||
PluginManager.API.PushResults(query,userPlugin.Metadata,results);
|
||||
}
|
||||
catch (Exception queryException)
|
||||
{
|
||||
Log.Error(string.Format("Plugin {0} query failed: {1}", thirdPlugin.Metadata.Name,
|
||||
Log.Error(string.Format("Plugin {0} query failed: {1}", userPlugin.Metadata.Name,
|
||||
queryException.Message));
|
||||
#if (DEBUG)
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
What does Wox.Core do?
|
||||
|
||||
* Handle Query
|
||||
* Loading Plugins
|
||||
* Loading Plugins (including system plugin and user plugin)
|
||||
@@ -18,7 +18,7 @@
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<OutputPath>..\Output\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
@@ -38,12 +38,17 @@
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Plugin\QueryDispatcher\IQueryDispatcher.cs" />
|
||||
<Compile Include="Plugin\QueryDispatcher\QueryDispatcher.cs" />
|
||||
<Compile Include="Plugin\QueryDispatcher\UserPluginQueryDispatcher.cs" />
|
||||
<Compile Include="Plugin\QueryDispatcher\SystemPluginQueryDispatcher.cs" />
|
||||
<Compile Include="Plugin\JsonRPCPlugin.cs" />
|
||||
<Compile Include="Plugin\JsonRPCPluginLoader.cs" />
|
||||
<Compile Include="Plugin\CSharpPluginLoader.cs" />
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Wox.Infrastructure
|
||||
{
|
||||
public static class ChineseToPinYin
|
||||
{
|
||||
[Obsolete]
|
||||
public static string ToPinYin(string txt)
|
||||
{
|
||||
return txt.Unidecode();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -67,21 +67,18 @@
|
||||
<Compile Include="Storage\JsonStrorage.cs" />
|
||||
<Compile Include="Storage\UserSettings\CustomizedPluginConfig.cs" />
|
||||
<Compile Include="Storage\UserSettings\FolderLink.cs" />
|
||||
<Compile Include="Storage\UserSettings\PluginHotkey.cs" />
|
||||
<Compile Include="Storage\UserSettings\ProgramSource.cs" />
|
||||
<Compile Include="Storage\UserSettings\UserSettingStorage.cs" />
|
||||
<Compile Include="Storage\UserSettings\WebSearch.cs" />
|
||||
<Compile Include="Timeit.cs" />
|
||||
<Compile Include="Unidecoder.Characters.cs" />
|
||||
<Compile Include="ChineseToPinYin.cs" />
|
||||
<Compile Include="Http\HttpRequest.cs" />
|
||||
<Compile Include="Storage\BaseStorage.cs" />
|
||||
<Compile Include="FuzzyMatcher.cs" />
|
||||
<Compile Include="Hotkey\GlobalHotkey.cs" />
|
||||
<Compile Include="Hotkey\HotkeyModel.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Storage\UserSelectedRecordStorage.cs" />
|
||||
<Compile Include="Storage\UserSettings\UserSettingStorage.cs" />
|
||||
<Compile Include="Storage\UserSettings\PluginHotkey.cs" />
|
||||
<Compile Include="Storage\UserSettings\ProgramSource.cs" />
|
||||
<Compile Include="Storage\UserSettings\WebSearch.cs" />
|
||||
<Compile Include="StringEmptyConverter.cs" />
|
||||
<Compile Include="Unidecoder.cs" />
|
||||
<Compile Include="WindowsShellRun.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:infrastructure="clr-namespace:Wox.Infrastructure;assembly=Wox.Infrastructure"
|
||||
xmlns:program="clr-namespace:Wox.Plugin.SystemPlugins.Program"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300" d:DesignWidth="600">
|
||||
|
||||
@@ -26,7 +27,7 @@
|
||||
<GridViewColumn Header="Location" Width="400">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Location, ConverterParameter=(null), Converter={infrastructure:StringEmptyConverter}}"/>
|
||||
<TextBlock Text="{Binding Location, ConverterParameter=(null), Converter={program:StringEmptyConverter}}"/>
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Markup;
|
||||
|
||||
namespace Wox.Infrastructure
|
||||
namespace Wox.Plugin.SystemPlugins.Program
|
||||
{
|
||||
public class StringEmptyConverter : MarkupExtension, IValueConverter
|
||||
{
|
||||
@@ -8,7 +8,7 @@ using Wox.Infrastructure.Storage.UserSettings;
|
||||
|
||||
namespace Wox.Plugin.SystemPlugins
|
||||
{
|
||||
public class ThirdpartyPluginIndicator : BaseSystemPlugin
|
||||
public class UserPluginIndicator : BaseSystemPlugin
|
||||
{
|
||||
private List<PluginPair> allPlugins = new List<PluginPair>();
|
||||
private PluginInitContext context;
|
||||
@@ -86,6 +86,7 @@
|
||||
<Compile Include="Program\ProgramSuffixes.xaml.cs">
|
||||
<DependentUpon>ProgramSuffixes.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Program\StringEmptyConverter.cs" />
|
||||
<Compile Include="SuggestionSources\Baidu.cs" />
|
||||
<Compile Include="SuggestionSources\SuggestionSourceFactory.cs" />
|
||||
<Compile Include="Sys\SysSettings.xaml.cs">
|
||||
@@ -102,7 +103,7 @@
|
||||
<Compile Include="Program\Programs.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Sys\Sys.cs" />
|
||||
<Compile Include="ThirdpartyPluginIndicator.cs" />
|
||||
<Compile Include="UserPluginIndicator.cs" />
|
||||
<Compile Include="SuggestionSources\Google.cs" />
|
||||
<Compile Include="SuggestionSources\ISuggestionSource.cs" />
|
||||
<Compile Include="WebSearch\WebSearchSetting.xaml.cs">
|
||||
|
||||
@@ -6,7 +6,12 @@ namespace Wox.Plugin
|
||||
{
|
||||
public interface IPublicAPI
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Push result to query window
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="plugin"></param>
|
||||
/// <param name="results"></param>
|
||||
void PushResults(Query query,PluginMetadata plugin, List<Result> results);
|
||||
|
||||
bool ShellRun(string cmd, bool runAsAdministrator = false);
|
||||
|
||||
@@ -8,6 +8,6 @@ namespace Wox.Plugin
|
||||
public enum PluginType
|
||||
{
|
||||
System,
|
||||
ThirdParty
|
||||
User
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Wox.CommandArgs
|
||||
|
||||
public void Execute(IList<string> args)
|
||||
{
|
||||
PluginManager.Init();
|
||||
PluginManager.Init(App.Window);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Wox.Commands
|
||||
{
|
||||
public abstract class BaseCommand
|
||||
{
|
||||
public abstract void Dispatch(Query query);
|
||||
|
||||
protected void UpdateResultView(List<Result> results)
|
||||
{
|
||||
App.Window.OnUpdateResultView(results);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Wox.Core.Plugin;
|
||||
using Wox.Helper;
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Wox.Commands
|
||||
{
|
||||
internal static class CommandFactory
|
||||
{
|
||||
private static PluginCommand pluginCmd = new PluginCommand();
|
||||
private static SystemCommand systemCmd = new SystemCommand();
|
||||
|
||||
public static void DispatchCommand(Query query)
|
||||
{
|
||||
if (PluginManager.HitThirdpartyKeyword(query))
|
||||
{
|
||||
pluginCmd.Dispatch(query);
|
||||
}
|
||||
else
|
||||
{
|
||||
systemCmd.Dispatch(query);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -116,7 +116,7 @@ namespace Wox.Helper
|
||||
try
|
||||
{
|
||||
metadata = JsonConvert.DeserializeObject<PluginMetadata>(File.ReadAllText(configPath));
|
||||
metadata.PluginType = PluginType.ThirdParty;
|
||||
metadata.PluginType = PluginType.User;
|
||||
metadata.PluginDirectory = pluginDirectory;
|
||||
}
|
||||
catch (Exception)
|
||||
|
||||
@@ -9,8 +9,8 @@ namespace Wox.ImageLoader
|
||||
[Serializable]
|
||||
public class ImageCacheStroage : BinaryStorage<ImageCacheStroage>
|
||||
{
|
||||
public int counter = 0;
|
||||
public const int maxCached = 200;
|
||||
private int counter = 0;
|
||||
private const int maxCached = 200;
|
||||
public Dictionary<string, int> TopUsedImages = new Dictionary<string, int>();
|
||||
|
||||
protected override string ConfigName
|
||||
|
||||
@@ -14,7 +14,6 @@ using WindowsInput;
|
||||
using WindowsInput.Native;
|
||||
using NHotkey;
|
||||
using NHotkey.Wpf;
|
||||
using Wox.Commands;
|
||||
using Wox.Core.Plugin;
|
||||
using Wox.Helper;
|
||||
using Wox.Infrastructure;
|
||||
@@ -22,6 +21,7 @@ using Wox.Infrastructure.Hotkey;
|
||||
using Wox.Infrastructure.Storage;
|
||||
using Wox.Infrastructure.Storage.UserSettings;
|
||||
using Wox.Plugin;
|
||||
using Wox.Storage;
|
||||
using Wox.Update;
|
||||
using Application = System.Windows.Application;
|
||||
using Brushes = System.Windows.Media.Brushes;
|
||||
@@ -127,7 +127,7 @@ namespace Wox
|
||||
|
||||
public void ReloadPlugins()
|
||||
{
|
||||
Dispatcher.Invoke(new Action(PluginManager.Init));
|
||||
Dispatcher.Invoke(new Action(()=> PluginManager.Init(this)));
|
||||
}
|
||||
|
||||
public List<PluginPair> GetAllPlugins()
|
||||
@@ -192,7 +192,7 @@ namespace Wox
|
||||
ThreadPool.QueueUserWorkItem(o =>
|
||||
{
|
||||
Thread.Sleep(50);
|
||||
PluginManager.Init();
|
||||
PluginManager.Init(this);
|
||||
});
|
||||
ThreadPool.QueueUserWorkItem(o =>
|
||||
{
|
||||
@@ -357,9 +357,9 @@ namespace Wox
|
||||
}, TimeSpan.FromMilliseconds(100), null);
|
||||
queryHasReturn = false;
|
||||
var q = new Query(lastQuery);
|
||||
CommandFactory.DispatchCommand(q);
|
||||
PluginManager.Query(q);
|
||||
BackToResultMode();
|
||||
if (PluginManager.HitThirdpartyKeyword(q))
|
||||
if (PluginManager.IsUserPluginQuery(q))
|
||||
{
|
||||
Dispatcher.DelayInvoke("ShowProgressbar", originQuery =>
|
||||
{
|
||||
|
||||
@@ -195,7 +195,7 @@ namespace Wox
|
||||
new CollectionContainer
|
||||
{
|
||||
Collection =
|
||||
PluginManager.AllPlugins.Where(o => o.Metadata.PluginType == PluginType.ThirdParty)
|
||||
PluginManager.AllPlugins.Where(o => o.Metadata.PluginType == PluginType.User)
|
||||
}
|
||||
};
|
||||
lbPlugins.ItemsSource = plugins;
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using Wox.Infrastructure.Storage;
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Wox.Infrastructure.Storage
|
||||
namespace Wox.Storage
|
||||
{
|
||||
public class UserSelectedRecordStorage : JsonStrorage<UserSelectedRecordStorage>
|
||||
{
|
||||
@@ -105,6 +105,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ImageLoader\ImageCacheStroage.cs" />
|
||||
<Compile Include="Storage\UserSelectedRecordStorage.cs" />
|
||||
<Compile Include="Update\NewVersionWindow.xaml.cs">
|
||||
<DependentUpon>NewVersionWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -124,10 +125,6 @@
|
||||
<Compile Include="CommandArgs\PluginDebuggerCommandArg.cs" />
|
||||
<Compile Include="CommandArgs\QueryCommandArg.cs" />
|
||||
<Compile Include="CommandArgs\ReloadPluginCommandArg.cs" />
|
||||
<Compile Include="Commands\BaseCommand.cs" />
|
||||
<Compile Include="Commands\CommandFactory.cs" />
|
||||
<Compile Include="Commands\PluginCommand.cs" />
|
||||
<Compile Include="Commands\SystemCommand.cs" />
|
||||
<Compile Include="Converters\AsyncConverter.cs" />
|
||||
<Compile Include="Converters\ConvertorBase.cs" />
|
||||
<Compile Include="Helper\DataWebRequestFactory.cs" />
|
||||
|
||||
Reference in New Issue
Block a user