Add start Wox on system startup config & code refactorying.

This commit is contained in:
qianlifeng
2014-02-06 22:22:02 +08:00
parent 9e1980f843
commit 67f14d6a62
33 changed files with 818 additions and 811 deletions

View File

@@ -1,127 +1,127 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
//From:http://blog.csdn.net/chamychen/article/details/7976125 //From:http://blog.csdn.net/chamychen/article/details/7976125
namespace Wox.Plugin.System.Common namespace Wox.Infrastructure
{ {
public static class ChineseToPinYin public static class ChineseToPinYin
{ {
private static readonly Dictionary<int, string> CodeCollections = new Dictionary<int, string> { private static readonly Dictionary<int, string> CodeCollections = new Dictionary<int, string> {
 { -20319, "a" }, { -20317, "ai" }, { -20304, "an" }, { -20295, "ang" }, { -20292, "ao" }, { -20283, "ba" }, { -20265, "bai" },  { -20319, "a" }, { -20317, "ai" }, { -20304, "an" }, { -20295, "ang" }, { -20292, "ao" }, { -20283, "ba" }, { -20265, "bai" },
{ -20257, "ban" }, { -20242, "bang" }, { -20230, "bao" }, { -20051, "bei" }, { -20036, "ben" }, { -20032, "beng" }, { -20026, "bi" } { -20257, "ban" }, { -20242, "bang" }, { -20230, "bao" }, { -20051, "bei" }, { -20036, "ben" }, { -20032, "beng" }, { -20026, "bi" }
, { -20002, "bian" }, { -19990, "biao" }, { -19986, "bie" }, { -19982, "bin" }, { -19976, "bing" }, { -19805, "bo" }, , { -20002, "bian" }, { -19990, "biao" }, { -19986, "bie" }, { -19982, "bin" }, { -19976, "bing" }, { -19805, "bo" },
{ -19784, "bu" }, { -19775, "ca" }, { -19774, "cai" }, { -19763, "can" }, { -19756, "cang" }, { -19751, "cao" }, { -19746, "ce" }, { -19784, "bu" }, { -19775, "ca" }, { -19774, "cai" }, { -19763, "can" }, { -19756, "cang" }, { -19751, "cao" }, { -19746, "ce" },
 { -19741, "ceng" }, { -19739, "cha" }, { -19728, "chai" }, { -19725, "chan" }, { -19715, "chang" }, { -19540, "chao" },  { -19741, "ceng" }, { -19739, "cha" }, { -19728, "chai" }, { -19725, "chan" }, { -19715, "chang" }, { -19540, "chao" },
{ -19531, "che" }, { -19525, "chen" }, { -19515, "cheng" }, { -19500, "chi" }, { -19484, "chong" }, { -19479, "chou" }, { -19531, "che" }, { -19525, "chen" }, { -19515, "cheng" }, { -19500, "chi" }, { -19484, "chong" }, { -19479, "chou" },
{ -19467, "chu" }, { -19289, "chuai" }, { -19288, "chuan" }, { -19281, "chuang" }, { -19275, "chui" }, { -19270, "chun" }, { -19467, "chu" }, { -19289, "chuai" }, { -19288, "chuan" }, { -19281, "chuang" }, { -19275, "chui" }, { -19270, "chun" },
 { -19263, "chuo" }, { -19261, "ci" }, { -19249, "cong" }, { -19243, "cou" }, { -19242, "cu" }, { -19238, "cuan" },  { -19263, "chuo" }, { -19261, "ci" }, { -19249, "cong" }, { -19243, "cou" }, { -19242, "cu" }, { -19238, "cuan" },
{ -19235, "cui" }, { -19227, "cun" }, { -19224, "cuo" }, { -19218, "da" }, { -19212, "dai" }, { -19038, "dan" }, { -19023, "dang" }, { -19235, "cui" }, { -19227, "cun" }, { -19224, "cuo" }, { -19218, "da" }, { -19212, "dai" }, { -19038, "dan" }, { -19023, "dang" },
 { -19018, "dao" }, { -19006, "de" }, { -19003, "deng" }, { -18996, "di" }, { -18977, "dian" }, { -18961, "diao" }, { -18952, "die" }  { -19018, "dao" }, { -19006, "de" }, { -19003, "deng" }, { -18996, "di" }, { -18977, "dian" }, { -18961, "diao" }, { -18952, "die" }
, { -18783, "ding" }, { -18774, "diu" }, { -18773, "dong" }, { -18763, "dou" }, { -18756, "du" }, { -18741, "duan" }, , { -18783, "ding" }, { -18774, "diu" }, { -18773, "dong" }, { -18763, "dou" }, { -18756, "du" }, { -18741, "duan" },
{ -18735, "dui" }, { -18731, "dun" }, { -18722, "duo" }, { -18710, "e" }, { -18697, "en" }, { -18696, "er" }, { -18526, "fa" }, { -18735, "dui" }, { -18731, "dun" }, { -18722, "duo" }, { -18710, "e" }, { -18697, "en" }, { -18696, "er" }, { -18526, "fa" },
 { -18518, "fan" }, { -18501, "fang" }, { -18490, "fei" }, { -18478, "fen" }, { -18463, "feng" }, { -18448, "fo" }, { -18447, "fou" }  { -18518, "fan" }, { -18501, "fang" }, { -18490, "fei" }, { -18478, "fen" }, { -18463, "feng" }, { -18448, "fo" }, { -18447, "fou" }
, { -18446, "fu" }, { -18239, "ga" }, { -18237, "gai" }, { -18231, "gan" }, { -18220, "gang" }, { -18211, "gao" }, { -18201, "ge" }, , { -18446, "fu" }, { -18239, "ga" }, { -18237, "gai" }, { -18231, "gan" }, { -18220, "gang" }, { -18211, "gao" }, { -18201, "ge" },
 { -18184, "gei" }, { -18183, "gen" }, { -18181, "geng" }, { -18012, "gong" }, { -17997, "gou" }, { -17988, "gu" }, { -17970, "gua" }  { -18184, "gei" }, { -18183, "gen" }, { -18181, "geng" }, { -18012, "gong" }, { -17997, "gou" }, { -17988, "gu" }, { -17970, "gua" }
, { -17964, "guai" }, { -17961, "guan" }, { -17950, "guang" }, { -17947, "gui" }, { -17931, "gun" }, { -17928, "guo" }, , { -17964, "guai" }, { -17961, "guan" }, { -17950, "guang" }, { -17947, "gui" }, { -17931, "gun" }, { -17928, "guo" },
{ -17922, "ha" }, { -17759, "hai" }, { -17752, "han" }, { -17733, "hang" }, { -17730, "hao" }, { -17721, "he" }, { -17703, "hei" }, { -17922, "ha" }, { -17759, "hai" }, { -17752, "han" }, { -17733, "hang" }, { -17730, "hao" }, { -17721, "he" }, { -17703, "hei" },
 { -17701, "hen" }, { -17697, "heng" }, { -17692, "hong" }, { -17683, "hou" }, { -17676, "hu" }, { -17496, "hua" },  { -17701, "hen" }, { -17697, "heng" }, { -17692, "hong" }, { -17683, "hou" }, { -17676, "hu" }, { -17496, "hua" },
{ -17487, "huai" }, { -17482, "huan" }, { -17468, "huang" }, { -17454, "hui" }, { -17433, "hun" }, { -17427, "huo" }, { -17487, "huai" }, { -17482, "huan" }, { -17468, "huang" }, { -17454, "hui" }, { -17433, "hun" }, { -17427, "huo" },
{ -17417, "ji" }, { -17202, "jia" }, { -17185, "jian" }, { -16983, "jiang" }, { -16970, "jiao" }, { -16942, "jie" }, { -17417, "ji" }, { -17202, "jia" }, { -17185, "jian" }, { -16983, "jiang" }, { -16970, "jiao" }, { -16942, "jie" },
{ -16915, "jin" }, { -16733, "jing" }, { -16708, "jiong" }, { -16706, "jiu" }, { -16689, "ju" }, { -16664, "juan" }, { -16915, "jin" }, { -16733, "jing" }, { -16708, "jiong" }, { -16706, "jiu" }, { -16689, "ju" }, { -16664, "juan" },
{ -16657, "jue" }, { -16647, "jun" }, { -16474, "ka" }, { -16470, "kai" }, { -16465, "kan" }, { -16459, "kang" }, { -16452, "kao" }, { -16657, "jue" }, { -16647, "jun" }, { -16474, "ka" }, { -16470, "kai" }, { -16465, "kan" }, { -16459, "kang" }, { -16452, "kao" },
 { -16448, "ke" }, { -16433, "ken" }, { -16429, "keng" }, { -16427, "kong" }, { -16423, "kou" }, { -16419, "ku" }, { -16412, "kua" }  { -16448, "ke" }, { -16433, "ken" }, { -16429, "keng" }, { -16427, "kong" }, { -16423, "kou" }, { -16419, "ku" }, { -16412, "kua" }
, { -16407, "kuai" }, { -16403, "kuan" }, { -16401, "kuang" }, { -16393, "kui" }, { -16220, "kun" }, { -16216, "kuo" }, , { -16407, "kuai" }, { -16403, "kuan" }, { -16401, "kuang" }, { -16393, "kui" }, { -16220, "kun" }, { -16216, "kuo" },
{ -16212, "la" }, { -16205, "lai" }, { -16202, "lan" }, { -16187, "lang" }, { -16180, "lao" }, { -16171, "le" }, { -16169, "lei" }, { -16212, "la" }, { -16205, "lai" }, { -16202, "lan" }, { -16187, "lang" }, { -16180, "lao" }, { -16171, "le" }, { -16169, "lei" },
{ -16158, "leng" }, { -16155, "li" }, { -15959, "lia" }, { -15958, "lian" }, { -15944, "liang" }, { -15933, "liao" }, { -16158, "leng" }, { -16155, "li" }, { -15959, "lia" }, { -15958, "lian" }, { -15944, "liang" }, { -15933, "liao" },
{ -15920, "lie" }, { -15915, "lin" }, { -15903, "ling" }, { -15889, "liu" }, { -15878, "long" }, { -15707, "lou" }, { -15701, "lu" }, { -15920, "lie" }, { -15915, "lin" }, { -15903, "ling" }, { -15889, "liu" }, { -15878, "long" }, { -15707, "lou" }, { -15701, "lu" },
 { -15681, "lv" }, { -15667, "luan" }, { -15661, "lue" }, { -15659, "lun" }, { -15652, "luo" }, { -15640, "ma" }, { -15631, "mai" },  { -15681, "lv" }, { -15667, "luan" }, { -15661, "lue" }, { -15659, "lun" }, { -15652, "luo" }, { -15640, "ma" }, { -15631, "mai" },
 { -15625, "man" }, { -15454, "mang" }, { -15448, "mao" }, { -15436, "me" }, { -15435, "mei" }, { -15419, "men" },  { -15625, "man" }, { -15454, "mang" }, { -15448, "mao" }, { -15436, "me" }, { -15435, "mei" }, { -15419, "men" },
{ -15416, "meng" }, { -15408, "mi" }, { -15394, "mian" }, { -15385, "miao" }, { -15377, "mie" }, { -15375, "min" }, { -15416, "meng" }, { -15408, "mi" }, { -15394, "mian" }, { -15385, "miao" }, { -15377, "mie" }, { -15375, "min" },
{ -15369, "ming" }, { -15363, "miu" }, { -15362, "mo" }, { -15183, "mou" }, { -15180, "mu" }, { -15165, "na" }, { -15158, "nai" }, { -15369, "ming" }, { -15363, "miu" }, { -15362, "mo" }, { -15183, "mou" }, { -15180, "mu" }, { -15165, "na" }, { -15158, "nai" },
{ -15153, "nan" }, { -15150, "nang" }, { -15149, "nao" }, { -15144, "ne" }, { -15143, "nei" }, { -15141, "nen" }, { -15140, "neng" } { -15153, "nan" }, { -15150, "nang" }, { -15149, "nao" }, { -15144, "ne" }, { -15143, "nei" }, { -15141, "nen" }, { -15140, "neng" }
, { -15139, "ni" }, { -15128, "nian" }, { -15121, "niang" }, { -15119, "niao" }, { -15117, "nie" }, { -15110, "nin" }, , { -15139, "ni" }, { -15128, "nian" }, { -15121, "niang" }, { -15119, "niao" }, { -15117, "nie" }, { -15110, "nin" },
{ -15109, "ning" }, { -14941, "niu" }, { -14937, "nong" }, { -14933, "nu" }, { -14930, "nv" }, { -14929, "nuan" }, { -14928, "nue" } { -15109, "ning" }, { -14941, "niu" }, { -14937, "nong" }, { -14933, "nu" }, { -14930, "nv" }, { -14929, "nuan" }, { -14928, "nue" }
, { -14926, "nuo" }, { -14922, "o" }, { -14921, "ou" }, { -14914, "pa" }, { -14908, "pai" }, { -14902, "pan" }, { -14894, "pang" }, , { -14926, "nuo" }, { -14922, "o" }, { -14921, "ou" }, { -14914, "pa" }, { -14908, "pai" }, { -14902, "pan" }, { -14894, "pang" },
 { -14889, "pao" }, { -14882, "pei" }, { -14873, "pen" }, { -14871, "peng" }, { -14857, "pi" }, { -14678, "pian" },  { -14889, "pao" }, { -14882, "pei" }, { -14873, "pen" }, { -14871, "peng" }, { -14857, "pi" }, { -14678, "pian" },
{ -14674, "piao" }, { -14670, "pie" }, { -14668, "pin" }, { -14663, "ping" }, { -14654, "po" }, { -14645, "pu" }, { -14630, "qi" }, { -14674, "piao" }, { -14670, "pie" }, { -14668, "pin" }, { -14663, "ping" }, { -14654, "po" }, { -14645, "pu" }, { -14630, "qi" },
 { -14594, "qia" }, { -14429, "qian" }, { -14407, "qiang" }, { -14399, "qiao" }, { -14384, "qie" }, { -14379, "qin" },  { -14594, "qia" }, { -14429, "qian" }, { -14407, "qiang" }, { -14399, "qiao" }, { -14384, "qie" }, { -14379, "qin" },
 { -14368, "qing" }, { -14355, "qiong" }, { -14353, "qiu" }, { -14345, "qu" }, { -14170, "quan" }, { -14159, "que" },  { -14368, "qing" }, { -14355, "qiong" }, { -14353, "qiu" }, { -14345, "qu" }, { -14170, "quan" }, { -14159, "que" },
{ -14151, "qun" }, { -14149, "ran" }, { -14145, "rang" }, { -14140, "rao" }, { -14137, "re" }, { -14135, "ren" }, { -14125, "reng" } { -14151, "qun" }, { -14149, "ran" }, { -14145, "rang" }, { -14140, "rao" }, { -14137, "re" }, { -14135, "ren" }, { -14125, "reng" }
, { -14123, "ri" }, { -14122, "rong" }, { -14112, "rou" }, { -14109, "ru" }, { -14099, "ruan" }, { -14097, "rui" }, { -14094, "run" } , { -14123, "ri" }, { -14122, "rong" }, { -14112, "rou" }, { -14109, "ru" }, { -14099, "ruan" }, { -14097, "rui" }, { -14094, "run" }
, { -14092, "ruo" }, { -14090, "sa" }, { -14087, "sai" }, { -14083, "san" }, { -13917, "sang" }, { -13914, "sao" }, { -13910, "se" } , { -14092, "ruo" }, { -14090, "sa" }, { -14087, "sai" }, { -14083, "san" }, { -13917, "sang" }, { -13914, "sao" }, { -13910, "se" }
, { -13907, "sen" }, { -13906, "seng" }, { -13905, "sha" }, { -13896, "shai" }, { -13894, "shan" }, { -13878, "shang" }, , { -13907, "sen" }, { -13906, "seng" }, { -13905, "sha" }, { -13896, "shai" }, { -13894, "shan" }, { -13878, "shang" },
{ -13870, "shao" }, { -13859, "she" }, { -13847, "shen" }, { -13831, "sheng" }, { -13658, "shi" }, { -13611, "shou" }, { -13870, "shao" }, { -13859, "she" }, { -13847, "shen" }, { -13831, "sheng" }, { -13658, "shi" }, { -13611, "shou" },
 { -13601, "shu" }, { -13406, "shua" }, { -13404, "shuai" }, { -13400, "shuan" }, { -13398, "shuang" }, { -13395, "shui" },  { -13601, "shu" }, { -13406, "shua" }, { -13404, "shuai" }, { -13400, "shuan" }, { -13398, "shuang" }, { -13395, "shui" },
 { -13391, "shun" }, { -13387, "shuo" }, { -13383, "si" }, { -13367, "song" }, { -13359, "sou" }, { -13356, "su" },  { -13391, "shun" }, { -13387, "shuo" }, { -13383, "si" }, { -13367, "song" }, { -13359, "sou" }, { -13356, "su" },
{ -13343, "suan" }, { -13340, "sui" }, { -13329, "sun" }, { -13326, "suo" }, { -13318, "ta" }, { -13147, "tai" }, { -13138, "tan" }, { -13343, "suan" }, { -13340, "sui" }, { -13329, "sun" }, { -13326, "suo" }, { -13318, "ta" }, { -13147, "tai" }, { -13138, "tan" },
 { -13120, "tang" }, { -13107, "tao" }, { -13096, "te" }, { -13095, "teng" }, { -13091, "ti" }, { -13076, "tian" },  { -13120, "tang" }, { -13107, "tao" }, { -13096, "te" }, { -13095, "teng" }, { -13091, "ti" }, { -13076, "tian" },
{ -13068, "tiao" }, { -13063, "tie" }, { -13060, "ting" }, { -12888, "tong" }, { -12875, "tou" }, { -12871, "tu" }, { -13068, "tiao" }, { -13063, "tie" }, { -13060, "ting" }, { -12888, "tong" }, { -12875, "tou" }, { -12871, "tu" },
{ -12860, "tuan" }, { -12858, "tui" }, { -12852, "tun" }, { -12849, "tuo" }, { -12838, "wa" }, { -12831, "wai" }, { -12829, "wan" } { -12860, "tuan" }, { -12858, "tui" }, { -12852, "tun" }, { -12849, "tuo" }, { -12838, "wa" }, { -12831, "wai" }, { -12829, "wan" }
, { -12812, "wang" }, { -12802, "wei" }, { -12607, "wen" }, { -12597, "weng" }, { -12594, "wo" }, { -12585, "wu" }, { -12556, "xi" } , { -12812, "wang" }, { -12802, "wei" }, { -12607, "wen" }, { -12597, "weng" }, { -12594, "wo" }, { -12585, "wu" }, { -12556, "xi" }
, { -12359, "xia" }, { -12346, "xian" }, { -12320, "xiang" }, { -12300, "xiao" }, { -12120, "xie" }, { -12099, "xin" }, , { -12359, "xia" }, { -12346, "xian" }, { -12320, "xiang" }, { -12300, "xiao" }, { -12120, "xie" }, { -12099, "xin" },
{ -12089, "xing" }, { -12074, "xiong" }, { -12067, "xiu" }, { -12058, "xu" }, { -12039, "xuan" }, { -11867, "xue" }, { -12089, "xing" }, { -12074, "xiong" }, { -12067, "xiu" }, { -12058, "xu" }, { -12039, "xuan" }, { -11867, "xue" },
{ -11861, "xun" }, { -11847, "ya" }, { -11831, "yan" }, { -11798, "yang" }, { -11781, "yao" }, { -11604, "ye" }, { -11589, "yi" }, { -11861, "xun" }, { -11847, "ya" }, { -11831, "yan" }, { -11798, "yang" }, { -11781, "yao" }, { -11604, "ye" }, { -11589, "yi" },
 { -11536, "yin" }, { -11358, "ying" }, { -11340, "yo" }, { -11339, "yong" }, { -11324, "you" }, { -11303, "yu" },  { -11536, "yin" }, { -11358, "ying" }, { -11340, "yo" }, { -11339, "yong" }, { -11324, "you" }, { -11303, "yu" },
{ -11097, "yuan" }, { -11077, "yue" }, { -11067, "yun" }, { -11055, "za" }, { -11052, "zai" }, { -11045, "zan" }, { -11097, "yuan" }, { -11077, "yue" }, { -11067, "yun" }, { -11055, "za" }, { -11052, "zai" }, { -11045, "zan" },
 { -11041, "zang" }, { -11038, "zao" }, { -11024, "ze" }, { -11020, "zei" }, { -11019, "zen" }, { -11018, "zeng" },  { -11041, "zang" }, { -11038, "zao" }, { -11024, "ze" }, { -11020, "zei" }, { -11019, "zen" }, { -11018, "zeng" },
{ -11014, "zha" }, { -10838, "zhai" }, { -10832, "zhan" }, { -10815, "zhang" }, { -10800, "zhao" }, { -10790, "zhe" }, { -11014, "zha" }, { -10838, "zhai" }, { -10832, "zhan" }, { -10815, "zhang" }, { -10800, "zhao" }, { -10790, "zhe" },
{ -10780, "zhen" }, { -10764, "zheng" }, { -10587, "zhi" }, { -10544, "zhong" }, { -10533, "zhou" }, { -10519, "zhu" }, { -10780, "zhen" }, { -10764, "zheng" }, { -10587, "zhi" }, { -10544, "zhong" }, { -10533, "zhou" }, { -10519, "zhu" },
{ -10331, "zhua" }, { -10329, "zhuai" }, { -10328, "zhuan" }, { -10322, "zhuang" }, { -10315, "zhui" }, { -10309, "zhun" }, { -10331, "zhua" }, { -10329, "zhuai" }, { -10328, "zhuan" }, { -10322, "zhuang" }, { -10315, "zhui" }, { -10309, "zhun" },
{ -10307, "zhuo" }, { -10296, "zi" }, { -10281, "zong" }, { -10274, "zou" }, { -10270, "zu" }, { -10262, "zuan" }, { -10260, "zui" } { -10307, "zhuo" }, { -10296, "zi" }, { -10281, "zong" }, { -10274, "zou" }, { -10270, "zu" }, { -10262, "zuan" }, { -10260, "zui" }
, { -10256, "zun" }, { -10254, "zuo" } }; , { -10256, "zun" }, { -10254, "zuo" } };
/// <summary> /// <summary>
/// 汉字转拼音 /// 汉字转拼音
/// </summary> /// </summary>
/// <param name="txt"> 需要转换的汉字 </param> /// <param name="txt"> 需要转换的汉字 </param>
/// <returns> 返回汉字对应的拼音 </returns> /// <returns> 返回汉字对应的拼音 </returns>
public static string ToPinYin(string txt) public static string ToPinYin(string txt)
{ {
txt = txt.Trim(); txt = txt.Trim();
byte[] arr = new byte[2]; //每个汉字为2字节 byte[] arr = new byte[2]; //每个汉字为2字节
StringBuilder result = new StringBuilder();//使用StringBuilder优化字符串连接 StringBuilder result = new StringBuilder();//使用StringBuilder优化字符串连接
int charCode = 0; int charCode = 0;
int arr1 = 0; int arr1 = 0;
int arr2 = 0; int arr2 = 0;
char[] arrChar = txt.ToCharArray(); char[] arrChar = txt.ToCharArray();
for (int j = 0; j < arrChar.Length; j++) //遍历输入的字符 for (int j = 0; j < arrChar.Length; j++) //遍历输入的字符
{ {
arr = Encoding.Default.GetBytes(arrChar[j].ToString());//根据系统默认编码得到字节码 arr = Encoding.Default.GetBytes(arrChar[j].ToString());//根据系统默认编码得到字节码
if (arr.Length == 1)//如果只有1字节说明该字符不是汉字结束本次循环 if (arr.Length == 1)//如果只有1字节说明该字符不是汉字结束本次循环
{ {
result.Append(arrChar[j].ToString()); result.Append(arrChar[j].ToString());
continue; continue;
} }
arr1 = (short)(arr[0]); //取字节1 arr1 = (short)(arr[0]); //取字节1
arr2 = (short)(arr[1]); //取字节2 arr2 = (short)(arr[1]); //取字节2
charCode = arr1 * 256 + arr2 - 65536;//计算汉字的编码 charCode = arr1 * 256 + arr2 - 65536;//计算汉字的编码
if (charCode > -10254 || charCode < -20319) //如果不在汉字编码范围内则不改变 if (charCode > -10254 || charCode < -20319) //如果不在汉字编码范围内则不改变
{ {
result.Append(arrChar[j]); result.Append(arrChar[j]);
} }
else else
{ {
//根据汉字编码范围查找对应的拼音并保存到结果中 //根据汉字编码范围查找对应的拼音并保存到结果中
//由于charCode的键不一定存在所以要找比他更小的键上一个键 //由于charCode的键不一定存在所以要找比他更小的键上一个键
if (!CodeCollections.ContainsKey(charCode)) if (!CodeCollections.ContainsKey(charCode))
{ {
for (int i = charCode; i <= 0; --i) for (int i = charCode; i <= 0; --i)
{ {
if (CodeCollections.ContainsKey(i)) if (CodeCollections.ContainsKey(i))
{ {
result.Append(" " + CodeCollections[i] + " "); result.Append(" " + CodeCollections[i] + " ");
break; break;
} }
} }
} }
else else
{ {
result.Append(" " + CodeCollections[charCode] + " "); result.Append(" " + CodeCollections[charCode] + " ");
} }
} }
} }
return result.ToString(); return result.ToString();
} }
} }
} }

