WingMan – Diff between revs 7 and 8

Subversion Repositories:
Rev:
Only display areas with differencesIgnore whitespace
Rev 7 Rev 8
1 using System; 1 using System;
2 using System.Collections.Generic; 2 using System.Collections.Generic;
3 using System.Drawing; 3 using System.Drawing;
4 using System.Linq; 4 using System.Linq;
5 using System.Net; 5 using System.Net;
6 using System.Threading; 6 using System.Threading;
7 using System.Threading.Tasks; 7 using System.Threading.Tasks;
8 using System.Windows.Forms; 8 using System.Windows.Forms;
9 using Gma.System.MouseKeyHook; 9 using Gma.System.MouseKeyHook;
10 using WingMan.Communication; 10 using WingMan.Communication;
11 using WingMan.Lobby; 11 using WingMan.Lobby;
12 using WingMan.MouseKey; 12 using WingMan.MouseKey;
13 using WingMan.Properties; 13 using WingMan.Properties;
-   14 using WingMan.Utilities;
14   15  
15 namespace WingMan 16 namespace WingMan
16 { 17 {
17 public partial class WingManForm : Form 18 public partial class WingManForm : Form
18 { 19 {
19 public WingManForm() 20 public WingManForm()
20 { 21 {
21 InitializeComponent(); 22 InitializeComponent();
22   23  
23 FormTaskScheduler = TaskScheduler.FromCurrentSynchronizationContext(); 24 FormTaskScheduler = TaskScheduler.FromCurrentSynchronizationContext();
24 FormCancellationTokenSource = new CancellationTokenSource(); 25 FormCancellationTokenSource = new CancellationTokenSource();
25   26  
26 MQTTCommunication = new MQTTCommunication(FormTaskScheduler, FormCancellationTokenSource.Token); 27 MQTTCommunication = new MQTTCommunication(FormTaskScheduler, FormCancellationTokenSource.Token);
-   28 MQTTCommunication.OnClientAuthenticationFailed += OnMQTTClientAuthenticationFailed;
-   29 MQTTCommunication.OnServerAuthenticationFailed += OnMQTTServerAuthenticationFailed;
27   30  
28 MouseKeyBindings = new MouseKeyBindings(new List<MouseKeyBinding>()); 31 MouseKeyBindings = new MouseKeyBindings(new List<MouseKeyBinding>());
29   32  
30 HelmListBoxBindingSource = new BindingSource 33 HelmListBoxBindingSource = new BindingSource
31 { 34 {
32 DataSource = MouseKeyBindings.Bindings 35 DataSource = MouseKeyBindings.Bindings
33 }; 36 };
34 HelmBindingsListBox.DisplayMember = "DisplayName"; 37 HelmBindingsListBox.DisplayMember = "DisplayName";
35 HelmBindingsListBox.ValueMember = "Keys"; 38 HelmBindingsListBox.ValueMember = "Keys";
36 HelmBindingsListBox.DataSource = HelmListBoxBindingSource; 39 HelmBindingsListBox.DataSource = HelmListBoxBindingSource;
37   40  
38 MouseKeyBindingsExchange = new MouseKeyBindingsExchange 41 MouseKeyBindingsExchange = new MouseKeyBindingsExchange
39 { 42 {
40 ExchangeBindings = new List<MouseKeyBindingExchange>() 43 ExchangeBindings = new List<MouseKeyBindingExchange>()
41 }; 44 };
42   45  
43 WingBindingsComboBoxSource = new BindingSource 46 WingBindingsComboBoxSource = new BindingSource
44 { 47 {
45 DataSource = MouseKeyBindingsExchange.ExchangeBindings 48 DataSource = MouseKeyBindingsExchange.ExchangeBindings
46 }; 49 };
47 WingBindingsComboBox.DisplayMember = "Nick"; 50 WingBindingsComboBox.DisplayMember = "Nick";
48 WingBindingsComboBox.ValueMember = "MouseKeyBindings"; 51 WingBindingsComboBox.ValueMember = "MouseKeyBindings";
49 WingBindingsComboBox.DataSource = WingBindingsComboBoxSource; 52 WingBindingsComboBox.DataSource = WingBindingsComboBoxSource;
50   53  
51 // Start lobby message synchronizer. 54 // Start lobby message synchronizer.
52 LobbyMessageSynchronizer = new LobbyMessageSynchronizer(MQTTCommunication, FormTaskScheduler, 55 LobbyMessageSynchronizer = new LobbyMessageSynchronizer(MQTTCommunication, FormTaskScheduler,
53 FormCancellationTokenSource.Token); 56 FormCancellationTokenSource.Token);
54 LobbyMessageSynchronizer.OnLobbyMessageReceived += OnLobbyMessageReceived; 57 LobbyMessageSynchronizer.OnLobbyMessageReceived += OnLobbyMessageReceived;
55   58  
56 // Start mouse key bindings synchronizer. 59 // Start mouse key bindings synchronizer.
57 MouseKeyBindingsSynchronizer = new MouseKeyBindingsSynchronizer(MouseKeyBindings, MQTTCommunication, 60 MouseKeyBindingsSynchronizer = new MouseKeyBindingsSynchronizer(MouseKeyBindings, MQTTCommunication,
58 FormTaskScheduler, FormCancellationTokenSource.Token); 61 FormTaskScheduler, FormCancellationTokenSource.Token);
59 MouseKeyBindingsSynchronizer.OnMouseKeyBindingsSynchronized += OnMouseKeyBindingsSynchronized; 62 MouseKeyBindingsSynchronizer.OnMouseKeyBindingsSynchronized += OnMouseKeyBindingsSynchronized;
60 } 63 }
61   64  
62 private static CancellationTokenSource FormCancellationTokenSource { get; set; } 65 private static CancellationTokenSource FormCancellationTokenSource { get; set; }
63   66  
64 private static TaskScheduler FormTaskScheduler { get; set; } 67 private static TaskScheduler FormTaskScheduler { get; set; }
65   68  
66 private static IKeyboardMouseEvents MouseKeyApplicationHook { get; set; } 69 private static IKeyboardMouseEvents MouseKeyApplicationHook { get; set; }
67   70  
68 private List<string> MouseKeyCombo { get; set; } 71 private List<string> MouseKeyCombo { get; set; }
69   72  
70 private MouseKeyBindings MouseKeyBindings { get; } 73 private MouseKeyBindings MouseKeyBindings { get; }
71   74  
72 private BindingSource HelmListBoxBindingSource { get; } 75 private BindingSource HelmListBoxBindingSource { get; }
73   76  
74 private BindingSource WingBindingsComboBoxSource { get; } 77 private BindingSource WingBindingsComboBoxSource { get; }
75   78  
76 private MouseKeyBindingsExchange MouseKeyBindingsExchange { get; } 79 private MouseKeyBindingsExchange MouseKeyBindingsExchange { get; }
77   80  
78 public MQTTCommunication MQTTCommunication { get; set; } 81 public MQTTCommunication MQTTCommunication { get; set; }
79   82  
80 public LobbyMessageSynchronizer LobbyMessageSynchronizer { get; set; } 83 public LobbyMessageSynchronizer LobbyMessageSynchronizer { get; set; }
81   84  
82 public MouseKeyBindingsSynchronizer MouseKeyBindingsSynchronizer { get; set; } 85 public MouseKeyBindingsSynchronizer MouseKeyBindingsSynchronizer { get; set; }
-   86  
-   87 private void OnMQTTServerAuthenticationFailed(object sender, EventArgs e)
-   88 {
-   89 ActivityTextBox.AppendText(
-   90 $"{Strings.Failed_to_authenticate_client}{Environment.NewLine}");
-   91 }
-   92  
-   93 private void OnMQTTClientAuthenticationFailed(object sender, EventArgs e)
-   94 {
-   95 ActivityTextBox.AppendText(
-   96 $"{Strings.Server_authentication_failed}{Environment.NewLine}");
-   97 }
83   98  
84 /// <summary> 99 /// <summary>
85 /// Clean up any resources being used. 100 /// Clean up any resources being used.
86 /// </summary> 101 /// </summary>
87 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> 102 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
88 protected override void Dispose(bool disposing) 103 protected override void Dispose(bool disposing)
89 { 104 {
90 if (disposing && components != null) 105 if (disposing && components != null)
91 { 106 {
92 FormCancellationTokenSource.Dispose(); 107 FormCancellationTokenSource.Dispose();
93 FormCancellationTokenSource = null; 108 FormCancellationTokenSource = null;
94   109  
95 components.Dispose(); 110 components.Dispose();
96 } 111 }
97   112  
98 base.Dispose(disposing); 113 base.Dispose(disposing);
99 } 114 }
100   115  
101 private void OnMouseKeyBindingsSynchronized(object sender, MouseKeyBindingsSynchronizedEventArgs e) 116 private void OnMouseKeyBindingsSynchronized(object sender, MouseKeyBindingsSynchronizedEventArgs e)
102 { 117 {
103 ActivityTextBox.AppendText( 118 ActivityTextBox.AppendText(
104 $"{Strings.Synchronized_bindings_with_client} : {e.Bindings.Nick} : {e.Bindings.MouseKeyBindings.Count}{Environment.NewLine}"); 119 $"{Strings.Synchronized_bindings_with_client} : {e.Bindings.Nick} : {e.Bindings.MouseKeyBindings.Count}{Environment.NewLine}");
105   120  
106 var exchangeBindings = MouseKeyBindingsExchange.ExchangeBindings.FirstOrDefault(exchangeBinding => 121 var exchangeBindings = MouseKeyBindingsExchange.ExchangeBindings.FirstOrDefault(exchangeBinding =>
107 string.Equals(exchangeBinding.Nick, e.Bindings.Nick, StringComparison.Ordinal)); 122 string.Equals(exchangeBinding.Nick, e.Bindings.Nick, StringComparison.Ordinal));
108   123  
109 // If the nick does not exist then add it. 124 // If the nick does not exist then add it.
110 if (exchangeBindings == null) 125 if (exchangeBindings == null)
111 { 126 {
112 MouseKeyBindingsExchange.ExchangeBindings.Add(e.Bindings); 127 MouseKeyBindingsExchange.ExchangeBindings.Add(e.Bindings);
113 WingBindingsComboBoxSource.ResetBindings(false); 128 WingBindingsComboBoxSource.ResetBindings(false);
114 UpdateWingListBoxItems(); 129 UpdateWingListBoxItems();
115 return; 130 return;
116 } 131 }
117   132  
118 // If the bindings for the nick have not changed then do not update. 133 // If the bindings for the nick have not changed then do not update.
119 if (exchangeBindings.MouseKeyBindings.SequenceEqual(e.Bindings.MouseKeyBindings)) 134 if (exchangeBindings.MouseKeyBindings.SequenceEqual(e.Bindings.MouseKeyBindings))
120 { 135 {
121 WingBindingsComboBoxSource.ResetBindings(false); 136 WingBindingsComboBoxSource.ResetBindings(false);
122 UpdateWingListBoxItems(); 137 UpdateWingListBoxItems();
123 return; 138 return;
124 } 139 }
125   140  
126 // Update the bindings. 141 // Update the bindings.
127 exchangeBindings.MouseKeyBindings = e.Bindings.MouseKeyBindings; 142 exchangeBindings.MouseKeyBindings = e.Bindings.MouseKeyBindings;
128 WingBindingsComboBoxSource.ResetBindings(false); 143 WingBindingsComboBoxSource.ResetBindings(false);
129 UpdateWingListBoxItems(); 144 UpdateWingListBoxItems();
130 } 145 }
131   146  
132 private void UpdateWingListBoxItems() 147 private void UpdateWingListBoxItems()
133 { 148 {
134 var exchangeBinding = (List<MouseKeyBinding>) WingBindingsComboBox.SelectedValue; 149 var exchangeBinding = (List<MouseKeyBinding>) WingBindingsComboBox.SelectedValue;
135 if (exchangeBinding == null) 150 if (exchangeBinding == null)
136 return; 151 return;
137   152  
138 WingBindingsListBox.Items.Clear(); 153 WingBindingsListBox.Items.Clear();
139 WingBindingsListBox.DisplayMember = "Name"; 154 WingBindingsListBox.DisplayMember = "Name";
140 WingBindingsListBox.ValueMember = "Name"; 155 WingBindingsListBox.ValueMember = "Name";
141 var i = exchangeBinding.Select(binding => (object) binding.Name).ToArray(); 156 var i = exchangeBinding.Select(binding => (object) binding.Name).ToArray();
142 if (i.Length == 0) 157 if (i.Length == 0)
143 return; 158 return;
144   159  
145 WingBindingsListBox.Items.AddRange(i); 160 WingBindingsListBox.Items.AddRange(i);
146 } 161 }
147   162  
148 private void OnLobbyMessageReceived(object sender, LobbyMessageReceivedEventArgs e) 163 private void OnLobbyMessageReceived(object sender, LobbyMessageReceivedEventArgs e)
149 { 164 {
150 LobbyTextBox.Invoke((MethodInvoker) delegate 165 LobbyTextBox.Invoke((MethodInvoker) delegate
151 { 166 {
152 LobbyTextBox.AppendText($"{e.Nick} : {e.Message}{Environment.NewLine}"); 167 LobbyTextBox.AppendText($"{e.Nick} : {e.Message}{Environment.NewLine}");
153 }); 168 });
154 } 169 }
155   170  
156 private void AddressTextBoxClick(object sender, EventArgs e) 171 private void AddressTextBoxClick(object sender, EventArgs e)
157 { 172 {
158 Address.BackColor = Color.Empty; 173 Address.BackColor = Color.Empty;
159 } 174 }
160   175  
161 private void PortTextBoxClick(object sender, EventArgs e) 176 private void PortTextBoxClick(object sender, EventArgs e)
162 { 177 {
163 Port.BackColor = Color.Empty; 178 Port.BackColor = Color.Empty;
164 } 179 }
165   180  
166 private async void HostButtonClickAsync(object sender, EventArgs e) 181 private async void HostButtonClickAsync(object sender, EventArgs e)
167 { 182 {
168 // Stop the MQTT server if it is running. 183 // Stop the MQTT server if it is running.
169 if (MQTTCommunication.Running) 184 if (MQTTCommunication.Running)
170 { 185 {
171 await MQTTCommunication.Stop().ConfigureAwait(false); 186 await MQTTCommunication.Stop().ConfigureAwait(false);
172 toolStripStatusLabel.Text = Strings.Server_stopped; 187 toolStripStatusLabel.Text = Strings.Server_stopped;
173 HostButton.BackColor = Color.Empty; 188 HostButton.BackColor = Color.Empty;
174   189  
175 // Enable controls. 190 // Enable controls.
176 ConnectButton.Enabled = true; 191 ConnectButton.Enabled = true;
177 Address.Enabled = true; 192 Address.Enabled = true;
178 Port.Enabled = true; 193 Port.Enabled = true;
179 Nick.Enabled = true; 194 Nick.Enabled = true;
180   195  
181 return; 196 return;
182 } 197 }
183   198  
184 if (!ValidateAddressPort(out var ipAddress, out var port, out var nick)) 199 if (!ValidateAddressPort(out var ipAddress, out var port, out var nick, out var password))
185 return; 200 return;
186   201  
187 // Start the MQTT server. 202 // Start the MQTT server.
188 await MQTTCommunication.Start(MQTTCommunicationType.Server, ipAddress, port, nick).ConfigureAwait(false); 203 await MQTTCommunication.Start(MQTTCommunicationType.Server, ipAddress, port, nick, password)
-   204 .ConfigureAwait(false);
189 toolStripStatusLabel.Text = Strings.Server_started; 205 toolStripStatusLabel.Text = Strings.Server_started;
190 HostButton.BackColor = Color.Aquamarine; 206 HostButton.BackColor = Color.Aquamarine;
191   207  
192 // Disable controls 208 // Disable controls
193 ConnectButton.Enabled = false; 209 ConnectButton.Enabled = false;
194 Address.Enabled = false; 210 Address.Enabled = false;
195 Port.Enabled = false; 211 Port.Enabled = false;
196 Nick.Enabled = false; 212 Nick.Enabled = false;
197 } 213 }
198   214  
199 private bool ValidateAddressPort(out IPAddress address, out int port, out string nick) 215 private bool ValidateAddressPort(out IPAddress address, out int port, out string nick, out string password)
200 { 216 {
201 address = IPAddress.Any; 217 address = IPAddress.Any;
202 port = 0; 218 port = 0;
203 nick = string.Empty; 219 nick = string.Empty;
-   220 password = string.Empty;
204   221  
205 if (string.IsNullOrEmpty(Address.Text) && 222 if (string.IsNullOrEmpty(Address.Text) &&
206 string.IsNullOrEmpty(Port.Text) && 223 string.IsNullOrEmpty(Port.Text) &&
207 string.IsNullOrEmpty(Nick.Text)) 224 string.IsNullOrEmpty(Nick.Text) &&
-   225 string.IsNullOrEmpty(Password.Text))
208 { 226 {
209 Address.BackColor = Color.LightPink; 227 Address.BackColor = Color.LightPink;
210 Port.BackColor = Color.LightPink; 228 Port.BackColor = Color.LightPink;
211 Nick.BackColor = Color.LightPink; 229 Nick.BackColor = Color.LightPink;
-   230 Password.BackColor = Color.LightPink;
212 return false; 231 return false;
213 } 232 }
214   233  
215 if (!IPAddress.TryParse(Address.Text, out address)) 234 if (!IPAddress.TryParse(Address.Text, out address))
216 { 235 {
217 Address.BackColor = Color.LightPink; 236 Address.BackColor = Color.LightPink;
218 return false; 237 return false;
219 } 238 }
220   239  
221 if (!uint.TryParse(Port.Text, out var uPort)) 240 if (!uint.TryParse(Port.Text, out var uPort))
222 { 241 {
223 Port.BackColor = Color.LightPink; 242 Port.BackColor = Color.LightPink;
224 return false; 243 return false;
225 } 244 }
226   245  
227 port = (int) uPort; 246 port = (int) uPort;
228   247  
229 if (string.IsNullOrEmpty(Nick.Text)) 248 if (string.IsNullOrEmpty(Nick.Text))
230 { 249 {
231 Nick.BackColor = Color.LightPink; 250 Nick.BackColor = Color.LightPink;
232 return false; 251 return false;
233 } 252 }
234   253  
235 nick = Nick.Text; 254 nick = Nick.Text;
-   255  
-   256 if (string.IsNullOrEmpty(Password.Text))
-   257 {
-   258 Password.BackColor = Color.LightPink;
-   259 return false;
-   260 }
-   261  
-   262 password = AES.LinearFeedbackShiftPassword(Password.Text);
236   263  
237 Address.BackColor = Color.Empty; 264 Address.BackColor = Color.Empty;
238 Port.BackColor = Color.Empty; 265 Port.BackColor = Color.Empty;
239 Nick.BackColor = Color.Empty; 266 Nick.BackColor = Color.Empty;
-   267 Password.BackColor = Color.Empty;
240   268  
241 return true; 269 return true;
242 } 270 }
243   271  
244 private async void ConnectButtonClickAsync(object sender, EventArgs e) 272 private async void ConnectButtonClickAsync(object sender, EventArgs e)
245 { 273 {
246 if (MQTTCommunication.Running) 274 if (MQTTCommunication.Running)
247 { 275 {
248 await MQTTCommunication.Stop().ConfigureAwait(false); 276 await MQTTCommunication.Stop().ConfigureAwait(false);
249 ConnectButton.Text = Strings.Connect; 277 ConnectButton.Text = Strings.Connect;
250 ConnectButton.BackColor = Color.Empty; 278 ConnectButton.BackColor = Color.Empty;
251   279  
252 Address.Enabled = true; 280 Address.Enabled = true;
253 Port.Enabled = true; 281 Port.Enabled = true;
254 Nick.Enabled = true; 282 Nick.Enabled = true;
255 HostButton.Enabled = true; 283 HostButton.Enabled = true;
256 return; 284 return;
257 } 285 }
258   286  
259 if (!ValidateAddressPort(out var ipAddress, out var port, out var nick)) 287 if (!ValidateAddressPort(out var ipAddress, out var port, out var nick, out var password))
260 return; 288 return;
-   289  
261   290 await MQTTCommunication.Start(MQTTCommunicationType.Client, ipAddress, port, nick, password)
262 await MQTTCommunication.Start(MQTTCommunicationType.Client, ipAddress, port, nick).ConfigureAwait(false); 291 .ConfigureAwait(false);
263   292  
264 toolStripStatusLabel.Text = Strings.Client_started; 293 toolStripStatusLabel.Text = Strings.Client_started;
265 ConnectButton.Text = Strings.Disconnect; 294 ConnectButton.Text = Strings.Disconnect;
266 ConnectButton.BackColor = Color.Aquamarine; 295 ConnectButton.BackColor = Color.Aquamarine;
267   296  
268 HostButton.Enabled = false; 297 HostButton.Enabled = false;
269 Address.Enabled = false; 298 Address.Enabled = false;
270 Port.Enabled = false; 299 Port.Enabled = false;
271 Nick.Enabled = false; 300 Nick.Enabled = false;
272 } 301 }
273   302  
274 private async void LobbySayTextBoxKeyDown(object sender, KeyEventArgs e) 303 private async void LobbySayTextBoxKeyDown(object sender, KeyEventArgs e)
275 { 304 {
276 if (e.KeyCode != Keys.Enter) 305 if (e.KeyCode != Keys.Enter)
277 return; 306 return;
278   307  
279 await LobbyMessageSynchronizer.Broadcast(LobbySayTextBox.Text).ConfigureAwait(false); 308 await LobbyMessageSynchronizer.Broadcast(LobbySayTextBox.Text).ConfigureAwait(false);
280   309  
281 LobbySayTextBox.Text = string.Empty; 310 LobbySayTextBox.Text = string.Empty;
282 } 311 }
283   312  
284 private void HelmAddButtonClick(object sender, EventArgs e) 313 private void HelmAddButtonClick(object sender, EventArgs e)
285 { 314 {
286 if (string.IsNullOrEmpty(HelmNameTextBox.Text)) 315 if (string.IsNullOrEmpty(HelmNameTextBox.Text))
287 { 316 {
288 HelmNameTextBox.BackColor = Color.LightPink; 317 HelmNameTextBox.BackColor = Color.LightPink;
289 return; 318 return;
290 } 319 }
291   320  
292 HelmAddButton.Enabled = false; 321 ShowOverlayPanel();
293   322  
294 MouseKeyCombo = new List<string>(); 323 MouseKeyCombo = new List<string>();
295   324  
296 MouseKeyApplicationHook = Hook.AppEvents(); 325 MouseKeyApplicationHook = Hook.AppEvents();
297 MouseKeyApplicationHook.MouseDown += MouseKeyHookOnMouseDown; 326 MouseKeyApplicationHook.MouseDown += MouseKeyHookOnMouseDown;
298 MouseKeyApplicationHook.KeyUp += MouseKeyHookOnKeyUp; 327 MouseKeyApplicationHook.KeyUp += MouseKeyHookOnKeyUp;
299 MouseKeyApplicationHook.KeyDown += MouseKeyHookOnKeyDown; 328 MouseKeyApplicationHook.KeyDown += MouseKeyHookOnKeyDown;
300 MouseKeyApplicationHook.MouseUp += MouseKeyHookOnMouseUp; 329 MouseKeyApplicationHook.MouseUp += MouseKeyHookOnMouseUp;
301 } 330 }
-   331  
-   332 private void ShowOverlayPanel()
-   333 {
-   334 OverlayPanel.BringToFront();
-   335 OverlayPanel.Visible = true;
-   336 OverlayPanel.Invalidate();
-   337 }
302   338  
303 private void MouseKeyHookOnKeyUp(object sender, KeyEventArgs e) 339 private void MouseKeyHookOnKeyUp(object sender, KeyEventArgs e)
304 { 340 {
305 MouseKeyBindings.Bindings.Add(new MouseKeyBinding(HelmNameTextBox.Text, MouseKeyCombo)); 341 MouseKeyBindings.Bindings.Add(new MouseKeyBinding(HelmNameTextBox.Text, MouseKeyCombo));
306   342  
307 HelmListBoxBindingSource.ResetBindings(false); 343 HelmListBoxBindingSource.ResetBindings(false);
308   344  
309 MouseKeyApplicationHook.KeyDown -= MouseKeyHookOnKeyDown; 345 MouseKeyApplicationHook.KeyDown -= MouseKeyHookOnKeyDown;
310 MouseKeyApplicationHook.KeyUp -= MouseKeyHookOnKeyUp; 346 MouseKeyApplicationHook.KeyUp -= MouseKeyHookOnKeyUp;
311 MouseKeyApplicationHook.KeyDown -= MouseKeyHookOnKeyDown; 347 MouseKeyApplicationHook.KeyDown -= MouseKeyHookOnKeyDown;
312 MouseKeyApplicationHook.KeyUp -= MouseKeyHookOnKeyUp; 348 MouseKeyApplicationHook.KeyUp -= MouseKeyHookOnKeyUp;
313   349  
314 MouseKeyApplicationHook.Dispose(); 350 MouseKeyApplicationHook.Dispose();
315   351  
316 HelmNameTextBox.Text = string.Empty; 352 HelmNameTextBox.Text = string.Empty;
-   353 HideOverlayPanel();
-   354 }
-   355  
-   356 private void HideOverlayPanel()
-   357 {
-   358 OverlayPanel.SendToBack();
317 HelmAddButton.Enabled = true; 359 OverlayPanel.Visible = false;
-   360 OverlayPanel.Invalidate();
318 } 361 }
319   362  
320 private void MouseKeyHookOnMouseUp(object sender, MouseEventArgs e) 363 private void MouseKeyHookOnMouseUp(object sender, MouseEventArgs e)
321 { 364 {
322 MouseKeyBindings.Bindings.Add(new MouseKeyBinding(HelmNameTextBox.Text, MouseKeyCombo)); 365 MouseKeyBindings.Bindings.Add(new MouseKeyBinding(HelmNameTextBox.Text, MouseKeyCombo));
323   366  
324 HelmListBoxBindingSource.ResetBindings(false); 367 HelmListBoxBindingSource.ResetBindings(false);
325   368  
326 MouseKeyApplicationHook.KeyDown -= MouseKeyHookOnKeyDown; 369 MouseKeyApplicationHook.KeyDown -= MouseKeyHookOnKeyDown;
327 MouseKeyApplicationHook.KeyUp -= MouseKeyHookOnKeyUp; 370 MouseKeyApplicationHook.KeyUp -= MouseKeyHookOnKeyUp;
328 MouseKeyApplicationHook.KeyDown -= MouseKeyHookOnKeyDown; 371 MouseKeyApplicationHook.KeyDown -= MouseKeyHookOnKeyDown;
329 MouseKeyApplicationHook.KeyUp -= MouseKeyHookOnKeyUp; 372 MouseKeyApplicationHook.KeyUp -= MouseKeyHookOnKeyUp;
330   373  
331 MouseKeyApplicationHook.Dispose(); 374 MouseKeyApplicationHook.Dispose();
332   375  
333 HelmNameTextBox.Text = string.Empty; 376 HelmNameTextBox.Text = string.Empty;
334 HelmAddButton.Enabled = true; 377 HideOverlayPanel();
335 } 378 }
336   379  
337   380  
338 private void MouseKeyHookOnMouseDown(object sender, MouseEventArgs e) 381 private void MouseKeyHookOnMouseDown(object sender, MouseEventArgs e)
339 { 382 {
340 MouseKeyCombo.Add(e.Button.ToDisplayName()); 383 MouseKeyCombo.Add(e.Button.ToDisplayName());
341 } 384 }
342   385  
343 private void MouseKeyHookOnKeyDown(object sender, KeyEventArgs e) 386 private void MouseKeyHookOnKeyDown(object sender, KeyEventArgs e)
344 { 387 {
345 e.SuppressKeyPress = true; 388 e.SuppressKeyPress = true;
346   389  
347 MouseKeyCombo.Add(e.KeyCode.ToDisplayName()); 390 MouseKeyCombo.Add(e.KeyCode.ToDisplayName());
348 } 391 }
349   392  
350 private void HelmNameTextBoxClick(object sender, EventArgs e) 393 private void HelmNameTextBoxClick(object sender, EventArgs e)
351 { 394 {
352 HelmNameTextBox.BackColor = Color.Empty; 395 HelmNameTextBox.BackColor = Color.Empty;
353 } 396 }
354   397  
355 private void HelmRemoveButtonClick(object sender, EventArgs e) 398 private void HelmRemoveButtonClick(object sender, EventArgs e)
356 { 399 {
357 var helmBinding = (MouseKeyBinding) HelmBindingsListBox.SelectedItem; 400 var helmBinding = (MouseKeyBinding) HelmBindingsListBox.SelectedItem;
358 if (helmBinding == null) 401 if (helmBinding == null)
359 return; 402 return;
360   403  
361 MouseKeyBindings.Bindings.Remove(helmBinding); 404 MouseKeyBindings.Bindings.Remove(helmBinding);
362 HelmListBoxBindingSource.ResetBindings(false); 405 HelmListBoxBindingSource.ResetBindings(false);
363 } 406 }
364   407  
365 private async void LobbySayButtonClick(object sender, EventArgs e) 408 private async void LobbySayButtonClick(object sender, EventArgs e)
366 { 409 {
367 await LobbyMessageSynchronizer.Broadcast(LobbySayTextBox.Text).ConfigureAwait(false); 410 await LobbyMessageSynchronizer.Broadcast(LobbySayTextBox.Text).ConfigureAwait(false);
368   411  
369 LobbySayTextBox.Text = string.Empty; 412 LobbySayTextBox.Text = string.Empty;
370 } 413 }
371   414  
372 private void WingBindingsComboBoxSelectionChangeCompleted(object sender, EventArgs e) 415 private void WingBindingsComboBoxSelectionChangeCompleted(object sender, EventArgs e)
373 { 416 {
374 UpdateWingListBoxItems(); 417 UpdateWingListBoxItems();
375 } 418 }
-   419  
-   420 private void WingBindingsBindButtonClicked(object sender, EventArgs e)
-   421 {
-   422 }
376 } 423 }
377 } 424 }
378   425