Merge branch 'V1.2.0' of https://github.com/qianlifeng/Wox into V1.2.0

This commit is contained in:
qianlifeng
2015-02-03 12:29:26 +08:00
10 changed files with 199 additions and 157 deletions

View File

@@ -34,6 +34,7 @@ using MenuItem = System.Windows.Forms.MenuItem;
using MessageBox = System.Windows.MessageBox;
using ToolTip = System.Windows.Controls.ToolTip;
using Wox.Infrastructure.Logger;
using IDataObject = System.Windows.IDataObject;
namespace Wox
{
@@ -135,6 +136,7 @@ namespace Wox
public event WoxGlobalKeyboardEventHandler GlobalKeyboardEvent;
public event AfterWoxQueryEventHandler AfterWoxQueryEvent;
public event AfterWoxQueryEventHandler BeforeWoxQueryEvent;
public event ResultItemDropEventHandler ResultItemDropEvent;
public void PushResults(Query query, PluginMetadata plugin, List<Result> results)
{
@@ -168,6 +170,7 @@ namespace Wox
progressBar.ToolTip = toolTip;
InitialTray();
pnlResult.LeftMouseClickEvent += SelectResult;
pnlResult.ItemDropEvent += pnlResult_ItemDropEvent;
pnlContextMenu.LeftMouseClickEvent += SelectResult;
pnlResult.RightMouseClickEvent += pnlResult_RightMouseClickEvent;
@@ -192,6 +195,19 @@ namespace Wox
});
}
void pnlResult_ItemDropEvent(Result result, IDataObject dropDataObject)
{
if (ResultItemDropEvent != null)
{
PluginPair pluginPair = PluginManager.AllPlugins.FirstOrDefault(o => o.Plugin == ResultItemDropEvent.Target);
if (pluginPair != null)
{
//todo:
ResultItemDropEvent(result, dropDataObject);
}
}
}
private bool KListener_hookedKeyboardCallback(KeyEvent keyevent, int vkcode, SpecialKeyState state)
{
if (GlobalKeyboardEvent != null)

View File

@@ -7,7 +7,7 @@
mc:Ignorable="d" d:DesignWidth="100" d:DesignHeight="100">
<!-- set max height of listbox to allow 6 results showed at once -->
<ListBox x:Name="lbResults" MaxHeight="300" HorizontalContentAlignment="Stretch" PreviewMouseDown="LbResults_OnPreviewMouseDown" Style="{DynamicResource BaseListboxStyle}" SelectionChanged ="lbResults_SelectionChanged" Focusable="False" KeyboardNavigation.DirectionalNavigation="Cycle" SelectionMode="Single" VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Standard">
<ListBox x:Name="lbResults" MaxHeight="300" AllowDrop="True" Drop="ListBoxItem_OnDrop" HorizontalContentAlignment="Stretch" PreviewMouseDown="LbResults_OnPreviewMouseDown" Style="{DynamicResource BaseListboxStyle}" SelectionChanged ="lbResults_SelectionChanged" Focusable="False" KeyboardNavigation.DirectionalNavigation="Cycle" SelectionMode="Single" VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Standard">
<ListBox.Resources>
<!--SelectedItem with focus-->
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="{DynamicResource ItemSelectedBackgroundColor}"/>

View File

@@ -16,6 +16,7 @@ namespace Wox
{
public event Action<Result> LeftMouseClickEvent;
public event Action<Result> RightMouseClickEvent;
public event Action<Result,IDataObject> ItemDropEvent;
protected virtual void OnRightMouseClick(Result result)
{
@@ -208,5 +209,20 @@ namespace Wox
}
Select(index);
}
private void ListBoxItem_OnDrop(object sender, DragEventArgs e)
{
var item = ItemsControl.ContainerFromElement(lbResults, e.OriginalSource as DependencyObject) as ListBoxItem;
if (item != null)
{
OnItemDropEvent(item.DataContext as Result,e.Data);
}
}
protected virtual void OnItemDropEvent(Result obj, IDataObject data)
{
var handler = ItemDropEvent;
if (handler != null) handler(obj,data);
}
}
}