View File

@@ -2,7 +2,7 @@
using System.Collections; using System.Collections;
using System.IO; using System.IO;
namespace Wox.Helper namespace Wox.Infrastructure
{ {
public class IniParser public class IniParser
{ {

96
Wox.Infrastructure/UAC.cs Normal file
View File

@@ -0,0 +1,96 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security.Principal;
using System.Text;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Media.Imaging;
using Size = System.Drawing.Size;
namespace Wox.Infrastructure
{
public static class UAC
{
/// <summary>
/// Execute methods that require Admin role, which will popup UAC window.
///
/// Notes:
/// 1. Invoker method shouldn't have any parameters
/// 2. Add attribute [MethodImpl(MethodImplOptions.NoInlining)] to invoker method
///
/// Example:
/// [MethodImpl(MethodImplOptions.NoInlining)]
/// private void OnStartWithWindowUnChecked()
/// {
/// UAC.ExecuteAdminMethod(() => SetStartup(false));
/// }
///
/// </summary>
/// <param name="method"></param>
public static void ExecuteAdminMethod(Action method)
{
if (method == null) return;
if (Environment.OSVersion.Version.Major <= 5 || IsAdministrator())
{
method();
return;
}
StackTrace stackTrace = new StackTrace();
// Get calling method name
MethodBase callingMethod = stackTrace.GetFrame(1).GetMethod();
string methodName = callingMethod.Name;
if (callingMethod.ReflectedType == null) return;
string className = callingMethod.ReflectedType.Name;
string nameSpace = callingMethod.ReflectedType.Namespace;
string args = string.Format("UAC {0} {1} {2}", nameSpace,className,methodName);
Debug.WriteLine(args);
var psi = new ProcessStartInfo
{
FileName = Path.Combine(Directory.GetCurrentDirectory(), "Wox.UAC.exe"),
Arguments = args,
CreateNoWindow = true,
Verb = "runas"
};
try
{
var process = new Process();
process.StartInfo = psi;
process.Start();
process.WaitForExit();
}
catch (Exception e)
{
MessageBox.Show("Execute failed: " + e);
#if (DEBUG)
{
throw;
}
#endif
}
}
private static bool IsAdministrator()
{
var identity = WindowsIdentity.GetCurrent();
if (identity != null)
{
var principal = new WindowsPrincipal(identity);
return principal.IsInRole(WindowsBuiltInRole.Administrator);
}
return false;
}
}
}

View File

@@ -35,15 +35,22 @@
<Reference Include="Newtonsoft.Json"> <Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.5.0.8\lib\net35\Newtonsoft.Json.dll</HintPath> <HintPath>..\packages\Newtonsoft.Json.5.0.8\lib\net35\Newtonsoft.Json.dll</HintPath>
</Reference> </Reference>
<Reference Include="PresentationCore" />
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="ChineseToPinYin.cs" />
<Compile Include="CommonStorage.cs" /> <Compile Include="CommonStorage.cs" />
<Compile Include="IniParser.cs" />
<Compile Include="UAC.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UserSettings\UserSelectedRecords.cs" /> <Compile Include="UserSettings\UserSelectedRecords.cs" />
<Compile Include="UserSettings\UserSetting.cs" /> <Compile Include="UserSettings\UserSetting.cs" />

View File

@@ -8,7 +8,7 @@ using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Windows.Forms; using System.Windows.Forms;
using Newtonsoft.Json; using Newtonsoft.Json;
using Wox.Plugin.System.Common; using Wox.Infrastructure;
namespace Wox.Plugin.System namespace Wox.Plugin.System
{ {

View File

@@ -7,7 +7,7 @@ using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using Microsoft.Win32; using Microsoft.Win32;
using Wox.Plugin.System.Common; using Wox.Infrastructure;
namespace Wox.Plugin.System namespace Wox.Plugin.System
{ {

View File

@@ -50,7 +50,6 @@
<Compile Include="WebSearchPlugin.cs" /> <Compile Include="WebSearchPlugin.cs" />
<Compile Include="WindowsShellRun.cs" /> <Compile Include="WindowsShellRun.cs" />
<Compile Include="CMD.cs" /> <Compile Include="CMD.cs" />
<Compile Include="Common\ChineseToPinYin.cs" />
<Compile Include="DirectoryIndicator.cs" /> <Compile Include="DirectoryIndicator.cs" />
<Compile Include="ISystemPlugin.cs" /> <Compile Include="ISystemPlugin.cs" />
<Compile Include="Programs.cs" /> <Compile Include="Programs.cs" />

View File

@@ -22,4 +22,4 @@ namespace Wox.Plugin
return language.ToUpper() == Python.ToUpper() || language.ToUpper() == CSharp.ToUpper(); return language.ToUpper() == Python.ToUpper() || language.ToUpper() == CSharp.ToUpper();
} }
} }
} }

View File

@@ -1,4 +1,4 @@
<Application x:Class="Wox.WorkflowInstaller.App" <Application x:Class="Wox.UAC.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml"> StartupUri="MainWindow.xaml">

View File

@@ -1,16 +1,16 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Configuration; using System.Configuration;
using System.Data; using System.Data;
using System.Linq; using System.Linq;
using System.Windows; using System.Windows;
namespace Wox.WorkflowInstaller namespace Wox.UAC
{ {
/// <summary> /// <summary>
/// App.xaml 的交互逻辑 /// App.xaml 的交互逻辑
/// </summary> /// </summary>
public partial class App : Application public partial class App : Application
{ {
} }
} }

View File

@@ -1,4 +1,4 @@
<Window x:Class="Wox.WorkflowInstaller.MainWindow" <Window x:Class="Wox.UAC.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525"> Title="MainWindow" Height="350" Width="525">

View File

@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Wox.UAC
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
string[] param = Environment.GetCommandLineArgs();
if (param.Length > 2)
{
switch (param[1])
{
case "UAC":
Invoke(param[2], param[3], param[4]);
break;
}
}
Application.Current.Shutdown(0);
}
private static void Invoke(string namespaceName, string className, string methodName)
{
Type type = Type.GetType(namespaceName + "." + className + "," + namespaceName);
if (type != null)
{
object instance = Activator.CreateInstance(type);
MethodInfo method = type.GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Instance);
if (method != null) method.Invoke(instance, null);
}
}
}
}

