WingMan

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 3  →  ?path2? @ 4
/trunk/WingMan/HelmBinding.cs
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace WingMan
{
public class HelmBinding
{
public string DisplayName => $"{Name} ({string.Join(" + ", Keys.ToArray())})";
 
public string Name { get; set; } = string.Empty;
 
public List<string> Keys { get; set; } = new List<string>();
}
}
/trunk/WingMan/HelmBindings.cs
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace WingMan
{
public class HelmBindings
{
public List<HelmBinding> Bindings { get; set; }
}
}
/trunk/WingMan/Properties/DataSources/KeyComboBindings.datasource
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is automatically generated by Visual Studio .Net. It is
used to store generic object data source configuration information.
Renaming the file extension or editing the content of this file may
cause the file to be unrecognizable by the program.
-->
<GenericObjectDataSource DisplayName="KeyComboBindings" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<TypeInfo>WingMan.KeyComboBindings, WingMan, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo>
</GenericObjectDataSource>
/trunk/WingMan/WingMan.csproj
@@ -32,8 +32,8 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="MonoGameEasyInput, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MonoGame.EasyInput.1.0.0\lib\monogame.easyinput\MonoGameEasyInput.dll</HintPath>
<Reference Include="Gma.System.MouseKeyHook, Version=5.6.130.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MouseKeyHook.5.6.0\lib\net40\Gma.System.MouseKeyHook.dll</HintPath>
</Reference>
<Reference Include="MQTTnet, Version=2.8.4.0, Culture=neutral, PublicKeyToken=b69712f52770c0a7, processorArchitecture=MSIL">
<HintPath>..\packages\MQTTnet.2.8.4\lib\net452\MQTTnet.dll</HintPath>
@@ -64,6 +64,8 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Communication\MQTTClient.cs" />
<Compile Include="HelmBinding.cs" />
<Compile Include="HelmBindings.cs" />
<Compile Include="LobbyMessage.cs" />
<Compile Include="WingManForm.cs">
<SubType>Form</SubType>
@@ -96,6 +98,7 @@
<LastGenOutput>Strings.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="packages.config" />
<None Include="Properties\DataSources\KeyComboBindings.datasource" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
/trunk/WingMan/WingManForm.Designer.cs
@@ -40,11 +40,11 @@
this.LobbySayTextBox = new System.Windows.Forms.TextBox();
this.LobbyTextBox = new System.Windows.Forms.TextBox();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.HelmBindingsListBox = new System.Windows.Forms.ListBox();
this.button3 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.HelmAddButton = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.textBox2 = new System.Windows.Forms.TextBox();
this.listBox2 = new System.Windows.Forms.ListBox();
this.HelmNameTextBox = new System.Windows.Forms.TextBox();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.label5 = new System.Windows.Forms.Label();
this.Nick = new System.Windows.Forms.TextBox();
@@ -61,6 +61,9 @@
this.groupBox5 = new System.Windows.Forms.GroupBox();
this.ActivityTextBox = new System.Windows.Forms.TextBox();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.tabPage3 = new System.Windows.Forms.TabPage();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
@@ -70,6 +73,9 @@
this.tabPage1.SuspendLayout();
this.groupBox5.SuspendLayout();
this.tabPage2.SuspendLayout();
this.tabPage3.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.tableLayoutPanel1.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
@@ -80,9 +86,9 @@
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.textBox1);
this.groupBox1.Controls.Add(this.listBox1);
this.groupBox1.Location = new System.Drawing.Point(12, 10);
this.groupBox1.Location = new System.Drawing.Point(8, 10);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(256, 296);
this.groupBox1.Size = new System.Drawing.Size(248, 296);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Wing (Them)";
@@ -92,7 +98,7 @@
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Location = new System.Drawing.Point(8, 24);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(240, 21);
this.comboBox1.Size = new System.Drawing.Size(232, 21);
this.comboBox1.TabIndex = 5;
//
// button2
@@ -118,7 +124,7 @@
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(8, 232);
this.label1.Location = new System.Drawing.Point(8, 236);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(54, 13);
this.label1.TabIndex = 2;
@@ -127,10 +133,10 @@
// textBox1
//
this.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.textBox1.Location = new System.Drawing.Point(72, 228);
this.textBox1.Location = new System.Drawing.Point(72, 232);
this.textBox1.Name = "textBox1";
this.textBox1.ReadOnly = true;
this.textBox1.Size = new System.Drawing.Size(172, 20);
this.textBox1.Size = new System.Drawing.Size(168, 20);
this.textBox1.TabIndex = 1;
//
// listBox1
@@ -139,7 +145,7 @@
this.listBox1.FormattingEnabled = true;
this.listBox1.Location = new System.Drawing.Point(8, 56);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(240, 132);
this.listBox1.Size = new System.Drawing.Size(232, 158);
this.listBox1.TabIndex = 0;
//
// groupBox2
@@ -147,9 +153,10 @@
this.groupBox2.Controls.Add(this.button5);
this.groupBox2.Controls.Add(this.LobbySayTextBox);
this.groupBox2.Controls.Add(this.LobbyTextBox);
this.groupBox2.Location = new System.Drawing.Point(276, 10);
this.groupBox2.Dock = System.Windows.Forms.DockStyle.Fill;
this.groupBox2.Location = new System.Drawing.Point(0, 0);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(256, 296);
this.groupBox2.Size = new System.Drawing.Size(530, 311);
this.groupBox2.TabIndex = 1;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Lobby";
@@ -157,7 +164,7 @@
// button5
//
this.button5.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button5.Location = new System.Drawing.Point(208, 264);
this.button5.Location = new System.Drawing.Point(480, 280);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(40, 20);
this.button5.TabIndex = 2;
@@ -166,9 +173,9 @@
// LobbySayTextBox
//
this.LobbySayTextBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.LobbySayTextBox.Location = new System.Drawing.Point(8, 264);
this.LobbySayTextBox.Location = new System.Drawing.Point(8, 280);
this.LobbySayTextBox.Name = "LobbySayTextBox";
this.LobbySayTextBox.Size = new System.Drawing.Size(192, 20);
this.LobbySayTextBox.Size = new System.Drawing.Size(464, 20);
this.LobbySayTextBox.TabIndex = 1;
this.LobbySayTextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.LobbySayTextBoxKeyDown);
//
@@ -179,23 +186,32 @@
this.LobbyTextBox.Multiline = true;
this.LobbyTextBox.Name = "LobbyTextBox";
this.LobbyTextBox.ReadOnly = true;
this.LobbyTextBox.Size = new System.Drawing.Size(240, 240);
this.LobbyTextBox.Size = new System.Drawing.Size(512, 256);
this.LobbyTextBox.TabIndex = 0;
//
// groupBox3
//
this.groupBox3.Controls.Add(this.HelmBindingsListBox);
this.groupBox3.Controls.Add(this.button3);
this.groupBox3.Controls.Add(this.button4);
this.groupBox3.Controls.Add(this.HelmAddButton);
this.groupBox3.Controls.Add(this.label2);
this.groupBox3.Controls.Add(this.textBox2);
this.groupBox3.Controls.Add(this.listBox2);
this.groupBox3.Location = new System.Drawing.Point(540, 10);
this.groupBox3.Controls.Add(this.HelmNameTextBox);
this.groupBox3.Location = new System.Drawing.Point(272, 8);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(256, 296);
this.groupBox3.Size = new System.Drawing.Size(248, 296);
this.groupBox3.TabIndex = 2;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "Helm (You)";
//
// HelmBindingsListBox
//
this.HelmBindingsListBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.HelmBindingsListBox.FormattingEnabled = true;
this.HelmBindingsListBox.Location = new System.Drawing.Point(8, 16);
this.HelmBindingsListBox.Name = "HelmBindingsListBox";
this.HelmBindingsListBox.Size = new System.Drawing.Size(232, 197);
this.HelmBindingsListBox.TabIndex = 7;
//
// button3
//
this.button3.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
@@ -205,43 +221,37 @@
this.button3.TabIndex = 6;
this.button3.Text = "Remove";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.HelmRemoveButtonClick);
//
// button4
// HelmAddButton
//
this.button4.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button4.Location = new System.Drawing.Point(88, 264);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(75, 23);
this.button4.TabIndex = 5;
this.button4.Text = "Add";
this.button4.UseVisualStyleBackColor = true;
this.HelmAddButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.HelmAddButton.Location = new System.Drawing.Point(88, 264);
this.HelmAddButton.Name = "HelmAddButton";
this.HelmAddButton.Size = new System.Drawing.Size(75, 23);
this.HelmAddButton.TabIndex = 5;
this.HelmAddButton.Text = "Add";
this.HelmAddButton.UseVisualStyleBackColor = true;
this.HelmAddButton.Click += new System.EventHandler(this.HelmAddButtonClick);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(24, 232);
this.label2.Location = new System.Drawing.Point(24, 236);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(35, 13);
this.label2.TabIndex = 4;
this.label2.Text = "Name";
//
// textBox2
// HelmNameTextBox
//
this.textBox2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.textBox2.Location = new System.Drawing.Point(72, 228);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(172, 20);
this.textBox2.TabIndex = 3;
this.HelmNameTextBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.HelmNameTextBox.Location = new System.Drawing.Point(72, 232);
this.HelmNameTextBox.Name = "HelmNameTextBox";
this.HelmNameTextBox.Size = new System.Drawing.Size(172, 20);
this.HelmNameTextBox.TabIndex = 3;
this.HelmNameTextBox.Click += new System.EventHandler(this.HelmNameTextBoxClick);
//
// listBox2
//
this.listBox2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.listBox2.FormattingEnabled = true;
this.listBox2.Location = new System.Drawing.Point(8, 16);
this.listBox2.Name = "listBox2";
this.listBox2.Size = new System.Drawing.Size(240, 184);
this.listBox2.TabIndex = 1;
//
// groupBox4
//
this.groupBox4.Controls.Add(this.label5);
@@ -342,7 +352,7 @@
this.toolStripStatusLabel});
this.statusStrip.Location = new System.Drawing.Point(0, 428);
this.statusStrip.Name = "statusStrip";
this.statusStrip.Size = new System.Drawing.Size(800, 22);
this.statusStrip.Size = new System.Drawing.Size(544, 22);
this.statusStrip.TabIndex = 4;
this.statusStrip.Text = "statusStrip1";
//
@@ -355,10 +365,12 @@
//
this.tabControl1.Controls.Add(this.tabPage1);
this.tabControl1.Controls.Add(this.tabPage2);
this.tabControl1.Location = new System.Drawing.Point(0, 64);
this.tabControl1.Controls.Add(this.tabPage3);
this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabControl1.Location = new System.Drawing.Point(3, 92);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(800, 360);
this.tabControl1.Size = new System.Drawing.Size(538, 337);
this.tabControl1.TabIndex = 5;
//
// tabPage1
@@ -368,7 +380,7 @@
this.tabPage1.Location = new System.Drawing.Point(4, 22);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
this.tabPage1.Size = new System.Drawing.Size(792, 334);
this.tabPage1.Size = new System.Drawing.Size(530, 311);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "Connection";
this.tabPage1.UseVisualStyleBackColor = true;
@@ -378,7 +390,7 @@
this.groupBox5.Controls.Add(this.ActivityTextBox);
this.groupBox5.Location = new System.Drawing.Point(8, 128);
this.groupBox5.Name = "groupBox5";
this.groupBox5.Size = new System.Drawing.Size(776, 200);
this.groupBox5.Size = new System.Drawing.Size(512, 176);
this.groupBox5.TabIndex = 5;
this.groupBox5.TabStop = false;
this.groupBox5.Text = "Activity";
@@ -389,34 +401,67 @@
this.ActivityTextBox.Location = new System.Drawing.Point(8, 16);
this.ActivityTextBox.Multiline = true;
this.ActivityTextBox.Name = "ActivityTextBox";
this.ActivityTextBox.Size = new System.Drawing.Size(760, 176);
this.ActivityTextBox.Size = new System.Drawing.Size(496, 152);
this.ActivityTextBox.TabIndex = 4;
//
// tabPage2
//
this.tabPage2.Controls.Add(this.groupBox1);
this.tabPage2.Controls.Add(this.groupBox2);
this.tabPage2.Controls.Add(this.groupBox3);
this.tabPage2.Location = new System.Drawing.Point(4, 22);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
this.tabPage2.Size = new System.Drawing.Size(792, 334);
this.tabPage2.Size = new System.Drawing.Size(530, 311);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "Bindings";
this.tabPage2.UseVisualStyleBackColor = true;
//
// tabPage3
//
this.tabPage3.Controls.Add(this.groupBox2);
this.tabPage3.Location = new System.Drawing.Point(4, 22);
this.tabPage3.Name = "tabPage3";
this.tabPage3.Size = new System.Drawing.Size(530, 311);
this.tabPage3.TabIndex = 2;
this.tabPage3.Text = "Chat";
this.tabPage3.UseVisualStyleBackColor = true;
//
// pictureBox1
//
this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBox1.Location = new System.Drawing.Point(3, 3);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(538, 83);
this.pictureBox1.TabIndex = 6;
this.pictureBox1.TabStop = false;
//
// tableLayoutPanel1
//
this.tableLayoutPanel1.ColumnCount = 1;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel1.Controls.Add(this.tabControl1, 0, 1);
this.tableLayoutPanel1.Controls.Add(this.pictureBox1, 0, 0);
this.tableLayoutPanel1.GrowStyle = System.Windows.Forms.TableLayoutPanelGrowStyle.FixedSize;
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 2;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20.71428F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 79.28571F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(544, 432);
this.tableLayoutPanel1.TabIndex = 7;
//
// WingManForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.tabControl1);
this.ClientSize = new System.Drawing.Size(544, 450);
this.Controls.Add(this.statusStrip);
this.Controls.Add(this.tableLayoutPanel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(816, 488);
this.MaximumSize = new System.Drawing.Size(560, 488);
this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(816, 488);
this.MinimumSize = new System.Drawing.Size(560, 488);
this.Name = "WingManForm";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.Text = "WingManForm";
@@ -435,6 +480,9 @@
this.groupBox5.ResumeLayout(false);
this.groupBox5.PerformLayout();
this.tabPage2.ResumeLayout(false);
this.tabPage3.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.tableLayoutPanel1.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
 
@@ -446,17 +494,16 @@
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.ListBox listBox2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox LobbySayTextBox;
public System.Windows.Forms.TextBox LobbyTextBox;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox HelmNameTextBox;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.Button HelmAddButton;
private System.Windows.Forms.Button button5;
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.Button HostButton;
@@ -475,6 +522,10 @@
private System.Windows.Forms.GroupBox groupBox5;
public System.Windows.Forms.TextBox ActivityTextBox;
private System.Windows.Forms.TabPage tabPage2;
private System.Windows.Forms.TabPage tabPage3;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.ListBox HelmBindingsListBox;
}
}
 
