forked from ispysoftware/iSpy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AddRemoteCommand.cs
125 lines (105 loc) · 3.75 KB
/
AddRemoteCommand.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace iSpyApplication
{
public partial class AddRemoteCommand : Form
{
public objectsCommand OC = null;
public AddRemoteCommand()
{
InitializeComponent();
RenderResources();
}
private void RenderResources()
{
button3.Text = "...";
label1.Text = LocRm.GetString("Name");
btnAddCommand.Text = LocRm.GetString("Add");
label83.Text = LocRm.GetString("ExecuteFile");
llblHelp.Text = LocRm.GetString("help");
}
private void button3_Click(object sender, EventArgs e)
{
var ofdDetect = new OpenFileDialog { FileName = "", InitialDirectory = Program.AppPath + @"sounds\" };
ofdDetect.ShowDialog(this);
if (ofdDetect.FileName != "")
{
txtExecute.Text = ofdDetect.FileName;
}
ofdDetect.Dispose();
}
private void btnAddCommand_Click(object sender, EventArgs e)
{
string name = txtName.Text.Trim();
string execute = txtExecute.Text.Trim();
if (OC != null)
{
OC.name = name;
OC.command = execute;
OC.emitshortcut = txtShortcutKeys.Text.Trim();
DialogResult = DialogResult.OK;
Close();
return;
}
if (MainForm.RemoteCommands.SingleOrDefault(p => p.name == name) != null)
{
MessageBox.Show(LocRm.GetString("UniqueNameCommand"));
return;
}
var oc = new objectsCommand { name = name, command = execute, id = MainForm.NextCommandId, emitshortcut = txtShortcutKeys.Text.Trim()};
MainForm.RemoteCommands.Add(oc);
DialogResult = DialogResult.OK;
Close();
}
private void txtShortcutKeys_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode != Keys.Back)
{
Keys modifierKeys = e.Modifiers;
Keys pressedKey = e.KeyData ^ modifierKeys;
if (modifierKeys != Keys.None && pressedKey != Keys.None)
{
var converter = new KeysConverter();
txtShortcutKeys.Text = converter.ConvertToString(e.KeyData);
}
e.Handled = true;
}
else
{
e.Handled = false;
e.SuppressKeyPress = true;
txtShortcutKeys.Text = "";
}
}
private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
MainForm.OpenUrl(MainForm.Website + "/userguide-remotecommands.aspx");
}
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
MainForm.OpenUrl(MainForm.Website + "/userguide-commandline.aspx");
}
private void tableLayoutPanel2_Paint(object sender, PaintEventArgs e)
{
}
private void AddRemoteCommand_Load(object sender, EventArgs e)
{
if (OC != null)
{
txtExecute.Text = OC.command;
txtShortcutKeys.Text = OC.emitshortcut;
if (OC.name.StartsWith("cmd_"))
txtName.Text = LocRm.GetString(OC.name);
else
txtName.Text = OC.name;
Text = btnAddCommand.Text = LocRm.GetString("Update");
}
}
}
}