View File

@@ -1,55 +1,55 @@
using System.Reflection; using System.Reflection;
using System.Resources; using System.Resources;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows; using System.Windows;
// 有关程序集的常规信息通过以下 // 有关程序集的常规信息通过以下
// 特性集控制。更改这些特性值可修改 // 特性集控制。更改这些特性值可修改
// 与程序集关联的信息。 // 与程序集关联的信息。
[assembly: AssemblyTitle("Wox.WorkflowInstaller")] [assembly: AssemblyTitle("Wox.UAC")]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("qianlifeng")] [assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Wox.WorkflowInstaller")] [assembly: AssemblyProduct("Wox.UAC")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2014")] [assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 使此程序集中的类型 // 将 ComVisible 设置为 false 使此程序集中的类型
// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型, // 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
// 则将该类型上的 ComVisible 特性设置为 true。 // 则将该类型上的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)] [assembly: ComVisible(false)]
//若要开始生成可本地化的应用程序,请在 //若要开始生成可本地化的应用程序,请在
//<PropertyGroup> 中的 .csproj 文件中 //<PropertyGroup> 中的 .csproj 文件中
//设置 <UICulture>CultureYouAreCodingWith</UICulture>。例如,如果您在源文件中 //设置 <UICulture>CultureYouAreCodingWith</UICulture>。 例如,如果您在源文件中
//使用的是美国英语,请将 <UICulture> 设置为 en-US。然后取消 //使用的是美国英语,请将 <UICulture> 设置为 en-US。 然后取消
//对以下 NeutralResourceLanguage 特性的注释。更新 //对以下 NeutralResourceLanguage 特性的注释。 更新
//以下行中的“en-US”以匹配项目文件中的 UICulture 设置。 //以下行中的“en-US”以匹配项目文件中的 UICulture 设置。
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo( [assembly: ThemeInfo(
ResourceDictionaryLocation.None, //主题特定资源词典所处位置 ResourceDictionaryLocation.None, //主题特定资源词典所处位置
//(在页面或应用程序资源词典中 //(在页面或应用程序资源词典中
// 未找到某个资源的情况下使用) // 未找到某个资源的情况下使用)
ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置 ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
//(在页面、应用程序或任何主题特定资源词典中 //(在页面、应用程序或任何主题特定资源词典中
// 未找到某个资源的情况下使用) // 未找到某个资源的情况下使用)
)] )]
// 程序集的版本信息由下面四个值组成: // 程序集的版本信息由下面四个值组成:
// //
// 主版本 // 主版本
// 次版本 // 次版本
// 生成号 // 生成号
// 修订号 // 修订号
// //
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”: // 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -1,71 +1,71 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// 此代码由工具生成。 // 此代码由工具生成。
// 运行时版本: 4.0.30319.18052 // 运行时版本: 4.0.30319.18408
// //
// 对此文件的更改可能会导致不正确的行为,并且如果 // 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将丢失。 // 重新生成代码,这些更改将丢失。
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
namespace Wox.WorkflowInstaller.Properties namespace Wox.UAC.Properties
{ {
/// <summary> /// <summary>
/// 一个强类型的资源类,用于查找本地化的字符串等。 /// 一个强类型的资源类,用于查找本地化的字符串等。
/// </summary> /// </summary>
// 此类是由 StronglyTypedResourceBuilder // 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。 // (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources internal class Resources
{ {
private static global::System.Resources.ResourceManager resourceMan; private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture; private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() internal Resources()
{ {
} }
/// <summary> /// <summary>
/// 返回此类使用的、缓存的 ResourceManager 实例。 /// 返回此类使用的、缓存的 ResourceManager 实例。
/// </summary> /// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager internal static global::System.Resources.ResourceManager ResourceManager
{ {
get get
{ {
if ((resourceMan == null)) if ((resourceMan == null))
{ {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Wox.WorkflowInstaller.Properties.Resources", typeof(Resources).Assembly); global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Wox.UAC.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp; resourceMan = temp;
} }
return resourceMan; return resourceMan;
} }
} }
/// <summary> /// <summary>
/// 为所有资源查找重写当前线程的 CurrentUICulture 属性, /// 为所有资源查找重写当前线程的 CurrentUICulture 属性,
/// 方法是使用此强类型资源类。 /// 方法是使用此强类型资源类。
/// </summary> /// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture internal static global::System.Globalization.CultureInfo Culture
{ {
get get
{ {
return resourceCulture; return resourceCulture;
} }
set set
{ {
resourceCulture = value; resourceCulture = value;
} }
} }
} }
} }