/trunk/WingMan/WingManForm.cs
@@ -1,4 +1,5 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@@ -6,10 +7,12 @@
using System.Globalization;
using System.Linq;
using System.Net;
using System.Resources;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Gma.System.MouseKeyHook;
using WingMan.Communication;
using WingMan.Host;
 
@@ -25,12 +28,38 @@
 
private SemaphoreSlim MQTTClientSemaphore { get; set; } = new SemaphoreSlim(1, 1);
 
private static IKeyboardMouseEvents MouseKeyApplicationHook { get; set; }
 
private static IKeyboardMouseEvents MouseKeyGlobalHook { get; set; }
 
private List<string> MouseKeyCombo { get; set; }
 
private HelmBindings HelmBindings { get; set; }
 
private BindingSource HelmBindingSource { get; set; }
 
public ConcurrentDictionary<string, HelmBindings> WingBindings { get; set; }
 
public WingManForm()
{
InitializeComponent();
 
MouseKeyGlobalHook = Hook.GlobalEvents();
 
MQTTClient = new MQTTClient(this);
MQTTServer = new MQTTServer(this);
 
HelmBindings = new HelmBindings();
HelmBindings.Bindings = new List<HelmBinding>();
 
HelmBindingSource = new BindingSource();
HelmBindingSource.DataSource = HelmBindings.Bindings;
 
HelmBindingsListBox.DisplayMember = "DisplayName";
HelmBindingsListBox.ValueMember = "Keys";
HelmBindingsListBox.DataSource = HelmBindingSource;
 
WingBindings = new ConcurrentDictionary<string, HelmBindings>();
}
 
