Input Config - fix anchoring of L+R checkbox, Input Widget - fix ToString method so things like Ctrl+UpArrow doesn't break
This commit is contained in:
parent
f23c5f8382
commit
47ebedb40c
|
@ -28,167 +28,168 @@
|
|||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(InputConfig));
|
||||
this.OK = new System.Windows.Forms.Button();
|
||||
this.Cancel = new System.Windows.Forms.Button();
|
||||
this.ButtonsGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.ControllerImage = new System.Windows.Forms.PictureBox();
|
||||
this.ControllerSelectGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.IDX_CONTROLLERENABLED = new System.Windows.Forms.CheckBox();
|
||||
this.ControllComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.SystemGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.SystemComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.AllowLR = new System.Windows.Forms.CheckBox();
|
||||
((System.ComponentModel.ISupportInitialize)(this.ControllerImage)).BeginInit();
|
||||
this.ControllerSelectGroupBox.SuspendLayout();
|
||||
this.SystemGroupBox.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// OK
|
||||
//
|
||||
this.OK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.OK.Location = new System.Drawing.Point(261, 309);
|
||||
this.OK.Name = "OK";
|
||||
this.OK.Size = new System.Drawing.Size(75, 23);
|
||||
this.OK.TabIndex = 0;
|
||||
this.OK.Text = "&Ok";
|
||||
this.OK.UseVisualStyleBackColor = true;
|
||||
this.OK.Click += new System.EventHandler(this.OK_Click);
|
||||
//
|
||||
// Cancel
|
||||
//
|
||||
this.Cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.Cancel.Location = new System.Drawing.Point(351, 309);
|
||||
this.Cancel.Name = "Cancel";
|
||||
this.Cancel.Size = new System.Drawing.Size(75, 23);
|
||||
this.Cancel.TabIndex = 1;
|
||||
this.Cancel.Text = "&Cancel";
|
||||
this.Cancel.UseVisualStyleBackColor = true;
|
||||
this.Cancel.Click += new System.EventHandler(this.Cancel_Click);
|
||||
//
|
||||
// ButtonsGroupBox
|
||||
//
|
||||
this.ButtonsGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ButtonsGroupBox.Location = new System.Drawing.Point(12, 68);
|
||||
this.ButtonsGroupBox.Name = "ButtonsGroupBox";
|
||||
this.ButtonsGroupBox.Size = new System.Drawing.Size(241, 264);
|
||||
this.ButtonsGroupBox.TabIndex = 2;
|
||||
this.ButtonsGroupBox.TabStop = false;
|
||||
this.ButtonsGroupBox.Text = "Buttons";
|
||||
//
|
||||
// ControllerImage
|
||||
//
|
||||
this.ControllerImage.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ControllerImage.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
|
||||
this.ControllerImage.Location = new System.Drawing.Point(259, 73);
|
||||
this.ControllerImage.Name = "ControllerImage";
|
||||
this.ControllerImage.Size = new System.Drawing.Size(169, 202);
|
||||
this.ControllerImage.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
|
||||
this.ControllerImage.TabIndex = 3;
|
||||
this.ControllerImage.TabStop = false;
|
||||
//
|
||||
// ControllerSelectGroupBox
|
||||
//
|
||||
this.ControllerSelectGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ControllerSelectGroupBox.Controls.Add(this.IDX_CONTROLLERENABLED);
|
||||
this.ControllerSelectGroupBox.Controls.Add(this.ControllComboBox);
|
||||
this.ControllerSelectGroupBox.Location = new System.Drawing.Point(13, 12);
|
||||
this.ControllerSelectGroupBox.Name = "ControllerSelectGroupBox";
|
||||
this.ControllerSelectGroupBox.Size = new System.Drawing.Size(240, 50);
|
||||
this.ControllerSelectGroupBox.TabIndex = 4;
|
||||
this.ControllerSelectGroupBox.TabStop = false;
|
||||
this.ControllerSelectGroupBox.Text = "Controller";
|
||||
//
|
||||
// IDX_CONTROLLERENABLED
|
||||
//
|
||||
this.IDX_CONTROLLERENABLED.AutoSize = true;
|
||||
this.IDX_CONTROLLERENABLED.Checked = true;
|
||||
this.IDX_CONTROLLERENABLED.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.IDX_CONTROLLERENABLED.Location = new System.Drawing.Point(143, 23);
|
||||
this.IDX_CONTROLLERENABLED.Name = "IDX_CONTROLLERENABLED";
|
||||
this.IDX_CONTROLLERENABLED.Size = new System.Drawing.Size(65, 17);
|
||||
this.IDX_CONTROLLERENABLED.TabIndex = 1;
|
||||
this.IDX_CONTROLLERENABLED.Text = "Enabled";
|
||||
this.IDX_CONTROLLERENABLED.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// ControllComboBox
|
||||
//
|
||||
this.ControllComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.ControllComboBox.FormattingEnabled = true;
|
||||
this.ControllComboBox.Location = new System.Drawing.Point(6, 19);
|
||||
this.ControllComboBox.Name = "ControllComboBox";
|
||||
this.ControllComboBox.Size = new System.Drawing.Size(110, 21);
|
||||
this.ControllComboBox.TabIndex = 0;
|
||||
this.ControllComboBox.SelectedIndexChanged += new System.EventHandler(this.ControllComboBox_SelectedIndexChanged);
|
||||
//
|
||||
// SystemGroupBox
|
||||
//
|
||||
this.SystemGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.SystemGroupBox.Controls.Add(this.SystemComboBox);
|
||||
this.SystemGroupBox.Location = new System.Drawing.Point(259, 12);
|
||||
this.SystemGroupBox.Name = "SystemGroupBox";
|
||||
this.SystemGroupBox.Size = new System.Drawing.Size(158, 50);
|
||||
this.SystemGroupBox.TabIndex = 6;
|
||||
this.SystemGroupBox.TabStop = false;
|
||||
this.SystemGroupBox.Text = "System";
|
||||
//
|
||||
// SystemComboBox
|
||||
//
|
||||
this.SystemComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.SystemComboBox.FormattingEnabled = true;
|
||||
this.SystemComboBox.Items.AddRange(new object[] {
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(InputConfig));
|
||||
this.OK = new System.Windows.Forms.Button();
|
||||
this.Cancel = new System.Windows.Forms.Button();
|
||||
this.ButtonsGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.ControllerImage = new System.Windows.Forms.PictureBox();
|
||||
this.ControllerSelectGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.IDX_CONTROLLERENABLED = new System.Windows.Forms.CheckBox();
|
||||
this.ControllComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.SystemGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.SystemComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.AllowLR = new System.Windows.Forms.CheckBox();
|
||||
((System.ComponentModel.ISupportInitialize)(this.ControllerImage)).BeginInit();
|
||||
this.ControllerSelectGroupBox.SuspendLayout();
|
||||
this.SystemGroupBox.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// OK
|
||||
//
|
||||
this.OK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.OK.Location = new System.Drawing.Point(261, 309);
|
||||
this.OK.Name = "OK";
|
||||
this.OK.Size = new System.Drawing.Size(75, 23);
|
||||
this.OK.TabIndex = 0;
|
||||
this.OK.Text = "&Ok";
|
||||
this.OK.UseVisualStyleBackColor = true;
|
||||
this.OK.Click += new System.EventHandler(this.OK_Click);
|
||||
//
|
||||
// Cancel
|
||||
//
|
||||
this.Cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.Cancel.Location = new System.Drawing.Point(351, 309);
|
||||
this.Cancel.Name = "Cancel";
|
||||
this.Cancel.Size = new System.Drawing.Size(75, 23);
|
||||
this.Cancel.TabIndex = 1;
|
||||
this.Cancel.Text = "&Cancel";
|
||||
this.Cancel.UseVisualStyleBackColor = true;
|
||||
this.Cancel.Click += new System.EventHandler(this.Cancel_Click);
|
||||
//
|
||||
// ButtonsGroupBox
|
||||
//
|
||||
this.ButtonsGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ButtonsGroupBox.Location = new System.Drawing.Point(12, 68);
|
||||
this.ButtonsGroupBox.Name = "ButtonsGroupBox";
|
||||
this.ButtonsGroupBox.Size = new System.Drawing.Size(241, 264);
|
||||
this.ButtonsGroupBox.TabIndex = 2;
|
||||
this.ButtonsGroupBox.TabStop = false;
|
||||
this.ButtonsGroupBox.Text = "Buttons";
|
||||
//
|
||||
// ControllerImage
|
||||
//
|
||||
this.ControllerImage.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ControllerImage.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
|
||||
this.ControllerImage.Location = new System.Drawing.Point(259, 73);
|
||||
this.ControllerImage.Name = "ControllerImage";
|
||||
this.ControllerImage.Size = new System.Drawing.Size(169, 202);
|
||||
this.ControllerImage.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
|
||||
this.ControllerImage.TabIndex = 3;
|
||||
this.ControllerImage.TabStop = false;
|
||||
//
|
||||
// ControllerSelectGroupBox
|
||||
//
|
||||
this.ControllerSelectGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ControllerSelectGroupBox.Controls.Add(this.IDX_CONTROLLERENABLED);
|
||||
this.ControllerSelectGroupBox.Controls.Add(this.ControllComboBox);
|
||||
this.ControllerSelectGroupBox.Location = new System.Drawing.Point(13, 12);
|
||||
this.ControllerSelectGroupBox.Name = "ControllerSelectGroupBox";
|
||||
this.ControllerSelectGroupBox.Size = new System.Drawing.Size(240, 50);
|
||||
this.ControllerSelectGroupBox.TabIndex = 4;
|
||||
this.ControllerSelectGroupBox.TabStop = false;
|
||||
this.ControllerSelectGroupBox.Text = "Controller";
|
||||
//
|
||||
// IDX_CONTROLLERENABLED
|
||||
//
|
||||
this.IDX_CONTROLLERENABLED.AutoSize = true;
|
||||
this.IDX_CONTROLLERENABLED.Checked = true;
|
||||
this.IDX_CONTROLLERENABLED.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.IDX_CONTROLLERENABLED.Location = new System.Drawing.Point(143, 23);
|
||||
this.IDX_CONTROLLERENABLED.Name = "IDX_CONTROLLERENABLED";
|
||||
this.IDX_CONTROLLERENABLED.Size = new System.Drawing.Size(65, 17);
|
||||
this.IDX_CONTROLLERENABLED.TabIndex = 1;
|
||||
this.IDX_CONTROLLERENABLED.Text = "Enabled";
|
||||
this.IDX_CONTROLLERENABLED.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// ControllComboBox
|
||||
//
|
||||
this.ControllComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.ControllComboBox.FormattingEnabled = true;
|
||||
this.ControllComboBox.Location = new System.Drawing.Point(6, 19);
|
||||
this.ControllComboBox.Name = "ControllComboBox";
|
||||
this.ControllComboBox.Size = new System.Drawing.Size(110, 21);
|
||||
this.ControllComboBox.TabIndex = 0;
|
||||
this.ControllComboBox.SelectedIndexChanged += new System.EventHandler(this.ControllComboBox_SelectedIndexChanged);
|
||||
//
|
||||
// SystemGroupBox
|
||||
//
|
||||
this.SystemGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.SystemGroupBox.Controls.Add(this.SystemComboBox);
|
||||
this.SystemGroupBox.Location = new System.Drawing.Point(259, 12);
|
||||
this.SystemGroupBox.Name = "SystemGroupBox";
|
||||
this.SystemGroupBox.Size = new System.Drawing.Size(158, 50);
|
||||
this.SystemGroupBox.TabIndex = 6;
|
||||
this.SystemGroupBox.TabStop = false;
|
||||
this.SystemGroupBox.Text = "System";
|
||||
//
|
||||
// SystemComboBox
|
||||
//
|
||||
this.SystemComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.SystemComboBox.FormattingEnabled = true;
|
||||
this.SystemComboBox.Items.AddRange(new object[] {
|
||||
"SMS / GG / SG-1000",
|
||||
"PC Engine / SGX",
|
||||
"Gameboy",
|
||||
"Sega Genesis",
|
||||
"TI-83",
|
||||
"NES"});
|
||||
this.SystemComboBox.Location = new System.Drawing.Point(6, 19);
|
||||
this.SystemComboBox.Name = "SystemComboBox";
|
||||
this.SystemComboBox.Size = new System.Drawing.Size(146, 21);
|
||||
this.SystemComboBox.TabIndex = 2;
|
||||
this.SystemComboBox.SelectedIndexChanged += new System.EventHandler(this.SystemComboBox_SelectedIndexChanged);
|
||||
//
|
||||
// AllowLR
|
||||
//
|
||||
this.AllowLR.AutoSize = true;
|
||||
this.AllowLR.Location = new System.Drawing.Point(261, 286);
|
||||
this.AllowLR.Name = "AllowLR";
|
||||
this.AllowLR.Size = new System.Drawing.Size(107, 17);
|
||||
this.AllowLR.TabIndex = 7;
|
||||
this.AllowLR.Text = "Allow L+R / U+D";
|
||||
this.AllowLR.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// InputConfig
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(440, 344);
|
||||
this.Controls.Add(this.AllowLR);
|
||||
this.Controls.Add(this.SystemGroupBox);
|
||||
this.Controls.Add(this.ControllerSelectGroupBox);
|
||||
this.Controls.Add(this.ControllerImage);
|
||||
this.Controls.Add(this.ButtonsGroupBox);
|
||||
this.Controls.Add(this.Cancel);
|
||||
this.Controls.Add(this.OK);
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "InputConfig";
|
||||
this.ShowIcon = false;
|
||||
this.Text = "Configure Controllers";
|
||||
this.Load += new System.EventHandler(this.InputConfig_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.ControllerImage)).EndInit();
|
||||
this.ControllerSelectGroupBox.ResumeLayout(false);
|
||||
this.ControllerSelectGroupBox.PerformLayout();
|
||||
this.SystemGroupBox.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
this.SystemComboBox.Location = new System.Drawing.Point(6, 19);
|
||||
this.SystemComboBox.Name = "SystemComboBox";
|
||||
this.SystemComboBox.Size = new System.Drawing.Size(146, 21);
|
||||
this.SystemComboBox.TabIndex = 2;
|
||||
this.SystemComboBox.SelectedIndexChanged += new System.EventHandler(this.SystemComboBox_SelectedIndexChanged);
|
||||
//
|
||||
// AllowLR
|
||||
//
|
||||
this.AllowLR.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.AllowLR.AutoSize = true;
|
||||
this.AllowLR.Location = new System.Drawing.Point(261, 286);
|
||||
this.AllowLR.Name = "AllowLR";
|
||||
this.AllowLR.Size = new System.Drawing.Size(107, 17);
|
||||
this.AllowLR.TabIndex = 7;
|
||||
this.AllowLR.Text = "Allow L+R / U+D";
|
||||
this.AllowLR.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// InputConfig
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(440, 344);
|
||||
this.Controls.Add(this.AllowLR);
|
||||
this.Controls.Add(this.SystemGroupBox);
|
||||
this.Controls.Add(this.ControllerSelectGroupBox);
|
||||
this.Controls.Add(this.ControllerImage);
|
||||
this.Controls.Add(this.ButtonsGroupBox);
|
||||
this.Controls.Add(this.Cancel);
|
||||
this.Controls.Add(this.OK);
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "InputConfig";
|
||||
this.ShowIcon = false;
|
||||
this.Text = "Configure Controllers";
|
||||
this.Load += new System.EventHandler(this.InputConfig_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.ControllerImage)).EndInit();
|
||||
this.ControllerSelectGroupBox.ResumeLayout(false);
|
||||
this.ControllerSelectGroupBox.PerformLayout();
|
||||
this.SystemGroupBox.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -5,135 +5,138 @@ using System.Windows.Forms;
|
|||
|
||||
namespace BizHawk.MultiClient
|
||||
{
|
||||
public class InputWidget : TextBox
|
||||
{
|
||||
public InputWidget()
|
||||
{
|
||||
this.ContextMenu = new ContextMenu();
|
||||
}
|
||||
public class InputWidget : TextBox
|
||||
{
|
||||
public InputWidget()
|
||||
{
|
||||
this.ContextMenu = new ContextMenu();
|
||||
}
|
||||
|
||||
public List<IBinding> Bindings = new List<IBinding>();
|
||||
public List<IBinding> Bindings = new List<IBinding>();
|
||||
|
||||
void UpdateLabel()
|
||||
{
|
||||
if (Bindings.Count == 0)
|
||||
{
|
||||
Text = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
Text = Bindings[0].ToString();
|
||||
}
|
||||
Update();
|
||||
}
|
||||
void UpdateLabel()
|
||||
{
|
||||
if (Bindings.Count == 0)
|
||||
{
|
||||
Text = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
Text = Bindings[0].ToString();
|
||||
}
|
||||
Update();
|
||||
}
|
||||
|
||||
protected override void OnKeyDown(KeyEventArgs e)
|
||||
{
|
||||
e.Handled = true;
|
||||
if (e.KeyCode == Keys.ControlKey) return;
|
||||
if (e.KeyCode == Keys.ShiftKey) return;
|
||||
if (e.KeyCode == Keys.Menu) return;
|
||||
if (e.KeyCode != Keys.Escape)
|
||||
{
|
||||
KeyboardBinding kb = new KeyboardBinding();
|
||||
kb.key = e.KeyCode;
|
||||
kb.modifiers = e.Modifiers;
|
||||
Bindings.Clear();
|
||||
Bindings.Add(kb);
|
||||
UpdateLabel();
|
||||
}
|
||||
else
|
||||
{
|
||||
Bindings.Clear();
|
||||
UpdateLabel();
|
||||
}
|
||||
this.Parent.SelectNextControl(this, true, true, true, true);
|
||||
}
|
||||
protected override void OnKeyDown(KeyEventArgs e)
|
||||
{
|
||||
e.Handled = true;
|
||||
if (e.KeyCode == Keys.ControlKey) return;
|
||||
if (e.KeyCode == Keys.ShiftKey) return;
|
||||
if (e.KeyCode == Keys.Menu) return;
|
||||
if (e.KeyCode != Keys.Escape)
|
||||
{
|
||||
KeyboardBinding kb = new KeyboardBinding();
|
||||
kb.key = e.KeyCode;
|
||||
kb.modifiers = e.Modifiers;
|
||||
Bindings.Clear();
|
||||
Bindings.Add(kb);
|
||||
UpdateLabel();
|
||||
}
|
||||
else
|
||||
{
|
||||
Bindings.Clear();
|
||||
UpdateLabel();
|
||||
}
|
||||
this.Parent.SelectNextControl(this, true, true, true, true);
|
||||
}
|
||||
|
||||
protected override void OnKeyPress(KeyPressEventArgs e)
|
||||
{
|
||||
e.Handled = true;
|
||||
}
|
||||
protected override void OnKeyPress(KeyPressEventArgs e)
|
||||
{
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
protected override void OnGotFocus(EventArgs e)
|
||||
{
|
||||
base.OnGotFocus(e);
|
||||
BackColor = Color.Pink;
|
||||
}
|
||||
protected override void OnGotFocus(EventArgs e)
|
||||
{
|
||||
base.OnGotFocus(e);
|
||||
BackColor = Color.Pink;
|
||||
}
|
||||
|
||||
protected override void OnLostFocus(EventArgs e)
|
||||
{
|
||||
base.OnLostFocus(e);
|
||||
BackColor = SystemColors.Window;
|
||||
}
|
||||
protected override void OnLostFocus(EventArgs e)
|
||||
{
|
||||
base.OnLostFocus(e);
|
||||
BackColor = SystemColors.Window;
|
||||
}
|
||||
|
||||
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
|
||||
{
|
||||
if (keyData == Keys.Tab)
|
||||
{
|
||||
KeyboardBinding kb = new KeyboardBinding();
|
||||
kb.key = keyData;
|
||||
Bindings.Clear();
|
||||
Bindings.Add(kb);
|
||||
UpdateLabel();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
|
||||
{
|
||||
if (keyData == Keys.Tab)
|
||||
{
|
||||
KeyboardBinding kb = new KeyboardBinding();
|
||||
kb.key = keyData;
|
||||
Bindings.Clear();
|
||||
Bindings.Add(kb);
|
||||
UpdateLabel();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public class KeyboardBinding : IBinding
|
||||
{
|
||||
public override string ToString()
|
||||
{
|
||||
// Convert Windows key names to SlimDX key names
|
||||
string str = "";
|
||||
if((modifiers & Keys.Shift)!=0)
|
||||
str += "LeftShift + ";
|
||||
if ((modifiers & Keys.Control) != 0)
|
||||
str += "LeftControl + ";
|
||||
if ((modifiers & Keys.Alt) != 0)
|
||||
str += "LeftAlt + ";
|
||||
// Convert Windows key names to SlimDX key names
|
||||
string str = "";
|
||||
|
||||
str += key.ToString();
|
||||
if (str.Length == 2 && str == "Up")
|
||||
str = "UpArrow";
|
||||
if (str.Length == 4 && str == "Down")
|
||||
str = "DownArrow";
|
||||
if (str.Length == 4 && str == "Left")
|
||||
str = "LeftArrow";
|
||||
if (str.Length == 5 && str == "Right")
|
||||
str = "RightArrow";
|
||||
if (str.Length >= 6 && str.Substring(0, 6) == "NumPad")
|
||||
str = str.Insert(3, "ber");
|
||||
if (str.Length == 7 && str.Substring(0, 7) == "Decimal")
|
||||
str = "NumberPadPeriod";
|
||||
if (str.Length == 6 && str.Substring(0, 6) == "Divide")
|
||||
str = "NumberPadSlash";
|
||||
if (str.Length == 8 && str.Substring(0, 8) == "Multiply")
|
||||
str = "NumberPadStar";
|
||||
if (str.Length == 8 && str.Substring(0, 8) == "Subtract")
|
||||
str = "NumberPadMinus";
|
||||
if (str.Length == 3 && str.Substring(0, 3) == "Add")
|
||||
str = "NumberPadPlus";
|
||||
if (str.Length == 4 && str == "Oem5")
|
||||
str = "BackSlash";
|
||||
if (str.Length == 4 && str == "Oem6")
|
||||
str = "RightBracket";
|
||||
if (str.Length == 4 && str == "Next")
|
||||
str = "PageDown";
|
||||
if (str.Length == 11 && str == "OemQuestion")
|
||||
str = "Slash";
|
||||
if (str.Length == 8 && str == "Oemtilde")
|
||||
str = "Grave";
|
||||
if (str.Length == 8 && str == "Oemcomma")
|
||||
str = "Comma";
|
||||
if (str.Length > 3)
|
||||
{
|
||||
if (str.Substring(0, 3) == "Oem")
|
||||
str = str.Substring(3, str.Length - 3);
|
||||
}
|
||||
//Oem Removed now removed from these but they still need conversion
|
||||
if (str.Length == 12 && str.Substring(0, 12) == "OpenBrackets")
|
||||
str = "LeftBracket";
|
||||
if (str.Length == 2 && str == "Up")
|
||||
str = "UpArrow";
|
||||
if (str.Length == 4 && str == "Down")
|
||||
str = "DownArrow";
|
||||
if (str.Length == 4 && str == "Left")
|
||||
str = "LeftArrow";
|
||||
if (str.Length == 5 && str == "Right")
|
||||
str = "RightArrow";
|
||||
if (str.Length >= 6 && str.Substring(0, 6) == "NumPad")
|
||||
str = str.Insert(3, "ber");
|
||||
if (str.Length == 7 && str.Substring(0, 7) == "Decimal")
|
||||
str = "NumberPadPeriod";
|
||||
if (str.Length == 6 && str.Substring(0, 6) == "Divide")
|
||||
str = "NumberPadSlash";
|
||||
if (str.Length == 8 && str.Substring(0, 8) == "Multiply")
|
||||
str = "NumberPadStar";
|
||||
if (str.Length == 8 && str.Substring(0, 8) == "Subtract")
|
||||
str = "NumberPadMinus";
|
||||
if (str.Length == 3 && str.Substring(0, 3) == "Add")
|
||||
str = "NumberPadPlus";
|
||||
if (str.Length == 4 && str == "Oem5")
|
||||
str = "BackSlash";
|
||||
if (str.Length == 4 && str == "Oem6")
|
||||
str = "RightBracket";
|
||||
if (str.Length == 4 && str == "Next")
|
||||
str = "PageDown";
|
||||
if (str.Length == 11 && str == "OemQuestion")
|
||||
str = "Slash";
|
||||
if (str.Length == 8 && str == "Oemtilde")
|
||||
str = "Grave";
|
||||
if (str.Length == 8 && str == "Oemcomma")
|
||||
str = "Comma";
|
||||
if (str.Length > 3)
|
||||
{
|
||||
if (str.Substring(0, 3) == "Oem")
|
||||
str = str.Substring(3, str.Length - 3);
|
||||
}
|
||||
//Oem Removed now removed from these but they still need conversion
|
||||
if (str.Length == 12 && str.Substring(0, 12) == "OpenBrackets")
|
||||
str = "LeftBracket";
|
||||
|
||||
if ((modifiers & Keys.Shift) != 0)
|
||||
str = str.Insert(0, "LeftShift + ");
|
||||
if ((modifiers & Keys.Control) != 0)
|
||||
str = str.Insert(0, "LeftControl + ");
|
||||
if ((modifiers & Keys.Alt) != 0)
|
||||
str = str.Insert(0, "LeftAlt + ");
|
||||
|
||||
return str;
|
||||
}
|
||||
public Keys key;
|
||||
|
|
Loading…
Reference in New Issue