summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2012-04-29 18:14:59 +0000
committerIan C <ianc@noddybox.co.uk>2012-04-29 18:14:59 +0000
commit0232442759a7bc0254e1bc2afa852df448f09cb8 (patch)
treece73d834e465f436e8df94ed2fc4271d57f68ad3
parent6b9f0d6bd993eed988a643918103099d8d021327 (diff)
Now save key when selection changes, and keep selection after remove.
-rw-r--r--Native/EmuKeyboardDesigner/EmuKeyboardDesigner.suobin50176 -> 50176 bytes
-rw-r--r--Native/EmuKeyboardDesigner/MainForm.cs30
2 files changed, 26 insertions, 4 deletions
diff --git a/Native/EmuKeyboardDesigner/EmuKeyboardDesigner.suo b/Native/EmuKeyboardDesigner/EmuKeyboardDesigner.suo
index 0619df7..aa47a7d 100644
--- a/Native/EmuKeyboardDesigner/EmuKeyboardDesigner.suo
+++ b/Native/EmuKeyboardDesigner/EmuKeyboardDesigner.suo
Binary files differ
diff --git a/Native/EmuKeyboardDesigner/MainForm.cs b/Native/EmuKeyboardDesigner/MainForm.cs
index 56887ba..36144b9 100644
--- a/Native/EmuKeyboardDesigner/MainForm.cs
+++ b/Native/EmuKeyboardDesigner/MainForm.cs
@@ -36,7 +36,7 @@ namespace EmuKeyboardDesigner
InitializeComponent();
}
- private void OnSetKey(object sender, EventArgs e)
+ private void SetKey(bool select, bool allowNew)
{
string sym = keysymTextBox.Text;
@@ -54,9 +54,12 @@ namespace EmuKeyboardDesigner
key.Height = imageControl.KeyHeight;
key.Sticky = stickyCheckBox.Checked;
- keyList.SelectedItem = key;
+ if (select)
+ {
+ keyList.SelectedItem = key;
+ }
}
- else
+ else if (allowNew)
{
KeyboardKey key = new KeyboardKey()
{
@@ -74,6 +77,11 @@ namespace EmuKeyboardDesigner
}
}
+ private void OnSetKey(object sender, EventArgs e)
+ {
+ SetKey(true, true);
+ }
+
private void OnLoad(object sender, EventArgs e)
{
OpenFileDialog fsel = new OpenFileDialog();
@@ -141,6 +149,8 @@ namespace EmuKeyboardDesigner
{
if (keyList.SelectedIndex > -1)
{
+ SetKey(false, false);
+
KeyboardKey key = (KeyboardKey)keyList.SelectedItem;
keysymTextBox.Text = key.KeySymbol;
@@ -156,7 +166,19 @@ namespace EmuKeyboardDesigner
{
if (keyList.SelectedIndex > -1)
{
- keyList.Items.RemoveAt(keyList.SelectedIndex);
+ int index = keyList.SelectedIndex;
+
+ keyList.Items.RemoveAt(index);
+
+ if (index > keyList.Items.Count - 1)
+ {
+ index--;
+ }
+
+ if (index > -1)
+ {
+ keyList.SelectedIndex = index;
+ }
}
}
}