Add web search feature & some UI changes.

This commit is contained in:
qianlifeng 2014-01-29 22:44:57 +08:00
parent 9f22a6d26d
commit fa3ae62254
31 changed files with 340 additions and 86 deletions

BIN
Doc/app.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 KiB

BIN
Doc/app.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

BIN
Python.Runtime.dll Normal file

Binary file not shown.

View file

@ -1,14 +1,10 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Threading;
using Newtonsoft.Json;
using Wox.Models;
using Wox.Infrastructure.UserSettings;
namespace Wox.Helper
namespace Wox.Infrastructure
{
[Serializable]
public class CommonStorage
@ -22,14 +18,7 @@ namespace Wox.Helper
private CommonStorage()
{
//default setting
UserSetting = new UserSetting
{
Theme = "Default",
ReplaceWinR = true,
WebSearches = new List<WebSearch>()
};
UserSetting = new UserSetting();
UserSelectedRecords = new UserSelectedRecords();
}
@ -81,5 +70,6 @@ namespace Wox.Helper
return storage;
}
}
}
}

View file

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的常规信息通过以下
// 特性集控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("Wox.Infrastructure")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Wox.Infrastructure")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 使此程序集中的类型
// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
// 则将该类型上的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("aee57a31-29e5-4f03-a41f-7917910fe90f")]
// 程序集的版本信息由下面四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -1,12 +1,8 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using Wox.Helper;
using Wox.Plugin;
namespace Wox.Models
namespace Wox.Infrastructure.UserSettings
{
[Serializable]
public class UserSelectedRecords

View file

@ -0,0 +1,48 @@
using System.Collections.Generic;
using System.IO;
namespace Wox.Infrastructure.UserSettings
{
public class UserSetting
{
public string Theme { get; set; }
public bool ReplaceWinR { get; set; }
public List<WebSearch> WebSearches { get; set; }
public UserSetting()
{
//default setting
Theme = "Default";
ReplaceWinR = true;
WebSearches = LoadDefaultWebSearches();
}
private List<WebSearch> LoadDefaultWebSearches()
{
List<WebSearch> webSearches = new List<WebSearch>();
WebSearch googleWebSearch = new WebSearch()
{
Title = "Google",
ActionWord = "g",
IconPath = Directory.GetCurrentDirectory() + @"\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 = Directory.GetCurrentDirectory() + @"\Images\websearch\wiki.png",
Url = "http://en.wikipedia.org/wiki/{q}",
Enabled = true
};
webSearches.Add(wikiWebSearch);
return webSearches;
}
}
}

View file

@ -0,0 +1,11 @@
namespace Wox.Infrastructure.UserSettings
{
public class WebSearch
{
public string Title { get; set; }
public string ActionWord { get; set; }
public string IconPath { get; set; }
public string Url { get; set; }
public bool Enabled { get; set; }
}
}

View file

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.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>{4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Wox.Infrastructure</RootNamespace>
<AssemblyName>Wox.Infrastructure</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.5.0.8\lib\net35\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="CommonStorage.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UserSettings\UserSelectedRecords.cs" />
<Compile Include="UserSettings\UserSetting.cs" />
<Compile Include="UserSettings\WebSearch.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Wox.Plugin\Wox.Plugin.csproj">
<Project>{8451ecdd-2ea4-4966-bb0a-7bbc40138e80}</Project>
<Name>Wox.Plugin</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<!-- 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

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="5.0.8" targetFramework="net35" />
</packages>

View file

@ -12,7 +12,7 @@ namespace Wox.Plugin.System
public List<Result> Query(Query query)
{
if (string.IsNullOrEmpty(query.RawQuery) || query.RawQuery.EndsWith(" ")) return new List<Result>();
if (string.IsNullOrEmpty(query.RawQuery)) return new List<Result>();
return QueryInternal(query);
}

View file

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Wox.Infrastructure;
namespace Wox.Plugin.System
{
@ -15,7 +16,7 @@ namespace Wox.Plugin.System
List<Result> results = new List<Result>();
if (string.IsNullOrEmpty(query.RawQuery)) return results;
foreach (PluginMetadata metadata in allPlugins.Select(o=>o.Metadata))
foreach (PluginMetadata metadata in allPlugins.Select(o => o.Metadata))
{
if (metadata.ActionKeyword.StartsWith(query.RawQuery))
{
@ -23,15 +24,27 @@ namespace Wox.Plugin.System
Result result = new Result
{
Title = metadata.ActionKeyword,
SubTitle = string.Format("Activate {0} workflow",metadata.Name),
SubTitle = string.Format("Activate {0} plugin", metadata.Name),
Score = 50,
IcoPath = "Images/work.png",
Action = () => changeQuery(metadataCopy.ActionKeyword + " "),
DontHideWoxAfterSelect = true
};
results.Add(result);
results.Add(result);
}
}
results.AddRange(CommonStorage.Instance.UserSetting.WebSearches.Where(o => o.ActionWord.StartsWith(query.RawQuery)).Select(n => new Result()
{
Title = n.ActionWord,
SubTitle = string.Format("Activate {0} plugin", n.ActionWord),
Score = 50,
IcoPath = "Images/work.png",
Action = () => changeQuery(n.ActionWord + " "),
DontHideWoxAfterSelect = true
}));
return results;
}

View file

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using Newtonsoft.Json;
using Wox.Infrastructure;
using Wox.Infrastructure.UserSettings;
namespace Wox.Plugin.System
{
public class WebSearchPlugin : BaseSystemPlugin
{
protected override List<Result> QueryInternal(Query query)
{
List<Result> results = new List<Result>();
if (string.IsNullOrEmpty(query.ActionName)) return results;
WebSearch webSearch =
CommonStorage.Instance.UserSetting.WebSearches.FirstOrDefault(o => o.ActionWord == query.ActionName);
if (webSearch != null)
{
string keyword = query.ActionParameters.Count > 0 ? query.RawQuery.Substring(query.RawQuery.IndexOf(' ') + 1) : "";
results.Add(new Result()
{
Title = string.Format("Search {0} for {1}", webSearch.Title, keyword),
IcoPath = webSearch.IconPath,
Action = () => Process.Start(webSearch.Url.Replace("{q}", keyword))
});
}
return results;
}
protected override void InitInternal(PluginInitContext context)
{
}
}
}

View file

@ -47,6 +47,7 @@
<ItemGroup>
<Compile Include="BaseSystemPlugin.cs" />
<Compile Include="BrowserBookmarks.cs" />
<Compile Include="WebSearchPlugin.cs" />
<Compile Include="WindowsShellRun.cs" />
<Compile Include="CMD.cs" />
<Compile Include="Common\ChineseToPinYin.cs" />
@ -59,6 +60,10 @@
<Compile Include="ThirdpartyPluginIndicator.cs" />
</ItemGroup>
<ItemGroup>
<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>

30
Wox.sln
View file

@ -19,6 +19,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Python.Runtime", "Pythonnet
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.Doc", "Plugins\Wox.Plugin.Doc\Wox.Plugin.Doc.csproj", "{6B6696B1-A547-4FD4-85EF-E1FD0F54AD2C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Infrastructure", "Wox.Infrastructure\Wox.Infrastructure.csproj", "{4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -280,6 +282,34 @@ Global
{6B6696B1-A547-4FD4-85EF-E1FD0F54AD2C}.UnitTests|Win32.ActiveCfg = Release|Any CPU
{6B6696B1-A547-4FD4-85EF-E1FD0F54AD2C}.UnitTests|x64.ActiveCfg = Release|Any CPU
{6B6696B1-A547-4FD4-85EF-E1FD0F54AD2C}.UnitTests|x86.ActiveCfg = Release|Any CPU
{4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}.Debug|Win32.ActiveCfg = Debug|Any CPU
{4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}.Debug|x64.ActiveCfg = Debug|Any CPU
{4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}.Debug|x86.ActiveCfg = Debug|Any CPU
{4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}.EmbeddingTest|Any CPU.ActiveCfg = Release|Any CPU
{4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}.EmbeddingTest|Any CPU.Build.0 = Release|Any CPU
{4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}.EmbeddingTest|Mixed Platforms.ActiveCfg = Release|Any CPU
{4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}.EmbeddingTest|Mixed Platforms.Build.0 = Release|Any CPU
{4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}.EmbeddingTest|Win32.ActiveCfg = Release|Any CPU
{4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}.EmbeddingTest|x64.ActiveCfg = Release|Any CPU
{4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}.EmbeddingTest|x86.ActiveCfg = Release|Any CPU
{4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}.Release|Any CPU.Build.0 = Release|Any CPU
{4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}.Release|Win32.ActiveCfg = Release|Any CPU
{4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}.Release|x64.ActiveCfg = Release|Any CPU
{4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}.Release|x86.ActiveCfg = Release|Any CPU
{4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}.UnitTests|Any CPU.ActiveCfg = Release|Any CPU
{4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}.UnitTests|Any CPU.Build.0 = Release|Any CPU
{4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}.UnitTests|Mixed Platforms.ActiveCfg = Release|Any CPU
{4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}.UnitTests|Mixed Platforms.Build.0 = Release|Any CPU
{4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}.UnitTests|Win32.ActiveCfg = Release|Any CPU
{4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}.UnitTests|x64.ActiveCfg = Release|Any CPU
{4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}.UnitTests|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.7 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

@ -12,6 +12,7 @@ using System.Windows.Input;
using System.Windows.Media.Animation;
using Wox.Commands;
using Wox.Helper;
using Wox.Infrastructure;
using Wox.Plugin;
using Wox.PluginLoader;
using Application = System.Windows.Application;

View file

@ -1,14 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Wox.Models
{
public class UserSetting
{
public string Theme { get; set; }
public bool ReplaceWinR { get; set; }
public List<WebSearch> WebSearches { get; set; }
}
}

View file

@ -1,10 +0,0 @@
namespace Wox.Models
{
public class WebSearch
{
public string Keyword { get; set; }
public string IconPath { get; set; }
public string Website { get; set; }
public string Enabled { get; set; }
}
}

View file

@ -15,12 +15,12 @@
<ColumnDefinition Width="73.064"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Image x:Name="imgIco" Width="32" Height="32" HorizontalAlignment="Left" ></Image>
<Grid HorizontalAlignment="Stretch" Margin="5 0 0 0" Grid.Column="1" VerticalAlignment="Stretch">
<Grid Margin="5 0 0 0" Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="23"></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition x:Name="SubTitleRowDefinition"></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Style="{DynamicResource ItemTitleStyle}" x:Name="tbTitle">Title</TextBlock>
<TextBlock Style="{DynamicResource ItemTitleStyle}" VerticalAlignment="Center" x:Name="tbTitle">Title</TextBlock>
<TextBlock Style="{DynamicResource ItemSubTitleStyle}" Grid.Row="1" x:Name="tbSubTitle">sub title</TextBlock>
</Grid>
<DockPanel Grid.Column="2" Visibility="Hidden">

View file

@ -9,6 +9,7 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using Wox.Annotations;
using Wox.Helper;
using Wox.Infrastructure;
using Wox.Plugin;
using Brush = System.Windows.Media.Brush;
@ -16,7 +17,6 @@ namespace Wox
{
public partial class ResultItem : UserControl, INotifyPropertyChanged
{
private bool selected;
public Result Result { get; private set; }
@ -55,6 +55,10 @@ namespace Wox
tbTitle.Text = result.Title;
tbSubTitle.Text = result.SubTitle;
if (string.IsNullOrEmpty(result.SubTitle))
{
SubTitleRowDefinition.Height = new GridLength(0);
}
string path = string.Empty;
if (!string.IsNullOrEmpty(result.IcoPath) && result.IcoPath.Contains(":\\") && File.Exists(result.IcoPath))
{

View file

@ -26,28 +26,28 @@
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="50"></RowDefinition>
</Grid.RowDefinitions>
<ListView Grid.Row="0">
<ListView x:Name="webSearchView" Grid.Row="0">
<ListView.View>
<GridView>
<GridView.Columns>
<GridViewColumn Header="Keyword" Width="180">
<GridViewColumn Header="ActionWord" Width="180">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=OPERATOR}"></TextBlock>
<TextBlock Text="{Binding Path=ActionWord}"></TextBlock>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Website" Width="500">
<GridViewColumn Header="Url" Width="500">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=DDATE}"></TextBlock>
<TextBlock Text="{Binding Path=Url}"></TextBlock>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Enable" Width="50" >
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=CONTENT}"></TextBlock>
<TextBlock Text="{Binding Path=Enabled}"></TextBlock>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>

View file

@ -4,6 +4,7 @@ using System.Linq;
using System.Windows;
using System.Windows.Controls;
using Wox.Helper;
using Wox.Infrastructure;
namespace Wox
{
@ -38,6 +39,7 @@ namespace Wox
themeComboBox.SelectedItem = CommonStorage.Instance.UserSetting.Theme;
cbReplaceWinR.IsChecked = CommonStorage.Instance.UserSetting.ReplaceWinR;
webSearchView.ItemsSource = CommonStorage.Instance.UserSetting.WebSearches;
}
private List<string> LoadAvailableThemes()

View file

@ -4,45 +4,30 @@
Icon="Images\app.png"
ResizeMode="NoResize"
WindowStartupLocation="CenterScreen"
Title="WebSearchSetting" Height="400" Width="674.766">
Title="WebSearchSetting" Height="300" Width="674.766">
<Grid>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition Height="40"></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition Height="24"></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition Height="24"></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition Height="24"></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Margin="10" FontSize="14" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right">Search URL:</TextBlock>
<TextBox Margin="10" Grid.Row="0" Width="400" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left"></TextBox>
<TextBlock Margin="10 0 10 0" Foreground="Gray" VerticalAlignment="Top" Grid.Row="1" Grid.Column="1" TextWrapping="Wrap" HorizontalAlignment="Left">Perform a search on a website and copy the result URL. Replace your search term with {query} in curly brackets</TextBlock>
<TextBlock Margin="10" FontSize="14" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right">Title:</TextBlock>
<TextBox x:Name="tbTitle" Margin="10" Grid.Row="0" Width="400" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left"></TextBox>
<TextBlock Margin="10" FontSize="14" Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right">Title:</TextBlock>
<TextBox Margin="10" Grid.Row="2" Width="400" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left"></TextBox>
<TextBlock Margin="10 0 10 0" Foreground="Gray" VerticalAlignment="Top" Grid.Row="3" Grid.Column="1" TextWrapping="Wrap" HorizontalAlignment="Left">What to show in the Wox. The search query is automatically appended for clarity.</TextBlock>
<TextBlock Margin="10" FontSize="14" Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right">URL:</TextBlock>
<TextBox x:Name="tbUrl" Margin="10" Grid.Row="1" Width="400" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left"></TextBox>
<TextBlock Margin="10" FontSize="14" Grid.Row="4" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right">Keyword:</TextBlock>
<TextBox Margin="10" Grid.Row="4" Width="400" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left"></TextBox>
<TextBlock Margin="10 0 10 0" Foreground="Gray" VerticalAlignment="Top" Grid.Row="5" Grid.Column="1" TextWrapping="Wrap" HorizontalAlignment="Left">What you type to use this shortcut.</TextBlock>
<TextBlock Margin="10" FontSize="14" Grid.Row="6" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right">Validation:</TextBlock>
<StackPanel Grid.Row="6" Grid.Column="1" VerticalAlignment="Center" Orientation="Horizontal">
<TextBox Margin="10" Width="400" HorizontalAlignment="Left"></TextBox>
<Button x:Name="btnValidation" Width="60" Height="24">Test</Button>
</StackPanel>
<TextBlock Margin="10 0 10 0" Foreground="Gray" VerticalAlignment="Top" Grid.Row="7" Grid.Column="1" TextWrapping="Wrap" HorizontalAlignment="Left">Type some text and click test to check it works.</TextBlock>
<TextBlock Margin="10" FontSize="14" Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right">ActionWord:</TextBlock>
<TextBox x:Name="tbActionword" Margin="10" Grid.Row="2" Width="400" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left"></TextBox>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Row="8" Grid.Column="1">
<Button x:Name="btnCancel" Click="BtnCancel_OnClick" Margin="10 0 10 0" Width="80" Height="25">Cancel</Button>
<Button Margin="10 0 10 0" Width="80" Height="25">Add</Button>
<Button x:Name="btnAdd" Margin="10 0 10 0" Width="80" Height="25" Click="btnAdd_OnClick">Add</Button>
</StackPanel>
</Grid>
</Window>

View file

@ -10,6 +10,9 @@ using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Wox.Helper;
using Wox.Infrastructure;
using Wox.Infrastructure.UserSettings;
namespace Wox
{
@ -24,5 +27,45 @@ namespace Wox
{
Close();
}
private void btnAdd_OnClick(object sender, RoutedEventArgs e)
{
string title = tbTitle.Text;
if (string.IsNullOrEmpty(title))
{
MessageBox.Show("Please input Title field");
return;
}
string url = tbUrl.Text;
if (string.IsNullOrEmpty(url))
{
MessageBox.Show("Please input URL field");
return;
}
string action = tbActionword.Text;
if (string.IsNullOrEmpty(action))
{
MessageBox.Show("Please input ActionWord field");
return;
}
if (CommonStorage.Instance.UserSetting.WebSearches.Exists(o => o.ActionWord == action))
{
MessageBox.Show("ActionWord has existed, please input a new one.");
return;
}
CommonStorage.Instance.UserSetting.WebSearches.Add(new WebSearch()
{
ActionWord = action,
Enabled = true,
IconPath="",
Url = url,
Title = title
});
CommonStorage.Instance.Save();
MessageBox.Show("Succeed!");
}
}
}

View file

@ -119,9 +119,6 @@
<Compile Include="Helper\DwmDropShadow.cs" />
<Compile Include="Helper\KeyboardHook.cs" />
<Compile Include="Helper\Log.cs" />
<Compile Include="Helper\CommonStorage.cs" />
<Compile Include="Models\UserSetting.cs" />
<Compile Include="Models\WebSearch.cs" />
<Compile Include="Helper\WoxException.cs" />
<Compile Include="Helper\KeyboardListener.cs" />
<Compile Include="Msg.xaml.cs">
@ -140,7 +137,6 @@
<Compile Include="ResultItem.xaml.cs">
<DependentUpon>ResultItem.xaml</DependentUpon>
</Compile>
<Compile Include="Models\UserSelectedRecords.cs" />
<Compile Include="SettingWindow.xaml.cs">
<DependentUpon>SettingWindow.xaml</DependentUpon>
</Compile>
@ -221,6 +217,10 @@
<Project>{097b4ac0-74e9-4c58-bcf8-c69746ec8271}</Project>
<Name>Python.Runtime</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.System\Wox.Plugin.System.csproj">
<Project>{69ce0206-cb41-453d-88af-df86092ef9b8}</Project>
<Name>Wox.Plugin.System</Name>
@ -277,7 +277,7 @@
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<PropertyGroup>
<PostBuildEvent>xcopy /Y $(ProjectDir)Images\*.* $(TargetDir)Images\
<PostBuildEvent>xcopy /Y /S $(ProjectDir)Images\*.* $(TargetDir)Images\
xcopy /Y $(ProjectDir)app.ico $(TargetDir)
xcopy /Y $(ProjectDir)Themes\*.* $(TargetDir)Themes\</PostBuildEvent>
</PropertyGroup>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 361 KiB

After

Width:  |  Height:  |  Size: 361 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.7 KiB

After

Width:  |  Height:  |  Size: 11 KiB