View File

@@ -1,14 +1,14 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:4.0.30319.18052 // Runtime Version:4.0.30319.18408
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
namespace Wox.WorkflowInstaller.Properties namespace Wox.UAC.Properties
{ {

View File

@@ -1,129 +1,141 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{FAFCAD04-C37E-477B-88C9-0C945E4FB928}</ProjectGuid> <ProjectGuid>{C9BC17A0-C2BC-4185-AC1F-32E3352C1233}</ProjectGuid>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Wox.WorkflowInstaller</RootNamespace> <RootNamespace>Wox.UAC</RootNamespace>
<AssemblyName>Wox.WorkflowInstaller</AssemblyName> <AssemblyName>Wox.UAC</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir> <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages> <RestorePackages>true</RestorePackages>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath> <OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest> <ApplicationIcon>app.ico</ApplicationIcon>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<ApplicationIcon>app.ico</ApplicationIcon> <ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="ICSharpCode.SharpZipLib"> <Reference Include="log4net">
<HintPath>..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll</HintPath> <HintPath>..\packages\log4net.2.0.3\lib\net35-full\log4net.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="WindowsBase" /> <Reference Include="WindowsBase" />
<Reference Include="PresentationCore" /> <Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" /> <Reference Include="PresentationFramework" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ApplicationDefinition Include="App.xaml"> <ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</ApplicationDefinition> </ApplicationDefinition>
<Page Include="MainWindow.xaml"> <Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
<Compile Include="App.xaml.cs"> <Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon> <DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Include="IniParser.cs" /> <Compile Include="MainWindow.xaml.cs">
<Compile Include="MainWindow.xaml.cs"> <DependentUpon>MainWindow.xaml</DependentUpon>
<DependentUpon>MainWindow.xaml</DependentUpon> <SubType>Code</SubType>
<SubType>Code</SubType> </Compile>
</Compile> </ItemGroup>
</ItemGroup> <ItemGroup>
<ItemGroup> <Compile Include="Properties\AssemblyInfo.cs">
<Compile Include="Properties\AssemblyInfo.cs"> <SubType>Code</SubType>
<SubType>Code</SubType> </Compile>
</Compile> <Compile Include="Properties\Resources.Designer.cs">
<Compile Include="Properties\Resources.Designer.cs"> <AutoGen>True</AutoGen>
<AutoGen>True</AutoGen> <DesignTime>True</DesignTime>
<DesignTime>True</DesignTime> <DependentUpon>Resources.resx</DependentUpon>
<DependentUpon>Resources.resx</DependentUpon> </Compile>
</Compile> <Compile Include="Properties\Settings.Designer.cs">
<Compile Include="Properties\Settings.Designer.cs"> <AutoGen>True</AutoGen>
<AutoGen>True</AutoGen> <DependentUpon>Settings.settings</DependentUpon>
<DependentUpon>Settings.settings</DependentUpon> <DesignTimeSharedInput>True</DesignTimeSharedInput>
<DesignTimeSharedInput>True</DesignTimeSharedInput> </Compile>
</Compile> <EmbeddedResource Include="Properties\Resources.resx">
<EmbeddedResource Include="Properties\Resources.resx"> <Generator>ResXFileCodeGenerator</Generator>
<Generator>ResXFileCodeGenerator</Generator> <LastGenOutput>Resources.Designer.cs</LastGenOutput>
<LastGenOutput>Resources.Designer.cs</LastGenOutput> </EmbeddedResource>
</EmbeddedResource> <None Include="app.manifest" />
<None Include="app.manifest"> <None Include="packages.config" />
<SubType>Designer</SubType> <None Include="Properties\Settings.settings">
</None> <Generator>SettingsSingleFileGenerator</Generator>
<None Include="packages.config" /> <LastGenOutput>Settings.Designer.cs</LastGenOutput>
<None Include="Properties\Settings.settings"> </None>
<Generator>SettingsSingleFileGenerator</Generator> <AppDesigner Include="Properties\" />
<LastGenOutput>Settings.Designer.cs</LastGenOutput> </ItemGroup>
</None> <ItemGroup>
<AppDesigner Include="Properties\" /> <ProjectReference Include="..\Wox.Infrastructure\Wox.Infrastructure.csproj">
</ItemGroup> <Project>{4fd29318-a8ab-4d8f-aa47-60bc241b8da3}</Project>
<ItemGroup> <Name>Wox.Infrastructure</Name>
<Resource Include="app.ico"> </ProjectReference>
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <ProjectReference Include="..\Wox.Plugin.System\Wox.Plugin.System.csproj">
</Resource> <Project>{69ce0206-cb41-453d-88af-df86092ef9b8}</Project>
</ItemGroup> <Name>Wox.Plugin.System</Name>
<ItemGroup> </ProjectReference>
<ProjectReference Include="..\Wox.Plugin\Wox.Plugin.csproj"> <ProjectReference Include="..\Wox.Plugin\Wox.Plugin.csproj">
<Project>{8451ECDD-2EA4-4966-BB0A-7BBC40138E80}</Project> <Project>{8451ecdd-2ea4-4966-bb0a-7bbc40138e80}</Project>
<Name>Wox.Plugin</Name> <Name>Wox.Plugin</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> <ProjectReference Include="..\Wox\Wox.csproj">
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Project>{DB90F671-D861-46BB-93A3-F1304F5BA1C5}</Project>
<PropertyGroup> <Name>Wox</Name>
<PostBuildEvent>xcopy /Y $(TargetPath) $(SolutionDir)Wox\bin\Debug\ </ProjectReference>
xcopy /Y $(TargetDir)ICSharpCode.SharpZipLib.dll $(SolutionDir)Wox\bin\Debug\</PostBuildEvent> </ItemGroup>
</PropertyGroup> <ItemGroup>
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" /> <Resource Include="app.ico" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. </ItemGroup>
Other similar extension points exist, see Microsoft.Common.targets. <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="BeforeBuild"> <PropertyGroup>
</Target> <PostBuildEvent>xcopy /Y /E $(TargetPath) $(SolutionDir)Wox\bin\Debug\</PostBuildEvent>
<Target Name="AfterBuild"> </PropertyGroup>
</Target> <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> </Project>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 361 KiB

After

Width:  |  Height:  |  Size: 361 KiB

View File

@@ -1,55 +1,46 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/> <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security> <security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"> <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC 清单选项 <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
如果要更改 Windows 用户帐户控制级别,请用以下节点之一替换 </requestedPrivileges>
requestedExecutionLevel 节点。 </security>
</trustInfo>
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<requestedExecutionLevel level="highestAvailable" uiAccess="false" /> <application>
<!-- 此应用程序设计使用的所有 Windows 版本的列表。
指定 requestedExecutionLevel 节点将会禁用文件和注册表虚拟化。 Windows 将会自动选择最兼容的环境。-->
如果要利用文件和注册表虚拟化实现向后
兼容性,则删除 requestedExecutionLevel 节点。 <!-- 如果应用程序设计为使用 Windows Vista请取消注释以下 supportedOS 节点-->
--> <!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"></supportedOS>-->
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges> <!-- 如果应用程序设计使用 Windows 7请取消注释以下 supportedOS 节点-->
</security> <!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>-->
</trustInfo>
<!-- 如果应用程序设计为使用 Windows 8请取消注释以下 supportedOS 节点-->
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> <!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"></supportedOS>-->
<application>
<!-- 应用程序设计使用的所有 Windows 版本的列表。 <!-- 如果应用程序设计使用 Windows 8.1,请取消对以下 supportedOS 节点的注释-->
Windows 将会自动选择最兼容的环境。--> <!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>-->
<!-- 如果应用程序设计为使用 Windows Vista请取消注释以下 supportedOS 节点--> </application>
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"></supportedOS>--> </compatibility>
<!-- 如果应用程序设计使用 Windows 7请取消注释以下 supportedOS 节点--> <!-- 用 Windows 公共控件和对话框的主题(Windows XP 和更高版本) -->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>--> <!-- <dependency>
<dependentAssembly>
<!-- 如果应用程序设计为使用 Windows 8请取消注释以下 supportedOS 节点--> <assemblyIdentity
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"></supportedOS>--> type="win32"
name="Microsoft.Windows.Common-Controls"
</application> version="6.0.0.0"
</compatibility> processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
<!-- 启用 Windows 公共控件和对话框的主题(Windows XP 和更高版本) --> language="*"
<!-- <dependency> />
<dependentAssembly> </dependentAssembly>
<assemblyIdentity </dependency>-->
type="win32"
name="Microsoft.Windows.Common-Controls" </asmv1:assembly>
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>-->
</asmv1:assembly>

4
Wox.UAC/packages.config Normal file
View File

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

View File

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

64
Wox.sln
View File

@@ -1,6 +1,8 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012 # Visual Studio 2013
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}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Test", "Wox.Test\Wox.Test.csproj", "{FF742965-9A80-41A5-B042-D6C7D3A21708}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin", "Wox.Plugin\Wox.Plugin.csproj", "{8451ECDD-2EA4-4966-BB0A-7BBC40138E80}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin", "Wox.Plugin\Wox.Plugin.csproj", "{8451ECDD-2EA4-4966-BB0A-7BBC40138E80}"
@@ -13,8 +15,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.System", "Wox.Pl
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.Fanyi", "Plugins\Wox.Plugin.Fanyi\Wox.Plugin.Fanyi.csproj", "{353769D3-D11C-4D86-BD06-AC8C1D68642B}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.Fanyi", "Plugins\Wox.Plugin.Fanyi\Wox.Plugin.Fanyi.csproj", "{353769D3-D11C-4D86-BD06-AC8C1D68642B}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.WorkflowInstaller", "Wox.WorkflowInstaller\Wox.WorkflowInstaller.csproj", "{FAFCAD04-C37E-477B-88C9-0C945E4FB928}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Python.Runtime", "Pythonnet.Runtime\Python.Runtime.csproj", "{097B4AC0-74E9-4C58-BCF8-C69746EC8271}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Python.Runtime", "Pythonnet.Runtime\Python.Runtime.csproj", "{097B4AC0-74E9-4C58-BCF8-C69746EC8271}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.Doc", "Plugins\Wox.Plugin.Doc\Wox.Plugin.Doc.csproj", "{6B6696B1-A547-4FD4-85EF-E1FD0F54AD2C}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.Doc", "Plugins\Wox.Plugin.Doc\Wox.Plugin.Doc.csproj", "{6B6696B1-A547-4FD4-85EF-E1FD0F54AD2C}"
@@ -23,6 +23,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Infrastructure", "Wox.I
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.Everything", "Plugins\Wox.Plugin.Everything\Wox.Plugin.Everything.csproj", "{230AE83F-E92E-4E69-8355-426B305DA9C0}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.Everything", "Plugins\Wox.Plugin.Everything\Wox.Plugin.Everything.csproj", "{230AE83F-E92E-4E69-8355-426B305DA9C0}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.UAC", "Wox.UAC\Wox.UAC.csproj", "{C9BC17A0-C2BC-4185-AC1F-32E3352C1233}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@@ -196,34 +198,6 @@ Global
{353769D3-D11C-4D86-BD06-AC8C1D68642B}.UnitTests|Win32.ActiveCfg = Release|Any CPU {353769D3-D11C-4D86-BD06-AC8C1D68642B}.UnitTests|Win32.ActiveCfg = Release|Any CPU
{353769D3-D11C-4D86-BD06-AC8C1D68642B}.UnitTests|x64.ActiveCfg = Release|Any CPU {353769D3-D11C-4D86-BD06-AC8C1D68642B}.UnitTests|x64.ActiveCfg = Release|Any CPU
{353769D3-D11C-4D86-BD06-AC8C1D68642B}.UnitTests|x86.ActiveCfg = Release|Any CPU {353769D3-D11C-4D86-BD06-AC8C1D68642B}.UnitTests|x86.ActiveCfg = Release|Any CPU
{FAFCAD04-C37E-477B-88C9-0C945E4FB928}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FAFCAD04-C37E-477B-88C9-0C945E4FB928}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FAFCAD04-C37E-477B-88C9-0C945E4FB928}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{FAFCAD04-C37E-477B-88C9-0C945E4FB928}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{FAFCAD04-C37E-477B-88C9-0C945E4FB928}.Debug|Win32.ActiveCfg = Debug|Any CPU
{FAFCAD04-C37E-477B-88C9-0C945E4FB928}.Debug|x64.ActiveCfg = Debug|Any CPU
{FAFCAD04-C37E-477B-88C9-0C945E4FB928}.Debug|x86.ActiveCfg = Debug|Any CPU
{FAFCAD04-C37E-477B-88C9-0C945E4FB928}.EmbeddingTest|Any CPU.ActiveCfg = Release|Any CPU
{FAFCAD04-C37E-477B-88C9-0C945E4FB928}.EmbeddingTest|Any CPU.Build.0 = Release|Any CPU
{FAFCAD04-C37E-477B-88C9-0C945E4FB928}.EmbeddingTest|Mixed Platforms.ActiveCfg = Release|Any CPU
{FAFCAD04-C37E-477B-88C9-0C945E4FB928}.EmbeddingTest|Mixed Platforms.Build.0 = Release|Any CPU
{FAFCAD04-C37E-477B-88C9-0C945E4FB928}.EmbeddingTest|Win32.ActiveCfg = Release|Any CPU
{FAFCAD04-C37E-477B-88C9-0C945E4FB928}.EmbeddingTest|x64.ActiveCfg = Release|Any CPU
{FAFCAD04-C37E-477B-88C9-0C945E4FB928}.EmbeddingTest|x86.ActiveCfg = Release|Any CPU
{FAFCAD04-C37E-477B-88C9-0C945E4FB928}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FAFCAD04-C37E-477B-88C9-0C945E4FB928}.Release|Any CPU.Build.0 = Release|Any CPU
{FAFCAD04-C37E-477B-88C9-0C945E4FB928}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{FAFCAD04-C37E-477B-88C9-0C945E4FB928}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{FAFCAD04-C37E-477B-88C9-0C945E4FB928}.Release|Win32.ActiveCfg = Release|Any CPU
{FAFCAD04-C37E-477B-88C9-0C945E4FB928}.Release|x64.ActiveCfg = Release|Any CPU
{FAFCAD04-C37E-477B-88C9-0C945E4FB928}.Release|x86.ActiveCfg = Release|Any CPU
{FAFCAD04-C37E-477B-88C9-0C945E4FB928}.UnitTests|Any CPU.ActiveCfg = Release|Any CPU
{FAFCAD04-C37E-477B-88C9-0C945E4FB928}.UnitTests|Any CPU.Build.0 = Release|Any CPU
{FAFCAD04-C37E-477B-88C9-0C945E4FB928}.UnitTests|Mixed Platforms.ActiveCfg = Release|Any CPU
{FAFCAD04-C37E-477B-88C9-0C945E4FB928}.UnitTests|Mixed Platforms.Build.0 = Release|Any CPU
{FAFCAD04-C37E-477B-88C9-0C945E4FB928}.UnitTests|Win32.ActiveCfg = Release|Any CPU
{FAFCAD04-C37E-477B-88C9-0C945E4FB928}.UnitTests|x64.ActiveCfg = Release|Any CPU
{FAFCAD04-C37E-477B-88C9-0C945E4FB928}.UnitTests|x86.ActiveCfg = Release|Any CPU
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Debug|Any CPU.Build.0 = Debug|Any CPU {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Debug|Any CPU.Build.0 = Debug|Any CPU
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
@@ -344,6 +318,34 @@ Global
{230AE83F-E92E-4E69-8355-426B305DA9C0}.UnitTests|x64.ActiveCfg = Release|x64 {230AE83F-E92E-4E69-8355-426B305DA9C0}.UnitTests|x64.ActiveCfg = Release|x64
{230AE83F-E92E-4E69-8355-426B305DA9C0}.UnitTests|x64.Build.0 = Release|x64 {230AE83F-E92E-4E69-8355-426B305DA9C0}.UnitTests|x64.Build.0 = Release|x64
{230AE83F-E92E-4E69-8355-426B305DA9C0}.UnitTests|x86.ActiveCfg = Release|Any CPU {230AE83F-E92E-4E69-8355-426B305DA9C0}.UnitTests|x86.ActiveCfg = Release|Any CPU
{C9BC17A0-C2BC-4185-AC1F-32E3352C1233}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C9BC17A0-C2BC-4185-AC1F-32E3352C1233}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C9BC17A0-C2BC-4185-AC1F-32E3352C1233}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{C9BC17A0-C2BC-4185-AC1F-32E3352C1233}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{C9BC17A0-C2BC-4185-AC1F-32E3352C1233}.Debug|Win32.ActiveCfg = Debug|Any CPU
{C9BC17A0-C2BC-4185-AC1F-32E3352C1233}.Debug|x64.ActiveCfg = Debug|Any CPU
{C9BC17A0-C2BC-4185-AC1F-32E3352C1233}.Debug|x86.ActiveCfg = Debug|Any CPU
{C9BC17A0-C2BC-4185-AC1F-32E3352C1233}.EmbeddingTest|Any CPU.ActiveCfg = Release|Any CPU
{C9BC17A0-C2BC-4185-AC1F-32E3352C1233}.EmbeddingTest|Any CPU.Build.0 = Release|Any CPU
{C9BC17A0-C2BC-4185-AC1F-32E3352C1233}.EmbeddingTest|Mixed Platforms.ActiveCfg = Release|Any CPU
{C9BC17A0-C2BC-4185-AC1F-32E3352C1233}.EmbeddingTest|Mixed Platforms.Build.0 = Release|Any CPU
{C9BC17A0-C2BC-4185-AC1F-32E3352C1233}.EmbeddingTest|Win32.ActiveCfg = Release|Any CPU
{C9BC17A0-C2BC-4185-AC1F-32E3352C1233}.EmbeddingTest|x64.ActiveCfg = Release|Any CPU
{C9BC17A0-C2BC-4185-AC1F-32E3352C1233}.EmbeddingTest|x86.ActiveCfg = Release|Any CPU
{C9BC17A0-C2BC-4185-AC1F-32E3352C1233}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C9BC17A0-C2BC-4185-AC1F-32E3352C1233}.Release|Any CPU.Build.0 = Release|Any CPU
{C9BC17A0-C2BC-4185-AC1F-32E3352C1233}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{C9BC17A0-C2BC-4185-AC1F-32E3352C1233}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{C9BC17A0-C2BC-4185-AC1F-32E3352C1233}.Release|Win32.ActiveCfg = Release|Any CPU
{C9BC17A0-C2BC-4185-AC1F-32E3352C1233}.Release|x64.ActiveCfg = Release|Any CPU
{C9BC17A0-C2BC-4185-AC1F-32E3352C1233}.Release|x86.ActiveCfg = Release|Any CPU
{C9BC17A0-C2BC-4185-AC1F-32E3352C1233}.UnitTests|Any CPU.ActiveCfg = Release|Any CPU
{C9BC17A0-C2BC-4185-AC1F-32E3352C1233}.UnitTests|Any CPU.Build.0 = Release|Any CPU
{C9BC17A0-C2BC-4185-AC1F-32E3352C1233}.UnitTests|Mixed Platforms.ActiveCfg = Release|Any CPU
{C9BC17A0-C2BC-4185-AC1F-32E3352C1233}.UnitTests|Mixed Platforms.Build.0 = Release|Any CPU
{C9BC17A0-C2BC-4185-AC1F-32E3352C1233}.UnitTests|Win32.ActiveCfg = Release|Any CPU
{C9BC17A0-C2BC-4185-AC1F-32E3352C1233}.UnitTests|x64.ActiveCfg = Release|Any CPU
{C9BC17A0-C2BC-4185-AC1F-32E3352C1233}.UnitTests|x86.ActiveCfg = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@@ -53,7 +53,6 @@ namespace Wox.Commands
{ {
if (currentPythonModulePath != thirdPlugin.Metadata.PluginDirecotry) if (currentPythonModulePath != thirdPlugin.Metadata.PluginDirecotry)
{ {
//this must initial in main thread
currentPythonModulePath = thirdPlugin.Metadata.PluginDirecotry; currentPythonModulePath = thirdPlugin.Metadata.PluginDirecotry;
if (GIL != IntPtr.Zero) if (GIL != IntPtr.Zero)
@@ -63,8 +62,8 @@ namespace Wox.Commands
} }
PythonEngine.Initialize(); PythonEngine.Initialize();
IntPtr pyStrPtr = Runtime.PyString_FromString(thirdPlugin.Metadata.PluginDirecotry); IntPtr pyStrPtr = Runtime.PyString_FromString(thirdPlugin.Metadata.PluginDirecotry);
IntPtr SysDotPath = Runtime.PySys_GetObject("path"); IntPtr sysDotPath = Runtime.PySys_GetObject("path");
Runtime.PyList_Append(SysDotPath, pyStrPtr); Runtime.PyList_Append(sysDotPath, pyStrPtr);
GIL = PythonEngine.BeginAllowThreads(); GIL = PythonEngine.BeginAllowThreads();
} }
} }