private void AddressTextBoxClick(object sender, EventArgs e)
@@ -224,5 +253,508 @@
}
 
}
 
private void HelmAddButtonClick(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(HelmNameTextBox.Text))
{
HelmNameTextBox.BackColor = Color.LightPink;
return;
}
 
HelmAddButton.Enabled = false;
 
MouseKeyCombo = new List<string>();
 
MouseKeyApplicationHook = Hook.AppEvents();
MouseKeyApplicationHook.MouseDown += MouseKeyHookOnMouseDown;
MouseKeyApplicationHook.KeyUp += MouseKeyHookOnKeyUp;
MouseKeyApplicationHook.KeyDown += MouseKeyHookOnKeyDown;
MouseKeyApplicationHook.MouseUp += MouseKeyHookOnMouseUp;
 
}
 
private void MouseKeyHookOnKeyUp(object sender, KeyEventArgs e)
{
HelmBindings.Bindings.Add(new HelmBinding
{
Keys = MouseKeyCombo,
Name = HelmNameTextBox.Text
});
 
HelmBindingSource.ResetBindings(false);
 
MouseKeyApplicationHook.KeyDown -= MouseKeyHookOnKeyDown;
MouseKeyApplicationHook.KeyUp -= MouseKeyHookOnKeyUp;
 
MouseKeyApplicationHook.Dispose();
 
HelmNameTextBox.Text = string.Empty;
HelmAddButton.Enabled = true;
}
 
