/trunk/WingMan/WingManForm.Designer.cs |
@@ -29,7 +29,7 @@ |
this.LobbySayTextBox = new System.Windows.Forms.TextBox(); |
this.LobbyTextBox = new System.Windows.Forms.TextBox(); |
this.groupBox3 = new System.Windows.Forms.GroupBox(); |
this.LocalBindingsListBox = new System.Windows.Forms.ListBox(); |
this.LocalBindingsCheckedListBox = new System.Windows.Forms.CheckedListBox(); |
this.button3 = new System.Windows.Forms.Button(); |
this.HelmAddButton = new System.Windows.Forms.Button(); |
this.label2 = new System.Windows.Forms.Label(); |
@@ -190,7 +190,7 @@ |
// |
// groupBox3 |
// |
this.groupBox3.Controls.Add(this.LocalBindingsListBox); |
this.groupBox3.Controls.Add(this.LocalBindingsCheckedListBox); |
this.groupBox3.Controls.Add(this.button3); |
this.groupBox3.Controls.Add(this.HelmAddButton); |
this.groupBox3.Controls.Add(this.label2); |
@@ -202,14 +202,15 @@ |
this.groupBox3.TabStop = false; |
this.groupBox3.Text = "Local (You)"; |
// |
// LocalBindingsListBox |
// LocalBindingsCheckedListBox |
// |
this.LocalBindingsListBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; |
this.LocalBindingsListBox.FormattingEnabled = true; |
this.LocalBindingsListBox.Location = new System.Drawing.Point(8, 16); |
this.LocalBindingsListBox.Name = "LocalBindingsListBox"; |
this.LocalBindingsListBox.Size = new System.Drawing.Size(232, 223); |
this.LocalBindingsListBox.TabIndex = 7; |
this.LocalBindingsCheckedListBox.CheckOnClick = true; |
this.LocalBindingsCheckedListBox.FormattingEnabled = true; |
this.LocalBindingsCheckedListBox.Location = new System.Drawing.Point(8, 16); |
this.LocalBindingsCheckedListBox.Name = "LocalBindingsCheckedListBox"; |
this.LocalBindingsCheckedListBox.Size = new System.Drawing.Size(240, 229); |
this.LocalBindingsCheckedListBox.TabIndex = 8; |
this.LocalBindingsCheckedListBox.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.LocalBindingsCheckedListBoxItemCheck); |
// |
// button3 |
// |
@@ -565,12 +566,12 @@ |
private System.Windows.Forms.TabPage tabPage3; |
private System.Windows.Forms.PictureBox pictureBox1; |
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; |
private System.Windows.Forms.ListBox LocalBindingsListBox; |
private System.Windows.Forms.Panel OverlayPanel; |
private System.Windows.Forms.Label OverlayPanelLabel; |
private System.Windows.Forms.Label label6; |
private System.Windows.Forms.TextBox Password; |
private System.Windows.Forms.NotifyIcon notifyIcon1; |
private System.Windows.Forms.CheckedListBox LocalBindingsCheckedListBox; |
} |
} |
|
/trunk/WingMan/WingManForm.cs |
@@ -1,6 +1,7 @@ |
using System; |
using System.Collections.Generic; |
using System.Collections.ObjectModel; |
using System.ComponentModel; |
using System.Drawing; |
using System.IO; |
using System.Linq; |
@@ -52,13 +53,14 @@ |
LocalKeyBindings = new LocalKeyBindings(new List<KeyBinding>()); |
RemoteKeyBindings = new RemoteKeyBindings(new ObservableCollection<RemoteKeyBinding>()); |
|
LocalListBoxBindingSource = new BindingSource |
LocalCheckedListBoxBindingSource = new BindingSource |
{ |
DataSource = LocalKeyBindings.Bindings |
}; |
LocalBindingsListBox.DisplayMember = "DisplayName"; |
LocalBindingsListBox.ValueMember = "Keys"; |
LocalBindingsListBox.DataSource = LocalListBoxBindingSource; |
LocalCheckedListBoxBindingSource.ListChanged += LocalCheckedListBoxBindingSourceOnListChanged; |
LocalBindingsCheckedListBox.DisplayMember = "DisplayName"; |
LocalBindingsCheckedListBox.ValueMember = "Keys"; |
LocalBindingsCheckedListBox.DataSource = LocalCheckedListBoxBindingSource; |
|
KeyBindingsExchange = new KeyBindingsExchange |
{ |
@@ -107,7 +109,7 @@ |
|
private RemoteKeyBindings RemoteKeyBindings { get; } |
|
private BindingSource LocalListBoxBindingSource { get; } |
private BindingSource LocalCheckedListBoxBindingSource { get; } |
|
private BindingSource RemoteBindingsComboBoxSource { get; } |
|
@@ -123,6 +125,25 @@ |
|
public KeySimulator KeySimulator { get; set; } |
|
private void LocalCheckedListBoxBindingSourceOnListChanged(object sender, ListChangedEventArgs e) |
{ |
// Check items |
LocalBindingsCheckedListBox.ItemCheck -= LocalBindingsCheckedListBoxItemCheck; |
|
for (var i = 0; i < LocalKeyBindings.Bindings.Count; ++i) |
switch (LocalKeyBindings.Bindings[i].Enabled) |
{ |
case true: |
LocalBindingsCheckedListBox.SetItemCheckState(i, CheckState.Checked); |
break; |
default: |
LocalBindingsCheckedListBox.SetItemCheckState(i, CheckState.Unchecked); |
break; |
} |
|
LocalBindingsCheckedListBox.ItemCheck += LocalBindingsCheckedListBoxItemCheck; |
} |
|
private void AutoCompletionOnLoadFailed(object sender, AutoCompletionFailedEventArgs args) |
{ |
ActivityTextBox.AppendText( |
@@ -482,12 +503,12 @@ |
string.Equals(binding.Name, LocalNameTextBox.Text, StringComparison.Ordinal))) |
{ |
LocalNameTextBox.BackColor = Color.LightPink; |
LocalBindingsListBox.BackColor = Color.LightPink; |
LocalBindingsCheckedListBox.BackColor = Color.LightPink; |
return; |
} |
|
LocalNameTextBox.BackColor = Color.Empty; |
LocalBindingsListBox.BackColor = Color.Empty; |
LocalBindingsCheckedListBox.BackColor = Color.Empty; |
|
ShowOverlayPanel(); |
|
@@ -509,7 +530,7 @@ |
{ |
LocalKeyBindings.Bindings.Add(new KeyBinding(LocalNameTextBox.Text, MouseKeyCombo)); |
|
LocalListBoxBindingSource.ResetBindings(false); |
LocalCheckedListBoxBindingSource.ResetBindings(false); |
|
MouseKeyApplicationHook.KeyDown -= LocalMouseKeyHookOnKeyDown; |
MouseKeyApplicationHook.KeyUp -= LocalMouseKeyHookOnKeyUp; |
@@ -545,12 +566,12 @@ |
|
private async void LocalBindingsRemoveButtonClick(object sender, EventArgs e) |
{ |
var helmBinding = (KeyBinding) LocalBindingsListBox.SelectedItem; |
var helmBinding = (KeyBinding) LocalBindingsCheckedListBox.SelectedItem; |
if (helmBinding == null) |
return; |
|
LocalKeyBindings.Bindings.Remove(helmBinding); |
LocalListBoxBindingSource.ResetBindings(false); |
LocalCheckedListBoxBindingSource.ResetBindings(false); |
|
await SaveLocalMouseKeyBindings(); |
} |
@@ -678,6 +699,25 @@ |
notifyIcon1.Visible = false; |
} |
|
private async void LocalBindingsCheckedListBoxItemCheck(object sender, ItemCheckEventArgs e) |
{ |
var helmBinding = (KeyBinding) LocalBindingsCheckedListBox.Items[e.Index]; |
if (helmBinding == null) |
return; |
|
switch (e.NewValue) |
{ |
case CheckState.Checked: |
helmBinding.Enabled = true; |
break; |
case CheckState.Unchecked: |
helmBinding.Enabled = false; |
break; |
} |
|
await SaveLocalMouseKeyBindings(); |
} |
|
#region Saving and loading |
|
private async Task SaveLocalMouseKeyBindings() |
@@ -721,7 +761,8 @@ |
foreach (var binding in loadedBindings.Bindings) |
LocalKeyBindings.Bindings.Add(binding); |
|
LocalListBoxBindingSource.ResetBindings(false); |
|
LocalCheckedListBoxBindingSource.ResetBindings(false); |
} |
} |
} |