View File

@@ -1,217 +0,0 @@
using System;
using System.Collections;
using System.IO;
namespace Wox.Helper
{
public class IniParser
{
private Hashtable keyPairs = new Hashtable();
private String iniFilePath;
private struct SectionPair
{
public String Section;
public String Key;
}
/// <summary>
/// Opens the INI file at the given path and enumerates the values in the IniParser.
/// </summary>
/// <param name="iniPath">Full path to INI file.</param>
public IniParser(String iniPath)
{
TextReader iniFile = null;
String strLine = null;
String currentRoot = null;
String[] keyPair = null;
iniFilePath = iniPath;
if (File.Exists(iniPath))
{
try
{
iniFile = new StreamReader(iniPath);
strLine = iniFile.ReadLine();
while (strLine != null)
{
strLine = strLine.Trim();
if (strLine != "")
{
if (strLine.StartsWith("[") && strLine.EndsWith("]"))
{
currentRoot = strLine.Substring(1, strLine.Length - 2).ToUpper();
}
else
{
keyPair = strLine.Split(new char[] { '=' }, 2);
SectionPair sectionPair;
String value = null;
if (currentRoot == null)
currentRoot = "ROOT";
sectionPair.Section = currentRoot;
sectionPair.Key = keyPair[0].ToUpper().Trim();
if (keyPair.Length > 1)
value = keyPair[1];
keyPairs.Add(sectionPair, value.Trim());
}
}
strLine = iniFile.ReadLine();
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (iniFile != null)
iniFile.Close();
}
}
else
throw new FileNotFoundException("Unable to locate " + iniPath);
}
/// <summary>
/// Returns the value for the given section, key pair.
/// </summary>
/// <param name="sectionName">Section name.</param>
/// <param name="settingName">Key name.</param>
public String GetSetting(String sectionName, String settingName)
{
SectionPair sectionPair;
sectionPair.Section = sectionName.ToUpper().Trim();
sectionPair.Key = settingName.ToUpper().Trim();
return (String)keyPairs[sectionPair];
}
/// <summary>
/// Enumerates all lines for given section.
/// </summary>
/// <param name="sectionName">Section to enum.</param>
public String[] EnumSection(String sectionName)
{
ArrayList tmpArray = new ArrayList();
foreach (SectionPair pair in keyPairs.Keys)
{
if (pair.Section == sectionName.ToUpper())
tmpArray.Add(pair.Key);
}
return (String[])tmpArray.ToArray(typeof(String));
}
/// <summary>
/// Adds or replaces a setting to the table to be saved.
/// </summary>
/// <param name="sectionName">Section to add under.</param>
/// <param name="settingName">Key name to add.</param>
/// <param name="settingValue">Value of key.</param>
public void AddSetting(String sectionName, String settingName, String settingValue)
{
SectionPair sectionPair;
sectionPair.Section = sectionName.ToUpper();
sectionPair.Key = settingName.ToUpper();
if (keyPairs.ContainsKey(sectionPair))
keyPairs.Remove(sectionPair);
keyPairs.Add(sectionPair, settingValue);
}
/// <summary>
/// Adds or replaces a setting to the table to be saved with a null value.
/// </summary>
/// <param name="sectionName">Section to add under.</param>
/// <param name="settingName">Key name to add.</param>
public void AddSetting(String sectionName, String settingName)
{
AddSetting(sectionName, settingName, null);
}
/// <summary>
/// Remove a setting.
/// </summary>
/// <param name="sectionName">Section to add under.</param>
/// <param name="settingName">Key name to add.</param>
public void DeleteSetting(String sectionName, String settingName)
{
SectionPair sectionPair;
sectionPair.Section = sectionName.ToUpper();
sectionPair.Key = settingName.ToUpper();
if (keyPairs.ContainsKey(sectionPair))
keyPairs.Remove(sectionPair);
}
/// <summary>
/// Save settings to new file.
/// </summary>
/// <param name="newFilePath">New file path.</param>
public void SaveSettings(String newFilePath)
{
ArrayList sections = new ArrayList();
String tmpValue = "";
String strToSave = "";
foreach (SectionPair sectionPair in keyPairs.Keys)
{
if (!sections.Contains(sectionPair.Section))
sections.Add(sectionPair.Section);
}
foreach (String section in sections)
{
strToSave += ("[" + section + "]\r\n");
foreach (SectionPair sectionPair in keyPairs.Keys)
{
if (sectionPair.Section == section)
{
tmpValue = (String)keyPairs[sectionPair];
if (tmpValue != null)
tmpValue = "=" + tmpValue;
strToSave += (sectionPair.Key + tmpValue + "\r\n");
}
}
strToSave += "\r\n";
}
try
{
TextWriter tw = new StreamWriter(newFilePath);
tw.Write(strToSave);
tw.Close();
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// Save settings back to ini file.
/// </summary>
public void SaveSettings()
{
SaveSettings(iniFilePath);
}
}
}

View File

@@ -1,47 +1,72 @@
using System; using System;
using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text;
using System.Windows; using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ICSharpCode.SharpZipLib.Zip; using ICSharpCode.SharpZipLib.Zip;
using Microsoft.Win32; using Microsoft.Win32;
using Wox.Helper; using Wox.Infrastructure;
using Wox.Plugin; using Wox.Plugin;
using Path = System.IO.Path;
namespace Wox.WorkflowInstaller namespace Wox.Helper
{ {
public class PluginInstaller
public partial class MainWindow
{ {
public MainWindow() [DllImport("shell32.dll")]
private static extern void SHChangeNotify(uint wEventId, uint uFlags, IntPtr dwItem1, IntPtr dwItem2);
/// <summary>
/// associate filetype with specified program
/// </summary>
/// <param name="filePath"></param>
/// <param name="fileType"></param>
/// <param name="iconPath"></param>
/// <param name="overrides"></param>
private static void SaveReg(string filePath, string fileType, string iconPath, bool overrides)
{ {
InitializeComponent(); RegistryKey classRootKey = Registry.ClassesRoot.OpenSubKey("", true);
Loaded += MainWindow_Loaded; RegistryKey woxKey = classRootKey.OpenSubKey(fileType, true);
string[] param = Environment.GetCommandLineArgs(); if (woxKey != null)
if (param.Length == 2)
{ {
string workflowPath = param[1]; if (!overrides)
//string workflowPath = @"c:\Users\Scott\Desktop\Desktop.wox";
if (workflowPath.EndsWith(".wox"))
{ {
InstallWorkflow(workflowPath); return;
} }
classRootKey.DeleteSubKeyTree(fileType);
} }
classRootKey.CreateSubKey(fileType);
woxKey = classRootKey.OpenSubKey(fileType, true);
woxKey.SetValue("", "wox.wox");
woxKey.SetValue("Content Type", "application/wox");
RegistryKey iconKey = woxKey.CreateSubKey("DefaultIcon");
iconKey.SetValue("", iconPath);
woxKey.CreateSubKey("shell");
RegistryKey shellKey = woxKey.OpenSubKey("shell", true);
shellKey.SetValue("", "Open");
RegistryKey openKey = shellKey.CreateSubKey("open");
openKey.SetValue("", "Open with wox");
openKey = shellKey.OpenSubKey("open", true);
openKey.CreateSubKey("command");
RegistryKey commandKey = openKey.OpenSubKey("command", true);
string pathString = "\"" + filePath + "\" \"%1\"";
commandKey.SetValue("", pathString);
//refresh cache
SHChangeNotify(0x8000000, 0, IntPtr.Zero, IntPtr.Zero);
} }
private void InstallWorkflow(string path) public void RegisterInstaller()
{
string filePath = Directory.GetCurrentDirectory() + "\\Wox.Installer.exe";
string iconPath = Directory.GetCurrentDirectory() + "\\app.ico";
SaveReg(filePath, ".wox", iconPath, false);
}
public void Install(string path)
{ {
if (File.Exists(path)) if (File.Exists(path))
{ {
@@ -56,7 +81,6 @@ namespace Wox.WorkflowInstaller
if (!File.Exists(iniPath)) if (!File.Exists(iniPath))
{ {
MessageBox.Show("Install failed: config is missing"); MessageBox.Show("Install failed: config is missing");
Close();
return; return;
} }
@@ -64,7 +88,6 @@ namespace Wox.WorkflowInstaller
if (plugin == null || plugin.Name == null) if (plugin == null || plugin.Name == null)
{ {
MessageBox.Show("Install failed: config of this workflow is invalid"); MessageBox.Show("Install failed: config of this workflow is invalid");
Close();
return; return;
} }
@@ -72,7 +95,6 @@ namespace Wox.WorkflowInstaller
if (!Directory.Exists(pluginFolerPath)) if (!Directory.Exists(pluginFolerPath))
{ {
MessageBox.Show("Install failed: cound't find workflow directory"); MessageBox.Show("Install failed: cound't find workflow directory");
Close();
return; return;
} }
@@ -122,16 +144,11 @@ namespace Wox.WorkflowInstaller
{ {
MessageBox.Show("You have installed workflow " + plugin.Name + " successfully. Please restart your wox to use new workflow."); MessageBox.Show("You have installed workflow " + plugin.Name + " successfully. Please restart your wox to use new workflow.");
} }
Close();
}
else
{
Close();
} }
} }
} }
private static PluginMetadata GetMetadataFromIni(string directory) private PluginMetadata GetMetadataFromIni(string directory)
{ {
string iniPath = directory + "\\plugin.ini"; string iniPath = directory + "\\plugin.ini";
@@ -182,7 +199,7 @@ namespace Wox.WorkflowInstaller
/// <param name="zipedFile">The ziped file.</param> /// <param name="zipedFile">The ziped file.</param>
/// <param name="strDirectory">The STR directory.</param> /// <param name="strDirectory">The STR directory.</param>
/// <param name="overWrite">overwirte</param> /// <param name="overWrite">overwirte</param>
public void UnZip(string zipedFile, string strDirectory, bool overWrite) private void UnZip(string zipedFile, string strDirectory, bool overWrite)
{ {
if (strDirectory == "") if (strDirectory == "")
strDirectory = Directory.GetCurrentDirectory(); strDirectory = Directory.GetCurrentDirectory();
@@ -231,52 +248,5 @@ namespace Wox.WorkflowInstaller
s.Close(); s.Close();
} }
} }
void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
string filePath = Directory.GetCurrentDirectory() + "\\Wox.WorkflowInstaller.exe";
string iconPath = Directory.GetCurrentDirectory() + "\\app.ico";
SaveReg(filePath, ".wox", iconPath, false);
}
[DllImport("shell32.dll")]
private static extern void SHChangeNotify(uint wEventId, uint uFlags, IntPtr dwItem1, IntPtr dwItem2);
private static void SaveReg(string filePath, string fileType, string iconPath, bool overrides)
{
RegistryKey classRootKey = Registry.ClassesRoot.OpenSubKey("", true);
RegistryKey woxKey = classRootKey.OpenSubKey(fileType, true);
if (woxKey != null)
{
if (!overrides)
{
return;
}
classRootKey.DeleteSubKeyTree(fileType);
}
classRootKey.CreateSubKey(fileType);
woxKey = classRootKey.OpenSubKey(fileType, true);
woxKey.SetValue("", "wox.wox");
woxKey.SetValue("Content Type", "application/wox");
RegistryKey iconKey = woxKey.CreateSubKey("DefaultIcon");
iconKey.SetValue("", iconPath);
woxKey.CreateSubKey("shell");
RegistryKey shellKey = woxKey.OpenSubKey("shell", true);
shellKey.SetValue("", "Open");
RegistryKey openKey = shellKey.CreateSubKey("open");
openKey.SetValue("", "Open with wox");
openKey = shellKey.OpenSubKey("open", true);
openKey.CreateSubKey("command");
RegistryKey commandKey = openKey.OpenSubKey("command", true);
string pathString = "\"" + filePath + "\" \"%1\"";
commandKey.SetValue("", pathString);
//refresh cache
SHChangeNotify(0x8000000, 0, IntPtr.Zero, IntPtr.Zero);
}
} }
} }

