mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 19:26:39 +02:00
Mouse select support & Code refactoring
This commit is contained in:
@@ -8,24 +8,11 @@ namespace WinAlfred.Commands
|
||||
{
|
||||
public abstract class BaseCommand
|
||||
{
|
||||
private MainWindow window;
|
||||
|
||||
public void Dispatch(Query query)
|
||||
{
|
||||
Dispatch(query, true);
|
||||
}
|
||||
|
||||
public abstract void Dispatch(Query query, bool updateView);
|
||||
|
||||
//TODO:Ugly, we should subscribe events here, instead of just use usercontrol as the parameter
|
||||
protected BaseCommand(MainWindow window)
|
||||
{
|
||||
this.window = window;
|
||||
}
|
||||
public abstract void Dispatch(Query query, bool updateView = true);
|
||||
|
||||
protected void UpdateResultView(List<Result> results)
|
||||
{
|
||||
window.OnUpdateResultView(results);
|
||||
App.Window.OnUpdateResultView(results);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using WinAlfred.Helper;
|
||||
using WinAlfred.Plugin;
|
||||
|
||||
namespace WinAlfred.Commands
|
||||
{
|
||||
public class Command
|
||||
{
|
||||
private PluginCommand pluginCmd;
|
||||
private SystemCommand systemCmd;
|
||||
|
||||
public Command(MainWindow window)
|
||||
{
|
||||
pluginCmd = new PluginCommand(window);
|
||||
systemCmd = new SystemCommand(window);
|
||||
}
|
||||
|
||||
public void DispatchCommand(Query query)
|
||||
{
|
||||
systemCmd.Dispatch(query);
|
||||
pluginCmd.Dispatch(query);
|
||||
}
|
||||
|
||||
public void DispatchCommand(Query query,bool updateView)
|
||||
{
|
||||
systemCmd.Dispatch(query,updateView);
|
||||
pluginCmd.Dispatch(query,updateView);
|
||||
}
|
||||
}
|
||||
}
|
||||
31
WinAlfred/Commands/CommandFactory.cs
Normal file
31
WinAlfred/Commands/CommandFactory.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
|
||||
{
|
||||
internal static class CommandFactory
|
||||
{
|
||||
private static PluginCommand pluginCmd;
|
||||
private static SystemCommand systemCmd;
|
||||
|
||||
public static void DispatchCommand(Query query, bool updateView = true)
|
||||
{
|
||||
//lazy init command instance.
|
||||
if (pluginCmd == null)
|
||||
{
|
||||
pluginCmd = new PluginCommand();
|
||||
}
|
||||
if (systemCmd == null)
|
||||
{
|
||||
systemCmd = new SystemCommand();
|
||||
}
|
||||
|
||||
systemCmd.Dispatch(query,updateView);
|
||||
pluginCmd.Dispatch(query,updateView);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,13 +14,7 @@ namespace WinAlfred.Commands
|
||||
private string currentPythonModulePath = string.Empty;
|
||||
private IntPtr GIL;
|
||||
|
||||
public PluginCommand(MainWindow mainWindow)
|
||||
: base(mainWindow)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void Dispatch(Query q,bool updateView)
|
||||
public override void Dispatch(Query q,bool updateView = true)
|
||||
{
|
||||
PluginPair thirdPlugin = Plugins.AllPlugins.FirstOrDefault(o => o.Metadata.ActionKeyword == q.ActionName);
|
||||
if (thirdPlugin != null && !string.IsNullOrEmpty(thirdPlugin.Metadata.ActionKeyword))
|
||||
|
||||
@@ -12,13 +12,12 @@ namespace WinAlfred.Commands
|
||||
{
|
||||
private List<PluginPair> systemPlugins;
|
||||
|
||||
public SystemCommand(MainWindow window)
|
||||
: base(window)
|
||||
public SystemCommand()
|
||||
{
|
||||
systemPlugins = Plugins.AllPlugins.Where(o => o.Metadata.PluginType == PluginType.System).ToList();
|
||||
}
|
||||
|
||||
public override void Dispatch(Query query,bool updateView)
|
||||
public override void Dispatch(Query query,bool updateView = true)
|
||||
{
|
||||
foreach (PluginPair pair in systemPlugins)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user