mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-15 19:27:56 +01:00
Add system commands
This commit is contained in:
31
WinAlfred/Commands/CommandDispatcher.cs
Normal file
31
WinAlfred/Commands/CommandDispatcher.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using WinAlfred.Helper;
|
||||
using WinAlfred.Plugin;
|
||||
|
||||
namespace WinAlfred.Commands
|
||||
{
|
||||
public class CommandDispatcher
|
||||
{
|
||||
private PluginCommand pluginCmd = new PluginCommand();
|
||||
private SystemCommand systemCmd = new SystemCommand();
|
||||
|
||||
//public delegate void resultUpdateDelegate(List<Result> results);
|
||||
|
||||
//public event resultUpdateDelegate OnResultUpdateEvent;
|
||||
|
||||
//protected virtual void OnOnResultUpdateEvent(List<Result> list)
|
||||
//{
|
||||
// resultUpdateDelegate handler = OnResultUpdateEvent;
|
||||
// if (handler != null) handler(list);
|
||||
//}
|
||||
|
||||
public void DispatchCommand(Query query)
|
||||
{
|
||||
systemCmd.Dispatch(query);
|
||||
pluginCmd.Dispatch(query);
|
||||
}
|
||||
}
|
||||
}
|
||||
45
WinAlfred/Commands/PluginCommand.cs
Normal file
45
WinAlfred/Commands/PluginCommand.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using WinAlfred.Helper;
|
||||
using WinAlfred.Plugin;
|
||||
using WinAlfred.PluginLoader;
|
||||
|
||||
namespace WinAlfred.Commands
|
||||
{
|
||||
public class PluginCommand
|
||||
{
|
||||
public void Dispatch(Query q)
|
||||
{
|
||||
//ThreadPool.QueueUserWorkItem(state =>
|
||||
//{
|
||||
foreach (PluginPair pair in Plugins.AllPlugins)
|
||||
{
|
||||
if (pair.Metadata.ActionKeyword == q.ActionName)
|
||||
{
|
||||
try
|
||||
{
|
||||
pair.Plugin.Query(q).ForEach(o => o.PluginDirectory = pair.Metadata.PluginDirecotry);
|
||||
}
|
||||
catch (Exception queryException)
|
||||
{
|
||||
Log.Error(string.Format("Plugin {0} query failed: {1}", pair.Metadata.Name,
|
||||
queryException.Message));
|
||||
#if (DEBUG)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
resultCtrl.Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
resultCtrl.AddResults(results.OrderByDescending(o => o.Score).ToList());
|
||||
resultCtrl.SelectFirst();
|
||||
}));
|
||||
//});
|
||||
}
|
||||
}
|
||||
}
|
||||
16
WinAlfred/Commands/SystemCommand.cs
Normal file
16
WinAlfred/Commands/SystemCommand.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using WinAlfred.Plugin;
|
||||
|
||||
namespace WinAlfred.Commands
|
||||
{
|
||||
public class SystemCommand
|
||||
{
|
||||
public void Dispatch(Query query)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user