private void MouseKeyHookOnMouseUp(object sender, MouseEventArgs e)
{
HelmBindings.Bindings.Add(new HelmBinding
{
Keys = MouseKeyCombo,
Name = HelmNameTextBox.Text
});
 
HelmBindingSource.ResetBindings(false);
 
MouseKeyApplicationHook.KeyDown -= MouseKeyHookOnKeyDown;
MouseKeyApplicationHook.KeyUp -= MouseKeyHookOnKeyUp;
 
MouseKeyApplicationHook.Dispose();
 
HelmNameTextBox.Text = string.Empty;
HelmAddButton.Enabled = true;
}
 
 
private void MouseKeyHookOnMouseDown(object sender, MouseEventArgs e)
{
MouseKeyCombo.Add(MouseButtonToName(e.Button));
}
 
private void MouseKeyHookOnKeyDown(object sender, KeyEventArgs e)
{
e.SuppressKeyPress = true;
 
MouseKeyCombo.Add(KeyCodeToName((int) e.KeyCode));
}
 
private void HelmNameTextBoxClick(object sender, EventArgs e)
{
HelmNameTextBox.BackColor = Color.Empty;
}
 
private string MouseButtonToName(MouseButtons button)
{
var mouseButton = string.Empty;
switch (button)
{
case MouseButtons.Left:
mouseButton = "Left Mouse Button";
break;
case MouseButtons.Middle:
mouseButton = "Middle Mouse Button";
break;
case MouseButtons.Right:
mouseButton = "Right Mouse Button";
break;
}
 
return mouseButton;
}
 
