From 0191a758903099bdd39dddb2ef456333eee04fe3 Mon Sep 17 00:00:00 2001 From: Ian C Date: Fri, 27 Apr 2012 16:24:53 +0000 Subject: Added basic logic of UI. Still to add key overlay to image control. --- .../EmuKeyboardDesigner/EmuKeyboardDesigner.csproj | 9 + Native/EmuKeyboardDesigner/EmuKeyboardDesigner.suo | Bin 43008 -> 49152 bytes .../EmuKeyboardDesigner/ImageControl.Designer.cs | 181 +++++++++++++++++++++ Native/EmuKeyboardDesigner/ImageControl.cs | 138 ++++++++++++++++ Native/EmuKeyboardDesigner/ImageControl.resx | 120 ++++++++++++++ Native/EmuKeyboardDesigner/MainForm.Designer.cs | 149 ++++++++++++++++- Native/EmuKeyboardDesigner/MainForm.cs | 127 +++++++++++++++ 7 files changed, 722 insertions(+), 2 deletions(-) create mode 100644 Native/EmuKeyboardDesigner/ImageControl.Designer.cs create mode 100644 Native/EmuKeyboardDesigner/ImageControl.cs create mode 100644 Native/EmuKeyboardDesigner/ImageControl.resx (limited to 'Native') diff --git a/Native/EmuKeyboardDesigner/EmuKeyboardDesigner.csproj b/Native/EmuKeyboardDesigner/EmuKeyboardDesigner.csproj index 9f15f6b..28f34ff 100644 --- a/Native/EmuKeyboardDesigner/EmuKeyboardDesigner.csproj +++ b/Native/EmuKeyboardDesigner/EmuKeyboardDesigner.csproj @@ -46,6 +46,12 @@ + + UserControl + + + ImageControl.cs + Form @@ -54,6 +60,9 @@ + + ImageControl.cs + MainForm.cs diff --git a/Native/EmuKeyboardDesigner/EmuKeyboardDesigner.suo b/Native/EmuKeyboardDesigner/EmuKeyboardDesigner.suo index 0230234..5dcb993 100644 Binary files a/Native/EmuKeyboardDesigner/EmuKeyboardDesigner.suo and b/Native/EmuKeyboardDesigner/EmuKeyboardDesigner.suo differ diff --git a/Native/EmuKeyboardDesigner/ImageControl.Designer.cs b/Native/EmuKeyboardDesigner/ImageControl.Designer.cs new file mode 100644 index 0000000..b181eb3 --- /dev/null +++ b/Native/EmuKeyboardDesigner/ImageControl.Designer.cs @@ -0,0 +1,181 @@ +namespace EmuKeyboardDesigner +{ + partial class ImageControl + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.xUpDown = new System.Windows.Forms.NumericUpDown(); + this.yUpDown = new System.Windows.Forms.NumericUpDown(); + this.heightUpDown = new System.Windows.Forms.NumericUpDown(); + this.widthUpDown = new System.Windows.Forms.NumericUpDown(); + this.label2 = new System.Windows.Forms.Label(); + this.imageBox = new System.Windows.Forms.PictureBox(); + this.loadButton = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.xUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.yUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.heightUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.widthUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.imageBox)).BeginInit(); + this.SuspendLayout(); + // + // label1 + // + this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.label1.Location = new System.Drawing.Point(13, 224); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(35, 13); + this.label1.TabIndex = 0; + this.label1.Text = "X,Y:"; + // + // xUpDown + // + this.xUpDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.xUpDown.Location = new System.Drawing.Point(44, 224); + this.xUpDown.Maximum = new decimal(new int[] { + 1000, + 0, + 0, + 0}); + this.xUpDown.Name = "xUpDown"; + this.xUpDown.Size = new System.Drawing.Size(50, 20); + this.xUpDown.TabIndex = 1; + this.xUpDown.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.xUpDown.ValueChanged += new System.EventHandler(this.OnXChanged); + // + // yUpDown + // + this.yUpDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.yUpDown.Location = new System.Drawing.Point(100, 224); + this.yUpDown.Maximum = new decimal(new int[] { + 1000, + 0, + 0, + 0}); + this.yUpDown.Name = "yUpDown"; + this.yUpDown.Size = new System.Drawing.Size(50, 20); + this.yUpDown.TabIndex = 2; + this.yUpDown.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.yUpDown.ValueChanged += new System.EventHandler(this.OnYChanged); + // + // heightUpDown + // + this.heightUpDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.heightUpDown.Location = new System.Drawing.Point(243, 224); + this.heightUpDown.Maximum = new decimal(new int[] { + 1000, + 0, + 0, + 0}); + this.heightUpDown.Name = "heightUpDown"; + this.heightUpDown.Size = new System.Drawing.Size(50, 20); + this.heightUpDown.TabIndex = 5; + this.heightUpDown.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.heightUpDown.ValueChanged += new System.EventHandler(this.OnHeightChanged); + // + // widthUpDown + // + this.widthUpDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.widthUpDown.Location = new System.Drawing.Point(187, 224); + this.widthUpDown.Maximum = new decimal(new int[] { + 1000, + 0, + 0, + 0}); + this.widthUpDown.Name = "widthUpDown"; + this.widthUpDown.Size = new System.Drawing.Size(50, 20); + this.widthUpDown.TabIndex = 4; + this.widthUpDown.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.widthUpDown.ValueChanged += new System.EventHandler(this.OnWidthChanged); + // + // label2 + // + this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.label2.Location = new System.Drawing.Point(156, 224); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(35, 13); + this.label2.TabIndex = 3; + this.label2.Text = "W, H:"; + // + // imageBox + // + this.imageBox.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.imageBox.Location = new System.Drawing.Point(0, 0); + this.imageBox.Name = "imageBox"; + this.imageBox.Size = new System.Drawing.Size(416, 212); + this.imageBox.TabIndex = 6; + this.imageBox.TabStop = false; + // + // loadButton + // + this.loadButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.loadButton.Location = new System.Drawing.Point(303, 222); + this.loadButton.Name = "loadButton"; + this.loadButton.Size = new System.Drawing.Size(111, 22); + this.loadButton.TabIndex = 7; + this.loadButton.Text = "Load Image"; + this.loadButton.UseVisualStyleBackColor = true; + this.loadButton.Click += new System.EventHandler(this.OnLoad); + // + // ImageControl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.loadButton); + this.Controls.Add(this.imageBox); + this.Controls.Add(this.heightUpDown); + this.Controls.Add(this.widthUpDown); + this.Controls.Add(this.label2); + this.Controls.Add(this.yUpDown); + this.Controls.Add(this.xUpDown); + this.Controls.Add(this.label1); + this.MinimumSize = new System.Drawing.Size(417, 247); + this.Name = "ImageControl"; + this.Size = new System.Drawing.Size(417, 247); + ((System.ComponentModel.ISupportInitialize)(this.xUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.yUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.heightUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.widthUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.imageBox)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.NumericUpDown xUpDown; + private System.Windows.Forms.NumericUpDown yUpDown; + private System.Windows.Forms.NumericUpDown heightUpDown; + private System.Windows.Forms.NumericUpDown widthUpDown; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.PictureBox imageBox; + private System.Windows.Forms.Button loadButton; + } +} diff --git a/Native/EmuKeyboardDesigner/ImageControl.cs b/Native/EmuKeyboardDesigner/ImageControl.cs new file mode 100644 index 0000000..06e4c74 --- /dev/null +++ b/Native/EmuKeyboardDesigner/ImageControl.cs @@ -0,0 +1,138 @@ +// This file is part of the Noddybox.Emulation C# suite. +// +// Noddybox.Emulation is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Noddybox.Emulation is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Noddybox.Emulation. If not, see . +// +// Copyright (c) 2012 Ian Cowburn +// +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +namespace EmuKeyboardDesigner +{ + public partial class ImageControl : UserControl + { + private Bitmap image; + + public ImageControl() + { + InitializeComponent(); + } + + public int KeyX + { + get + { + return Convert.ToInt32(xUpDown.Value); + } + set + { + xUpDown.Value = value; + } + } + + public int KeyY + { + get + { + return Convert.ToInt32(yUpDown.Value); + } + set + { + yUpDown.Value = value; + } + } + + public int KeyWidth + { + get + { + return Convert.ToInt32(widthUpDown.Value); + } + set + { + widthUpDown.Value = value; + } + } + + public int KeyHeight + { + get + { + return Convert.ToInt32(heightUpDown.Value); + } + set + { + heightUpDown.Value = value; + } + } + + private void UpdateKeyOverlay() + { + if (image != null) + { + } + } + + private void OnXChanged(object sender, EventArgs e) + { + UpdateKeyOverlay(); + } + + private void OnYChanged(object sender, EventArgs e) + { + UpdateKeyOverlay(); + } + + private void OnWidthChanged(object sender, EventArgs e) + { + UpdateKeyOverlay(); + } + + private void OnHeightChanged(object sender, EventArgs e) + { + UpdateKeyOverlay(); + } + + private void OnLoad(object sender, EventArgs e) + { + OpenFileDialog fsel = new OpenFileDialog(); + + fsel.Title = "Select image to load"; + fsel.CheckFileExists = true; + fsel.CheckPathExists = true; + fsel.Filter = "Image Files(*.PNG;*.JPG;*.BMP)|*.PNG;*.JPG;*.BMP|All files (*.*)|*.*"; + + if (fsel.ShowDialog() == DialogResult.OK) + { + try + { + image = (Bitmap)Image.FromFile(fsel.FileName); + imageBox.Image = image; + } + catch (Exception ex) + { + MessageBox.Show("Failed to load " + fsel.FileName, ex.GetType().ToString(), MessageBoxButtons.OK); + } + } + + UpdateKeyOverlay(); + } + } +} diff --git a/Native/EmuKeyboardDesigner/ImageControl.resx b/Native/EmuKeyboardDesigner/ImageControl.resx new file mode 100644 index 0000000..29dcb1b --- /dev/null +++ b/Native/EmuKeyboardDesigner/ImageControl.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Native/EmuKeyboardDesigner/MainForm.Designer.cs b/Native/EmuKeyboardDesigner/MainForm.Designer.cs index 6dd8653..a43a21d 100644 --- a/Native/EmuKeyboardDesigner/MainForm.Designer.cs +++ b/Native/EmuKeyboardDesigner/MainForm.Designer.cs @@ -45,12 +45,157 @@ namespace EmuKeyboardDesigner /// private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); + this.keyList = new System.Windows.Forms.ListBox(); + this.label1 = new System.Windows.Forms.Label(); + this.stickyCheckBox = new System.Windows.Forms.CheckBox(); + this.label2 = new System.Windows.Forms.Label(); + this.keysymTextBox = new System.Windows.Forms.TextBox(); + this.loadButton = new System.Windows.Forms.Button(); + this.saveButton = new System.Windows.Forms.Button(); + this.setButton = new System.Windows.Forms.Button(); + this.imageControl = new EmuKeyboardDesigner.ImageControl(); + this.removeButton = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // keyList + // + this.keyList.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.keyList.FormattingEnabled = true; + this.keyList.Location = new System.Drawing.Point(500, 27); + this.keyList.Name = "keyList"; + this.keyList.Size = new System.Drawing.Size(192, 394); + this.keyList.TabIndex = 0; + this.keyList.SelectedIndexChanged += new System.EventHandler(this.OnKeySelected); + // + // label1 + // + this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(497, 9); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(33, 13); + this.label1.TabIndex = 1; + this.label1.Text = "Keys:"; + // + // stickyCheckBox + // + this.stickyCheckBox.AutoSize = true; + this.stickyCheckBox.Location = new System.Drawing.Point(241, 11); + this.stickyCheckBox.Name = "stickyCheckBox"; + this.stickyCheckBox.Size = new System.Drawing.Size(55, 17); + this.stickyCheckBox.TabIndex = 2; + this.stickyCheckBox.Text = "Sticky"; + this.stickyCheckBox.UseVisualStyleBackColor = true; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(12, 9); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(65, 13); + this.label2.TabIndex = 3; + this.label2.Text = "Key Symbol:"; + // + // keysymTextBox + // + this.keysymTextBox.Location = new System.Drawing.Point(83, 9); + this.keysymTextBox.Name = "keysymTextBox"; + this.keysymTextBox.Size = new System.Drawing.Size(152, 20); + this.keysymTextBox.TabIndex = 4; + // + // loadButton + // + this.loadButton.Location = new System.Drawing.Point(501, 434); + this.loadButton.Name = "loadButton"; + this.loadButton.Size = new System.Drawing.Size(75, 23); + this.loadButton.TabIndex = 6; + this.loadButton.Text = "Load Keys"; + this.loadButton.UseVisualStyleBackColor = true; + this.loadButton.Click += new System.EventHandler(this.OnLoad); + // + // saveButton + // + this.saveButton.Location = new System.Drawing.Point(605, 434); + this.saveButton.Name = "saveButton"; + this.saveButton.Size = new System.Drawing.Size(75, 23); + this.saveButton.TabIndex = 7; + this.saveButton.Text = "Save Keys"; + this.saveButton.UseVisualStyleBackColor = true; + this.saveButton.Click += new System.EventHandler(this.OnSave); + // + // setButton + // + this.setButton.Location = new System.Drawing.Point(406, 9); + this.setButton.Name = "setButton"; + this.setButton.Size = new System.Drawing.Size(85, 23); + this.setButton.TabIndex = 8; + this.setButton.Text = "Set Key"; + this.setButton.UseVisualStyleBackColor = true; + this.setButton.Click += new System.EventHandler(this.OnSetKey); + // + // imageControl + // + this.imageControl.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.imageControl.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.imageControl.KeyHeight = 0; + this.imageControl.KeyWidth = 0; + this.imageControl.KeyX = 0; + this.imageControl.KeyY = 0; + this.imageControl.Location = new System.Drawing.Point(12, 35); + this.imageControl.MinimumSize = new System.Drawing.Size(417, 247); + this.imageControl.Name = "imageControl"; + this.imageControl.Size = new System.Drawing.Size(482, 423); + this.imageControl.TabIndex = 5; + // + // removeButton + // + this.removeButton.Location = new System.Drawing.Point(322, 9); + this.removeButton.Name = "removeButton"; + this.removeButton.Size = new System.Drawing.Size(78, 23); + this.removeButton.TabIndex = 9; + this.removeButton.Text = "Remove Key"; + this.removeButton.UseVisualStyleBackColor = true; + this.removeButton.Click += new System.EventHandler(this.OnRemoveKey); + // + // MainForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Text = "Form1"; + this.ClientSize = new System.Drawing.Size(692, 470); + this.Controls.Add(this.removeButton); + this.Controls.Add(this.setButton); + this.Controls.Add(this.saveButton); + this.Controls.Add(this.loadButton); + this.Controls.Add(this.imageControl); + this.Controls.Add(this.keysymTextBox); + this.Controls.Add(this.label2); + this.Controls.Add(this.stickyCheckBox); + this.Controls.Add(this.label1); + this.Controls.Add(this.keyList); + this.MinimumSize = new System.Drawing.Size(700, 500); + this.Name = "MainForm"; + this.Text = "Emulation Keyboard Designer"; + this.ResumeLayout(false); + this.PerformLayout(); + } #endregion + + private System.Windows.Forms.ListBox keyList; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.CheckBox stickyCheckBox; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.TextBox keysymTextBox; + private ImageControl imageControl; + private System.Windows.Forms.Button loadButton; + private System.Windows.Forms.Button saveButton; + private System.Windows.Forms.Button setButton; + private System.Windows.Forms.Button removeButton; } } diff --git a/Native/EmuKeyboardDesigner/MainForm.cs b/Native/EmuKeyboardDesigner/MainForm.cs index 8ea1502..56887ba 100644 --- a/Native/EmuKeyboardDesigner/MainForm.cs +++ b/Native/EmuKeyboardDesigner/MainForm.cs @@ -16,6 +16,7 @@ // Copyright (c) 2012 Ian Cowburn // using System; +using System.IO; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -23,6 +24,8 @@ using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; +using Noddybox.Emulation.Keyboard.Schema; +using System.Xml; namespace EmuKeyboardDesigner { @@ -32,5 +35,129 @@ namespace EmuKeyboardDesigner { InitializeComponent(); } + + private void OnSetKey(object sender, EventArgs e) + { + string sym = keysymTextBox.Text; + + if (!String.IsNullOrWhiteSpace(sym)) + { + int index = keyList.FindStringExact(sym); + + if (index > -1) + { + KeyboardKey key = (KeyboardKey)keyList.Items[index]; + + key.X = imageControl.KeyX; + key.Y = imageControl.KeyY; + key.Width = imageControl.KeyWidth; + key.Height = imageControl.KeyHeight; + key.Sticky = stickyCheckBox.Checked; + + keyList.SelectedItem = key; + } + else + { + KeyboardKey key = new KeyboardKey() + { + KeySymbol = sym, + X = imageControl.KeyX, + Y = imageControl.KeyY, + Width = imageControl.KeyWidth, + Height = imageControl.KeyHeight, + Sticky = stickyCheckBox.Checked + }; + + keyList.Items.Add(key); + keyList.SelectedItem = key; + } + } + } + + private void OnLoad(object sender, EventArgs e) + { + OpenFileDialog fsel = new OpenFileDialog(); + + fsel.Filter = "XML Files(*.XML)|*.XML"; + + if (fsel.ShowDialog() == DialogResult.OK) + { + try + { + XmlDocument xml = new XmlDocument(); + + xml.Load(fsel.FileName); + + KeyboardDefinition def = KeyboardDefinition.CreateFromXML(xml); + + keyList.Items.Clear(); + + foreach (KeyboardKey k in def.Definitions) + { + keyList.Items.Add(k); + } + + if (keyList.Items.Count > 0) + { + keyList.SelectedIndex = 0; + } + } + catch (Exception ex) + { + MessageBox.Show("Failed to load " + fsel.FileName + "\n\n" + ex.Message, ex.GetType().ToString(), MessageBoxButtons.OK); + } + } + } + + private void OnSave(object sender, EventArgs e) + { + SaveFileDialog fsel = new SaveFileDialog(); + + fsel.Filter = "XML Files(*.XML)|*.XML"; + + if (fsel.ShowDialog() == DialogResult.OK) + { + try + { + KeyboardDefinition def = new KeyboardDefinition(); + + foreach (KeyboardKey k in keyList.Items) + { + def.Definitions.Add(k); + } + + XmlDocument doc = def.CreateXML(); + + doc.Save(fsel.FileName); + } + catch (Exception ex) + { + MessageBox.Show("Failed to save " + fsel.FileName + "\n\n" + ex.Message, ex.GetType().ToString(), MessageBoxButtons.OK); + } + } + } + + private void OnKeySelected(object sender, EventArgs e) + { + if (keyList.SelectedIndex > -1) + { + KeyboardKey key = (KeyboardKey)keyList.SelectedItem; + + keysymTextBox.Text = key.KeySymbol; + imageControl.KeyX = key.X; + imageControl.KeyY = key.Y; + imageControl.KeyWidth = key.Width; + imageControl.KeyHeight = key.Height; + stickyCheckBox.Checked = key.Sticky; + } + } + + private void OnRemoveKey(object sender, EventArgs e) + { + if (keyList.SelectedIndex > -1) + { + keyList.Items.RemoveAt(keyList.SelectedIndex); + } + } } } -- cgit v1.2.3