This commit is contained in:
qianlifeng
2015-01-09 09:45:40 +08:00
27 changed files with 322 additions and 249 deletions

View File

@@ -13,7 +13,6 @@ namespace Wox.Plugin.CMD
{
public class CMD : IPlugin, ISettingProvider,IPluginI18n
{
private readonly GlobalHotkey globalHotkey = new GlobalHotkey();
private PluginInitContext context;
private bool WinRStroked;
private readonly KeyboardSimulator keyboardSimulator = new KeyboardSimulator(new InputSimulator());
@@ -174,20 +173,20 @@ namespace Wox.Plugin.CMD
public void Init(PluginInitContext context)
{
this.context = context;
globalHotkey.hookedKeyboardCallback += KListener_hookedKeyboardCallback;
context.API.GlobalKeyboardEvent += API_GlobalKeyboardEvent;
}
private bool KListener_hookedKeyboardCallback(KeyEvent keyevent, int vkcode, SpecialKeyState state)
bool API_GlobalKeyboardEvent(int keyevent, int vkcode, SpecialKeyState state)
{
if (CMDStorage.Instance.ReplaceWinR)
{
if (keyevent == KeyEvent.WM_KEYDOWN && vkcode == (int)Keys.R && state.WinPressed)
if (keyevent == (int)KeyEvent.WM_KEYDOWN && vkcode == (int)Keys.R && state.WinPressed)
{
WinRStroked = true;
OnWinRPressed();
return false;
}
if (keyevent == KeyEvent.WM_KEYUP && WinRStroked && vkcode == (int)Keys.LWin)
if (keyevent == (int)KeyEvent.WM_KEYUP && WinRStroked && vkcode == (int)Keys.LWin)
{
WinRStroked = false;
keyboardSimulator.ModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.CONTROL);

View File

@@ -1,8 +1,8 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<system:String x:Key="wox_plugin_cmd_relace_winr">替换 Win+R</system:String>
<system:String x:Key="wox_plugin_cmd_leave_cmd_open">执行后不关闭命令窗口</system:String>
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<system:String x:Key="wox_plugin_cmd_relace_winr">替换 Win+R</system:String>
<system:String x:Key="wox_plugin_cmd_leave_cmd_open">执行后不关闭命令窗口</system:String>
</ResourceDictionary>

View File

@@ -82,7 +82,7 @@ namespace Wox.Plugin.Folder
}
}).ToList();
if (!driverNames.Any(input.StartsWith))
if (driverNames != null && !driverNames.Any(input.StartsWith))
return results;
if (!input.EndsWith("\\"))

View File

@@ -1,11 +1,11 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<system:String x:Key="wox_plugin_folder_delete">删除</system:String>
<system:String x:Key="wox_plugin_folder_edit">编辑</system:String>
<system:String x:Key="wox_plugin_folder_add">添加</system:String>
<system:String x:Key="wox_plugin_folder_folder_path">文件夹路径</system:String>
<system:String x:Key="wox_plugin_folder_select_folder_link_warning">请选择一个文件夹</system:String>
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<system:String x:Key="wox_plugin_folder_delete">删除</system:String>
<system:String x:Key="wox_plugin_folder_edit">编辑</system:String>
<system:String x:Key="wox_plugin_folder_add">添加</system:String>
<system:String x:Key="wox_plugin_folder_folder_path">文件夹路径</system:String>
<system:String x:Key="wox_plugin_folder_select_folder_link_warning">请选择一个文件夹</system:String>
</ResourceDictionary>

View File

@@ -1,11 +1,11 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<system:String x:Key="wox_plugin_folder_delete">刪除</system:String>
<system:String x:Key="wox_plugin_folder_edit">編輯</system:String>
<system:String x:Key="wox_plugin_folder_add">添加</system:String>
<system:String x:Key="wox_plugin_folder_folder_path">文件夾路徑</system:String>
<system:String x:Key="wox_plugin_folder_select_folder_link_warning">請選擇一個文件夾</system:String>
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<system:String x:Key="wox_plugin_folder_delete">刪除</system:String>
<system:String x:Key="wox_plugin_folder_edit">編輯</system:String>
<system:String x:Key="wox_plugin_folder_add">添加</system:String>
<system:String x:Key="wox_plugin_folder_folder_path">文件夾路徑</system:String>
<system:String x:Key="wox_plugin_folder_select_folder_link_warning">請選擇一個文件夾</system:String>
</ResourceDictionary>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -4,6 +4,7 @@ using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Windows;
using Wox.Infrastructure;
using Wox.Plugin.Program.ProgramSources;

View File

@@ -81,6 +81,9 @@
<None Include="Images\program.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Images\cmd.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<Content Include="Languages\en.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>

View File

@@ -0,0 +1,15 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<system:String x:Key="wox_plugin_sys_command">Command</system:String>
<system:String x:Key="wox_plugin_sys_desc">Description</system:String>
<system:String x:Key="wox_plugin_sys_shutdown_computer">Shutdown Computer</system:String>
<system:String x:Key="wox_plugin_sys_log_off">Log off</system:String>
<system:String x:Key="wox_plugin_sys_lock">Lock this computer</system:String>
<system:String x:Key="wox_plugin_sys_exit">Close Wox</system:String>
<system:String x:Key="wox_plugin_sys_restart">Restart Wox</system:String>
<system:String x:Key="wox_plugin_sys_setting">Tweak this app</system:String>
</ResourceDictionary>

View File

@@ -0,0 +1,15 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<system:String x:Key="wox_plugin_sys_command">命令</system:String>
<system:String x:Key="wox_plugin_sys_desc">描述</system:String>
<system:String x:Key="wox_plugin_sys_shutdown_computer">关闭电脑</system:String>
<system:String x:Key="wox_plugin_sys_log_off">注销</system:String>
<system:String x:Key="wox_plugin_sys_lock">锁定这台电脑</system:String>
<system:String x:Key="wox_plugin_sys_exit">退出Wox</system:String>
<system:String x:Key="wox_plugin_sys_restart">重启Wox</system:String>
<system:String x:Key="wox_plugin_sys_setting">设置</system:String>
</ResourceDictionary>

View File

@@ -0,0 +1,15 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<system:String x:Key="wox_plugin_sys_command">命令</system:String>
<system:String x:Key="wox_plugin_sys_desc">描述</system:String>
<system:String x:Key="wox_plugin_sys_shutdown_computer">關閉電腦</system:String>
<system:String x:Key="wox_plugin_sys_log_off">註銷</system:String>
<system:String x:Key="wox_plugin_sys_lock">鎖定這臺電腦</system:String>
<system:String x:Key="wox_plugin_sys_exit">退出Wox</system:String>
<system:String x:Key="wox_plugin_sys_restart">重啟Wox</system:String>
<system:String x:Key="wox_plugin_sys_setting">設置</system:String>
</ResourceDictionary>

View File

@@ -1,13 +1,16 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace Wox.Plugin.Sys
{
public class Sys : IPlugin, ISettingProvider
public class Sys : IPlugin, ISettingProvider ,IPluginI18n
{
List<Result> availableResults = new List<Result>();
private PluginInitContext context;
#region DllImport
@@ -32,9 +35,12 @@ 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();
}
List<Result> results = new List<Result>();
foreach (Result availableResult in availableResults)
{
if (availableResult.Title.ToLower().StartsWith(query.RawQuery.ToLower()))
@@ -47,11 +53,16 @@ namespace Wox.Plugin.Sys
public void Init(PluginInitContext context)
{
availableResults.AddRange(new Result[] {
this.context = context;
}
private void LoadCommands()
{
availableResults.AddRange(new Result[] {
new Result
{
Title = "Shutdown",
SubTitle = "Shutdown Computer",
SubTitle = context.API.GetTranslation("wox_plugin_sys_shutdown_computer"),
Score = 100,
IcoPath = "Images\\exit.png",
Action = (c) =>
@@ -65,7 +76,7 @@ namespace Wox.Plugin.Sys
new Result
{
Title = "Log off",
SubTitle = "Log off current user",
SubTitle = context.API.GetTranslation("wox_plugin_sys_log_off"),
Score = 100,
IcoPath = "Images\\logoff.png",
Action = (c) => ExitWindowsEx(EWX_LOGOFF, 0)
@@ -73,7 +84,7 @@ namespace Wox.Plugin.Sys
new Result
{
Title = "Lock",
SubTitle = "Lock this computer",
SubTitle = context.API.GetTranslation("wox_plugin_sys_lock"),
Score = 100,
IcoPath = "Images\\lock.png",
Action = (c) =>
@@ -85,7 +96,7 @@ namespace Wox.Plugin.Sys
new Result
{
Title = "Exit",
SubTitle = "Close this app",
SubTitle = context.API.GetTranslation("wox_plugin_sys_exit"),
Score = 110,
IcoPath = "Images\\app.png",
Action = (c) =>
@@ -97,7 +108,7 @@ namespace Wox.Plugin.Sys
new Result
{
Title = "Restart Wox",
SubTitle = "Restart Wox",
SubTitle = context.API.GetTranslation("wox_plugin_sys_restart"),
Score = 110,
IcoPath = "Images\\restart.png",
Action = (c) =>
@@ -115,7 +126,7 @@ namespace Wox.Plugin.Sys
new Result
{
Title = "Settings",
SubTitle = "Tweak this app",
SubTitle = context.API.GetTranslation("wox_plugin_sys_setting"),
Score = 100,
IcoPath = "Images\\app.png",
Action = (c) =>
@@ -127,7 +138,10 @@ namespace Wox.Plugin.Sys
});
}
public string GetLanguagesFolder()
{
return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Languages");
}
}
}

View File

@@ -9,14 +9,14 @@
<ListView x:Name="lbxCommands" Grid.Row="0">
<ListView.View>
<GridView>
<GridViewColumn Header="Command" Width="150">
<GridViewColumn Header="{DynamicResource wox_plugin_sys_command}" Width="150">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Title}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Description" Width="Auto">
<GridViewColumn Header="{DynamicResource wox_plugin_sys_desc}" Width="Auto">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding SubTitle}"/>

View File

@@ -64,6 +64,21 @@
</ProjectReference>
</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="SysSettings.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>

View File

@@ -1,28 +1,28 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<system:String x:Key="wox_plugin_websearch_delete">删除</system:String>
<system:String x:Key="wox_plugin_websearch_edit">编辑</system:String>
<system:String x:Key="wox_plugin_websearch_add">添加</system:String>
<system:String x:Key="wox_plugin_websearch_action_keyword">触发关键字</system:String>
<system:String x:Key="wox_plugin_websearch_url">URL</system:String>
<system:String x:Key="wox_plugin_websearch_enable_suggestion">启用搜索建议</system:String>
<system:String x:Key="wox_plugin_websearch_pls_select_web_search">请选择一项</system:String>
<system:String x:Key="wox_plugin_websearch_delete_warning">你确定要删除 {0} 吗?</system:String>
<!--web search edit-->
<system:String x:Key="wox_plugin_websearch_title">标题</system:String>
<system:String x:Key="wox_plugin_websearch_enable">启用</system:String>
<system:String x:Key="wox_plugin_websearch_icon">图标</system:String>
<system:String x:Key="wox_plugin_websearch_select_icon">选择图标</system:String>
<system:String x:Key="wox_plugin_websearch_cancel">取消</system:String>
<system:String x:Key="wox_plugin_websearch_invalid_web_search">非法的网页搜索</system:String>
<system:String x:Key="wox_plugin_websearch_input_title">请输入标题</system:String>
<system:String x:Key="wox_plugin_websearch_input_action_keyword">请输入触发关键字</system:String>
<system:String x:Key="wox_plugin_websearch_input_url">请输入URL</system:String>
<system:String x:Key="wox_plugin_websearch_action_keyword_exist">触发关键字已经存在,请选择一个新的关键字</system:String>
<system:String x:Key="wox_plugin_websearch_succeed">操作成功</system:String>
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<system:String x:Key="wox_plugin_websearch_delete">删除</system:String>
<system:String x:Key="wox_plugin_websearch_edit">编辑</system:String>
<system:String x:Key="wox_plugin_websearch_add">添加</system:String>
<system:String x:Key="wox_plugin_websearch_action_keyword">触发关键字</system:String>
<system:String x:Key="wox_plugin_websearch_url">URL</system:String>
<system:String x:Key="wox_plugin_websearch_enable_suggestion">启用搜索建议</system:String>
<system:String x:Key="wox_plugin_websearch_pls_select_web_search">请选择一项</system:String>
<system:String x:Key="wox_plugin_websearch_delete_warning">你确定要删除 {0} 吗?</system:String>
<!--web search edit-->
<system:String x:Key="wox_plugin_websearch_title">标题</system:String>
<system:String x:Key="wox_plugin_websearch_enable">启用</system:String>
<system:String x:Key="wox_plugin_websearch_icon">图标</system:String>
<system:String x:Key="wox_plugin_websearch_select_icon">选择图标</system:String>
<system:String x:Key="wox_plugin_websearch_cancel">取消</system:String>
<system:String x:Key="wox_plugin_websearch_invalid_web_search">非法的网页搜索</system:String>
<system:String x:Key="wox_plugin_websearch_input_title">请输入标题</system:String>
<system:String x:Key="wox_plugin_websearch_input_action_keyword">请输入触发关键字</system:String>
<system:String x:Key="wox_plugin_websearch_input_url">请输入URL</system:String>
<system:String x:Key="wox_plugin_websearch_action_keyword_exist">触发关键字已经存在,请选择一个新的关键字</system:String>
<system:String x:Key="wox_plugin_websearch_succeed">操作成功</system:String>
</ResourceDictionary>

View File

@@ -1,28 +1,28 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<system:String x:Key="wox_plugin_websearch_delete">刪除</system:String>
<system:String x:Key="wox_plugin_websearch_edit">編輯</system:String>
<system:String x:Key="wox_plugin_websearch_add">添加</system:String>
<system:String x:Key="wox_plugin_websearch_action_keyword">觸發關鍵字</system:String>
<system:String x:Key="wox_plugin_websearch_url">URL</system:String>
<system:String x:Key="wox_plugin_websearch_enable_suggestion">啟用搜索建議</system:String>
<system:String x:Key="wox_plugin_websearch_pls_select_web_search">請選擇一項</system:String>
<system:String x:Key="wox_plugin_websearch_delete_warning">你確定要刪除 {0} 嗎?</system:String>
<!--web search edit-->
<system:String x:Key="wox_plugin_websearch_title">標題</system:String>
<system:String x:Key="wox_plugin_websearch_enable">啟用</system:String>
<system:String x:Key="wox_plugin_websearch_icon">圖標</system:String>
<system:String x:Key="wox_plugin_websearch_select_icon">選擇圖標</system:String>
<system:String x:Key="wox_plugin_websearch_cancel">取消</system:String>
<system:String x:Key="wox_plugin_websearch_invalid_web_search">非法的網頁搜索</system:String>
<system:String x:Key="wox_plugin_websearch_input_title">請輸入標題</system:String>
<system:String x:Key="wox_plugin_websearch_input_action_keyword">請輸入觸發關鍵字</system:String>
<system:String x:Key="wox_plugin_websearch_input_url">請輸入URL</system:String>
<system:String x:Key="wox_plugin_websearch_action_keyword_exist">觸發關鍵字已經存在,請選擇一個新的關鍵字</system:String>
<system:String x:Key="wox_plugin_websearch_succeed">操作成功</system:String>
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<system:String x:Key="wox_plugin_websearch_delete">刪除</system:String>
<system:String x:Key="wox_plugin_websearch_edit">編輯</system:String>
<system:String x:Key="wox_plugin_websearch_add">添加</system:String>
<system:String x:Key="wox_plugin_websearch_action_keyword">觸發關鍵字</system:String>
<system:String x:Key="wox_plugin_websearch_url">URL</system:String>
<system:String x:Key="wox_plugin_websearch_enable_suggestion">啟用搜索建議</system:String>
<system:String x:Key="wox_plugin_websearch_pls_select_web_search">請選擇一項</system:String>
<system:String x:Key="wox_plugin_websearch_delete_warning">你確定要刪除 {0} 嗎?</system:String>
<!--web search edit-->
<system:String x:Key="wox_plugin_websearch_title">標題</system:String>
<system:String x:Key="wox_plugin_websearch_enable">啟用</system:String>
<system:String x:Key="wox_plugin_websearch_icon">圖標</system:String>
<system:String x:Key="wox_plugin_websearch_select_icon">選擇圖標</system:String>
<system:String x:Key="wox_plugin_websearch_cancel">取消</system:String>
<system:String x:Key="wox_plugin_websearch_invalid_web_search">非法的網頁搜索</system:String>
<system:String x:Key="wox_plugin_websearch_input_title">請輸入標題</system:String>
<system:String x:Key="wox_plugin_websearch_input_action_keyword">請輸入觸發關鍵字</system:String>
<system:String x:Key="wox_plugin_websearch_input_url">請輸入URL</system:String>
<system:String x:Key="wox_plugin_websearch_action_keyword_exist">觸發關鍵字已經存在,請選擇一個新的關鍵字</system:String>
<system:String x:Key="wox_plugin_websearch_succeed">操作成功</system:String>
</ResourceDictionary>