Add drop event.

This commit is contained in:
qianlifeng 2015-02-03 18:32:16 +08:00
parent 38948053cc
commit 5d9a94466a
8 changed files with 30 additions and 25 deletions

View file

@ -23,6 +23,7 @@ namespace Wox.Plugin.Folder
{
this.context = context;
this.context.API.BackKeyDownEvent += ApiBackKeyDownEvent;
this.context.API.ResultItemDropEvent += API_ResultItemDropEvent;
InitialDriverList();
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)
{
string query = e.Query;

View file

@ -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()

View file

@ -8,6 +8,7 @@ using System.Windows.Forms;
using Newtonsoft.Json;
using Wox.Infrastructure.Logger;
using Wox.Plugin;
using Wox.Core.Exception;
namespace Wox.Core.Plugin
{
@ -83,7 +84,7 @@ namespace Wox.Core.Plugin
private void ExecuteWoxAPI(string method, object[] parameters)
{
MethodInfo methodInfo = PluginManager.API.GetType().GetMethod(method);
if (methodInfo != null)
if (methodInfo != null)
{
try
{
@ -141,8 +142,7 @@ namespace Wox.Core.Plugin
string error = errorReader.ReadToEnd();
if (!string.IsNullOrEmpty(error))
{
//todo:
// ErrorReporting.TryShowErrorMessageBox(error, new WoxJsonRPCException(error));
throw 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;
}

View file

@ -19,6 +19,7 @@ using Wox.Core.UI;
using Wox.Core.Updater;
using Wox.Core.UserSettings;
using Wox.Infrastructure.Http;
using Wox.Infrastructure.Logger;
namespace Wox.CrashReporter
{
@ -53,15 +54,12 @@ namespace Wox.CrashReporter
private void SendReport()
{
Hide();
string error = string.Format("{{\"data\":{0}}}", ExceptionFormatter.FormatExcpetion(exception));
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"));
}
else
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("reportWindow_report_failed"));
Log.Warn("sending crash report failed: " + response);
}
Dispatcher.Invoke(new Action(Close));
}

View file

@ -10,7 +10,7 @@ namespace Wox.Plugin
public delegate void WoxKeyDownEventHandler(WoxKeyDownEventArgs 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>
/// Global keyboard events

View file

@ -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);
if (pluginPair != null)
foreach (var delegateHandler in ResultItemDropEvent.GetInvocationList())
{
//todo:
ResultItemDropEvent(result, dropDataObject);
if (delegateHandler.Target == pluginPair.Plugin)
{
delegateHandler.DynamicInvoke(result, dropDataObject, args);
}
}
}
}

View file

@ -16,7 +16,7 @@ namespace Wox
{
public event Action<Result> LeftMouseClickEvent;
public event Action<Result> RightMouseClickEvent;
public event Action<Result,IDataObject> ItemDropEvent;
public event Action<Result, IDataObject, DragEventArgs> ItemDropEvent;
protected virtual void OnRightMouseClick(Result result)
{
@ -215,14 +215,14 @@ namespace Wox
var item = ItemsControl.ContainerFromElement(lbResults, e.OriginalSource as DependencyObject) as ListBoxItem;
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;
if (handler != null) handler(obj,data);
if (handler != null) handler(obj, data, e);
}
}
}

View file

@ -15,7 +15,6 @@ build:
after_test:
- ps: .\deploy\nuget\pack.ps1
- cmd: .\deploy\UpdateGenerator\build.bat
#- cmd: .\deploy\Cleanup.bat
deploy:
provider: NuGet