private string KeyCodeToName(int code)
{
var keyString = string.Empty;
switch (code)
{
case 0:
break;
case 1:
keyString = "Mouse Left";
break;
case 2:
keyString = "Mouse Right";
break;
case 3:
keyString = "Cancel";
break;
case 4:
keyString = "Mouse Middle";
break;
case 5:
keyString = "Special 1";
break;
case 6:
keyString = "Special 2";
break;
case 8:
keyString = "Back";
break;
case 9:
keyString = "TAB";
break;
case 12:
keyString = "Clear";
break;
case 13:
keyString = "Enter";
break;
case 16:
keyString = "Shift";
break;
case 17:
keyString = "Ctrl";
break;
case 18:
keyString = "Menu";
break;
case 19:
keyString = "Pause";
break;
case 20:
keyString = "Caps Lock";
break;
case 21:
keyString = "Kana/Hangul";
break;
case 23:
keyString = "Junja";
break;
case 24:
keyString = "Final";
break;
case 25:
keyString = "Hanja/Kanji";
break;
case 27:
keyString = "Esc";
break;
case 28:
keyString = "Convert";
break;
case 29:
keyString = "NonConvert";
break;
case 30:
keyString = "Accept";
break;
case 31:
keyString = "Mode";
break;
case 32:
keyString = "Space";
break;
case 33:
keyString = "Page Up";
break;
case 34:
keyString = "Page Down";
break;
case 35:
keyString = "End";
break;
case 36:
keyString = "Home";
break;
case 37:
keyString = "Left";
break;
case 38:
keyString = "Up";
break;
case 39:
keyString = "Right";
break;
case 40:
keyString = "Down";
break;
case 41:
keyString = "Select";
break;
case 42:
keyString = "Print";
break;
case 43:
keyString = "Execute";
break;
case 44:
keyString = "Snapshot";
break;
case 45:
keyString = "Insert";
break;
case 46:
keyString = "Delete";
break;
case 47:
keyString = "Help";
break;
case 48:
keyString = "Num 0";
break;
case 49:
keyString = "Num 1";
break;
case 50:
keyString = "Num 2";
break;
case 51:
keyString = "Num 3";
break;
case 52:
keyString = "Num 4";
break;
case 53:
keyString = "Num 5";
break;
case 54:
keyString = "Num 6";
break;
case 55:
keyString = "Num 7";
break;
case 56:
keyString = "Num 8";
break;
case 57:
keyString = "Num 9";
break;
case 65:
keyString = "A";
break;
case 66:
keyString = "B";
break;
case 67:
keyString = "C";
break;
case 68:
keyString = "D";
break;
case 69:
keyString = "E";
break;
case 70:
keyString = "F";
break;
case 71:
keyString = "G";
break;
case 72:
keyString = "H";
break;
case 73:
keyString = "I";
break;
case 74:
keyString = "J";
break;
case 75:
keyString = "K";
break;
case 76:
keyString = "L";
break;
case 77:
keyString = "M";
break;
case 78:
keyString = "N";
break;
case 79:
keyString = "O";
break;
case 80:
keyString = "P";
break;
case 81:
keyString = "Q";
break;
case 82:
keyString = "R";
break;
case 83:
keyString = "S";
break;
case 84:
keyString = "T";
break;
case 85:
keyString = "U";
break;
case 86:
keyString = "V";
break;
case 87:
keyString = "W";
break;
case 88:
keyString = "X";
break;
case 89:
keyString = "Y";
break;
case 90:
keyString = "Z";
break;
case 91:
keyString = "Windows Left";
break;
case 92:
keyString = "Windows Right";
break;
case 93:
keyString = "Application";
break;
case 95:
keyString = "Sleep";
break;
case 96:
keyString = "NumPad 0";
break;
case 97:
keyString = "NumPad 1";
break;
case 98:
keyString = "NumPad 2";
break;
case 99:
keyString = "NumPad 3";
break;
case 100:
keyString = "NumPad 4";
break;
case 101:
keyString = "NumPad 5";
break;
case 102:
keyString = "NumPad 6";
break;
case 103:
keyString = "NumPad 7";
break;
case 104:
keyString = "NumPad 8";
break;
case 105:
keyString = "NumPad 9";
break;
case 106:
keyString = "NumPad *";
break;
case 107:
keyString = "NumPad +";
break;
case 108:
keyString = "NumPad .";
break;
case 109:
keyString = "NumPad -";
break;
case 110:
keyString = "NumPad ,";
break;
case 111:
keyString = "NumPad /";
break;
case 112:
keyString = "F1";
break;
case 113:
keyString = "F2";
break;
case 114:
keyString = "F3";
break;
case 115:
keyString = "F4";
break;
case 116:
keyString = "F5";
break;
case 117:
keyString = "F6";
break;
case 118:
keyString = "F7";
break;
case 119:
keyString = "F8";
break;
case 120:
keyString = "F9";
break;
case 121:
keyString = "F10";
break;
case 122:
keyString = "F11";
break;
case 123:
keyString = "F12";
break;
case 124:
keyString = "F13";
break;
case 125:
keyString = "F14";
break;
case 126:
keyString = "F15";
break;
case 127:
keyString = "F16";
break;
case 128:
keyString = "F17";
break;
case 129:
keyString = "F18";
break;
case 130:
keyString = "F19";
break;
case 131:
keyString = "F20";
break;
case 132:
keyString = "F21";
break;
case 133:
keyString = "F22";
break;
case 134:
keyString = "F23";
break;
case 135:
keyString = "F24";
break;
case 144:
keyString = "Num lock";
break;
case 145:
keyString = "Scroll";
break;
case 160:
keyString = "Shift Left";
break;
case 161:
keyString = "Shift Right";
break;
case 162:
keyString = "Ctrl Left";
break;
case 163:
keyString = "Ctrl Right";
break;
case 164:
keyString = "Menu Left";
break;
case 165:
keyString = "Menu Right";
break;
default:
break;
}
 
return keyString;
}
 
private void HelmRemoveButtonClick(object sender, EventArgs e)
{
var helmBinding = (HelmBinding)HelmBindingsListBox.SelectedItem;
if (helmBinding == null)
return;
 
HelmBindings.Bindings.Remove(helmBinding);
HelmBindingSource.ResetBindings(false);
}
}
}
/trunk/WingMan/packages.config
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MonoGame.EasyInput" version="1.0.0" targetFramework="net452" />
<package id="MouseKeyHook" version="5.6.0" targetFramework="net452" />
<package id="MQTTnet" version="2.8.4" targetFramework="net452" />
<package id="MQTTnet.Extensions.ManagedClient" version="2.8.4" targetFramework="net452" />
<package id="Open.NAT" version="2.1.0.0" targetFramework="net452" />