-
Notifications
You must be signed in to change notification settings - Fork 0
/
Plugin.cs
54 lines (46 loc) · 1.16 KB
/
Plugin.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
using System;
using System.Collections.Generic;
using System.Diagnostics;
namespace Wox.Plugin.Rdp
{
public class PuttyPlugin: IPlugin
{
private PluginInitContext context;
public void Init(PluginInitContext context)
{
this.context = context;
}
public List<Result> Query(Query query)
{
List<Result> results = new List<Result>();
if (query.ActionParameters.Count != 0)
results.Add(MakeResult(query.ActionParameters[0], ""));
results.Add(MakeResult(null, null));
return results;
}
private Result MakeResult(string name, string desc)
{
return new Result() {
Title = name ?? "Remote Desktop Connection",
SubTitle = desc ?? "Launch Clean Remote Desktop Connection",
IcoPath = "Images\\plugin.png",
Action = e => {
try {
var p = new Process();
p.StartInfo.FileName = "mstsc";
if (name != null) {
p.StartInfo.Arguments = "/v:" + name;
}
p.Start();
} catch (Exception ex) {
context.ShowMsg.Invoke("Rdp Error: " + name, ex.Message, "");
return false;
// ignore exception
}
return true;
}
};
}
}
// end namespace
}