public override void OnKeyDown(KeyEventArgs e) { var allowToolSelection = true; if (SelectedTool != null) { SelectedTool.OnKeyDown(e); allowToolSelection = SelectedTool.AllowToolShortcuts; } if (!e.Handled && allowToolSelection) { foreach (var tool in Tools) { if (e.KeyData == tool.Accelerator && tool != SelectedTool) { SelectedTool = tool; e.Handled = true; break; } } } if (!e.Handled) { base.OnKeyDown(e); } }
public override void OnKeyDown(KeyEventArgs e) { base.OnKeyDown(e); if (e.Handled) { return; } //Console.WriteLine("Pressed {0}", e.KeyData.ToString()); if (AllowEditing) { if (!e.Handled && AllowToolSelection) { foreach (var tool in Tools) { if (e.KeyData == tool.Accelerator && tool != SelectedTool) { SelectedTool = tool; e.Handled = true; break; } } } if (!e.Handled && SelectedTool != null) { SelectedTool.OnKeyDown(e); } if (!e.Handled && AllowKeyboardEditing && e.IsChar) { byte[] bytes = CurrentPage.Font.Encoding.GetBytes(new char[] { e.KeyChar }); byte b = bytes[0]; if (b < CurrentPage.Font.NumChars) { InsertCharacter(b); e.Handled = true; } } } }