View File

@@ -182,9 +182,9 @@ namespace Wox
{ {
if (args != null && args.Length > 0) if (args != null && args.Length > 0)
{ {
switch (args[0]) switch (args[0].ToLower())
{ {
case "reloadWorkflows": case "reloadworkflows":
Plugins.Init(); Plugins.Init();
break; break;

View File

@@ -5,6 +5,7 @@ using System.Linq;
using System.Reflection; using System.Reflection;
using System.Windows.Forms; using System.Windows.Forms;
using Wox.Helper; using Wox.Helper;
using Wox.Infrastructure;
using Wox.Plugin; using Wox.Plugin;
using Wox.Plugin.System; using Wox.Plugin.System;

View File

@@ -10,14 +10,18 @@
<TabControl Height="auto" > <TabControl Height="auto" >
<TabItem Header="Basic"> <TabItem Header="Basic">
<StackPanel Orientation="Vertical" Margin="10"> <StackPanel Orientation="Vertical" Margin="10">
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal" Margin="10">
<CheckBox x:Name="cbStartWithWindows" Unchecked="CbStartWithWindows_OnUnchecked" Checked="CbStartWithWindows_OnChecked" />
<TextBlock Text="Start Wox on system startup" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="10">
<CheckBox x:Name="cbReplaceWinR" />
<TextBlock Text="Replace Win+R" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="10">
<TextBlock Text="Theme:" /> <TextBlock Text="Theme:" />
<ComboBox x:Name="themeComboBox" SelectionChanged="ThemeComboBox_OnSelectionChanged" HorizontalAlignment="Left" VerticalAlignment="Top" Width="120"/> <ComboBox x:Name="themeComboBox" SelectionChanged="ThemeComboBox_OnSelectionChanged" HorizontalAlignment="Left" VerticalAlignment="Top" Width="120"/>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal">
<CheckBox x:Name="cbReplaceWinR" />
<TextBlock Text="Replace Win+R:" />
</StackPanel>
</StackPanel> </StackPanel>
</TabItem> </TabItem>
<TabItem Header="Web Search"> <TabItem Header="Web Search">

View File

@@ -1,11 +1,18 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.CompilerServices;
using System.Security.Permissions;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Forms;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Microsoft.Win32;
using Wox.Helper; using Wox.Helper;
using Wox.Infrastructure; using Wox.Infrastructure;
using Wox.Infrastructure.UserSettings; using Wox.Infrastructure.UserSettings;
using MessageBox = System.Windows.MessageBox;
namespace Wox namespace Wox
{ {
@@ -13,6 +20,11 @@ namespace Wox
{ {
private MainWindow mainWindow; private MainWindow mainWindow;
public SettingWidow()
{
InitializeComponent();
}
public SettingWidow(MainWindow mainWindow) public SettingWidow(MainWindow mainWindow)
{ {
this.mainWindow = mainWindow; this.mainWindow = mainWindow;
@@ -98,5 +110,47 @@ namespace Wox
MessageBox.Show("Please select a web search"); MessageBox.Show("Please select a web search");
} }
} }
private void CbStartWithWindows_OnChecked(object sender, RoutedEventArgs e)
{
OnStartWithWindowsChecked();
}
private void CbStartWithWindows_OnUnchecked(object sender, RoutedEventArgs e)
{
OnStartWithWindowUnChecked();
}
[MethodImpl(MethodImplOptions.NoInlining)]
private void OnStartWithWindowUnChecked()
{
UAC.ExecuteAdminMethod(() => SetStartup(false));
}
[MethodImpl(MethodImplOptions.NoInlining)]
private void OnStartWithWindowsChecked()
{
UAC.ExecuteAdminMethod(() => SetStartup(true));
}
private void SetStartup(bool startup)
{
RegistryKey rk = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
if (rk != null)
{
if (startup)
{
rk.SetValue("Wox",Path.Combine(Directory.GetCurrentDirectory(),"Wox.exe startHide"));
}
else
{
rk.DeleteValue("Wox", false);
}
}
}
} }
} }

View File

@@ -4,13 +4,14 @@
Icon="Images\app.png" Icon="Images\app.png"
ResizeMode="NoResize" ResizeMode="NoResize"
WindowStartupLocation="CenterScreen" WindowStartupLocation="CenterScreen"
Title="WebSearchSetting" Height="300" Width="674.766"> Title="WebSearchSetting" Height="350" Width="674.766">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition></RowDefinition> <RowDefinition></RowDefinition>
<RowDefinition></RowDefinition> <RowDefinition></RowDefinition>
<RowDefinition></RowDefinition> <RowDefinition></RowDefinition>
<RowDefinition></RowDefinition> <RowDefinition></RowDefinition>
<RowDefinition Height="60"></RowDefinition>
<RowDefinition></RowDefinition> <RowDefinition></RowDefinition>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
@@ -29,7 +30,13 @@
<TextBlock Margin="10" FontSize="14" Grid.Row="3" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right">Enable:</TextBlock> <TextBlock Margin="10" FontSize="14" Grid.Row="3" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right">Enable:</TextBlock>
<CheckBox x:Name="cbEnable" IsChecked="True" Margin="10" Grid.Row="3" Grid.Column="1" VerticalAlignment="Center"></CheckBox> <CheckBox x:Name="cbEnable" IsChecked="True" Margin="10" Grid.Row="3" Grid.Column="1" VerticalAlignment="Center"></CheckBox>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Row="4" Grid.Column="1"> <TextBlock Margin="10" FontSize="14" Grid.Row="4" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right">Icon:</TextBlock>
<StackPanel Orientation="Horizontal" Grid.Row="4" Grid.Column="1" Margin="10">
<Image x:Name="imgIcon" Width="24" Height="24" Margin="0 0 10 0" />
<Button x:Name="btnSelectIcon" Height="24" Click="BtnSelectIcon_OnClick">Select Icon</Button>
<TextBlock x:Name="tbIconPath" Visibility="Hidden"></TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Row="5" Grid.Column="1">
<Button x:Name="btnCancel" Click="BtnCancel_OnClick" Margin="10 0 10 0" Width="80" Height="25">Cancel</Button> <Button x:Name="btnCancel" Click="BtnCancel_OnClick" Margin="10 0 10 0" Width="80" Height="25">Cancel</Button>
<Button x:Name="btnAdd" Margin="10 0 10 0" Width="80" Height="25" Click="btnAdd_OnClick"><TextBlock x:Name="lblAdd">Add</TextBlock></Button> <Button x:Name="btnAdd" Margin="10 0 10 0" Width="80" Height="25" Click="btnAdd_OnClick"><TextBlock x:Name="lblAdd">Add</TextBlock></Button>
</StackPanel> </StackPanel>

View File

@@ -42,12 +42,25 @@ namespace Wox
update = true; update = true;
lblAdd.Text = "Update"; lblAdd.Text = "Update";
tbIconPath.Text = webSearch.IconPath;
ShowIcon(webSearch.IconPath);
cbEnable.IsChecked = webSearch.Enabled; cbEnable.IsChecked = webSearch.Enabled;
tbTitle.Text = webSearch.Title; tbTitle.Text = webSearch.Title;
tbUrl.Text = webSearch.Url; tbUrl.Text = webSearch.Url;
tbActionword.Text = webSearch.ActionWord; tbActionword.Text = webSearch.ActionWord;
} }
private void ShowIcon(string path)
{
try
{
imgIcon.Source = new BitmapImage(new Uri(path));
}
catch (Exception)
{
}
}
private void BtnCancel_OnClick(object sender, RoutedEventArgs e) private void BtnCancel_OnClick(object sender, RoutedEventArgs e)
{ {
Close(); Close();
@@ -88,7 +101,7 @@ namespace Wox
{ {
ActionWord = action, ActionWord = action,
Enabled = cbEnable.IsChecked ?? false, Enabled = cbEnable.IsChecked ?? false,
IconPath = "", IconPath = tbIconPath.Text,
Url = url, Url = url,
Title = title Title = title
}); });
@@ -97,7 +110,7 @@ namespace Wox
else else
{ {
updateWebSearch.ActionWord = action; updateWebSearch.ActionWord = action;
updateWebSearch.IconPath = ""; updateWebSearch.IconPath = tbIconPath.Text;
updateWebSearch.Enabled = cbEnable.IsChecked ?? false; updateWebSearch.Enabled = cbEnable.IsChecked ?? false;
updateWebSearch.Url = url; updateWebSearch.Url = url;
updateWebSearch.Title= title; updateWebSearch.Title= title;
@@ -107,5 +120,23 @@ namespace Wox
settingWidow.ReloadWebSearchView(); settingWidow.ReloadWebSearchView();
Close(); Close();
} }
private void BtnSelectIcon_OnClick(object sender, RoutedEventArgs e)
{
var dlg = new Microsoft.Win32.OpenFileDialog
{
DefaultExt = ".png",
Filter =
"JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|JPG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif"
};
bool? result = dlg.ShowDialog();
if (result == true)
{
string filename = dlg.FileName;
tbIconPath.Text = filename;
ShowIcon(filename);
}
}
} }
} }

