-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDlgEditHotKey.cs
More file actions
109 lines (94 loc) · 3.91 KB
/
DlgEditHotKey.cs
File metadata and controls
109 lines (94 loc) · 3.91 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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Windows.Media.Casting;
namespace VirtualDesktopHelper
{
public partial class DlgEditHotKey : Form
{
private readonly VDesktopConfiguration configuration;
private VDesktopConfiguration workingCopy;
private bool switchToSelectionInProgress = false;
private bool sendToSelectionInProgress = false;
public DlgEditHotKey(VDesktopConfiguration configuration)
{
this.configuration = configuration;
this.workingCopy = configuration.Clone();
InitializeComponent();
txtDesktopName.Text = configuration.Name;
chkSwitchToSHFT.Checked = configuration.SwitchToHotKey.HotKeyUsesShift;
chkSwitchToCTRL.Checked = configuration.SwitchToHotKey.HotKeyUsesCtrl;
chkSwitchToALT.Checked = configuration.SwitchToHotKey.HotKeyUsesAlt;
txtSwitchToHotKey.Text = configuration.SwitchToHotKey.HotKey;
chkSendToCTRL.Checked = configuration.SwitchToHotKey.HotKeyUsesCtrl;
chkSendToALT.Checked = configuration.SwitchToHotKey.HotKeyUsesAlt;
chkSendToSHFT.Checked = configuration.SwitchToHotKey.HotKeyUsesShift;
txtSendToHotKey.Text = configuration.SendToHotKey.HotKey;
}
private void UpdateDialog()
{
workingCopy.SwitchToHotKey.HotKeyUsesCtrl = chkSwitchToCTRL.Checked;
workingCopy.SwitchToHotKey.HotKeyUsesShift = chkSwitchToSHFT.Checked;
workingCopy.SwitchToHotKey.HotKeyUsesAlt = chkSwitchToALT.Checked;
txtSwitchToHotKey.Text = workingCopy.SwitchToHotKey.HotKey;
workingCopy.SendToHotKey.HotKeyUsesCtrl = chkSendToCTRL.Checked;
workingCopy.SendToHotKey.HotKeyUsesShift = chkSendToSHFT.Checked;
workingCopy.SendToHotKey.HotKeyUsesAlt = chkSendToALT.Checked;
txtSendToHotKey.Text = workingCopy.SendToHotKey.HotKey;
btnOk.Enabled = !string.IsNullOrEmpty(txtDesktopName.Text);
}
public DlgEditHotKey() : this(new VDesktopConfiguration())
{
}
private void btnOk_Click(object sender, EventArgs e)
{
configuration.SwitchToHotKey= workingCopy.SwitchToHotKey;
configuration.SendToHotKey = workingCopy.SendToHotKey;
configuration.Name = txtDesktopName.Text;
DialogResult = DialogResult.OK;
Close();
}
private void btnCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
private void btnSwitchToSelectHotKey_Click(object sender, EventArgs e)
{
switchToSelectionInProgress = true;
lblInstructionSwitchTo.Visible = true;
}
private void btnSendToSelectHotKey_Click(object sender, EventArgs e)
{
sendToSelectionInProgress = true;
lblInstructionSendTo.Visible = true;
}
private void DlgEditHotKey_KeyDown(object sender, KeyEventArgs e)
{
if (switchToSelectionInProgress)
{
workingCopy.SwitchToHotKey.HotKeyKey = e.KeyCode;
UpdateDialog();
switchToSelectionInProgress = false;
lblInstructionSwitchTo.Visible = false;
}
else if (sendToSelectionInProgress)
{
workingCopy.SendToHotKey.HotKeyKey = e.KeyCode;
UpdateDialog();
sendToSelectionInProgress = false;
lblInstructionSendTo.Visible = false;
}
}
private void ChkBox_CheckedChanged(object sender, EventArgs e)
{
UpdateDialog();
}
}
}