/trunk/WingMan/WingManForm.cs |
@@ -1,5 +1,6 @@ |
using System; |
using System.Collections.Generic; |
using System.Collections.ObjectModel; |
using System.Drawing; |
using System.IO; |
using System.Linq; |
@@ -10,9 +11,9 @@ |
using Gma.System.MouseKeyHook; |
using MQTTnet.Extensions.ManagedClient; |
using MQTTnet.Server; |
using WingMan.Bindings; |
using WingMan.Communication; |
using WingMan.Lobby; |
using WingMan.MouseKey; |
using WingMan.Properties; |
using WingMan.Utilities; |
|
@@ -39,7 +40,7 @@ |
MqttCommunication.OnServerClientDisconnected += OnMqttServerClientDisconnected; |
|
LocalKeyBindings = new LocalKeyBindings(new List<KeyBinding>()); |
RemoteKeyBindings = new RemoteKeyBindings(new List<RemoteKeyBinding>()); |
RemoteKeyBindings = new RemoteKeyBindings(new ObservableCollection<RemoteKeyBinding>()); |
|
LocalListBoxBindingSource = new BindingSource |
{ |
@@ -232,7 +233,7 @@ |
if (exchangeBindings == null) |
return; |
|
var replaceMouseBindings = new List<RemoteKeyBinding>(); |
var replaceMouseBindings = new ObservableCollection<RemoteKeyBinding>(); |
foreach (var remoteBinding in RemoteKeyBindings.Bindings) |
{ |
if (!exchangeBindings.Any(binding => |
@@ -448,7 +449,7 @@ |
OverlayPanel.Invalidate(); |
} |
|
private void LocalMouseKeyHookOnKeyUp(object sender, KeyEventArgs e) |
private async void LocalMouseKeyHookOnKeyUp(object sender, KeyEventArgs e) |
{ |
LocalKeyBindings.Bindings.Add(new KeyBinding(LocalNameTextBox.Text, MouseKeyCombo)); |
|
@@ -462,7 +463,7 @@ |
LocalNameTextBox.Text = string.Empty; |
HideOverlayPanel(); |
|
//await SaveLocalMouseKeyBindings(); |
await SaveLocalMouseKeyBindings(); |
} |
|
private void HideOverlayPanel() |
@@ -486,7 +487,7 @@ |
LocalNameTextBox.BackColor = Color.Empty; |
} |
|
private void LocalBindingsRemoveButtonClick(object sender, EventArgs e) |
private async void LocalBindingsRemoveButtonClick(object sender, EventArgs e) |
{ |
var helmBinding = (KeyBinding) LocalBindingsListBox.SelectedItem; |
if (helmBinding == null) |
@@ -495,7 +496,7 @@ |
LocalKeyBindings.Bindings.Remove(helmBinding); |
LocalListBoxBindingSource.ResetBindings(false); |
|
// await SaveLocalMouseKeyBindings(); |
await SaveLocalMouseKeyBindings(); |
} |
|
private async void LobbySayButtonClick(object sender, EventArgs e) |
@@ -510,11 +511,11 @@ |
UpdateRemoteItems(); |
} |
|
private void WingManFormOnLoad(object sender, EventArgs e) |
private async void WingManFormOnLoad(object sender, EventArgs e) |
{ |
// await LoadLocalMouseKeyBindings(); |
await LoadLocalMouseKeyBindings(); |
|
// await LoadRemoteMouseKeyBindings(); |
await LoadRemoteMouseKeyBindings(); |
} |
|
private void RemoteBindingsBindButtonClicked(object sender, EventArgs e) |
@@ -566,7 +567,7 @@ |
MouseKeyCombo.Add(key); |
} |
|
private void RemoteMouseKeyHookOnKeyUp(object sender, KeyEventArgs e) |
private async void RemoteMouseKeyHookOnKeyUp(object sender, KeyEventArgs e) |
{ |
RemoteKeyBindings.Bindings.Add(new RemoteKeyBinding(RemoteBindingsComboBox.Text, |
(string) RemoteBindingsListBox.SelectedItem, MouseKeyCombo)); |
@@ -579,7 +580,7 @@ |
RemoteBindingsBindToBox.Text = string.Join(" + ", MouseKeyCombo); |
HideOverlayPanel(); |
|
// await SaveRemoteMouseKeyBindings(); |
await SaveRemoteMouseKeyBindings(); |
} |
|
private void RemoteBindingsListBoxSelectedValueChanged(object sender, EventArgs e) |
@@ -590,9 +591,13 @@ |
if (string.IsNullOrEmpty(name)) |
return; |
|
var nick = RemoteBindingsComboBox.Text; |
if (string.IsNullOrEmpty(nick)) |
return; |
|
foreach (var binding in RemoteKeyBindings.Bindings) |
{ |
if (!string.Equals(binding.Name, name)) |
if (!string.Equals(binding.Nick, nick) || !string.Equals(binding.Name, name)) |
continue; |
|
RemoteBindingsBindToBox.Text = string.Join(" + ", binding.Keys); |