-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHotkeyForm.cs
61 lines (54 loc) · 1.62 KB
/
HotkeyForm.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace QwertyToMIDI
{
public class HotkeyForm : Form
{
public event EventHandler<HotkeyEventArgs> HotkeyPressed;
public HotkeyForm()
{
InitializeComponent();
}
private void InitializeComponent()
{
lhk = new Label();
SuspendLayout();
//
// lhk
//
lhk.Dock = DockStyle.Fill;
lhk.Location = new Point(0, 0);
lhk.Name = "lhk";
lhk.Size = new Size(234, 61);
lhk.TabIndex = 0;
lhk.Text = "Press the key...";
lhk.TextAlign = ContentAlignment.MiddleCenter;
//
// HotkeyForm
//
ClientSize = new Size(234, 61);
Controls.Add(lhk);
FormBorderStyle = FormBorderStyle.FixedDialog;
MaximizeBox = false;
Name = "HotkeyForm";
StartPosition = FormStartPosition.CenterParent;
Text = "Choose Hotkey";
KeyDown += HotkeyForm_KeyDown;
ResumeLayout(false);
}
private void HotkeyForm_KeyDown(object sender, KeyEventArgs e)
{
// Вызов события при нажатии клавиши
HotkeyPressed?.Invoke(this, new HotkeyEventArgs { SelectedHotkey = e.KeyCode });
Close();
}
private Label lhk;
}
public class HotkeyEventArgs : EventArgs
{
public Keys SelectedHotkey { get; set; }
}
}