private void Game_KeyUp(object sender, KeyEventArgs e) { if (!_choiceControl.Focused) { Keys pressedKey = e.KeyCode; if (pressedKey >= Keys.D1 && pressedKey < Keys.D9) { MultiChooseControl multiControl = _choiceControl as MultiChooseControl; if (multiControl == null) { return; } int order = pressedKey - Keys.D0; multiControl.InvokeClickHandlerByOrder(order); } } }
/// <summary> /// Initialize multi-choice buttons. /// </summary> /// <param name="choices"></param> private void InitializeMultiChoice(IList <string> choices) { if (_choiceControl != null) { choicePanel.Controls.Remove(_choiceControl); _choiceControl.Dispose(); } var control = new MultiChooseControl(choices) { Dock = DockStyle.Fill }; control.Chosen += (sender, s) => OnChoice(s); control.Dock = DockStyle.Fill; choicePanel.Controls.Add(control); _choiceControl = control; }