private void cmbInput_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)Keys.Enter && tcMUD.SelectedTab != null) { Connection c = (Connection)conns[tcMUD.SelectedTab]; if (c == null) { return; } string command = aliases.BuildAlias(cmbInput.Text); c.SendCommand(command); cmbInput.Items.Insert(0, cmbInput.Text); while (cmbInput.Items.Count > config.HistorySize) { //too many items in the history, chop it off cmbInput.Items.RemoveAt(cmbInput.Items.Count - 1); } cmbInput.SelectAll(); e.Handled = true; } else if (e.KeyChar == (char)Keys.Escape) { int result = cmbInput.FindString(cmbInput.Text); if (result != -1) { int partial = cmbInput.Text.Length; //cmbInput.Focus(); cmbInput.Text = cmbInput.Items[result].ToString(); cmbInput.SelectionStart = partial; cmbInput.SelectionLength = cmbInput.Text.Length - partial; e.Handled = true; } } if (numPadPressed) { e.Handled = true; numPadPressed = false; } }
private void cmbInput_KeyDown(object sender, KeyEventArgs e) { if (tcMUD.SelectedTab != null) { Connection c = (Connection)conns[tcMUD.SelectedTab]; switch (e.KeyCode) { case Keys.NumPad1: { c.SendCommand("northwest"); numPadPressed = true; break; } case Keys.NumPad2: { c.SendCommand("south"); numPadPressed = true; break; } case Keys.NumPad3: { c.SendCommand("southeast"); numPadPressed = true; break; } case Keys.NumPad4: { c.SendCommand("west"); numPadPressed = true; break; } case Keys.NumPad5: { c.SendCommand("look"); numPadPressed = true; break; } case Keys.NumPad6: { c.SendCommand("east"); numPadPressed = true; break; } case Keys.NumPad7: { c.SendCommand("northwest"); numPadPressed = true; break; } case Keys.NumPad8: { c.SendCommand("north"); numPadPressed = true; break; } case Keys.NumPad9: { c.SendCommand("northeast"); numPadPressed = true; break; } } //end switch } //end if }