mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-09 04:37:30 +02:00
Add drop event.
This commit is contained in:
@@ -23,6 +23,7 @@ namespace Wox.Plugin.Folder
|
|||||||
{
|
{
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.context.API.BackKeyDownEvent += ApiBackKeyDownEvent;
|
this.context.API.BackKeyDownEvent += ApiBackKeyDownEvent;
|
||||||
|
this.context.API.ResultItemDropEvent += API_ResultItemDropEvent;
|
||||||
InitialDriverList();
|
InitialDriverList();
|
||||||
if (FolderStorage.Instance.FolderLinks == null)
|
if (FolderStorage.Instance.FolderLinks == null)
|
||||||
{
|
{
|
||||||
@@ -31,6 +32,11 @@ namespace Wox.Plugin.Folder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void API_ResultItemDropEvent(Result result, IDataObject dropObject,DragEventArgs e)
|
||||||
|
{
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
|
||||||
private void ApiBackKeyDownEvent(WoxKeyDownEventArgs e)
|
private void ApiBackKeyDownEvent(WoxKeyDownEventArgs e)
|
||||||
{
|
{
|
||||||
string query = e.Query;
|
string query = e.Query;
|
||||||
|
|||||||
@@ -115,9 +115,9 @@ namespace Wox.Plugin.Program
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void API_ResultItemDropEvent(Result result, IDataObject dropObject)
|
void API_ResultItemDropEvent(Result result, IDataObject dropObject, DragEventArgs args)
|
||||||
{
|
{
|
||||||
|
args.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void IndexPrograms()
|
public static void IndexPrograms()
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ using System.Windows.Forms;
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Wox.Infrastructure.Logger;
|
using Wox.Infrastructure.Logger;
|
||||||
using Wox.Plugin;
|
using Wox.Plugin;
|
||||||
|
using Wox.Core.Exception;
|
||||||
|
|
||||||
namespace Wox.Core.Plugin
|
namespace Wox.Core.Plugin
|
||||||
{
|
{
|
||||||
@@ -83,7 +84,7 @@ namespace Wox.Core.Plugin
|
|||||||
private void ExecuteWoxAPI(string method, object[] parameters)
|
private void ExecuteWoxAPI(string method, object[] parameters)
|
||||||
{
|
{
|
||||||
MethodInfo methodInfo = PluginManager.API.GetType().GetMethod(method);
|
MethodInfo methodInfo = PluginManager.API.GetType().GetMethod(method);
|
||||||
if (methodInfo != null)
|
if (methodInfo != null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -141,8 +142,7 @@ namespace Wox.Core.Plugin
|
|||||||
string error = errorReader.ReadToEnd();
|
string error = errorReader.ReadToEnd();
|
||||||
if (!string.IsNullOrEmpty(error))
|
if (!string.IsNullOrEmpty(error))
|
||||||
{
|
{
|
||||||
//todo:
|
throw new WoxJsonRPCException(error);
|
||||||
// ErrorReporting.TryShowErrorMessageBox(error, new WoxJsonRPCException(error));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -151,9 +151,9 @@ namespace Wox.Core.Plugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch(System.Exception e)
|
||||||
{
|
{
|
||||||
return null;
|
throw new WoxJsonRPCException(e.Message);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ using Wox.Core.UI;
|
|||||||
using Wox.Core.Updater;
|
using Wox.Core.Updater;
|
||||||
using Wox.Core.UserSettings;
|
using Wox.Core.UserSettings;
|
||||||
using Wox.Infrastructure.Http;
|
using Wox.Infrastructure.Http;
|
||||||
|
using Wox.Infrastructure.Logger;
|
||||||
|
|
||||||
namespace Wox.CrashReporter
|
namespace Wox.CrashReporter
|
||||||
{
|
{
|
||||||
@@ -53,15 +54,12 @@ namespace Wox.CrashReporter
|
|||||||
|
|
||||||
private void SendReport()
|
private void SendReport()
|
||||||
{
|
{
|
||||||
|
Hide();
|
||||||
string error = string.Format("{{\"data\":{0}}}", ExceptionFormatter.FormatExcpetion(exception));
|
string error = string.Format("{{\"data\":{0}}}", ExceptionFormatter.FormatExcpetion(exception));
|
||||||
string response = HttpRequest.Post(APIServer.ErrorReportURL, error, HttpProxy.Instance);
|
string response = HttpRequest.Post(APIServer.ErrorReportURL, error, HttpProxy.Instance);
|
||||||
if (response.ToLower() == "ok")
|
if (response.ToLower() != "ok")
|
||||||
{
|
{
|
||||||
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("reportWindow_report_succeed"));
|
Log.Warn("sending crash report failed: " + response);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("reportWindow_report_failed"));
|
|
||||||
}
|
}
|
||||||
Dispatcher.Invoke(new Action(Close));
|
Dispatcher.Invoke(new Action(Close));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace Wox.Plugin
|
|||||||
public delegate void WoxKeyDownEventHandler(WoxKeyDownEventArgs e);
|
public delegate void WoxKeyDownEventHandler(WoxKeyDownEventArgs e);
|
||||||
public delegate void AfterWoxQueryEventHandler(WoxQueryEventArgs e);
|
public delegate void AfterWoxQueryEventHandler(WoxQueryEventArgs e);
|
||||||
|
|
||||||
public delegate void ResultItemDropEventHandler(Result result, IDataObject dropObject);
|
public delegate void ResultItemDropEventHandler(Result result, IDataObject dropObject, DragEventArgs e);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Global keyboard events
|
/// Global keyboard events
|
||||||
|
|||||||
@@ -195,15 +195,17 @@ namespace Wox
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void pnlResult_ItemDropEvent(Result result, IDataObject dropDataObject)
|
void pnlResult_ItemDropEvent(Result result, IDataObject dropDataObject, DragEventArgs args)
|
||||||
{
|
{
|
||||||
if (ResultItemDropEvent != null)
|
PluginPair pluginPair = PluginManager.AllPlugins.FirstOrDefault(o => o.Metadata.ID == result.PluginID);
|
||||||
|
if (ResultItemDropEvent != null && pluginPair != null)
|
||||||
{
|
{
|
||||||
PluginPair pluginPair = PluginManager.AllPlugins.FirstOrDefault(o => o.Plugin == ResultItemDropEvent.Target);
|
foreach (var delegateHandler in ResultItemDropEvent.GetInvocationList())
|
||||||
if (pluginPair != null)
|
|
||||||
{
|
{
|
||||||
//todo:
|
if (delegateHandler.Target == pluginPair.Plugin)
|
||||||
ResultItemDropEvent(result, dropDataObject);
|
{
|
||||||
|
delegateHandler.DynamicInvoke(result, dropDataObject, args);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace Wox
|
|||||||
{
|
{
|
||||||
public event Action<Result> LeftMouseClickEvent;
|
public event Action<Result> LeftMouseClickEvent;
|
||||||
public event Action<Result> RightMouseClickEvent;
|
public event Action<Result> RightMouseClickEvent;
|
||||||
public event Action<Result,IDataObject> ItemDropEvent;
|
public event Action<Result, IDataObject, DragEventArgs> ItemDropEvent;
|
||||||
|
|
||||||
protected virtual void OnRightMouseClick(Result result)
|
protected virtual void OnRightMouseClick(Result result)
|
||||||
{
|
{
|
||||||
@@ -215,14 +215,14 @@ namespace Wox
|
|||||||
var item = ItemsControl.ContainerFromElement(lbResults, e.OriginalSource as DependencyObject) as ListBoxItem;
|
var item = ItemsControl.ContainerFromElement(lbResults, e.OriginalSource as DependencyObject) as ListBoxItem;
|
||||||
if (item != null)
|
if (item != null)
|
||||||
{
|
{
|
||||||
OnItemDropEvent(item.DataContext as Result,e.Data);
|
OnItemDropEvent(item.DataContext as Result, e.Data, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnItemDropEvent(Result obj, IDataObject data)
|
protected virtual void OnItemDropEvent(Result obj, IDataObject data, DragEventArgs e)
|
||||||
{
|
{
|
||||||
var handler = ItemDropEvent;
|
var handler = ItemDropEvent;
|
||||||
if (handler != null) handler(obj,data);
|
if (handler != null) handler(obj, data, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,7 +15,6 @@ build:
|
|||||||
after_test:
|
after_test:
|
||||||
- ps: .\deploy\nuget\pack.ps1
|
- ps: .\deploy\nuget\pack.ps1
|
||||||
- cmd: .\deploy\UpdateGenerator\build.bat
|
- cmd: .\deploy\UpdateGenerator\build.bat
|
||||||
#- cmd: .\deploy\Cleanup.bat
|
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
provider: NuGet
|
provider: NuGet
|
||||||
|
|||||||
Reference in New Issue
Block a user