some API changes for Query class and renames.

This commit is contained in:
qianlifeng
2015-01-26 17:46:55 +08:00
parent ddf6154600
commit 7821f41723
29 changed files with 371 additions and 289 deletions

View File

@@ -21,14 +21,14 @@ namespace Wox.Plugin.CMD
{ {
List<Result> results = new List<Result>(); List<Result> results = new List<Result>();
List<Result> pushedResults = new List<Result>(); List<Result> pushedResults = new List<Result>();
if (query.RawQuery == ">") if (query.Search == ">")
{ {
return GetAllHistoryCmds(); return GetAllHistoryCmds();
} }
if (query.RawQuery.StartsWith(">") && query.RawQuery.Length > 1) if (query.Search.StartsWith(">") && query.Search.Length > 1)
{ {
string cmd = query.RawQuery.Substring(1); string cmd = query.Search.Substring(1);
var queryCmd = GetCurrentCmd(cmd); var queryCmd = GetCurrentCmd(cmd);
context.API.PushResults(query, context.CurrentPluginMetadata, new List<Result>() { queryCmd }); context.API.PushResults(query, context.CurrentPluginMetadata, new List<Result>() { queryCmd });
pushedResults.Add(queryCmd); pushedResults.Add(queryCmd);

View File

@@ -28,13 +28,13 @@ namespace Wox.Plugin.Caculator
public List<Result> Query(Query query) public List<Result> Query(Query query)
{ {
if (query.RawQuery.Length <= 2 // don't affect when user only input "e" or "i" keyword if (query.Search.Length <= 2 // don't affect when user only input "e" or "i" keyword
|| !regValidExpressChar.IsMatch(query.RawQuery) || !regValidExpressChar.IsMatch(query.Search)
|| !IsBracketComplete(query.RawQuery)) return new List<Result>(); || !IsBracketComplete(query.Search)) return new List<Result>();
try try
{ {
var result = yampContext.Run(query.RawQuery); var result = yampContext.Run(query.Search);
if (result.Output != null && !string.IsNullOrEmpty(result.Result)) if (result.Output != null && !string.IsNullOrEmpty(result.Result))
{ {
return new List<Result>() { new Result() { return new List<Result>() { new Result() {

View File

@@ -29,7 +29,7 @@ namespace Wox.Plugin.Color
public List<Result> Query(Query query) public List<Result> Query(Query query)
{ {
var raw = query.RawQuery; var raw = query.Search;
if (!IsAvailable(raw)) return new List<Result>(0); if (!IsAvailable(raw)) return new List<Result>(0);
try try
{ {

View File

@@ -38,9 +38,7 @@ namespace Wox.Plugin.ControlPanel
public List<Result> Query(Query query) public List<Result> Query(Query query)
{ {
if (query.RawQuery.EndsWith(" ") || query.RawQuery.Length <= 1) return new List<Result>(); string myQuery = query.Search.Trim();
string myQuery = query.RawQuery.Trim();
List<Result> results = new List<Result>(); List<Result> results = new List<Result>();
foreach (var item in controlPanelItems) foreach (var item in controlPanelItems)

View File

@@ -53,8 +53,7 @@ namespace Wox.Plugin.Folder
public List<Result> Query(Query query) public List<Result> Query(Query query)
{ {
if(string.IsNullOrEmpty(query.RawQuery)) return new List<Result>(); string input = query.Search.ToLower();
string input = query.RawQuery.ToLower();
List<FolderLink> userFolderLinks = FolderStorage.Instance.FolderLinks.Where( List<FolderLink> userFolderLinks = FolderStorage.Instance.FolderLinks.Where(
x => x.Nickname.StartsWith(input, StringComparison.OrdinalIgnoreCase)).ToList(); x => x.Nickname.StartsWith(input, StringComparison.OrdinalIgnoreCase)).ToList();

View File

@@ -13,16 +13,14 @@ namespace Wox.Plugin.PluginIndicator
public List<Result> Query(Query query) public List<Result> Query(Query query)
{ {
List<Result> results = new List<Result>(); List<Result> results = new List<Result>();
if (string.IsNullOrEmpty(query.RawQuery)) return results;
if (allPlugins.Count == 0) if (allPlugins.Count == 0)
{ {
allPlugins = context.API.GetAllPlugins().Where(o => !PluginManager.IsWildcardPlugin(o.Metadata)).ToList(); allPlugins = context.API.GetAllPlugins().Where(o => !PluginManager.IsSystemPlugin(o.Metadata)).ToList();
} }
foreach (PluginMetadata metadata in allPlugins.Select(o => o.Metadata)) foreach (PluginMetadata metadata in allPlugins.Select(o => o.Metadata))
{ {
if (metadata.ActionKeyword.StartsWith(query.RawQuery)) if (metadata.ActionKeyword.StartsWith(query.Search))
{ {
PluginMetadata metadataCopy = metadata; PluginMetadata metadataCopy = metadata;
var customizedPluginConfig = UserSettingStorage.Instance.CustomizedPluginConfigs.FirstOrDefault(o => o.ID == metadataCopy.ID); var customizedPluginConfig = UserSettingStorage.Instance.CustomizedPluginConfigs.FirstOrDefault(o => o.ID == metadataCopy.ID);
@@ -47,7 +45,7 @@ namespace Wox.Plugin.PluginIndicator
} }
} }
results.AddRange(UserSettingStorage.Instance.WebSearches.Where(o => o.ActionWord.StartsWith(query.RawQuery) && o.Enabled).Select(n => new Result() results.AddRange(UserSettingStorage.Instance.WebSearches.Where(o => o.ActionWord.StartsWith(query.Search) && o.Enabled).Select(n => new Result()
{ {
Title = n.ActionWord, Title = n.ActionWord,
SubTitle = string.Format("Activate {0} web search", n.ActionWord), SubTitle = string.Format("Activate {0} web search", n.ActionWord),

View File

@@ -10,59 +10,37 @@ using Newtonsoft.Json;
namespace Wox.Plugin.PluginManagement namespace Wox.Plugin.PluginManagement
{ {
public class WoxPluginResult
{
public string plugin_file;
public string description;
public int liked_count;
public string name;
public string version;
}
public class Main : IPlugin public class Main : IPlugin
{ {
private static string APIBASE = "https://api.getwox.com"; private static string APIBASE = "https://api.getwox.com";
private static string PluginPath = AppDomain.CurrentDomain.BaseDirectory + "Plugins";
private static string PluginConfigName = "plugin.json"; private static string PluginConfigName = "plugin.json";
private static string pluginSearchUrl = APIBASE +"/plugin/search/"; private static string pluginSearchUrl = APIBASE + "/plugin/search/";
private PluginInitContext context; private PluginInitContext context;
public List<Result> Query(Query query) public List<Result> Query(Query query)
{ {
List<Result> results = new List<Result>(); List<Result> results = new List<Result>();
if (query.ActionParameters.Count == 0) if (string.IsNullOrEmpty(query.Search))
{ {
results.Add(new Result("wpm install <pluginName>", "Images\\plugin.png", "search and install wox plugins") results.Add(new Result("install <pluginName>", "Images\\plugin.png", "search and install wox plugins")
{ {
Action = e => Action = e => ChangeToInstallCommand()
{
context.API.ChangeQuery("wpm install ");
return false;
}
}); });
results.Add(new Result("wpm uninstall <pluginName>", "Images\\plugin.png", "uninstall plugin") results.Add(new Result("uninstall <pluginName>", "Images\\plugin.png", "uninstall plugin")
{ {
Action = e => Action = e => ChangeToUninstallCommand()
{
context.API.ChangeQuery("wpm uninstall ");
return false;
}
}); });
results.Add(new Result("wpm list", "Images\\plugin.png", "list plugins installed") results.Add(new Result("list", "Images\\plugin.png", "list plugins installed")
{ {
Action = e => Action = e => ChangeToListCommand()
{
context.API.ChangeQuery("wpm list");
return false;
}
}); });
return results; return results;
} }
if (query.ActionParameters.Count > 0) if (!string.IsNullOrEmpty(query.FirstSearch))
{ {
bool hit = false; bool hit = false;
switch (query.ActionParameters[0].ToLower()) switch (query.FirstSearch.ToLower())
{ {
case "list": case "list":
hit = true; hit = true;
@@ -71,51 +49,39 @@ namespace Wox.Plugin.PluginManagement
case "uninstall": case "uninstall":
hit = true; hit = true;
results = ListUnInstalledPlugins(query); results = UnInstallPlugins(query);
break; break;
case "install": case "install":
hit = true; hit = true;
if (query.ActionParameters.Count > 1) if (!string.IsNullOrEmpty(query.SecondSearch))
{ {
results = InstallPlugin(query); results = InstallPlugin(query.SecondSearch);
} }
break; break;
} }
if (!hit) if (!hit)
{ {
if ("install".Contains(query.ActionParameters[0].ToLower())) if ("install".Contains(query.FirstSearch.ToLower()))
{ {
results.Add(new Result("wpm install <pluginName>", "Images\\plugin.png", "search and install wox plugins") results.Add(new Result("install <pluginName>", "Images\\plugin.png", "search and install wox plugins")
{ {
Action = e => Action = e => ChangeToInstallCommand()
{
context.API.ChangeQuery("wpm install ");
return false;
}
}); });
} }
if ("uninstall".Contains(query.ActionParameters[0].ToLower())) if ("uninstall".Contains(query.FirstSearch.ToLower()))
{ {
results.Add(new Result("wpm uninstall <pluginName>", "Images\\plugin.png", "uninstall plugin") results.Add(new Result("uninstall <pluginName>", "Images\\plugin.png", "uninstall plugin")
{ {
Action = e => Action = e => ChangeToUninstallCommand()
{
context.API.ChangeQuery("wpm uninstall ");
return false;
}
}); });
} }
if ("list".Contains(query.ActionParameters[0].ToLower())) if ("list".Contains(query.FirstSearch.ToLower()))
{ {
results.Add(new Result("wpm list", "Images\\plugin.png", "list plugins installed") results.Add(new Result("list", "Images\\plugin.png", "list plugins installed")
{ {
Action = e => Action = e => ChangeToListCommand()
{
context.API.ChangeQuery("wpm list");
return false;
}
}); });
} }
} }
@@ -124,10 +90,49 @@ namespace Wox.Plugin.PluginManagement
return results; return results;
} }
private List<Result> InstallPlugin(Query query) private bool ChangeToListCommand()
{
if (context.CurrentPluginMetadata.ActionKeyword == "*")
{
context.API.ChangeQuery("list ");
}
else
{
context.API.ChangeQuery(string.Format("{0} list ", context.CurrentPluginMetadata.ActionKeyword));
}
return false;
}
private bool ChangeToUninstallCommand()
{
if (context.CurrentPluginMetadata.ActionKeyword == "*")
{
context.API.ChangeQuery("uninstall ");
}
else
{
context.API.ChangeQuery(string.Format("{0} uninstall ", context.CurrentPluginMetadata.ActionKeyword));
}
return false;
}
private bool ChangeToInstallCommand()
{
if (context.CurrentPluginMetadata.ActionKeyword == "*")
{
context.API.ChangeQuery("install ");
}
else
{
context.API.ChangeQuery(string.Format("{0} install ", context.CurrentPluginMetadata.ActionKeyword));
}
return false;
}
private List<Result> InstallPlugin(string queryPluginName)
{ {
List<Result> results = new List<Result>(); List<Result> results = new List<Result>();
HttpWebResponse response = HttpRequest.CreateGetHttpResponse(pluginSearchUrl + query.ActionParameters[1], context.Proxy); HttpWebResponse response = HttpRequest.CreateGetHttpResponse(pluginSearchUrl + queryPluginName, context.Proxy);
Stream s = response.GetResponseStream(); Stream s = response.GetResponseStream();
if (s != null) if (s != null)
{ {
@@ -140,7 +145,7 @@ namespace Wox.Plugin.PluginManagement
} }
catch catch
{ {
context.API.ShowMsg("Coundn't parse api search results", "Please update your Wox!",string.Empty); context.API.ShowMsg("Coundn't parse api search results", "Please update your Wox!", string.Empty);
return results; return results;
} }
@@ -194,19 +199,19 @@ namespace Wox.Plugin.PluginManagement
return results; return results;
} }
private List<Result> ListUnInstalledPlugins(Query query) private List<Result> UnInstallPlugins(Query query)
{ {
List<Result> results = new List<Result>(); List<Result> results = new List<Result>();
List<PluginMetadata> allInstalledPlugins = ParseRegularPlugins(); List<PluginMetadata> allInstalledPlugins = context.API.GetAllPlugins().Select(o => o.Metadata).ToList();
if (query.ActionParameters.Count > 1) if (!string.IsNullOrEmpty(query.SecondSearch))
{ {
string pluginName = query.ActionParameters[1];
allInstalledPlugins = allInstalledPlugins =
allInstalledPlugins.Where(o => o.Name.ToLower().Contains(pluginName.ToLower())).ToList(); allInstalledPlugins.Where(o => o.Name.ToLower().Contains(query.SecondSearch.ToLower())).ToList();
} }
foreach (PluginMetadata plugin in allInstalledPlugins) foreach (PluginMetadata plugin in allInstalledPlugins)
{ {
var plugin1 = plugin;
results.Add(new Result() results.Add(new Result()
{ {
Title = plugin.Name, Title = plugin.Name,
@@ -214,7 +219,7 @@ namespace Wox.Plugin.PluginManagement
IcoPath = plugin.FullIcoPath, IcoPath = plugin.FullIcoPath,
Action = e => Action = e =>
{ {
UnInstalledPlugins(plugin); UnInstallPlugin(plugin1);
return false; return false;
} }
}); });
@@ -222,7 +227,7 @@ namespace Wox.Plugin.PluginManagement
return results; return results;
} }
private void UnInstalledPlugins(PluginMetadata plugin) private void UnInstallPlugin(PluginMetadata plugin)
{ {
string content = string.Format("Do you want to uninstall following plugin?\r\n\r\nName: {0}\r\nVersion: {1}\r\nAuthor: {2}", plugin.Name, plugin.Version, plugin.Author); string content = string.Format("Do you want to uninstall following plugin?\r\n\r\nName: {0}\r\nVersion: {1}\r\nAuthor: {2}", plugin.Name, plugin.Version, plugin.Author);
if (MessageBox.Show(content, "Wox", MessageBoxButtons.YesNo) == DialogResult.Yes) if (MessageBox.Show(content, "Wox", MessageBoxButtons.YesNo) == DialogResult.Yes)
@@ -235,7 +240,7 @@ namespace Wox.Plugin.PluginManagement
private List<Result> ListInstalledPlugins() private List<Result> ListInstalledPlugins()
{ {
List<Result> results = new List<Result>(); List<Result> results = new List<Result>();
foreach (PluginMetadata plugin in ParseRegularPlugins()) foreach (PluginMetadata plugin in context.API.GetAllPlugins().Select(o => o.Metadata))
{ {
results.Add(new Result() results.Add(new Result()
{ {
@@ -247,61 +252,6 @@ namespace Wox.Plugin.PluginManagement
return results; return results;
} }
private static List<PluginMetadata> ParseRegularPlugins()
{
List<PluginMetadata> pluginMetadatas = new List<PluginMetadata>();
if (!Directory.Exists(PluginPath))
Directory.CreateDirectory(PluginPath);
string[] directories = Directory.GetDirectories(PluginPath);
foreach (string directory in directories)
{
PluginMetadata metadata = GetMetadataFromJson(directory);
if (metadata != null) pluginMetadatas.Add(metadata);
}
return pluginMetadatas;
}
private static PluginMetadata GetMetadataFromJson(string pluginDirectory)
{
string configPath = Path.Combine(pluginDirectory, PluginConfigName);
PluginMetadata metadata;
if (!File.Exists(configPath))
{
return null;
}
try
{
metadata = JsonConvert.DeserializeObject<PluginMetadata>(File.ReadAllText(configPath));
metadata.PluginType = PluginType.User;
metadata.PluginDirectory = pluginDirectory;
}
catch (Exception)
{
string error = string.Format("Parse plugin config {0} failed: json format is not valid", configPath);
return null;
}
if (!AllowedLanguage.IsAllowed(metadata.Language))
{
string error = string.Format("Parse plugin config {0} failed: invalid language {1}", configPath,
metadata.Language);
return null;
}
if (!File.Exists(metadata.ExecuteFilePath))
{
string error = string.Format("Parse plugin config {0} failed: ExecuteFile {1} didn't exist", configPath,
metadata.ExecuteFilePath);
return null;
}
return metadata;
}
public void Init(PluginInitContext context) public void Init(PluginInitContext context)
{ {
this.context = context; this.context = context;

View File

@@ -1,91 +1,92 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <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')" /> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{049490F0-ECD2-4148-9B39-2135EC346EBE}</ProjectGuid> <ProjectGuid>{049490F0-ECD2-4148-9B39-2135EC346EBE}</ProjectGuid>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Wox.Plugin.PluginManagement</RootNamespace> <RootNamespace>Wox.Plugin.PluginManagement</RootNamespace>
<AssemblyName>Wox.Plugin.PluginManagement</AssemblyName> <AssemblyName>Wox.Plugin.PluginManagement</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<RestorePackages>true</RestorePackages> <RestorePackages>true</RestorePackages>
<TargetFrameworkProfile /> <TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>..\..\Output\Debug\Plugins\Wox.Plugin.PluginManagement\</OutputPath> <OutputPath>..\..\Output\Debug\Plugins\Wox.Plugin.PluginManagement\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit> <Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>..\..\Output\Release\Plugins\Wox.Plugin.PluginManagement\</OutputPath> <OutputPath>..\..\Output\Release\Plugins\Wox.Plugin.PluginManagement\</OutputPath>
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit> <Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Newtonsoft.Json"> <Reference Include="Newtonsoft.Json">
<HintPath>..\..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll</HintPath> <HintPath>..\..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="HttpRequest.cs" /> <Compile Include="HttpRequest.cs" />
<Compile Include="Main.cs" /> <Compile Include="Main.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> <Compile Include="WoxPluginResult.cs" />
<ItemGroup> </ItemGroup>
<ProjectReference Include="..\..\Wox.Plugin\Wox.Plugin.csproj"> <ItemGroup>
<Project>{8451ecdd-2ea4-4966-bb0a-7bbc40138e80}</Project> <ProjectReference Include="..\..\Wox.Plugin\Wox.Plugin.csproj">
<Name>Wox.Plugin</Name> <Project>{8451ecdd-2ea4-4966-bb0a-7bbc40138e80}</Project>
</ProjectReference> <Name>Wox.Plugin</Name>
</ItemGroup> </ProjectReference>
<ItemGroup> </ItemGroup>
<None Include="packages.config" /> <ItemGroup>
<None Include="plugin.json"> <None Include="packages.config" />
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <None Include="plugin.json">
</None> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</ItemGroup> </None>
<ItemGroup> </ItemGroup>
<None Include="Images\plugin.png"> <ItemGroup>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <None Include="Images\plugin.png">
</None> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</ItemGroup> </None>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> </ItemGroup>
<PropertyGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PostBuildEvent> <PropertyGroup>
</PostBuildEvent> <PostBuildEvent>
</PropertyGroup> </PostBuildEvent>
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" /> </PropertyGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<PropertyGroup> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。启用“NuGet 程序包还原”可下载这些程序包。有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText> <PropertyGroup>
</PropertyGroup> <ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。启用“NuGet 程序包还原”可下载这些程序包。有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" /> </PropertyGroup>
</Target> <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. <!-- 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. Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild"> <Target Name="BeforeBuild">
</Target> </Target>
<Target Name="AfterBuild"> <Target Name="AfterBuild">
</Target> </Target>
--> -->
</Project> </Project>

View File

@@ -0,0 +1,11 @@
namespace Wox.Plugin.PluginManagement
{
public class WoxPluginResult
{
public string plugin_file;
public string description;
public int liked_count;
public string name;
public string version;
}
}

View File

@@ -26,9 +26,7 @@ namespace Wox.Plugin.Program
public List<Result> Query(Query query) public List<Result> Query(Query query)
{ {
if (query.RawQuery.Trim().Length <= 1) return new List<Result>(); var fuzzyMather = FuzzyMatcher.Create(query.Search);
var fuzzyMather = FuzzyMatcher.Create(query.RawQuery);
List<Program> returnList = programs.Where(o => MatchProgram(o, fuzzyMather)).ToList(); List<Program> returnList = programs.Where(o => MatchProgram(o, fuzzyMather)).ToList();
returnList.ForEach(ScoreFilter); returnList.ForEach(ScoreFilter);
returnList = returnList.OrderByDescending(o => o.Score).ToList(); returnList = returnList.OrderByDescending(o => o.Score).ToList();

View File

@@ -13,7 +13,7 @@ namespace Wox.Plugin.QueryHistory
public List<Result> Query(Query query) public List<Result> Query(Query query)
{ {
var histories = QueryHistoryStorage.Instance.GetHistory(); var histories = QueryHistoryStorage.Instance.GetHistory();
string filter = query.GetAllRemainingParameter(); string filter = query.Search;
if (!string.IsNullOrEmpty(filter)) if (!string.IsNullOrEmpty(filter))
{ {
histories = histories.Where(o => o.Query.Contains(filter)).ToList(); histories = histories.Where(o => o.Query.Contains(filter)).ToList();

View File

@@ -34,7 +34,6 @@ namespace Wox.Plugin.Sys
public List<Result> Query(Query query) public List<Result> Query(Query query)
{ {
if (query.RawQuery.EndsWith(" ") || query.RawQuery.Length <= 1) return new List<Result>();
if (availableResults.Count == 0) if (availableResults.Count == 0)
{ {
LoadCommands(); LoadCommands();
@@ -43,7 +42,7 @@ namespace Wox.Plugin.Sys
List<Result> results = new List<Result>(); List<Result> results = new List<Result>();
foreach (Result availableResult in availableResults) foreach (Result availableResult in availableResults)
{ {
if (availableResult.Title.ToLower().StartsWith(query.RawQuery.ToLower())) if (availableResult.Title.ToLower().StartsWith(query.Search.ToLower()))
{ {
results.Add(availableResult); results.Add(availableResult);
} }

View File

@@ -45,9 +45,7 @@ namespace Wox.Plugin.Url
public List<Result> Query(Query query) public List<Result> Query(Query query)
{ {
if(string.IsNullOrEmpty(query.RawQuery)) return new List<Result>(); var raw = query.Search;
var raw = query.RawQuery;
if (IsURL(raw)) if (IsURL(raw))
{ {
return new List<Result> return new List<Result>

View File

@@ -18,11 +18,11 @@ namespace Wox.Plugin.WebSearch
List<Result> results = new List<Result>(); List<Result> results = new List<Result>();
Core.UserSettings.WebSearch webSearch = Core.UserSettings.WebSearch webSearch =
UserSettingStorage.Instance.WebSearches.FirstOrDefault(o => o.ActionWord == query.ActionName && o.Enabled); UserSettingStorage.Instance.WebSearches.FirstOrDefault(o => o.ActionWord == query.FirstSearch.Trim() && o.Enabled);
if (webSearch != null) if (webSearch != null)
{ {
string keyword = query.ActionParameters.Count > 0 ? query.GetAllRemainingParameter() : ""; string keyword = query.SecondToEndSearch;
string title = keyword; string title = keyword;
string subtitle = "Search " + webSearch.Title; string subtitle = "Search " + webSearch.Title;
if (string.IsNullOrEmpty(keyword)) if (string.IsNullOrEmpty(keyword))

View File

@@ -19,7 +19,7 @@ namespace Wox.Core.Plugin
/// </summary> /// </summary>
public static class PluginManager public static class PluginManager
{ {
public const string ActionKeywordWildcard = "*"; public const string ActionKeywordWildcardSign = "*";
public static String DebuggerMode { get; private set; } public static String DebuggerMode { get; private set; }
public static IPublicAPI API { get; private set; } public static IPublicAPI API { get; private set; }
@@ -104,7 +104,10 @@ namespace Wox.Core.Plugin
public static void Query(Query query) public static void Query(Query query)
{ {
QueryDispatcher.QueryDispatcher.Dispatch(query); if (!string.IsNullOrEmpty(query.RawQuery.Trim()))
{
QueryDispatcher.QueryDispatcher.Dispatch(query);
}
} }
public static List<PluginPair> AllPlugins public static List<PluginPair> AllPlugins
@@ -115,16 +118,24 @@ namespace Wox.Core.Plugin
} }
} }
public static bool IsRegularPluginQuery(Query query) public static bool IsUserPluginQuery(Query query)
{ {
if (string.IsNullOrEmpty(query.ActionName)) return false; if (string.IsNullOrEmpty(query.RawQuery)) return false;
return plugins.Any(o => o.Metadata.PluginType == PluginType.User && o.Metadata.ActionKeyword == query.ActionName); var strings = query.RawQuery.Split(' ');
var actionKeyword = string.Empty;
if (strings.Length > 0)
{
actionKeyword = strings[0].Trim();
}
if (string.IsNullOrEmpty(actionKeyword)) return false;
return plugins.Any(o => o.Metadata.PluginType == PluginType.User && o.Metadata.ActionKeyword == actionKeyword);
} }
public static bool IsWildcardPlugin(PluginMetadata metadata) public static bool IsSystemPlugin(PluginMetadata metadata)
{ {
return metadata.ActionKeyword == ActionKeywordWildcard; return metadata.ActionKeyword == ActionKeywordWildcardSign;
} }
public static void ActivatePluginDebugger(string path) public static void ActivatePluginDebugger(string path)

View File

@@ -3,18 +3,20 @@ namespace Wox.Core.Plugin.QueryDispatcher
{ {
internal static class QueryDispatcher internal static class QueryDispatcher
{ {
private static IQueryDispatcher regularDispatcher = new RegularPluginQueryDispatcher(); private static readonly IQueryDispatcher UserPluginDispatcher = new UserPluginQueryDispatcher();
private static IQueryDispatcher wildcardDispatcher = new WildcardPluginQueryDispatcher(); private static readonly IQueryDispatcher SystemPluginDispatcher = new SystemPluginQueryDispatcher();
public static void Dispatch(Wox.Plugin.Query query) public static void Dispatch(Wox.Plugin.Query query)
{ {
if (PluginManager.IsRegularPluginQuery(query)) if (PluginManager.IsUserPluginQuery(query))
{ {
regularDispatcher.Dispatch(query); query.Search = query.RawQuery.Substring(query.RawQuery.IndexOf(' ') + 1);
UserPluginDispatcher.Dispatch(query);
} }
else else
{ {
wildcardDispatcher.Dispatch(query); query.Search = query.RawQuery;
SystemPluginDispatcher.Dispatch(query);
} }
} }
} }

View File

@@ -8,9 +8,9 @@ using Wox.Plugin;
namespace Wox.Core.Plugin.QueryDispatcher namespace Wox.Core.Plugin.QueryDispatcher
{ {
public class WildcardPluginQueryDispatcher : IQueryDispatcher public class SystemPluginQueryDispatcher : IQueryDispatcher
{ {
private IEnumerable<PluginPair> allSytemPlugins = PluginManager.AllPlugins.Where(o => PluginManager.IsWildcardPlugin(o.Metadata)); private IEnumerable<PluginPair> allSytemPlugins = PluginManager.AllPlugins.Where(o => PluginManager.IsSystemPlugin(o.Metadata));
public void Dispatch(Query query) public void Dispatch(Query query)
{ {

View File

@@ -9,14 +9,14 @@ using Wox.Plugin;
namespace Wox.Core.Plugin.QueryDispatcher namespace Wox.Core.Plugin.QueryDispatcher
{ {
public class RegularPluginQueryDispatcher : IQueryDispatcher public class UserPluginQueryDispatcher : IQueryDispatcher
{ {
public void Dispatch(Query query) public void Dispatch(Query query)
{ {
PluginPair regularPlugin = PluginManager.AllPlugins.FirstOrDefault(o => o.Metadata.ActionKeyword == query.ActionName); PluginPair userPlugin = PluginManager.AllPlugins.FirstOrDefault(o => o.Metadata.ActionKeyword == query.GetActionKeyword());
if (regularPlugin != null && !string.IsNullOrEmpty(regularPlugin.Metadata.ActionKeyword)) if (userPlugin != null && !string.IsNullOrEmpty(userPlugin.Metadata.ActionKeyword))
{ {
var customizedPluginConfig = UserSettingStorage.Instance.CustomizedPluginConfigs.FirstOrDefault(o => o.ID == regularPlugin.Metadata.ID); var customizedPluginConfig = UserSettingStorage.Instance.CustomizedPluginConfigs.FirstOrDefault(o => o.ID == userPlugin.Metadata.ID);
if (customizedPluginConfig != null && customizedPluginConfig.Disabled) if (customizedPluginConfig != null && customizedPluginConfig.Disabled)
{ {
//need to stop the loading animation //need to stop the loading animation
@@ -28,16 +28,16 @@ namespace Wox.Core.Plugin.QueryDispatcher
{ {
try try
{ {
List<Result> results = regularPlugin.Plugin.Query(query) ?? new List<Result>(); List<Result> results = userPlugin.Plugin.Query(query) ?? new List<Result>();
results.ForEach(o => results.ForEach(o =>
{ {
o.PluginID = regularPlugin.Metadata.ID; o.PluginID = userPlugin.Metadata.ID;
}); });
PluginManager.API.PushResults(query, regularPlugin.Metadata, results); PluginManager.API.PushResults(query, userPlugin.Metadata, results);
} }
catch (System.Exception e) catch (System.Exception e)
{ {
throw new WoxPluginException(regularPlugin.Metadata.Name, e); throw new WoxPluginException(userPlugin.Metadata.Name, e);
} }
}); });
} }

View File

@@ -2,6 +2,8 @@
===== =====
* Handle Query * Handle Query
* Define Wox exceptions
* Manage Plugins (including system plugin and user plugin) * Manage Plugins (including system plugin and user plugin)
* Manage Themes * Manage Themes
* Manage i18n * Manage i18n
* Manage Update and version

View File

@@ -83,8 +83,8 @@
<Compile Include="Plugin\PluginInstaller.cs" /> <Compile Include="Plugin\PluginInstaller.cs" />
<Compile Include="Plugin\QueryDispatcher\IQueryDispatcher.cs" /> <Compile Include="Plugin\QueryDispatcher\IQueryDispatcher.cs" />
<Compile Include="Plugin\QueryDispatcher\QueryDispatcher.cs" /> <Compile Include="Plugin\QueryDispatcher\QueryDispatcher.cs" />
<Compile Include="Plugin\QueryDispatcher\RegularPluginQueryDispatcher.cs" /> <Compile Include="Plugin\QueryDispatcher\UserPluginQueryDispatcher.cs" />
<Compile Include="Plugin\QueryDispatcher\WildcardPluginQueryDispatcher.cs" /> <Compile Include="Plugin\QueryDispatcher\SystemPluginQueryDispatcher.cs" />
<Compile Include="Plugin\JsonRPCPlugin.cs" /> <Compile Include="Plugin\JsonRPCPlugin.cs" />
<Compile Include="Plugin\JsonRPCPluginLoader.cs" /> <Compile Include="Plugin\JsonRPCPluginLoader.cs" />
<Compile Include="Plugin\CSharpPluginLoader.cs" /> <Compile Include="Plugin\CSharpPluginLoader.cs" />

View File

@@ -31,6 +31,11 @@ namespace Wox.Plugin
public string IcoPath { get; set; } public string IcoPath { get; set; }
public override string ToString()
{
return Name;
}
public string FullIcoPath public string FullIcoPath
{ {
get get

View File

@@ -9,5 +9,10 @@ namespace Wox.Plugin
{ {
public IPlugin Plugin { get; set; } public IPlugin Plugin { get; set; }
public PluginMetadata Metadata { get; set; } public PluginMetadata Metadata { get; set; }
public override string ToString()
{
return Metadata.Name;
}
} }
} }

View File

@@ -16,4 +16,5 @@ using System.Runtime.InteropServices;
[assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: InternalsVisibleTo("Wox")] [assembly: InternalsVisibleTo("Wox")]
[assembly: InternalsVisibleTo("Wox.Core")] [assembly: InternalsVisibleTo("Wox.Core")]
[assembly: InternalsVisibleTo("Wox.Test")]

View File

@@ -1,11 +1,112 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
namespace Wox.Plugin namespace Wox.Plugin
{ {
public class Query public class Query
{ {
public string RawQuery { get; set; } /// <summary>
/// Raw query, this includes action keyword if it has
/// We didn't recommend use this property directly. You should always use Search property.
/// </summary>
public string RawQuery { get; internal set; }
/// <summary>
/// Search part of a query.
/// This will not include action keyword if regular plugin gets it, and if a system plugin gets it, it should be same as RawQuery.
/// Since we allow user to switch a regular plugin to system plugin, so this property will always give you the "real" query part of
/// the query
/// </summary>
public string Search { get; internal set; }
internal string GetActionKeyword()
{
if (!string.IsNullOrEmpty(RawQuery))
{
var strings = RawQuery.Split(' ');
if (strings.Length > 0)
{
return strings[0];
}
}
return string.Empty;
}
/// <summary>
/// Return first search split by space if it has
/// </summary>
public string FirstSearch
{
get
{
return SplitSearch(0);
}
}
/// <summary>
/// strings from second search (including) to last search
/// </summary>
public string SecondToEndSearch
{
get
{
if (string.IsNullOrEmpty(Search)) return string.Empty;
var strings = Search.Split(' ');
if (strings.Length > 1)
{
return Search.Substring(Search.IndexOf(' ') + 1);
}
return string.Empty;
}
}
/// <summary>
/// Return second search split by space if it has
/// </summary>
public string SecondSearch
{
get
{
return SplitSearch(1);
}
}
/// <summary>
/// Return third search split by space if it has
/// </summary>
public string ThirdSearch
{
get
{
return SplitSearch(2);
}
}
private string SplitSearch(int index)
{
if (string.IsNullOrEmpty(Search)) return string.Empty;
var strings = Search.Split(' ');
if (strings.Length > index)
{
return strings[index];
}
return string.Empty;
}
public override string ToString()
{
return RawQuery;
}
[Obsolete("Use Search instead, A plugin developer shouldn't care about action name, as it may changed by users. " +
"this property will be removed in v1.3.0")]
public string ActionName { get; private set; } public string ActionName { get; private set; }
[Obsolete("Use Search instead, this property will be removed in v1.3.0")]
public List<string> ActionParameters { get; private set; } public List<string> ActionParameters { get; private set; }
public Query(string rawQuery) public Query(string rawQuery)
@@ -33,10 +134,11 @@ namespace Wox.Plugin
} }
} }
[Obsolete("Use Search instead, this method will be removed in v1.3.0")]
public string GetAllRemainingParameter() public string GetAllRemainingParameter()
{ {
string[] strings = RawQuery.Split(new char[]{ ' ' }, 2, System.StringSplitOptions.None); string[] strings = RawQuery.Split(new char[] { ' ' }, 2, System.StringSplitOptions.None);
if (strings.Length > 1) if (strings.Length > 1)
{ {
return strings[1]; return strings[1];

View File

@@ -10,22 +10,27 @@ namespace Wox.Test
public class QueryTest public class QueryTest
{ {
[Test] [Test]
public void QueryActionTest() public void UserPluginQueryTest()
{ {
Query q = new Query("this"); Query q = new Query("f file.txt file2 file3");
q.Search = "file.txt file2 file3";
q = new Query("ev file.txt"); Assert.AreEqual(q.FirstSearch, "file.txt");
Assert.AreEqual(q.ActionName,"ev"); Assert.AreEqual(q.SecondSearch, "file2");
Assert.AreEqual(q.ActionParameters.Count,1); Assert.AreEqual(q.ThirdSearch, "file3");
Assert.AreEqual(q.ActionParameters[0],"file.txt"); Assert.AreEqual(q.SecondToEndSearch, "file2 file3");
}
q = new Query("ev file.txt file2.txt"); [Test]
Assert.AreEqual(q.ActionName,"ev"); public void SystemPluginQueryTest()
Assert.AreEqual(q.ActionParameters.Count,2); {
Assert.AreEqual(q.ActionParameters[1],"file2.txt"); Query q = new Query("file.txt file2 file3");
q.Search = q.RawQuery;
q = new Query("ev file.txt file2.tx st"); Assert.AreEqual(q.FirstSearch, "file.txt");
Assert.AreEqual(q.GetAllRemainingParameter(), "file.txt file2.tx st"); Assert.AreEqual(q.SecondSearch, "file2");
Assert.AreEqual(q.ThirdSearch, "file3");
Assert.AreEqual(q.SecondToEndSearch, "file2 file3");
} }
} }
} }

View File

@@ -1,7 +1,7 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013 # Visual Studio 2013
VisualStudioVersion = 12.0.30723.0 VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Test", "Wox.Test\Wox.Test.csproj", "{FF742965-9A80-41A5-B042-D6C7D3A21708}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Test", "Wox.Test\Wox.Test.csproj", "{FF742965-9A80-41A5-B042-D6C7D3A21708}"
EndProject EndProject
@@ -43,6 +43,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.QueryHistory", "
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.UpdateFeedGenerator", "Wox.UpdateFeedGenerator\Wox.UpdateFeedGenerator.csproj", "{D120E62B-EC59-4FB4-8129-EFDD4C446A5F}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.UpdateFeedGenerator", "Wox.UpdateFeedGenerator\Wox.UpdateFeedGenerator.csproj", "{D120E62B-EC59-4FB4-8129-EFDD4C446A5F}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.Everything", "Plugins\Wox.Plugin.Everything\Wox.Plugin.Everything.csproj", "{230AE83F-E92E-4E69-8355-426B305DA9C0}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@@ -125,6 +127,10 @@ Global
{D120E62B-EC59-4FB4-8129-EFDD4C446A5F}.Debug|Any CPU.Build.0 = Debug|Any CPU {D120E62B-EC59-4FB4-8129-EFDD4C446A5F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D120E62B-EC59-4FB4-8129-EFDD4C446A5F}.Release|Any CPU.ActiveCfg = Release|Any CPU {D120E62B-EC59-4FB4-8129-EFDD4C446A5F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D120E62B-EC59-4FB4-8129-EFDD4C446A5F}.Release|Any CPU.Build.0 = Release|Any CPU {D120E62B-EC59-4FB4-8129-EFDD4C446A5F}.Release|Any CPU.Build.0 = Release|Any CPU
{230AE83F-E92E-4E69-8355-426B305DA9C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{230AE83F-E92E-4E69-8355-426B305DA9C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{230AE83F-E92E-4E69-8355-426B305DA9C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{230AE83F-E92E-4E69-8355-426B305DA9C0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@@ -142,5 +148,6 @@ Global
{A3DCCBCA-ACC1-421D-B16E-210896234C26} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87} {A3DCCBCA-ACC1-421D-B16E-210896234C26} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
{F35190AA-4758-4D9E-A193-E3BDF6AD3567} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87} {F35190AA-4758-4D9E-A193-E3BDF6AD3567} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
{B552DCB6-692E-4B1D-9E0B-9096A2A7E6B0} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87} {B552DCB6-692E-4B1D-9E0B-9096A2A7E6B0} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
{230AE83F-E92E-4E69-8355-426B305DA9C0} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View File

@@ -57,7 +57,7 @@ namespace Wox
} }
//check new action keyword didn't used by other plugin //check new action keyword didn't used by other plugin
if (tbAction.Text.Trim() != PluginManager.ActionKeywordWildcard && PluginManager.AllPlugins.Exists(o => o.Metadata.ActionKeyword == tbAction.Text.Trim())) if (tbAction.Text.Trim() != PluginManager.ActionKeywordWildcardSign && PluginManager.AllPlugins.Exists(o => o.Metadata.ActionKeyword == tbAction.Text.Trim()))
{ {
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("newActionKeywordHasBeenAssigned")); MessageBox.Show(InternationalizationManager.Instance.GetTranslation("newActionKeywordHasBeenAssigned"));
return; return;

View File

@@ -18,7 +18,7 @@
<Window.Resources> <Window.Resources>
<ResourceDictionary Source="/PresentationFramework.Classic,Version=3.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,processorArchitecture=MSIL;component/themes/Classic.xaml"/> <ResourceDictionary Source="/PresentationFramework.Classic,Version=3.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,processorArchitecture=MSIL;component/themes/Classic.xaml"/>
</Window.Resources> </Window.Resources>
<Border Style="{DynamicResource WindowBorderStyle}" MouseDown="Border_OnMouseDown"> <Border Style="{DynamicResource WindowBorderStyle}" MouseDown="Border_OnMouseDown" BorderBrush="#FF000000" CornerRadius="8">
<StackPanel Orientation="Vertical"> <StackPanel Orientation="Vertical">
<TextBox Style="{DynamicResource QueryBoxStyle}" PreviewDragOver="TbQuery_OnPreviewDragOver" AllowDrop="True" Grid.Row="0" x:Name="tbQuery" PreviewKeyDown="TbQuery_OnPreviewKeyDown" TextChanged="TextBoxBase_OnTextChanged" /> <TextBox Style="{DynamicResource QueryBoxStyle}" PreviewDragOver="TbQuery_OnPreviewDragOver" AllowDrop="True" Grid.Row="0" x:Name="tbQuery" PreviewKeyDown="TbQuery_OnPreviewKeyDown" TextChanged="TextBoxBase_OnTextChanged" />
<Line Style="{DynamicResource PendingLineStyle}" x:Name="progressBar" Y1="0" Y2="0" X2="100" Grid.Row="1" Height="2" StrokeThickness="1"></Line> <Line Style="{DynamicResource PendingLineStyle}" x:Name="progressBar" Y1="0" Y2="0" X2="100" Grid.Row="1" Height="2" StrokeThickness="1"></Line>

View File

@@ -406,16 +406,6 @@ namespace Wox
pnlContextMenu.Visibility = Visibility.Collapsed; pnlContextMenu.Visibility = Visibility.Collapsed;
} }
private bool IsWebSearchMode
{
get
{
Query q = new Query(tbQuery.Text);
return !UserSettingStorage.Instance.EnableWebSearchSuggestion &&
UserSettingStorage.Instance.WebSearches.Exists(o => o.ActionWord == q.ActionName && o.Enabled);
}
}
private void Border_OnMouseDown(object sender, MouseButtonEventArgs e) private void Border_OnMouseDown(object sender, MouseButtonEventArgs e)
{ {
if (e.ChangedButton == MouseButton.Left) DragMove(); if (e.ChangedButton == MouseButton.Left) DragMove();