Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
Don't add empty line
Browse files Browse the repository at this point in the history
  • Loading branch information
qianlifeng committed Aug 18, 2014
1 parent 5268219 commit 2956789
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 98 deletions.
34 changes: 13 additions & 21 deletions Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ 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<string> dataList = new List<string>();

public List<Result> Query(Query query)
{
var results = new List<Result>();
List<string> displayData = new List<string>();
List<string> displayData;
if (query.ActionParameters.Count == 0)
{
displayData = dataList;
Expand All @@ -31,29 +31,21 @@ public List<Result> 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());
Expand All @@ -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()))
{
Expand All @@ -84,7 +76,7 @@ void ClipboardMonitor_OnClipboardChange(ClipboardFormat format, object data)

if (dataList.Count > MaxDataCount)
{
dataList.Remove(dataList.First());
dataList.Remove(dataList.Last());
}
}
}
Expand Down
154 changes: 77 additions & 77 deletions Wox.Plugin.Clipboard.csproj
Original file line number Diff line number Diff line change
@@ -1,84 +1,84 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{8C14DC11-2737-4DCB-A121-5D7BDD57FEA2}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Wox.Plugin.Clipboard</RootNamespace>
<AssemblyName>Wox.Plugin.Clipboard</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\Output\Release\Plugins\Wox.Plugin.Clipboard\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="WindowsInput">
<HintPath>packages\WindowsInput.0.2.0.0\lib\net20\WindowsInput.dll</HintPath>
</Reference>
<Reference Include="Wox.Plugin">
<HintPath>..\Wox\Output\Debug\Wox.Plugin.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="ClipboardMonitor.cs" />
<Compile Include="Main.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="plugin.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Content Include="Images\clipboard.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。启用“NuGet 程序包还原”可下载这些程序包。有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{8C14DC11-2737-4DCB-A121-5D7BDD57FEA2}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Wox.Plugin.Clipboard</RootNamespace>
<AssemblyName>Wox.Plugin.Clipboard</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\Output\Release\Plugins\Wox.Plugin.Clipboard\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="WindowsInput">
<HintPath>packages\InputSimulator.1.0.4.0\lib\net20\WindowsInput.dll</HintPath>
</Reference>
<Reference Include="Wox.Plugin">
<HintPath>..\Wox\Output\Debug\Wox.Plugin.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="ClipboardMonitor.cs" />
<Compile Include="Main.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="plugin.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Content Include="Images\clipboard.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。启用“NuGet 程序包还原”可下载这些程序包。有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
-->
</Project>
10 changes: 10 additions & 0 deletions obj/Debug/Wox.Plugin.Clipboard.csproj.FileListAbsolute.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 2956789

Please sign in to comment.