From 0232442759a7bc0254e1bc2afa852df448f09cb8 Mon Sep 17 00:00:00 2001 From: Ian C Date: Sun, 29 Apr 2012 18:14:59 +0000 Subject: Now save key when selection changes, and keep selection after remove. --- Native/EmuKeyboardDesigner/EmuKeyboardDesigner.suo | Bin 50176 -> 50176 bytes Native/EmuKeyboardDesigner/MainForm.cs | 30 ++++++++++++++++++--- 2 files changed, 26 insertions(+), 4 deletions(-) (limited to 'Native/EmuKeyboardDesigner') diff --git a/Native/EmuKeyboardDesigner/EmuKeyboardDesigner.suo b/Native/EmuKeyboardDesigner/EmuKeyboardDesigner.suo index 0619df7..aa47a7d 100644 Binary files a/Native/EmuKeyboardDesigner/EmuKeyboardDesigner.suo and b/Native/EmuKeyboardDesigner/EmuKeyboardDesigner.suo 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; + } } } } -- cgit v1.2.3