mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-06-07 09:28:03 +08:00
some API changes for Query class and renames.
This commit is contained in:
parent
ddf6154600
commit
7821f41723
@ -21,14 +21,14 @@ namespace Wox.Plugin.CMD
|
||||
{
|
||||
List<Result> results = new List<Result>();
|
||||
List<Result> pushedResults = new List<Result>();
|
||||
if (query.RawQuery == ">")
|
||||
if (query.Search == ">")
|
||||
{
|
||||
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);
|
||||
context.API.PushResults(query, context.CurrentPluginMetadata, new List<Result>() { queryCmd });
|
||||
pushedResults.Add(queryCmd);
|
||||
|
@ -28,13 +28,13 @@ namespace Wox.Plugin.Caculator
|
||||
|
||||
public List<Result> Query(Query query)
|
||||
{
|
||||
if (query.RawQuery.Length <= 2 // don't affect when user only input "e" or "i" keyword
|
||||
|| !regValidExpressChar.IsMatch(query.RawQuery)
|
||||
|| !IsBracketComplete(query.RawQuery)) return new List<Result>();
|
||||
if (query.Search.Length <= 2 // don't affect when user only input "e" or "i" keyword
|
||||
|| !regValidExpressChar.IsMatch(query.Search)
|
||||
|| !IsBracketComplete(query.Search)) return new List<Result>();
|
||||
|
||||
try
|
||||
{
|
||||
var result = yampContext.Run(query.RawQuery);
|
||||
var result = yampContext.Run(query.Search);
|
||||
if (result.Output != null && !string.IsNullOrEmpty(result.Result))
|
||||
{
|
||||
return new List<Result>() { new Result() {
|
||||
|
@ -29,7 +29,7 @@ namespace Wox.Plugin.Color
|
||||
|
||||
public List<Result> Query(Query query)
|
||||
{
|
||||
var raw = query.RawQuery;
|
||||
var raw = query.Search;
|
||||
if (!IsAvailable(raw)) return new List<Result>(0);
|
||||
try
|
||||
{
|
||||
|
@ -38,9 +38,7 @@ namespace Wox.Plugin.ControlPanel
|
||||
|
||||
public List<Result> Query(Query query)
|
||||
{
|
||||
if (query.RawQuery.EndsWith(" ") || query.RawQuery.Length <= 1) return new List<Result>();
|
||||
string myQuery = query.RawQuery.Trim();
|
||||
|
||||
string myQuery = query.Search.Trim();
|
||||
List<Result> results = new List<Result>();
|
||||
|
||||
foreach (var item in controlPanelItems)
|
||||
|
@ -53,8 +53,7 @@ namespace Wox.Plugin.Folder
|
||||
|
||||
public List<Result> Query(Query query)
|
||||
{
|
||||
if(string.IsNullOrEmpty(query.RawQuery)) return new List<Result>();
|
||||
string input = query.RawQuery.ToLower();
|
||||
string input = query.Search.ToLower();
|
||||
|
||||
List<FolderLink> userFolderLinks = FolderStorage.Instance.FolderLinks.Where(
|
||||
x => x.Nickname.StartsWith(input, StringComparison.OrdinalIgnoreCase)).ToList();
|
||||
|
@ -13,16 +13,14 @@ namespace Wox.Plugin.PluginIndicator
|
||||
public List<Result> Query(Query query)
|
||||
{
|
||||
List<Result> results = new List<Result>();
|
||||
if (string.IsNullOrEmpty(query.RawQuery)) return results;
|
||||
|
||||
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))
|
||||
{
|
||||
if (metadata.ActionKeyword.StartsWith(query.RawQuery))
|
||||
if (metadata.ActionKeyword.StartsWith(query.Search))
|
||||
{
|
||||
PluginMetadata metadataCopy = metadata;
|
||||
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,
|
||||
SubTitle = string.Format("Activate {0} web search", n.ActionWord),
|
||||
|
@ -10,59 +10,37 @@ using Newtonsoft.Json;
|
||||
|
||||
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
|
||||
{
|
||||
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 pluginSearchUrl = APIBASE +"/plugin/search/";
|
||||
private static string pluginSearchUrl = APIBASE + "/plugin/search/";
|
||||
private PluginInitContext context;
|
||||
|
||||
public List<Result> Query(Query query)
|
||||
{
|
||||
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 =>
|
||||
{
|
||||
context.API.ChangeQuery("wpm install ");
|
||||
return false;
|
||||
}
|
||||
Action = e => ChangeToInstallCommand()
|
||||
});
|
||||
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 =>
|
||||
{
|
||||
context.API.ChangeQuery("wpm uninstall ");
|
||||
return false;
|
||||
}
|
||||
Action = e => ChangeToUninstallCommand()
|
||||
});
|
||||
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 =>
|
||||
{
|
||||
context.API.ChangeQuery("wpm list");
|
||||
return false;
|
||||
}
|
||||
Action = e => ChangeToListCommand()
|
||||
});
|
||||
return results;
|
||||
}
|
||||
|
||||
if (query.ActionParameters.Count > 0)
|
||||
if (!string.IsNullOrEmpty(query.FirstSearch))
|
||||
{
|
||||
bool hit = false;
|
||||
switch (query.ActionParameters[0].ToLower())
|
||||
switch (query.FirstSearch.ToLower())
|
||||
{
|
||||
case "list":
|
||||
hit = true;
|
||||
@ -71,51 +49,39 @@ namespace Wox.Plugin.PluginManagement
|
||||
|
||||
case "uninstall":
|
||||
hit = true;
|
||||
results = ListUnInstalledPlugins(query);
|
||||
results = UnInstallPlugins(query);
|
||||
break;
|
||||
|
||||
case "install":
|
||||
hit = true;
|
||||
if (query.ActionParameters.Count > 1)
|
||||
if (!string.IsNullOrEmpty(query.SecondSearch))
|
||||
{
|
||||
results = InstallPlugin(query);
|
||||
results = InstallPlugin(query.SecondSearch);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
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 =>
|
||||
{
|
||||
context.API.ChangeQuery("wpm install ");
|
||||
return false;
|
||||
}
|
||||
Action = e => ChangeToInstallCommand()
|
||||
});
|
||||
}
|
||||
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 =>
|
||||
{
|
||||
context.API.ChangeQuery("wpm uninstall ");
|
||||
return false;
|
||||
}
|
||||
Action = e => ChangeToUninstallCommand()
|
||||
});
|
||||
}
|
||||
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 =>
|
||||
{
|
||||
context.API.ChangeQuery("wpm list");
|
||||
return false;
|
||||
}
|
||||
Action = e => ChangeToListCommand()
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -124,10 +90,49 @@ namespace Wox.Plugin.PluginManagement
|
||||
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>();
|
||||
HttpWebResponse response = HttpRequest.CreateGetHttpResponse(pluginSearchUrl + query.ActionParameters[1], context.Proxy);
|
||||
HttpWebResponse response = HttpRequest.CreateGetHttpResponse(pluginSearchUrl + queryPluginName, context.Proxy);
|
||||
Stream s = response.GetResponseStream();
|
||||
if (s != null)
|
||||
{
|
||||
@ -140,7 +145,7 @@ namespace Wox.Plugin.PluginManagement
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
@ -194,19 +199,19 @@ namespace Wox.Plugin.PluginManagement
|
||||
return results;
|
||||
}
|
||||
|
||||
private List<Result> ListUnInstalledPlugins(Query query)
|
||||
private List<Result> UnInstallPlugins(Query query)
|
||||
{
|
||||
List<Result> results = new List<Result>();
|
||||
List<PluginMetadata> allInstalledPlugins = ParseRegularPlugins();
|
||||
if (query.ActionParameters.Count > 1)
|
||||
List<PluginMetadata> allInstalledPlugins = context.API.GetAllPlugins().Select(o => o.Metadata).ToList();
|
||||
if (!string.IsNullOrEmpty(query.SecondSearch))
|
||||
{
|
||||
string pluginName = query.ActionParameters[1];
|
||||
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)
|
||||
{
|
||||
var plugin1 = plugin;
|
||||
results.Add(new Result()
|
||||
{
|
||||
Title = plugin.Name,
|
||||
@ -214,7 +219,7 @@ namespace Wox.Plugin.PluginManagement
|
||||
IcoPath = plugin.FullIcoPath,
|
||||
Action = e =>
|
||||
{
|
||||
UnInstalledPlugins(plugin);
|
||||
UnInstallPlugin(plugin1);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
@ -222,7 +227,7 @@ namespace Wox.Plugin.PluginManagement
|
||||
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);
|
||||
if (MessageBox.Show(content, "Wox", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
||||
@ -235,7 +240,7 @@ namespace Wox.Plugin.PluginManagement
|
||||
private List<Result> ListInstalledPlugins()
|
||||
{
|
||||
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()
|
||||
{
|
||||
@ -247,61 +252,6 @@ namespace Wox.Plugin.PluginManagement
|
||||
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)
|
||||
{
|
||||
this.context = context;
|
||||
|
@ -1,91 +1,92 @@
|
||||
<?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>{049490F0-ECD2-4148-9B39-2135EC346EBE}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Wox.Plugin.PluginManagement</RootNamespace>
|
||||
<AssemblyName>Wox.Plugin.PluginManagement</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
|
||||
<RestorePackages>true</RestorePackages>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\Output\Debug\Plugins\Wox.Plugin.PluginManagement\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\Output\Release\Plugins\Wox.Plugin.PluginManagement\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>..\..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<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" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="HttpRequest.cs" />
|
||||
<Compile Include="Main.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Wox.Plugin\Wox.Plugin.csproj">
|
||||
<Project>{8451ecdd-2ea4-4966-bb0a-7bbc40138e80}</Project>
|
||||
<Name>Wox.Plugin</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
<None Include="plugin.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Images\plugin.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</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>{049490F0-ECD2-4148-9B39-2135EC346EBE}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Wox.Plugin.PluginManagement</RootNamespace>
|
||||
<AssemblyName>Wox.Plugin.PluginManagement</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
|
||||
<RestorePackages>true</RestorePackages>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\Output\Debug\Plugins\Wox.Plugin.PluginManagement\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\Output\Release\Plugins\Wox.Plugin.PluginManagement\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>..\..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<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" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="HttpRequest.cs" />
|
||||
<Compile Include="Main.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="WoxPluginResult.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Wox.Plugin\Wox.Plugin.csproj">
|
||||
<Project>{8451ecdd-2ea4-4966-bb0a-7bbc40138e80}</Project>
|
||||
<Name>Wox.Plugin</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
<None Include="plugin.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Images\plugin.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</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>
|
11
Plugins/Wox.Plugin.PluginManagement/WoxPluginResult.cs
Normal file
11
Plugins/Wox.Plugin.PluginManagement/WoxPluginResult.cs
Normal 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;
|
||||
}
|
||||
}
|
@ -26,9 +26,7 @@ namespace Wox.Plugin.Program
|
||||
|
||||
public List<Result> Query(Query query)
|
||||
{
|
||||
if (query.RawQuery.Trim().Length <= 1) return new List<Result>();
|
||||
|
||||
var fuzzyMather = FuzzyMatcher.Create(query.RawQuery);
|
||||
var fuzzyMather = FuzzyMatcher.Create(query.Search);
|
||||
List<Program> returnList = programs.Where(o => MatchProgram(o, fuzzyMather)).ToList();
|
||||
returnList.ForEach(ScoreFilter);
|
||||
returnList = returnList.OrderByDescending(o => o.Score).ToList();
|
||||
|
@ -13,7 +13,7 @@ namespace Wox.Plugin.QueryHistory
|
||||
public List<Result> Query(Query query)
|
||||
{
|
||||
var histories = QueryHistoryStorage.Instance.GetHistory();
|
||||
string filter = query.GetAllRemainingParameter();
|
||||
string filter = query.Search;
|
||||
if (!string.IsNullOrEmpty(filter))
|
||||
{
|
||||
histories = histories.Where(o => o.Query.Contains(filter)).ToList();
|
||||
|
@ -34,7 +34,6 @@ namespace Wox.Plugin.Sys
|
||||
|
||||
public List<Result> Query(Query query)
|
||||
{
|
||||
if (query.RawQuery.EndsWith(" ") || query.RawQuery.Length <= 1) return new List<Result>();
|
||||
if (availableResults.Count == 0)
|
||||
{
|
||||
LoadCommands();
|
||||
@ -43,7 +42,7 @@ namespace Wox.Plugin.Sys
|
||||
List<Result> results = new List<Result>();
|
||||
foreach (Result availableResult in availableResults)
|
||||
{
|
||||
if (availableResult.Title.ToLower().StartsWith(query.RawQuery.ToLower()))
|
||||
if (availableResult.Title.ToLower().StartsWith(query.Search.ToLower()))
|
||||
{
|
||||
results.Add(availableResult);
|
||||
}
|
||||
|
@ -45,9 +45,7 @@ namespace Wox.Plugin.Url
|
||||
|
||||
public List<Result> Query(Query query)
|
||||
{
|
||||
if(string.IsNullOrEmpty(query.RawQuery)) return new List<Result>();
|
||||
|
||||
var raw = query.RawQuery;
|
||||
var raw = query.Search;
|
||||
if (IsURL(raw))
|
||||
{
|
||||
return new List<Result>
|
||||
|
@ -18,11 +18,11 @@ namespace Wox.Plugin.WebSearch
|
||||
List<Result> results = new List<Result>();
|
||||
|
||||
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)
|
||||
{
|
||||
string keyword = query.ActionParameters.Count > 0 ? query.GetAllRemainingParameter() : "";
|
||||
string keyword = query.SecondToEndSearch;
|
||||
string title = keyword;
|
||||
string subtitle = "Search " + webSearch.Title;
|
||||
if (string.IsNullOrEmpty(keyword))
|
||||
|
@ -19,7 +19,7 @@ namespace Wox.Core.Plugin
|
||||
/// </summary>
|
||||
public static class PluginManager
|
||||
{
|
||||
public const string ActionKeywordWildcard = "*";
|
||||
public const string ActionKeywordWildcardSign = "*";
|
||||
|
||||
public static String DebuggerMode { get; private set; }
|
||||
public static IPublicAPI API { get; private set; }
|
||||
@ -104,7 +104,10 @@ namespace Wox.Core.Plugin
|
||||
|
||||
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
|
||||
@ -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)
|
||||
|
@ -3,18 +3,20 @@ namespace Wox.Core.Plugin.QueryDispatcher
|
||||
{
|
||||
internal static class QueryDispatcher
|
||||
{
|
||||
private static IQueryDispatcher regularDispatcher = new RegularPluginQueryDispatcher();
|
||||
private static IQueryDispatcher wildcardDispatcher = new WildcardPluginQueryDispatcher();
|
||||
private static readonly IQueryDispatcher UserPluginDispatcher = new UserPluginQueryDispatcher();
|
||||
private static readonly IQueryDispatcher SystemPluginDispatcher = new SystemPluginQueryDispatcher();
|
||||
|
||||
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
|
||||
{
|
||||
wildcardDispatcher.Dispatch(query);
|
||||
query.Search = query.RawQuery;
|
||||
SystemPluginDispatcher.Dispatch(query);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,9 +8,9 @@ using Wox.Plugin;
|
||||
|
||||
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)
|
||||
{
|
@ -9,14 +9,14 @@ using Wox.Plugin;
|
||||
|
||||
namespace Wox.Core.Plugin.QueryDispatcher
|
||||
{
|
||||
public class RegularPluginQueryDispatcher : IQueryDispatcher
|
||||
public class UserPluginQueryDispatcher : IQueryDispatcher
|
||||
{
|
||||
public void Dispatch(Query query)
|
||||
{
|
||||
PluginPair regularPlugin = PluginManager.AllPlugins.FirstOrDefault(o => o.Metadata.ActionKeyword == query.ActionName);
|
||||
if (regularPlugin != null && !string.IsNullOrEmpty(regularPlugin.Metadata.ActionKeyword))
|
||||
PluginPair userPlugin = PluginManager.AllPlugins.FirstOrDefault(o => o.Metadata.ActionKeyword == query.GetActionKeyword());
|
||||
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)
|
||||
{
|
||||
//need to stop the loading animation
|
||||
@ -28,16 +28,16 @@ namespace Wox.Core.Plugin.QueryDispatcher
|
||||
{
|
||||
try
|
||||
{
|
||||
List<Result> results = regularPlugin.Plugin.Query(query) ?? new List<Result>();
|
||||
List<Result> results = userPlugin.Plugin.Query(query) ?? new List<Result>();
|
||||
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)
|
||||
{
|
||||
throw new WoxPluginException(regularPlugin.Metadata.Name, e);
|
||||
throw new WoxPluginException(userPlugin.Metadata.Name, e);
|
||||
}
|
||||
});
|
||||
}
|
@ -2,6 +2,8 @@
|
||||
=====
|
||||
|
||||
* Handle Query
|
||||
* Define Wox exceptions
|
||||
* Manage Plugins (including system plugin and user plugin)
|
||||
* Manage Themes
|
||||
* Manage i18n
|
||||
* Manage i18n
|
||||
* Manage Update and version
|
@ -83,8 +83,8 @@
|
||||
<Compile Include="Plugin\PluginInstaller.cs" />
|
||||
<Compile Include="Plugin\QueryDispatcher\IQueryDispatcher.cs" />
|
||||
<Compile Include="Plugin\QueryDispatcher\QueryDispatcher.cs" />
|
||||
<Compile Include="Plugin\QueryDispatcher\RegularPluginQueryDispatcher.cs" />
|
||||
<Compile Include="Plugin\QueryDispatcher\WildcardPluginQueryDispatcher.cs" />
|
||||
<Compile Include="Plugin\QueryDispatcher\UserPluginQueryDispatcher.cs" />
|
||||
<Compile Include="Plugin\QueryDispatcher\SystemPluginQueryDispatcher.cs" />
|
||||
<Compile Include="Plugin\JsonRPCPlugin.cs" />
|
||||
<Compile Include="Plugin\JsonRPCPluginLoader.cs" />
|
||||
<Compile Include="Plugin\CSharpPluginLoader.cs" />
|
||||
|
@ -31,6 +31,11 @@ namespace Wox.Plugin
|
||||
|
||||
public string IcoPath { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
public string FullIcoPath
|
||||
{
|
||||
get
|
||||
|
@ -9,5 +9,10 @@ namespace Wox.Plugin
|
||||
{
|
||||
public IPlugin Plugin { get; set; }
|
||||
public PluginMetadata Metadata { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Metadata.Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,4 +16,5 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
|
||||
[assembly: InternalsVisibleTo("Wox")]
|
||||
[assembly: InternalsVisibleTo("Wox.Core")]
|
||||
[assembly: InternalsVisibleTo("Wox.Core")]
|
||||
[assembly: InternalsVisibleTo("Wox.Test")]
|
@ -1,11 +1,112 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Wox.Plugin
|
||||
{
|
||||
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; }
|
||||
|
||||
[Obsolete("Use Search instead, this property will be removed in v1.3.0")]
|
||||
public List<string> ActionParameters { get; private set; }
|
||||
|
||||
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()
|
||||
{
|
||||
|
||||
string[] strings = RawQuery.Split(new char[]{ ' ' }, 2, System.StringSplitOptions.None);
|
||||
string[] strings = RawQuery.Split(new char[] { ' ' }, 2, System.StringSplitOptions.None);
|
||||
if (strings.Length > 1)
|
||||
{
|
||||
return strings[1];
|
||||
|
@ -10,22 +10,27 @@ namespace Wox.Test
|
||||
public class QueryTest
|
||||
{
|
||||
[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.ActionName,"ev");
|
||||
Assert.AreEqual(q.ActionParameters.Count,1);
|
||||
Assert.AreEqual(q.ActionParameters[0],"file.txt");
|
||||
Assert.AreEqual(q.FirstSearch, "file.txt");
|
||||
Assert.AreEqual(q.SecondSearch, "file2");
|
||||
Assert.AreEqual(q.ThirdSearch, "file3");
|
||||
Assert.AreEqual(q.SecondToEndSearch, "file2 file3");
|
||||
}
|
||||
|
||||
q = new Query("ev file.txt file2.txt");
|
||||
Assert.AreEqual(q.ActionName,"ev");
|
||||
Assert.AreEqual(q.ActionParameters.Count,2);
|
||||
Assert.AreEqual(q.ActionParameters[1],"file2.txt");
|
||||
[Test]
|
||||
public void SystemPluginQueryTest()
|
||||
{
|
||||
Query q = new Query("file.txt file2 file3");
|
||||
q.Search = q.RawQuery;
|
||||
|
||||
q = new Query("ev file.txt file2.tx st");
|
||||
Assert.AreEqual(q.GetAllRemainingParameter(), "file.txt file2.tx st");
|
||||
Assert.AreEqual(q.FirstSearch, "file.txt");
|
||||
Assert.AreEqual(q.SecondSearch, "file2");
|
||||
Assert.AreEqual(q.ThirdSearch, "file3");
|
||||
Assert.AreEqual(q.SecondToEndSearch, "file2 file3");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
9
Wox.sln
9
Wox.sln
@ -1,7 +1,7 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.30723.0
|
||||
VisualStudioVersion = 12.0.21005.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Test", "Wox.Test\Wox.Test.csproj", "{FF742965-9A80-41A5-B042-D6C7D3A21708}"
|
||||
EndProject
|
||||
@ -43,6 +43,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.QueryHistory", "
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.UpdateFeedGenerator", "Wox.UpdateFeedGenerator\Wox.UpdateFeedGenerator.csproj", "{D120E62B-EC59-4FB4-8129-EFDD4C446A5F}"
|
||||
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
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
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}.Release|Any CPU.ActiveCfg = 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
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@ -142,5 +148,6 @@ Global
|
||||
{A3DCCBCA-ACC1-421D-B16E-210896234C26} = {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}
|
||||
{230AE83F-E92E-4E69-8355-426B305DA9C0} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
@ -57,7 +57,7 @@ namespace Wox
|
||||
}
|
||||
|
||||
//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"));
|
||||
return;
|
||||
|
@ -18,7 +18,7 @@
|
||||
<Window.Resources>
|
||||
<ResourceDictionary Source="/PresentationFramework.Classic,Version=3.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,processorArchitecture=MSIL;component/themes/Classic.xaml"/>
|
||||
</Window.Resources>
|
||||
<Border Style="{DynamicResource WindowBorderStyle}" MouseDown="Border_OnMouseDown">
|
||||
<Border Style="{DynamicResource WindowBorderStyle}" MouseDown="Border_OnMouseDown" BorderBrush="#FF000000" CornerRadius="8">
|
||||
<StackPanel Orientation="Vertical">
|
||||
<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>
|
||||
|
@ -406,16 +406,6 @@ namespace Wox
|
||||
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)
|
||||
{
|
||||
if (e.ChangedButton == MouseButton.Left) DragMove();
|
||||
|
Loading…
Reference in New Issue
Block a user