Example #1
0
        private void textBoxText_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                var cmd = textBoxText.Text;
                textBoxText.Text = "";
                if (cmd == "connect")
                {
                    DoConnect();
                    return;
                }
                if (this.client.State != SocketState.Connected)
                {
                    this.Log("请先连接网络");
                    return;
                }

                DoSend(cmd);
            }
            else if (e.KeyCode == Keys.Up)
            {
                string str;
                if (CommandHistory.TryLoadFormer(out str))
                {
                    textBoxText.Text = str;
                }
            }
            else if (e.KeyCode == Keys.Down)
            {
                string str;
                if (CommandHistory.TryLoadLatter(out str))
                {
                    textBoxText.Text = str;
                }
            }
            if (e.KeyCode == Keys.Tab)
            {
                var hintResult = AutoComplete.GetHint(textBeforeHint, textHintIndex++);
                if (hintResult != "")
                {
                    isAutoComplete             = true;
                    textBoxText.Text           = hintResult;
                    textBoxText.SelectionStart = textBoxText.Text.Length;
                    isAutoComplete             = false;
                }

                e.Handled = true;
            }
        }