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

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@@ -16,7 +16,8 @@ namespace Wox.Plugin.Program.ProgramSources
this.baseDirectory = baseDirectory; this.baseDirectory = baseDirectory;
} }
public FileSystemProgramSource(ProgramSource source):this(source.Location) public FileSystemProgramSource(ProgramSource source)
: this(source.Location)
{ {
this.BonusPoints = source.BonusPoints; this.BonusPoints = source.BonusPoints;
} }
@@ -50,17 +51,9 @@ namespace Wox.Plugin.Program.ProgramSources
GetAppFromDirectory(subDirectory, list); GetAppFromDirectory(subDirectory, list);
} }
} }
catch (UnauthorizedAccessException e) catch (Exception e)
{ {
Log.Warn(string.Format("Can't access to directory {0}", path)); Log.Warn(string.Format("GetAppFromDirectory failed: {0} - {1}", path, e.Message));
}
catch (DirectoryNotFoundException e)
{
Log.Warn(string.Format("Directory {0} doesn't exist", path));
}
catch (PathTooLongException e)
{
Log.Warn(string.Format("File path too long: {0}", e.Message));
} }
} }

View File

@@ -103,6 +103,7 @@ namespace Wox.Plugin.Program
public void Init(PluginInitContext context) public void Init(PluginInitContext context)
{ {
this.context = context; this.context = context;
this.context.API.ResultItemDropEvent += API_ResultItemDropEvent;
using (new Timeit("Preload programs")) using (new Timeit("Preload programs"))
{ {
programs = ProgramCacheStorage.Instance.Programs; programs = ProgramCacheStorage.Instance.Programs;
@@ -114,6 +115,11 @@ namespace Wox.Plugin.Program
} }
} }
void API_ResultItemDropEvent(Result result, IDataObject dropObject)
{
}
public static void IndexPrograms() public static void IndexPrograms()
{ {
lock (lockObject) lock (lockObject)

View File

@@ -85,6 +85,9 @@
<None Include="Images\cmd.png"> <None Include="Images\cmd.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Include="Images\folder.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<Content Include="Languages\en.xaml"> <Content Include="Languages\en.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>

View File

@@ -22,8 +22,8 @@ namespace Wox.Core.Updater
{ {
private static UpdaterManager instance; private static UpdaterManager instance;
private const string VersionCheckURL = "https://api.getwox.com/release/latest/"; private const string VersionCheckURL = "https://api.getwox.com/release/latest/";
//private const string UpdateFeedURL = "http://upgrade.getwox.com/update.xml"; private const string UpdateFeedURL = "http://upgrade.getwox.com/update.xml";
private const string UpdateFeedURL = "http://127.0.0.1:8888/update.xml"; //private const string UpdateFeedURL = "http://127.0.0.1:8888/update.xml";
private static SemanticVersion currentVersion; private static SemanticVersion currentVersion;
public event EventHandler PrepareUpdateReady; public event EventHandler PrepareUpdateReady;

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Windows;
using System.Windows.Input; using System.Windows.Input;
namespace Wox.Plugin namespace Wox.Plugin
@@ -9,6 +10,8 @@ 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);
/// <summary> /// <summary>
/// Global keyboard events /// Global keyboard events
/// </summary> /// </summary>

View File

@@ -119,5 +119,10 @@ namespace Wox.Plugin
/// Fired before wox start to execute a query /// Fired before wox start to execute a query
/// </summary> /// </summary>
event AfterWoxQueryEventHandler BeforeWoxQueryEvent; event AfterWoxQueryEventHandler BeforeWoxQueryEvent;
/// <summary>
/// Fired after drop to result item of current plugin
/// </summary>
event ResultItemDropEventHandler ResultItemDropEvent;
} }
} }

View File

@@ -34,6 +34,7 @@ using MenuItem = System.Windows.Forms.MenuItem;
using MessageBox = System.Windows.MessageBox; using MessageBox = System.Windows.MessageBox;
using ToolTip = System.Windows.Controls.ToolTip; using ToolTip = System.Windows.Controls.ToolTip;
using Wox.Infrastructure.Logger; using Wox.Infrastructure.Logger;
using IDataObject = System.Windows.IDataObject;
namespace Wox namespace Wox
{ {
@@ -135,6 +136,7 @@ namespace Wox
public event WoxGlobalKeyboardEventHandler GlobalKeyboardEvent; public event WoxGlobalKeyboardEventHandler GlobalKeyboardEvent;
public event AfterWoxQueryEventHandler AfterWoxQueryEvent; public event AfterWoxQueryEventHandler AfterWoxQueryEvent;
public event AfterWoxQueryEventHandler BeforeWoxQueryEvent; public event AfterWoxQueryEventHandler BeforeWoxQueryEvent;
public event ResultItemDropEventHandler ResultItemDropEvent;
public void PushResults(Query query, PluginMetadata plugin, List<Result> results) public void PushResults(Query query, PluginMetadata plugin, List<Result> results)
{ {
@@ -168,6 +170,7 @@ namespace Wox
progressBar.ToolTip = toolTip; progressBar.ToolTip = toolTip;
InitialTray(); InitialTray();
pnlResult.LeftMouseClickEvent += SelectResult; pnlResult.LeftMouseClickEvent += SelectResult;
pnlResult.ItemDropEvent += pnlResult_ItemDropEvent;
pnlContextMenu.LeftMouseClickEvent += SelectResult; pnlContextMenu.LeftMouseClickEvent += SelectResult;
pnlResult.RightMouseClickEvent += pnlResult_RightMouseClickEvent; 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) private bool KListener_hookedKeyboardCallback(KeyEvent keyevent, int vkcode, SpecialKeyState state)
{ {
if (GlobalKeyboardEvent != null) if (GlobalKeyboardEvent != null)

View File

@@ -7,7 +7,7 @@
mc:Ignorable="d" d:DesignWidth="100" d:DesignHeight="100"> mc:Ignorable="d" d:DesignWidth="100" d:DesignHeight="100">
<!-- set max height of listbox to allow 6 results showed at once --> <!-- 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> <ListBox.Resources>
<!--SelectedItem with focus--> <!--SelectedItem with focus-->
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="{DynamicResource ItemSelectedBackgroundColor}"/> <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> LeftMouseClickEvent;
public event Action<Result> RightMouseClickEvent; public event Action<Result> RightMouseClickEvent;
public event Action<Result,IDataObject> ItemDropEvent;
protected virtual void OnRightMouseClick(Result result) protected virtual void OnRightMouseClick(Result result)
{ {
@@ -208,5 +209,20 @@ namespace Wox
} }
Select(index); 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);
}
} }
} }