-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMain.cs
67 lines (59 loc) · 1.81 KB
/
Main.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Windows.Forms;
namespace Wox.Plugin.UrlEncode
{
public class Main : IPlugin
{
public List<Result> Query(Query query)
{
var list = new List<Result>();
if (query.ActionParameters.Count == 0)
{
list.Add(new Result() {
IcoPath ="Images\\app.png",
Title = "Please input a string"
});
return list;
}
if (query.ActionParameters.Count > 0)
{
var str = query.ActionParameters[0];
list.Add(new Result()
{
IcoPath = "Images\\encode.png",
Title = HttpUtility.UrlEncode(str),
SubTitle = "Copy to clipboard",
Action = (c) =>
{
Clipboard.SetText(HttpUtility.UrlEncode(str));
return true;
}
});
list.Add(new Result()
{
IcoPath = "Images\\decode.png",
Title = HttpUtility.UrlDecode(str),
SubTitle = "Copy to clipboard",
Action = (c) =>
{
Clipboard.SetText(HttpUtility.UrlDecode(str));
return true;
}
});
if (str.Contains("%"))
{
// may be a encode string, change order
list.Reverse();
}
}
return list;
}
public void Init(PluginInitContext context)
{
}
}
}