WingMan – Diff between revs 10 and 14
?pathlinks?
Rev 10 | Rev 14 | |||
---|---|---|---|---|
Line 1... | Line 1... | |||
1 | using System; |
1 | using System; |
|
2 | using System.Collections.Generic; |
2 | using System.Collections.Generic; |
|
- | 3 | using System.Collections.ObjectModel; |
||
3 | using System.Drawing; |
4 | using System.Drawing; |
|
4 | using System.IO; |
5 | using System.IO; |
|
5 | using System.Linq; |
6 | using System.Linq; |
|
6 | using System.Net; |
7 | using System.Net; |
|
7 | using System.Threading; |
8 | using System.Threading; |
|
8 | using System.Threading.Tasks; |
9 | using System.Threading.Tasks; |
|
9 | using System.Windows.Forms; |
10 | using System.Windows.Forms; |
|
10 | using Gma.System.MouseKeyHook; |
11 | using Gma.System.MouseKeyHook; |
|
11 | using MQTTnet.Extensions.ManagedClient; |
12 | using MQTTnet.Extensions.ManagedClient; |
|
12 | using MQTTnet.Server; |
13 | using MQTTnet.Server; |
|
- | 14 | using WingMan.Bindings; |
||
13 | using WingMan.Communication; |
15 | using WingMan.Communication; |
|
14 | using WingMan.Lobby; |
16 | using WingMan.Lobby; |
|
15 | using WingMan.MouseKey; |
- | ||
16 | using WingMan.Properties; |
17 | using WingMan.Properties; |
|
17 | using WingMan.Utilities; |
18 | using WingMan.Utilities; |
|
Line 18... | Line 19... | |||
18 | |
19 | |
|
19 | namespace WingMan |
20 | namespace WingMan |
|
Line 37... | Line 38... | |||
37 | MqttCommunication.OnServerStarted += OnMqttServerStarted; |
38 | MqttCommunication.OnServerStarted += OnMqttServerStarted; |
|
38 | MqttCommunication.OnServerClientConnected += OnMqttServerClientConnected; |
39 | MqttCommunication.OnServerClientConnected += OnMqttServerClientConnected; |
|
39 | MqttCommunication.OnServerClientDisconnected += OnMqttServerClientDisconnected; |
40 | MqttCommunication.OnServerClientDisconnected += OnMqttServerClientDisconnected; |
|
Line 40... | Line 41... | |||
40 | |
41 | |
|
41 | LocalKeyBindings = new LocalKeyBindings(new List<KeyBinding>()); |
42 | LocalKeyBindings = new LocalKeyBindings(new List<KeyBinding>()); |
|
Line 42... | Line 43... | |||
42 | RemoteKeyBindings = new RemoteKeyBindings(new List<RemoteKeyBinding>()); |
43 | RemoteKeyBindings = new RemoteKeyBindings(new ObservableCollection<RemoteKeyBinding>()); |
|
43 | |
44 | |
|
44 | LocalListBoxBindingSource = new BindingSource |
45 | LocalListBoxBindingSource = new BindingSource |
|
45 | { |
46 | { |
|
Line 230... | Line 231... | |||
230 | { |
231 | { |
|
231 | var exchangeBindings = (List<KeyBinding>) RemoteBindingsComboBox.SelectedValue; |
232 | var exchangeBindings = (List<KeyBinding>) RemoteBindingsComboBox.SelectedValue; |
|
232 | if (exchangeBindings == null) |
233 | if (exchangeBindings == null) |
|
233 | return; |
234 | return; |
|
Line 234... | Line 235... | |||
234 | |
235 | |
|
235 | var replaceMouseBindings = new List<RemoteKeyBinding>(); |
236 | var replaceMouseBindings = new ObservableCollection<RemoteKeyBinding>(); |
|
236 | foreach (var remoteBinding in RemoteKeyBindings.Bindings) |
237 | foreach (var remoteBinding in RemoteKeyBindings.Bindings) |
|
237 | { |
238 | { |
|
238 | if (!exchangeBindings.Any(binding => |
239 | if (!exchangeBindings.Any(binding => |
|
239 | string.Equals(binding.Name, remoteBinding.Name, StringComparison.Ordinal))) |
240 | string.Equals(binding.Name, remoteBinding.Name, StringComparison.Ordinal))) |
|
Line 446... | Line 447... | |||
446 | OverlayPanel.BringToFront(); |
447 | OverlayPanel.BringToFront(); |
|
447 | OverlayPanel.Visible = true; |
448 | OverlayPanel.Visible = true; |
|
448 | OverlayPanel.Invalidate(); |
449 | OverlayPanel.Invalidate(); |
|
449 | } |
450 | } |
|
Line 450... | Line 451... | |||
450 | |
451 | |
|
451 | private void LocalMouseKeyHookOnKeyUp(object sender, KeyEventArgs e) |
452 | private async void LocalMouseKeyHookOnKeyUp(object sender, KeyEventArgs e) |
|
452 | { |
453 | { |
|
Line 453... | Line 454... | |||
453 | LocalKeyBindings.Bindings.Add(new KeyBinding(LocalNameTextBox.Text, MouseKeyCombo)); |
454 | LocalKeyBindings.Bindings.Add(new KeyBinding(LocalNameTextBox.Text, MouseKeyCombo)); |
|
Line 460... | Line 461... | |||
460 | MouseKeyApplicationHook.Dispose(); |
461 | MouseKeyApplicationHook.Dispose(); |
|
Line 461... | Line 462... | |||
461 | |
462 | |
|
462 | LocalNameTextBox.Text = string.Empty; |
463 | LocalNameTextBox.Text = string.Empty; |
|
Line 463... | Line 464... | |||
463 | HideOverlayPanel(); |
464 | HideOverlayPanel(); |
|
464 | |
465 | |
|
Line 465... | Line 466... | |||
465 | //await SaveLocalMouseKeyBindings(); |
466 | await SaveLocalMouseKeyBindings(); |
|
466 | } |
467 | } |
|
467 | |
468 | |
|
Line 484... | Line 485... | |||
484 | private void LocalNameTextBoxClick(object sender, EventArgs e) |
485 | private void LocalNameTextBoxClick(object sender, EventArgs e) |
|
485 | { |
486 | { |
|
486 | LocalNameTextBox.BackColor = Color.Empty; |
487 | LocalNameTextBox.BackColor = Color.Empty; |
|
487 | } |
488 | } |
|
Line 488... | Line 489... | |||
488 | |
489 | |
|
489 | private void LocalBindingsRemoveButtonClick(object sender, EventArgs e) |
490 | private async void LocalBindingsRemoveButtonClick(object sender, EventArgs e) |
|
490 | { |
491 | { |
|
491 | var helmBinding = (KeyBinding) LocalBindingsListBox.SelectedItem; |
492 | var helmBinding = (KeyBinding) LocalBindingsListBox.SelectedItem; |
|
492 | if (helmBinding == null) |
493 | if (helmBinding == null) |
|
Line 493... | Line 494... | |||
493 | return; |
494 | return; |
|
494 | |
495 | |
|
Line 495... | Line 496... | |||
495 | LocalKeyBindings.Bindings.Remove(helmBinding); |
496 | LocalKeyBindings.Bindings.Remove(helmBinding); |
|
496 | LocalListBoxBindingSource.ResetBindings(false); |
497 | LocalListBoxBindingSource.ResetBindings(false); |
|
Line 497... | Line 498... | |||
497 | |
498 | |
|
498 | // await SaveLocalMouseKeyBindings(); |
499 | await SaveLocalMouseKeyBindings(); |
|
499 | } |
500 | } |
|
Line 508... | Line 509... | |||
508 | private void RemoteBindingsComboBoxSelectionChangeCompleted(object sender, EventArgs e) |
509 | private void RemoteBindingsComboBoxSelectionChangeCompleted(object sender, EventArgs e) |
|
509 | { |
510 | { |
|
510 | UpdateRemoteItems(); |
511 | UpdateRemoteItems(); |
|
511 | } |
512 | } |
|
Line 512... | Line 513... | |||
512 | |
513 | |
|
513 | private void WingManFormOnLoad(object sender, EventArgs e) |
514 | private async void WingManFormOnLoad(object sender, EventArgs e) |
|
514 | { |
515 | { |
|
Line 515... | Line 516... | |||
515 | // await LoadLocalMouseKeyBindings(); |
516 | await LoadLocalMouseKeyBindings(); |
|
516 | |
517 | |
|
Line 517... | Line 518... | |||
517 | // await LoadRemoteMouseKeyBindings(); |
518 | await LoadRemoteMouseKeyBindings(); |
|
518 | } |
519 | } |
|
519 | |
520 | |
|
Line 564... | Line 565... | |||
564 | KeyConversion.KeysToString.TryGetValue((byte) e.KeyCode, out var key); |
565 | KeyConversion.KeysToString.TryGetValue((byte) e.KeyCode, out var key); |
|
Line 565... | Line 566... | |||
565 | |
566 | |
|
566 | MouseKeyCombo.Add(key); |
567 | MouseKeyCombo.Add(key); |
|
Line 567... | Line 568... | |||
567 | } |
568 | } |
|
568 | |
569 | |
|
569 | private void RemoteMouseKeyHookOnKeyUp(object sender, KeyEventArgs e) |
570 | private async void RemoteMouseKeyHookOnKeyUp(object sender, KeyEventArgs e) |
|
570 | { |
571 | { |
|
Line 571... | Line 572... | |||
571 | RemoteKeyBindings.Bindings.Add(new RemoteKeyBinding(RemoteBindingsComboBox.Text, |
572 | RemoteKeyBindings.Bindings.Add(new RemoteKeyBinding(RemoteBindingsComboBox.Text, |
|
Line 577... | Line 578... | |||
577 | MouseKeyApplicationHook.Dispose(); |
578 | MouseKeyApplicationHook.Dispose(); |
|
Line 578... | Line 579... | |||
578 | |
579 | |
|
579 | RemoteBindingsBindToBox.Text = string.Join(" + ", MouseKeyCombo); |
580 | RemoteBindingsBindToBox.Text = string.Join(" + ", MouseKeyCombo); |
|
Line 580... | Line 581... | |||
580 | HideOverlayPanel(); |
581 | HideOverlayPanel(); |
|
581 | |
582 | |
|
Line 582... | Line 583... | |||
582 | // await SaveRemoteMouseKeyBindings(); |
583 | await SaveRemoteMouseKeyBindings(); |
|
583 | } |
584 | } |
|
584 | |
585 | |
|
Line 585... | Line 586... | |||
585 | private void RemoteBindingsListBoxSelectedValueChanged(object sender, EventArgs e) |
586 | private void RemoteBindingsListBoxSelectedValueChanged(object sender, EventArgs e) |
|
586 | { |
587 | { |
|
587 | RemoteBindingsBindToBox.Text = ""; |
588 | RemoteBindingsBindToBox.Text = ""; |
|
Line -... | Line 589... | |||
- | 589 | |
||
- | 590 | var name = (string) RemoteBindingsListBox.SelectedItem; |
||
- | 591 | if (string.IsNullOrEmpty(name)) |
||
- | 592 | return; |
||
588 | |
593 | |
|
589 | var name = (string) RemoteBindingsListBox.SelectedItem; |
594 | var nick = RemoteBindingsComboBox.Text; |
|
590 | if (string.IsNullOrEmpty(name)) |
595 | if (string.IsNullOrEmpty(nick)) |
|
591 | return; |
596 | return; |
|
Line 592... | Line 597... | |||
592 | |
597 | |
|
593 | foreach (var binding in RemoteKeyBindings.Bindings) |
598 | foreach (var binding in RemoteKeyBindings.Bindings) |
|
594 | { |
599 | { |