mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
Allow drag drop to install wox plugin.
This commit is contained in:
@@ -90,7 +90,6 @@ namespace Wox {
|
||||
}
|
||||
PluginInstaller.Install(path);
|
||||
Environment.Exit(0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.Args.Length > 0 && e.Args[0].ToLower() == "plugindebugger") {
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
Deactivated="MainWindow_OnDeactivated"
|
||||
WindowStyle="None"
|
||||
WindowStartupLocation="Manual"
|
||||
Drop="MainWindow_OnDrop"
|
||||
AllowDrop="True"
|
||||
ShowInTaskbar="False"
|
||||
Style="{DynamicResource WindowStyle}"
|
||||
Icon="Images\app.png"
|
||||
@@ -18,7 +20,7 @@
|
||||
</Window.Resources>
|
||||
<Border Style="{DynamicResource WindowBorderStyle}" MouseDown="Border_OnMouseDown">
|
||||
<StackPanel Orientation="Vertical">
|
||||
<TextBox Style="{DynamicResource QueryBoxStyle}" Grid.Row="0" x:Name="tbQuery" PreviewKeyDown="TbQuery_OnPreviewKeyDown" TextChanged="TextBoxBase_OnTextChanged" />
|
||||
<TextBox Style="{DynamicResource QueryBoxStyle}" PreviewDragOver="TbQuery_OnPreviewDragOver" AllowDrop="True" Grid.Row="0" x:Name="tbQuery" PreviewKeyDown="TbQuery_OnPreviewKeyDown" TextChanged="TextBoxBase_OnTextChanged" />
|
||||
<Line Style="{DynamicResource PendingLineStyle}" x:Name="progressBar" Y1="0" Y2="0" X2="100" Grid.Row="1" Height="2" StrokeThickness="1"></Line>
|
||||
<wox:ResultPanel x:Name="resultCtrl" Grid.Row="2"/>
|
||||
</StackPanel>
|
||||
|
||||
@@ -24,6 +24,7 @@ using Application = System.Windows.Application;
|
||||
using Brushes = System.Windows.Media.Brushes;
|
||||
using Color = System.Windows.Media.Color;
|
||||
using ContextMenu = System.Windows.Forms.ContextMenu;
|
||||
using DragEventArgs = System.Windows.DragEventArgs;
|
||||
using FontFamily = System.Windows.Media.FontFamily;
|
||||
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
|
||||
using MenuItem = System.Windows.Forms.MenuItem;
|
||||
@@ -39,6 +40,10 @@ namespace Wox {
|
||||
|
||||
#region Properties
|
||||
|
||||
private static readonly object locker = new object();
|
||||
public static bool initialized = false;
|
||||
|
||||
private static readonly List<Result> waitShowResultList = new List<Result>();
|
||||
private readonly GlobalHotkey globalHotkey = new GlobalHotkey();
|
||||
private readonly KeyboardSimulator keyboardSimulator = new KeyboardSimulator(new InputSimulator());
|
||||
private readonly Storyboard progressBarStoryboard = new Storyboard();
|
||||
@@ -454,16 +459,25 @@ namespace Wox {
|
||||
|
||||
queryHasReturn = true;
|
||||
progressBar.Dispatcher.Invoke(new Action(StopProgress));
|
||||
if (list.Count > 0) {
|
||||
list.ForEach(
|
||||
o => {
|
||||
if (o.AutoAjustScore) o.Score += UserSelectedRecordStorage.Instance.GetSelectedCount(o);
|
||||
});
|
||||
Dispatcher.DelayInvoke("ShowResult", k => resultCtrl.Dispatcher.Invoke(new Action(() => {
|
||||
List<Result> results = list.Where(o => o.OriginQuery != null && o.OriginQuery.RawQuery == lastQuery).ToList();
|
||||
resultCtrl.AddResults(results);
|
||||
})), TimeSpan.FromMilliseconds(isCMDMode ? 0 : 50));
|
||||
}
|
||||
if (list.Count > 0)
|
||||
{
|
||||
//todo:this should be opened to users, it's their choice to use it or not in their workflows
|
||||
list.ForEach(
|
||||
o =>
|
||||
{
|
||||
if (o.AutoAjustScore) o.Score += UserSelectedRecordStorage.Instance.GetSelectedCount(o);
|
||||
});
|
||||
lock (locker)
|
||||
{
|
||||
waitShowResultList.AddRange(list);
|
||||
}
|
||||
Dispatcher.DelayInvoke("ShowResult", k => resultCtrl.Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
List<Result> l = waitShowResultList.Where(o => o.OriginQuery != null && o.OriginQuery.RawQuery == lastQuery).ToList();
|
||||
waitShowResultList.Clear();
|
||||
resultCtrl.AddResults(l);
|
||||
})), TimeSpan.FromMilliseconds(isCMDMode ? 0 : 50));
|
||||
}
|
||||
}
|
||||
|
||||
public void SetTheme(string themeName) {
|
||||
@@ -514,5 +528,19 @@ namespace Wox {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void MainWindow_OnDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(System.Windows.DataFormats.FileDrop))
|
||||
{
|
||||
// Note that you can have more than one file.
|
||||
string[] files = (string[])e.Data.GetData(System.Windows.DataFormats.FileDrop);
|
||||
PluginInstaller.Install(files[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private void TbQuery_OnPreviewDragOver(object sender, DragEventArgs e)
|
||||
{
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user