View File

@@ -78,6 +78,10 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Accessibility" /> <Reference Include="Accessibility" />
<Reference Include="ICSharpCode.SharpZipLib, Version=0.86.0.518, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll</HintPath>
</Reference>
<Reference Include="log4net"> <Reference Include="log4net">
<HintPath>..\packages\log4net.2.0.3\lib\net35-full\log4net.dll</HintPath> <HintPath>..\packages\log4net.2.0.3\lib\net35-full\log4net.dll</HintPath>
</Reference> </Reference>
@@ -119,6 +123,7 @@
<Compile Include="Helper\DwmDropShadow.cs" /> <Compile Include="Helper\DwmDropShadow.cs" />
<Compile Include="Helper\KeyboardHook.cs" /> <Compile Include="Helper\KeyboardHook.cs" />
<Compile Include="Helper\Log.cs" /> <Compile Include="Helper\Log.cs" />
<Compile Include="Helper\PluginInstaller.cs" />
<Compile Include="Helper\WoxException.cs" /> <Compile Include="Helper\WoxException.cs" />
<Compile Include="Helper\KeyboardListener.cs" /> <Compile Include="Helper\KeyboardListener.cs" />
<Compile Include="Msg.xaml.cs"> <Compile Include="Msg.xaml.cs">
@@ -126,7 +131,6 @@
</Compile> </Compile>
<Compile Include="PluginLoader\BasePluginLoader.cs" /> <Compile Include="PluginLoader\BasePluginLoader.cs" />
<Compile Include="PluginLoader\CSharpPluginLoader.cs" /> <Compile Include="PluginLoader\CSharpPluginLoader.cs" />
<Compile Include="Helper\IniParser.cs" />
<Compile Include="PluginLoader\Plugins.cs" /> <Compile Include="PluginLoader\Plugins.cs" />
<Compile Include="PluginLoader\PythonPluginLoader.cs" /> <Compile Include="PluginLoader\PythonPluginLoader.cs" />
<Compile Include="PluginLoader\PythonPluginWrapper.cs" /> <Compile Include="PluginLoader\PythonPluginWrapper.cs" />