fix program plugin doesn't work in XP issue.

This commit is contained in:
qianlifeng
2014-01-06 21:25:24 +08:00
parent 3901422a54
commit 97b5526cc1
13 changed files with 291 additions and 108 deletions

110
WinAlfred.2010.sln Normal file
View File

@@ -0,0 +1,110 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinAlfred.Test", "WinAlfred.Test\WinAlfred.Test.csproj", "{FF742965-9A80-41A5-B042-D6C7D3A21708}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinAlfred.Plugin", "WinAlfred.Plugin\WinAlfred.Plugin.csproj", "{8451ECDD-2EA4-4966-BB0A-7BBC40138E80}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Plugin", "Plugin", "{3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinAlfred", "WinAlfred\WinAlfred.csproj", "{DB90F671-D861-46BB-93A3-F1304F5BA1C5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinAlfred.Plugin.System", "WinAlfred.Plugin.System\WinAlfred.Plugin.System.csproj", "{69CE0206-CB41-453D-88AF-DF86092EF9B8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinAlfred.Plugin.Fanyi", "Plugins\WinAlfred.Plugin.Fanyi\WinAlfred.Plugin.Fanyi.csproj", "{353769D3-D11C-4D86-BD06-AC8C1D68642B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|Mixed Platforms = Release|Mixed Platforms
Release|Win32 = Release|Win32
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FF742965-9A80-41A5-B042-D6C7D3A21708}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FF742965-9A80-41A5-B042-D6C7D3A21708}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FF742965-9A80-41A5-B042-D6C7D3A21708}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{FF742965-9A80-41A5-B042-D6C7D3A21708}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{FF742965-9A80-41A5-B042-D6C7D3A21708}.Debug|Win32.ActiveCfg = Debug|Any CPU
{FF742965-9A80-41A5-B042-D6C7D3A21708}.Debug|x64.ActiveCfg = Debug|Any CPU
{FF742965-9A80-41A5-B042-D6C7D3A21708}.Debug|x86.ActiveCfg = Debug|Any CPU
{FF742965-9A80-41A5-B042-D6C7D3A21708}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FF742965-9A80-41A5-B042-D6C7D3A21708}.Release|Any CPU.Build.0 = Release|Any CPU
{FF742965-9A80-41A5-B042-D6C7D3A21708}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{FF742965-9A80-41A5-B042-D6C7D3A21708}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{FF742965-9A80-41A5-B042-D6C7D3A21708}.Release|Win32.ActiveCfg = Release|Any CPU
{FF742965-9A80-41A5-B042-D6C7D3A21708}.Release|x64.ActiveCfg = Release|Any CPU
{FF742965-9A80-41A5-B042-D6C7D3A21708}.Release|x86.ActiveCfg = Release|Any CPU
{8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Debug|Win32.ActiveCfg = Debug|x86
{8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Debug|Win32.Build.0 = Debug|x86
{8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Debug|x64.ActiveCfg = Debug|Any CPU
{8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Debug|x86.ActiveCfg = Debug|Any CPU
{8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Debug|x86.Build.0 = Debug|Any CPU
{8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Release|Any CPU.Build.0 = Release|Any CPU
{8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Release|Win32.ActiveCfg = Release|x86
{8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Release|Win32.Build.0 = Release|x86
{8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Release|x64.ActiveCfg = Release|Any CPU
{8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Release|x86.ActiveCfg = Release|Any CPU
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|Win32.ActiveCfg = Debug|Any CPU
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|x64.ActiveCfg = Debug|Any CPU
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|x86.ActiveCfg = Debug|Any CPU
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|Any CPU.Build.0 = Release|Any CPU
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|Win32.ActiveCfg = Release|Any CPU
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|x64.ActiveCfg = Release|Any CPU
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|x86.ActiveCfg = Release|Any CPU
{69CE0206-CB41-453D-88AF-DF86092EF9B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{69CE0206-CB41-453D-88AF-DF86092EF9B8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{69CE0206-CB41-453D-88AF-DF86092EF9B8}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{69CE0206-CB41-453D-88AF-DF86092EF9B8}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{69CE0206-CB41-453D-88AF-DF86092EF9B8}.Debug|Win32.ActiveCfg = Debug|Any CPU
{69CE0206-CB41-453D-88AF-DF86092EF9B8}.Debug|x64.ActiveCfg = Debug|Any CPU
{69CE0206-CB41-453D-88AF-DF86092EF9B8}.Debug|x86.ActiveCfg = Debug|Any CPU
{69CE0206-CB41-453D-88AF-DF86092EF9B8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{69CE0206-CB41-453D-88AF-DF86092EF9B8}.Release|Any CPU.Build.0 = Release|Any CPU
{69CE0206-CB41-453D-88AF-DF86092EF9B8}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{69CE0206-CB41-453D-88AF-DF86092EF9B8}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{69CE0206-CB41-453D-88AF-DF86092EF9B8}.Release|Win32.ActiveCfg = Release|Any CPU
{69CE0206-CB41-453D-88AF-DF86092EF9B8}.Release|x64.ActiveCfg = Release|Any CPU
{69CE0206-CB41-453D-88AF-DF86092EF9B8}.Release|x86.ActiveCfg = Release|Any CPU
{353769D3-D11C-4D86-BD06-AC8C1D68642B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{353769D3-D11C-4D86-BD06-AC8C1D68642B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{353769D3-D11C-4D86-BD06-AC8C1D68642B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{353769D3-D11C-4D86-BD06-AC8C1D68642B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{353769D3-D11C-4D86-BD06-AC8C1D68642B}.Debug|Win32.ActiveCfg = Debug|Any CPU
{353769D3-D11C-4D86-BD06-AC8C1D68642B}.Debug|x64.ActiveCfg = Debug|Any CPU
{353769D3-D11C-4D86-BD06-AC8C1D68642B}.Debug|x86.ActiveCfg = Debug|Any CPU
{353769D3-D11C-4D86-BD06-AC8C1D68642B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{353769D3-D11C-4D86-BD06-AC8C1D68642B}.Release|Any CPU.Build.0 = Release|Any CPU
{353769D3-D11C-4D86-BD06-AC8C1D68642B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{353769D3-D11C-4D86-BD06-AC8C1D68642B}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{353769D3-D11C-4D86-BD06-AC8C1D68642B}.Release|Win32.ActiveCfg = Release|Any CPU
{353769D3-D11C-4D86-BD06-AC8C1D68642B}.Release|x64.ActiveCfg = Release|Any CPU
{353769D3-D11C-4D86-BD06-AC8C1D68642B}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{353769D3-D11C-4D86-BD06-AC8C1D68642B} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
namespace WinAlfred.Plugin.System
{
public class DirectoryIndicator : ISystemPlugin
{
public List<Result> Query(Query query)
{
List<Result> results = new List<Result>();
if (string.IsNullOrEmpty(query.RawQuery)) return results;
if (CheckIfDirectory(query.RawQuery))
{
Result result = new Result
{
Title = "Open this directory",
SubTitle = string.Format("path: {0}", query.RawQuery),
Score = 50,
IcoPath = "Images/folder.png",
Action = () => Process.Start(query.RawQuery)
};
results.Add(result);
}
return results;
}
private bool CheckIfDirectory(string path)
{
return Directory.Exists(path);
}
public void Init(PluginInitContext context)
{
}
public string Name
{
get
{
return "DirectoryIndicator";
}
}
public string Description
{
get
{
return "DirectoryIndicator";
}
}
}
}

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using Microsoft.Win32; using Microsoft.Win32;
@@ -27,6 +28,12 @@ namespace WinAlfred.Plugin.System
List<Program> installedList = new List<Program>(); List<Program> installedList = new List<Program>();
[DllImport("shell32.dll")]
static extern bool SHGetSpecialFolderPath(IntPtr hwndOwner,[Out] StringBuilder lpszPath, int nFolder, bool fCreate);
const int CSIDL_COMMON_STARTMENU = 0x16; // \Windows\Start Menu\Programs
const int CSIDL_COMMON_PROGRAMS = 0x17;
public List<Result> Query(Query query) public List<Result> Query(Query query)
{ {
if (string.IsNullOrEmpty(query.RawQuery) || query.RawQuery.EndsWith(" ") || query.RawQuery.Length <= 1) return new List<Result>(); if (string.IsNullOrEmpty(query.RawQuery) || query.RawQuery.EndsWith(" ") || query.RawQuery.Length <= 1) return new List<Result>();
@@ -64,7 +71,10 @@ namespace WinAlfred.Plugin.System
public void Init(PluginInitContext context) public void Init(PluginInitContext context)
{ {
indexDirectory.Add(Environment.GetFolderPath(Environment.SpecialFolder.Programs)); indexDirectory.Add(Environment.GetFolderPath(Environment.SpecialFolder.Programs));
indexDirectory.Add(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\Microsoft\Windows\Start Menu\Programs");
StringBuilder commonStartMenuPath = new StringBuilder(560);
SHGetSpecialFolderPath(IntPtr.Zero, commonStartMenuPath, CSIDL_COMMON_PROGRAMS, false);
indexDirectory.Add(commonStartMenuPath.ToString());
GetAppFromStartMenu(); GetAppFromStartMenu();
} }

View File

@@ -41,6 +41,7 @@
<ItemGroup> <ItemGroup>
<Compile Include="CMD.cs" /> <Compile Include="CMD.cs" />
<Compile Include="Common\ChineseToPinYin.cs" /> <Compile Include="Common\ChineseToPinYin.cs" />
<Compile Include="DirectoryIndicator.cs" />
<Compile Include="ISystemPlugin.cs" /> <Compile Include="ISystemPlugin.cs" />
<Compile Include="Programs.cs" /> <Compile Include="Programs.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />

View File

@@ -17,4 +17,4 @@
<appender-ref ref="LogFileAppender"/> <appender-ref ref="LogFileAppender"/>
</root> </root>
</log4net> </log4net>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration> <startup><supportedRuntime version="v2.0.50727"/></startup></configuration>

View File

@@ -14,7 +14,6 @@
<Setter Property="Height" Value="36"/> <Setter Property="Height" Value="36"/>
<Setter Property="VerticalContentAlignment" Value="Center"/> <Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/> <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/> <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>

BIN
WinAlfred/Images/folder.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@@ -91,8 +91,14 @@ namespace WinAlfred
{ {
Show(); Show();
//FocusManager.SetFocusedElement(this, tbQuery); //FocusManager.SetFocusedElement(this, tbQuery);
tbQuery.Focusable = true;
Keyboard.Focus(tbQuery); Keyboard.Focus(tbQuery);
tbQuery.SelectAll(); tbQuery.SelectAll();
if (!tbQuery.IsKeyboardFocused)
{
MessageBox.Show("didnt focus");
}
} }
private void MainWindow_OnLoaded(object sender, RoutedEventArgs e) private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)

View File

@@ -195,6 +195,8 @@ namespace WinAlfred
public bool AcceptSelect() public bool AcceptSelect()
{ {
int index = GetCurrentSelectedResultIndex(); int index = GetCurrentSelectedResultIndex();
if (index < 0) return false;
var resultItemControl = pnlContainer.Children[index] as ResultItem; var resultItemControl = pnlContainer.Children[index] as ResultItem;
if (resultItemControl != null) if (resultItemControl != null)
{ {

View File

@@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>WinAlfred</RootNamespace> <RootNamespace>WinAlfred</RootNamespace>
<AssemblyName>WinAlfred</AssemblyName> <AssemblyName>WinAlfred</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
@@ -59,9 +59,6 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Accessibility" /> <Reference Include="Accessibility" />
<Reference Include="Jurassic">
<HintPath>C:\Users\Scott\Desktop\Jurassic.dll</HintPath>
</Reference>
<Reference Include="log4net"> <Reference Include="log4net">
<HintPath>..\packages\log4net.2.0.3\lib\net35-full\log4net.dll</HintPath> <HintPath>..\packages\log4net.2.0.3\lib\net35-full\log4net.dll</HintPath>
</Reference> </Reference>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="log4net" version="2.0.3" targetFramework="net35" requireReinstallation="True" /> <package id="log4net" version="2.0.3" targetFramework="net35" />
<package id="Newtonsoft.Json" version="5.0.8" targetFramework="net35" requireReinstallation="True" /> <package id="Newtonsoft.Json" version="5.0.8" targetFramework="net35" />
</packages> </packages>