forked from Collective-Software/ClickPaste
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSettingsForm.cs
More file actions
121 lines (114 loc) · 3.94 KB
/
Copy pathSettingsForm.cs
File metadata and controls
121 lines (114 loc) · 3.94 KB
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics.Eventing.Reader;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ClickPaste
{
public partial class SettingsForm : Form
{
RadioButton[] _methods;
CheckBox[] _modifiers;
public SettingsForm()
{
InitializeComponent();
_methods = new RadioButton[2];
_methods[0] = Method_Forms;
_methods[1] = Method_AutoIt;
_modifiers = new CheckBox[4];
_modifiers[0] = HotKey_Alt;
_modifiers[1] = HotKey_Control;
_modifiers[2] = HotKey_Shift;
_modifiers[3] = HotKey_Windows;
foreach(var method in _methods)
{
method.Checked = (Properties.Settings.Default.TypeMethod == int.Parse(method.Tag.ToString()));
}
DelayBetweenMS.Text = Properties.Settings.Default.KeyDelayBetweenMS.ToString();
DelayBeforeMS.Text = Properties.Settings.Default.KeyDelayBeforeMS.ToString();
HotKey_Letter.Text = Properties.Settings.Default.HotKey;
foreach(var mod in _modifiers)
{
mod.Checked = (0 != (Properties.Settings.Default.HotKeyModifier & int.Parse(mod.Tag.ToString())));
}
}
private void HotKey_Letter_KeyDown(object sender, KeyEventArgs e)
{
switch(e.KeyCode)
{
case Keys.Alt:
case Keys.Menu:
case Keys.LMenu:
case Keys.RMenu:
case Keys.Shift:
case Keys.ShiftKey:
case Keys.LShiftKey:
case Keys.RShiftKey:
case Keys.Control:
case Keys.ControlKey:
case Keys.LControlKey:
case Keys.RControlKey:
case Keys.LWin:
case Keys.RWin:
case Keys.Return:
break;
case Keys.Delete:
case Keys.Back:
HotKey_Letter.Text = string.Empty;
break;
default:
HotKey_Letter.Text = e.KeyCode.ToString();
break;
}
e.SuppressKeyPress = true;
}
private void Done_Click(object sender, EventArgs e)
{
foreach(var method in _methods)
{
if (_methods[0].Checked)
{
Properties.Settings.Default.TypeMethod = (int)TypeMethod.Forms_SendKeys;
}
else
{
Properties.Settings.Default.TypeMethod = (int)TypeMethod.AutoIt_Send;
}
}
int delay;
if (int.TryParse(DelayBetweenMS.Text, out delay))
{
Properties.Settings.Default.KeyDelayBetweenMS = delay;
}
if (int.TryParse(DelayBeforeMS.Text, out delay))
{
Properties.Settings.Default.KeyDelayBeforeMS = delay;
}
var letter = HotKey_Letter.Text;
if (letter.Length == 1) letter = letter.ToUpperInvariant(); // can't find 'v' but knows 'V'
Properties.Settings.Default.HotKey = letter;
int mods = 0;
foreach (var mod in _modifiers)
{
if (mod.Checked)
{
mods |= int.Parse(mod.Tag.ToString());
}
Properties.Settings.Default.HotKeyModifier = mods;
}
Properties.Settings.Default.Save();
}
private void groupBox4_Enter(object sender, EventArgs e)
{
}
private void Method_Forms_CheckedChanged(object sender, EventArgs e)
{
}
}
}