From 2956789a1e6fb19a7b433f436514a1fd8c1529ac Mon Sep 17 00:00:00 2001 From: qianlifeng Date: Mon, 18 Aug 2014 18:05:18 +0800 Subject: [PATCH] Don't add empty line --- Main.cs | 34 ++-- Wox.Plugin.Clipboard.csproj | 154 +++++++++--------- ...ugin.Clipboard.csproj.FileListAbsolute.txt | 10 ++ 3 files changed, 100 insertions(+), 98 deletions(-) diff --git a/Main.cs b/Main.cs index f09f1ae..e51ce70 100644 --- a/Main.cs +++ b/Main.cs @@ -10,7 +10,7 @@ namespace Wox.Plugin.Clipboard { public class Main : IPlugin { - private const int MaxDataCount = 100; + private const int MaxDataCount = 300; private readonly KeyboardSimulator keyboardSimulator = new KeyboardSimulator(new InputSimulator()); private PluginInitContext context; List dataList = new List(); @@ -18,7 +18,7 @@ public class Main : IPlugin public List Query(Query query) { var results = new List(); - List displayData = new List(); + List displayData; if (query.ActionParameters.Count == 0) { displayData = dataList; @@ -31,29 +31,21 @@ public List Query(Query query) results.AddRange(displayData.Select(o => new Result { - Title = o, + Title = o.Trim(), IcoPath = "Images\\clipboard.png", Action = c => { - if (c.SpecialKeyState.CtrlPressed) + try { - context.ShowCurrentResultItemTooltip(o); - return false; + System.Windows.Forms.Clipboard.SetText(o); + context.API.HideApp(); + keyboardSimulator.ModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_V); + return true; } - else + catch (Exception e) { - try - { - System.Windows.Forms.Clipboard.SetText(o); - context.HideApp(); - keyboardSimulator.ModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_V); - return true; - } - catch(Exception e) - { - context.ShowMsg("Error", e.Message, null); - return false; - } + context.API.ShowMsg("Error", e.Message, null); + return false; } } }).Reverse()); @@ -74,7 +66,7 @@ void ClipboardMonitor_OnClipboardChange(ClipboardFormat format, object data) format == ClipboardFormat.Text || format == ClipboardFormat.UnicodeText) { - if (data != null && !string.IsNullOrEmpty(data.ToString())) + if (data != null && !string.IsNullOrEmpty(data.ToString().Trim())) { if (dataList.Contains(data.ToString())) { @@ -84,7 +76,7 @@ void ClipboardMonitor_OnClipboardChange(ClipboardFormat format, object data) if (dataList.Count > MaxDataCount) { - dataList.Remove(dataList.First()); + dataList.Remove(dataList.Last()); } } } diff --git a/Wox.Plugin.Clipboard.csproj b/Wox.Plugin.Clipboard.csproj index 3aa576f..c42eb00 100644 --- a/Wox.Plugin.Clipboard.csproj +++ b/Wox.Plugin.Clipboard.csproj @@ -1,84 +1,84 @@ - - - - - Debug - AnyCPU - {8C14DC11-2737-4DCB-A121-5D7BDD57FEA2} - Library - Properties - Wox.Plugin.Clipboard - Wox.Plugin.Clipboard - v3.5 - 512 - ..\..\ - true - - - true - full - false - bin\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - ..\..\Output\Release\Plugins\Wox.Plugin.Clipboard\ - TRACE - prompt - 4 - - - - - - - - - - - packages\WindowsInput.0.2.0.0\lib\net20\WindowsInput.dll - - - ..\Wox\Output\Debug\Wox.Plugin.dll - - - - - - - - - - - PreserveNewest - - - - - PreserveNewest - - - - - - - - - - - 这台计算机上缺少此项目引用的 NuGet 程序包。启用“NuGet 程序包还原”可下载这些程序包。有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 - - - + + + + + Debug + AnyCPU + {8C14DC11-2737-4DCB-A121-5D7BDD57FEA2} + Library + Properties + Wox.Plugin.Clipboard + Wox.Plugin.Clipboard + v3.5 + 512 + ..\..\ + true + + + true + full + false + bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + ..\..\Output\Release\Plugins\Wox.Plugin.Clipboard\ + TRACE + prompt + 4 + + + + + + + + + + + packages\InputSimulator.1.0.4.0\lib\net20\WindowsInput.dll + + + ..\Wox\Output\Debug\Wox.Plugin.dll + + + + + + + + + + + PreserveNewest + + + + + PreserveNewest + + + + + + + + + + + 这台计算机上缺少此项目引用的 NuGet 程序包。启用“NuGet 程序包还原”可下载这些程序包。有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 + + + + --> \ No newline at end of file diff --git a/obj/Debug/Wox.Plugin.Clipboard.csproj.FileListAbsolute.txt b/obj/Debug/Wox.Plugin.Clipboard.csproj.FileListAbsolute.txt index 7b9c875..bcbd976 100644 --- a/obj/Debug/Wox.Plugin.Clipboard.csproj.FileListAbsolute.txt +++ b/obj/Debug/Wox.Plugin.Clipboard.csproj.FileListAbsolute.txt @@ -31,3 +31,13 @@ e:\github\Wox.Plugin.ClipboardManager\bin\WindowsInput.dll e:\github\Wox.Plugin.ClipboardManager\bin\Wox.Plugin.dll e:\github\Wox.Plugin.ClipboardManager\bin\WindowsInput.xml e:\github\Wox.Plugin.ClipboardManager\bin\Wox.Plugin.pdb +d:\Personal\Github\Wox.Plugin.ClipboardManager\bin\Images\clipboard.png +d:\Personal\Github\Wox.Plugin.ClipboardManager\bin\plugin.json +d:\Personal\Github\Wox.Plugin.ClipboardManager\bin\Wox.Plugin.Clipboard.dll +d:\Personal\Github\Wox.Plugin.ClipboardManager\bin\Wox.Plugin.Clipboard.pdb +d:\Personal\Github\Wox.Plugin.ClipboardManager\bin\WindowsInput.dll +d:\Personal\Github\Wox.Plugin.ClipboardManager\bin\Wox.Plugin.dll +d:\Personal\Github\Wox.Plugin.ClipboardManager\bin\WindowsInput.xml +d:\Personal\Github\Wox.Plugin.ClipboardManager\bin\Wox.Plugin.pdb +d:\Personal\Github\Wox.Plugin.ClipboardManager\obj\Debug\Wox.Plugin.Clipboard.dll +d:\Personal\Github\Wox.Plugin.ClipboardManager\obj\Debug\Wox.Plugin.Clipboard.pdb