mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-02-24 04:00:02 +01:00
fix issues
This commit is contained in:
@@ -10,7 +10,12 @@ namespace WinAlfred.Commands
|
||||
{
|
||||
private MainWindow window;
|
||||
|
||||
public abstract void Dispatch(Query query);
|
||||
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)
|
||||
|
||||
@@ -23,5 +23,11 @@ namespace WinAlfred.Commands
|
||||
systemCmd.Dispatch(query);
|
||||
pluginCmd.Dispatch(query);
|
||||
}
|
||||
|
||||
public void DispatchCommand(Query query,bool updateView)
|
||||
{
|
||||
systemCmd.Dispatch(query,updateView);
|
||||
pluginCmd.Dispatch(query,updateView);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace WinAlfred.Commands
|
||||
|
||||
}
|
||||
|
||||
public override void Dispatch(Query q)
|
||||
public override void Dispatch(Query q,bool updateView)
|
||||
{
|
||||
PluginPair thirdPlugin = Plugins.AllPlugins.FirstOrDefault(o => o.Metadata.ActionKeyword == q.ActionName);
|
||||
if (thirdPlugin != null && !string.IsNullOrEmpty(thirdPlugin.Metadata.ActionKeyword))
|
||||
@@ -39,7 +39,7 @@ namespace WinAlfred.Commands
|
||||
o.PluginDirectory = thirdPlugin.Metadata.PluginDirecotry;
|
||||
o.OriginQuery = q;
|
||||
});
|
||||
UpdateResultView(r);
|
||||
if(updateView) UpdateResultView(r);
|
||||
}
|
||||
catch (Exception queryException)
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace WinAlfred.Commands
|
||||
systemPlugins = Plugins.AllPlugins.Where(o => o.Metadata.PluginType == PluginType.System).ToList();
|
||||
}
|
||||
|
||||
public override void Dispatch(Query query)
|
||||
public override void Dispatch(Query query,bool updateView)
|
||||
{
|
||||
foreach (PluginPair pair in systemPlugins)
|
||||
{
|
||||
@@ -31,7 +31,7 @@ namespace WinAlfred.Commands
|
||||
result.PluginDirectory = pair1.Metadata.PluginDirecotry;
|
||||
result.OriginQuery = query;
|
||||
}
|
||||
if(results.Count > 0) UpdateResultView(results);
|
||||
if(results.Count > 0 && updateView) UpdateResultView(results);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,19 +7,12 @@ using System.Windows.Controls;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Threading;
|
||||
using Microsoft.Win32;
|
||||
using WinAlfred.Commands;
|
||||
using WinAlfred.Helper;
|
||||
using WinAlfred.Plugin;
|
||||
using WinAlfred.PluginLoader;
|
||||
using DataFormats = System.Windows.DataFormats;
|
||||
using DragDropEffects = System.Windows.DragDropEffects;
|
||||
using DragEventArgs = System.Windows.DragEventArgs;
|
||||
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
|
||||
using MessageBox = System.Windows.MessageBox;
|
||||
using Timer = System.Threading.Timer;
|
||||
|
||||
namespace WinAlfred
|
||||
{
|
||||
@@ -41,6 +34,28 @@ namespace WinAlfred
|
||||
resultCtrl.resultItemChangedEvent += resultCtrl_resultItemChangedEvent;
|
||||
ThreadPool.SetMaxThreads(30, 10);
|
||||
InitProgressbarAnimation();
|
||||
WakeupApp();
|
||||
}
|
||||
|
||||
private void WakeupApp()
|
||||
{
|
||||
//After hide winalfred in the background for a long time. It will become very slow in the next show.
|
||||
//This is caused by the Virtual Mermory Page Mechanisam. So, our solution is execute some codes in every 20min
|
||||
//which may prevent sysetem uninstall memory from RAM to disk.
|
||||
|
||||
System.Timers.Timer t = new System.Timers.Timer(1000 * 30 * 1) { AutoReset = true, Enabled = true };
|
||||
t.Elapsed += (o, e) => Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
if (Visibility != Visibility.Visible)
|
||||
{
|
||||
double oldLeft = Left;
|
||||
Left = 20000;
|
||||
ShowWinAlfred();
|
||||
cmdDispatcher.DispatchCommand(new Query("qq"),false);
|
||||
HideWinAlfred();
|
||||
Left = oldLeft;
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
private void InitProgressbarAnimation()
|
||||
|
||||
Reference in New Issue
Block a user