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 = 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;

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() public static void IndexPrograms()

View File

@@ -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
{ {
@@ -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;
} }

View File

@@ -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));
} }

View File

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

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

View File

@@ -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);
} }
} }
} }

View File

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