Move web search setting to its own project

This commit is contained in:
qianlifeng 2015-01-26 22:50:38 +08:00
parent 56fa719931
commit 87958d9db8
13 changed files with 270 additions and 253 deletions

View File

@ -45,18 +45,18 @@ namespace Wox.Plugin.PluginIndicator
}
}
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),
Score = 100,
IcoPath = "Images/work.png",
Action = (c) =>
{
context.API.ChangeQuery(n.ActionWord + " ");
return false;
}
}));
//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),
// Score = 100,
// IcoPath = "Images/work.png",
// Action = (c) =>
// {
// context.API.ChangeQuery(n.ActionWord + " ");
// return false;
// }
//}));
return results;
}

View File

@ -1,6 +1,6 @@
using System;
namespace Wox.Core.UserSettings
namespace Wox.Plugin.WebSearch
{
[Serializable]
public class WebSearch

View File

@ -17,8 +17,8 @@ namespace Wox.Plugin.WebSearch
{
List<Result> results = new List<Result>();
Core.UserSettings.WebSearch webSearch =
UserSettingStorage.Instance.WebSearches.FirstOrDefault(o => o.ActionWord == query.FirstSearch.Trim() && o.Enabled);
WebSearch webSearch =
WebSearchStorage.Instance.WebSearches.FirstOrDefault(o => o.ActionWord == query.FirstSearch.Trim() && o.Enabled);
if (webSearch != null)
{
@ -46,10 +46,10 @@ namespace Wox.Plugin.WebSearch
}
});
if (UserSettingStorage.Instance.EnableWebSearchSuggestion && !string.IsNullOrEmpty(keyword))
if (WebSearchStorage.Instance.EnableWebSearchSuggestion && !string.IsNullOrEmpty(keyword))
{
ISuggestionSource sugg = SuggestionSourceFactory.GetSuggestionSource(
UserSettingStorage.Instance.WebSearchSuggestionSource);
WebSearchStorage.Instance.WebSearchSuggestionSource);
if (sugg != null)
{
var result = sugg.GetSuggestions(keyword);
@ -80,8 +80,8 @@ namespace Wox.Plugin.WebSearch
{
this.context = context;
if (UserSettingStorage.Instance.WebSearches == null)
UserSettingStorage.Instance.WebSearches = UserSettingStorage.Instance.LoadDefaultWebSearches();
if (WebSearchStorage.Instance.WebSearches == null)
WebSearchStorage.Instance.WebSearches = WebSearchStorage.Instance.LoadDefaultWebSearches();
}
#region ISettingProvider Members

View File

@ -14,7 +14,7 @@ namespace Wox.Plugin.WebSearch
private string defaultWebSearchImageDirectory = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Images\\websearch");
private WebSearchesSetting settingWindow;
private bool update;
private Core.UserSettings.WebSearch updateWebSearch;
private WebSearch updateWebSearch;
private PluginInitContext context;
public WebSearchSetting(WebSearchesSetting settingWidow,PluginInitContext context)
@ -24,9 +24,9 @@ namespace Wox.Plugin.WebSearch
InitializeComponent();
}
public void UpdateItem(Core.UserSettings.WebSearch webSearch)
public void UpdateItem(WebSearch webSearch)
{
updateWebSearch = UserSettingStorage.Instance.WebSearches.FirstOrDefault(o => o == webSearch);
updateWebSearch = WebSearchStorage.Instance.WebSearches.FirstOrDefault(o => o == webSearch);
if (updateWebSearch == null || string.IsNullOrEmpty(updateWebSearch.Url))
{
@ -91,13 +91,13 @@ namespace Wox.Plugin.WebSearch
if (!update)
{
if (UserSettingStorage.Instance.WebSearches.Exists(o => o.ActionWord == action))
if (WebSearchStorage.Instance.WebSearches.Exists(o => o.ActionWord == action))
{
string warning = context.API.GetTranslation("wox_plugin_websearch_action_keyword_exist");
MessageBox.Show(warning);
return;
}
UserSettingStorage.Instance.WebSearches.Add(new Core.UserSettings.WebSearch()
WebSearchStorage.Instance.WebSearches.Add(new WebSearch()
{
ActionWord = action,
Enabled = cbEnable.IsChecked ?? false,
@ -110,7 +110,7 @@ namespace Wox.Plugin.WebSearch
}
else
{
if (UserSettingStorage.Instance.WebSearches.Exists(o => o.ActionWord == action && o != updateWebSearch))
if (WebSearchStorage.Instance.WebSearches.Exists(o => o.ActionWord == action && o != updateWebSearch))
{
string warning = context.API.GetTranslation("wox_plugin_websearch_action_keyword_exist");
MessageBox.Show(warning);

View File

@ -0,0 +1,78 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using Newtonsoft.Json;
using Wox.Core.UserSettings;
using Wox.Infrastructure.Storage;
namespace Wox.Plugin.WebSearch
{
public class WebSearchStorage :JsonStrorage<WebSearchStorage>
{
[JsonProperty]
public List<WebSearch> WebSearches { get; set; }
[JsonProperty]
public bool EnableWebSearchSuggestion { get; set; }
[JsonProperty]
public string WebSearchSuggestionSource { get; set; }
protected override string ConfigFolder
{
get { return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); }
}
protected override string ConfigName
{
get { return "setting"; }
}
protected override WebSearchStorage LoadDefault()
{
WebSearches = LoadDefaultWebSearches();
return this;
}
public List<WebSearch> LoadDefaultWebSearches()
{
List<WebSearch> webSearches = new List<WebSearch>();
WebSearch googleWebSearch = new WebSearch()
{
Title = "Google",
ActionWord = "g",
IconPath = @"Images\websearch\google.png",
Url = "https://www.google.com/search?q={q}",
Enabled = true
};
webSearches.Add(googleWebSearch);
WebSearch wikiWebSearch = new WebSearch()
{
Title = "Wikipedia",
ActionWord = "wiki",
IconPath = @"Images\websearch\wiki.png",
Url = "http://en.wikipedia.org/wiki/{q}",
Enabled = true
};
webSearches.Add(wikiWebSearch);
WebSearch findIcon = new WebSearch()
{
Title = "FindIcon",
ActionWord = "findicon",
IconPath = @"Images\websearch\pictures.png",
Url = "http://findicons.com/search/{q}",
Enabled = true
};
webSearches.Add(findIcon);
return webSearches;
}
}
}

View File

@ -24,9 +24,9 @@ namespace Wox.Plugin.WebSearch
private void Setting_Loaded(object sender, RoutedEventArgs e)
{
webSearchView.ItemsSource = UserSettingStorage.Instance.WebSearches;
cbEnableWebSearchSuggestion.IsChecked = UserSettingStorage.Instance.EnableWebSearchSuggestion;
comboBoxSuggestionSource.Visibility = UserSettingStorage.Instance.EnableWebSearchSuggestion
webSearchView.ItemsSource = WebSearchStorage.Instance.WebSearches;
cbEnableWebSearchSuggestion.IsChecked = WebSearchStorage.Instance.EnableWebSearchSuggestion;
comboBoxSuggestionSource.Visibility = WebSearchStorage.Instance.EnableWebSearchSuggestion
? Visibility.Visible
: Visibility.Collapsed;
@ -35,7 +35,7 @@ namespace Wox.Plugin.WebSearch
new ComboBoxItem() {Content = "Google"},
new ComboBoxItem() {Content = "Baidu"},
};
ComboBoxItem selected = items.FirstOrDefault(o => o.Content.ToString() == UserSettingStorage.Instance.WebSearchSuggestionSource);
ComboBoxItem selected = items.FirstOrDefault(o => o.Content.ToString() == WebSearchStorage.Instance.WebSearchSuggestionSource);
if (selected == null)
{
selected = items[0];
@ -58,14 +58,14 @@ namespace Wox.Plugin.WebSearch
private void btnDeleteWebSearch_OnClick(object sender, RoutedEventArgs e)
{
Core.UserSettings.WebSearch selectedWebSearch = webSearchView.SelectedItem as Core.UserSettings.WebSearch;
WebSearch selectedWebSearch = webSearchView.SelectedItem as WebSearch;
if (selectedWebSearch != null)
{
string msg = string.Format(context.API.GetTranslation("wox_plugin_websearch_delete_warning"),selectedWebSearch.Title);
if (MessageBox.Show(msg,string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
{
UserSettingStorage.Instance.WebSearches.Remove(selectedWebSearch);
WebSearchStorage.Instance.WebSearches.Remove(selectedWebSearch);
webSearchView.Items.Refresh();
}
}
@ -78,7 +78,7 @@ namespace Wox.Plugin.WebSearch
private void btnEditWebSearch_OnClick(object sender, RoutedEventArgs e)
{
Core.UserSettings.WebSearch selectedWebSearch = webSearchView.SelectedItem as Core.UserSettings.WebSearch;
WebSearch selectedWebSearch = webSearchView.SelectedItem as WebSearch;
if (selectedWebSearch != null)
{
WebSearchSetting webSearch = new WebSearchSetting(this,context);
@ -95,23 +95,22 @@ namespace Wox.Plugin.WebSearch
private void CbEnableWebSearchSuggestion_OnChecked(object sender, RoutedEventArgs e)
{
comboBoxSuggestionSource.Visibility = Visibility.Visible;
UserSettingStorage.Instance.EnableWebSearchSuggestion = true;
UserSettingStorage.Instance.Save();
WebSearchStorage.Instance.EnableWebSearchSuggestion = true;
WebSearchStorage.Instance.Save();
}
private void CbEnableWebSearchSuggestion_OnUnchecked(object sender, RoutedEventArgs e)
{
comboBoxSuggestionSource.Visibility = Visibility.Collapsed;
UserSettingStorage.Instance.EnableWebSearchSuggestion = false;
UserSettingStorage.Instance.Save();
WebSearchStorage.Instance.EnableWebSearchSuggestion = false;
WebSearchStorage.Instance.Save();
}
private void ComboBoxSuggestionSource_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (e.AddedItems.Count > 0)
{
UserSettingStorage.Instance.WebSearchSuggestionSource =
((ComboBoxItem) e.AddedItems[0]).Content.ToString();
WebSearchStorage.Instance.WebSearchSuggestionSource = ((ComboBoxItem) e.AddedItems[0]).Content.ToString();
UserSettingStorage.Instance.Save();
}
}

View File

@ -1,145 +1,147 @@
<?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>{403B57F2-1856-4FC7-8A24-36AB346B763E}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Wox.Plugin.WebSearch</RootNamespace>
<AssemblyName>Wox.Plugin.WebSearch</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.WebSearch\</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.WebSearch\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xaml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SuggestionSources\Baidu.cs" />
<Compile Include="SuggestionSources\Google.cs" />
<Compile Include="SuggestionSources\ISuggestionSource.cs" />
<Compile Include="SuggestionSources\SuggestionSourceFactory.cs" />
<Compile Include="WebSearchesSetting.xaml.cs">
<DependentUpon>WebSearchesSetting.xaml</DependentUpon>
</Compile>
<Compile Include="WebSearchPlugin.cs" />
<Compile Include="WebSearchSetting.xaml.cs">
<DependentUpon>WebSearchSetting.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<Content Include="Languages\en.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Include="Languages\zh-cn.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Languages\zh-tw.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<Page Include="WebSearchesSetting.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="WebSearchSetting.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Service References\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Wox.Core\Wox.Core.csproj">
<Project>{B749F0DB-8E75-47DB-9E5E-265D16D0C0D2}</Project>
<Name>Wox.Core</Name>
</ProjectReference>
<ProjectReference Include="..\..\Wox.Infrastructure\Wox.Infrastructure.csproj">
<Project>{4fd29318-a8ab-4d8f-aa47-60bc241b8da3}</Project>
<Name>Wox.Infrastructure</Name>
</ProjectReference>
<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\web_search.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Include="Images\websearch\google.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Include="Images\websearch\wiki.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<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>
-->
<?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>{403B57F2-1856-4FC7-8A24-36AB346B763E}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Wox.Plugin.WebSearch</RootNamespace>
<AssemblyName>Wox.Plugin.WebSearch</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.WebSearch\</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.WebSearch\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xaml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SuggestionSources\Baidu.cs" />
<Compile Include="SuggestionSources\Google.cs" />
<Compile Include="SuggestionSources\ISuggestionSource.cs" />
<Compile Include="SuggestionSources\SuggestionSourceFactory.cs" />
<Compile Include="WebSearch.cs" />
<Compile Include="WebSearchesSetting.xaml.cs">
<DependentUpon>WebSearchesSetting.xaml</DependentUpon>
</Compile>
<Compile Include="WebSearchPlugin.cs" />
<Compile Include="WebSearchSetting.xaml.cs">
<DependentUpon>WebSearchSetting.xaml</DependentUpon>
</Compile>
<Compile Include="WebSearchStorage.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Languages\en.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Include="Languages\zh-cn.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Languages\zh-tw.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<Page Include="WebSearchesSetting.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="WebSearchSetting.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Service References\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Wox.Core\Wox.Core.csproj">
<Project>{B749F0DB-8E75-47DB-9E5E-265D16D0C0D2}</Project>
<Name>Wox.Core</Name>
</ProjectReference>
<ProjectReference Include="..\..\Wox.Infrastructure\Wox.Infrastructure.csproj">
<Project>{4fd29318-a8ab-4d8f-aa47-60bc241b8da3}</Project>
<Name>Wox.Infrastructure</Name>
</ProjectReference>
<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\web_search.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Include="Images\websearch\google.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Include="Images\websearch\wiki.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<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>

View File

@ -121,13 +121,10 @@ namespace Wox.Core.Plugin
public static bool IsUserPluginQuery(Query query)
{
if (string.IsNullOrEmpty(query.RawQuery)) return false;
var strings = query.RawQuery.Split(' ');
var actionKeyword = string.Empty;
if (strings.Length > 0)
{
actionKeyword = strings[0].Trim();
}
if(strings.Length == 1) return false;
var actionKeyword = strings[0].Trim();
if (string.IsNullOrEmpty(actionKeyword)) return false;
return plugins.Any(o => o.Metadata.PluginType == PluginType.User && o.Metadata.ActionKeyword == actionKeyword);

View File

@ -55,9 +55,6 @@ namespace Wox.Core.UserSettings
[JsonProperty]
public string ResultItemFontStretch { get; set; }
[JsonProperty]
public List<WebSearch> WebSearches { get; set; }
[JsonProperty]
public double WindowLeft { get; set; }
@ -72,18 +69,14 @@ namespace Wox.Core.UserSettings
[JsonProperty]
public bool StartWoxOnSystemStartup { get; set; }
[Obsolete]
[JsonProperty]
public double Opacity { get; set; }
[Obsolete]
[JsonProperty]
public OpacityMode OpacityMode { get; set; }
[JsonProperty]
public bool EnableWebSearchSuggestion { get; set; }
[JsonProperty]
public string WebSearchSuggestionSource { get; set; }
[JsonProperty]
public bool LeaveCmdOpen { get; set; }
@ -105,44 +98,6 @@ namespace Wox.Core.UserSettings
[JsonProperty]
public string ProxyPassword { get; set; }
public List<WebSearch> LoadDefaultWebSearches()
{
List<WebSearch> webSearches = new List<WebSearch>();
WebSearch googleWebSearch = new WebSearch()
{
Title = "Google",
ActionWord = "g",
IconPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\Images\websearch\google.png",
Url = "https://www.google.com/search?q={q}",
Enabled = true
};
webSearches.Add(googleWebSearch);
WebSearch wikiWebSearch = new WebSearch()
{
Title = "Wikipedia",
ActionWord = "wiki",
IconPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\Images\websearch\wiki.png",
Url = "http://en.wikipedia.org/wiki/{q}",
Enabled = true
};
webSearches.Add(wikiWebSearch);
WebSearch findIcon = new WebSearch()
{
Title = "FindIcon",
ActionWord = "findicon",
IconPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\Images\websearch\pictures.png",
Url = "http://findicons.com/search/{q}",
Enabled = true
};
webSearches.Add(findIcon);
return webSearches;
}
protected override string ConfigFolder
{
get { return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Config"); }
@ -167,7 +122,6 @@ namespace Wox.Core.UserSettings
DontPromptUpdateMsg = false;
Theme = "Dark";
Language = "en";
WebSearches = LoadDefaultWebSearches();
CustomizedPluginConfigs = new List<CustomizedPluginConfig>();
Hotkey = "Alt + Space";
QueryBoxFont = FontFamily.GenericSansSerif.Name;

View File

@ -99,7 +99,6 @@
<Compile Include="UserSettings\CustomizedPluginConfig.cs" />
<Compile Include="UserSettings\PluginHotkey.cs" />
<Compile Include="UserSettings\UserSettingStorage.cs" />
<Compile Include="UserSettings\WebSearch.cs" />
<Compile Include="Version\SemanticVersion.cs" />
<Compile Include="Version\VersionManager.cs" />
</ItemGroup>

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Wox.Core.Plugin;
using Wox.Plugin;
namespace Wox.Test

View File

@ -13,12 +13,11 @@
AllowDrop="True"
ShowInTaskbar="False"
Style="{DynamicResource WindowStyle}"
Icon="Images\app.png"
>
Icon="Images\app.png">
<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" CornerRadius="0">
<Border Style="{DynamicResource WindowBorderStyle}" MouseDown="Border_OnMouseDown">
<StackPanel Orientation="Vertical">
<TextBox Style="{DynamicResource QueryBoxStyle}" PreviewDragOver="TbQuery_OnPreviewDragOver" AllowDrop="True"
x:Name="tbQuery" PreviewKeyDown="TbQuery_OnPreviewKeyDown" TextChanged="TextBoxBase_OnTextChanged" />

View File

@ -162,10 +162,6 @@ namespace Wox
InitializeComponent();
ThreadPool.SetMaxThreads(30, 10);
ThreadPool.SetMinThreads(10, 5);
if (UserSettingStorage.Instance.OpacityMode == OpacityMode.LayeredWindow)
{
this.AllowsTransparency = true;
}
WebRequest.RegisterPrefix("data", new DataWebRequestFactory());
GlobalHotkey.Instance.hookedKeyboardCallback += KListener_hookedKeyboardCallback;
@ -241,14 +237,6 @@ namespace Wox
}
InitProgressbarAnimation();
//only works for win7+
if (UserSettingStorage.Instance.OpacityMode == OpacityMode.DWM)
DwmDropShadow.DropShadowToWindow(this);
this.Background = Brushes.Transparent;
HwndSource.FromHwnd(new WindowInteropHelper(this).Handle).CompositionTarget.BackgroundColor = Color.FromArgb(0, 0, 0, 0);
WindowIntelopHelper.DisableControlBox(this);
UpdaterManager.Instance.CheckUpdate();
}
@ -354,7 +342,7 @@ namespace Wox
Query(q);
Dispatcher.DelayInvoke("ShowProgressbar", originQuery =>
{
if (!queryHasReturn && originQuery == lastQuery)
if (!queryHasReturn && originQuery == lastQuery && !string.IsNullOrEmpty(lastQuery))
{
StartProgress();
}