示例#1
0
        private void textBox1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Escape)
            {
                e.Handled          = true;
                e.SuppressKeyPress = true;
                this.Visible       = false;
                return;
            }
            if (e.KeyCode != Keys.Enter)
            {
                return;
            }

            string text = textBox1.Text;

            textBox1.Text = "";

            var message = new MyCommand(this).ParseAndExecute(text);

            if (message.IsError)
            {
                prettierLabel1.Text2 = ColorConsole.ClearColors(message.GetMessage());
            }
            else
            {
                prettierLabel1.Text2 = "";
            }

            if (text == MyCommand.BREAK_COMMAND || text == MyCommand.WORK_COMMAND)
            {
                player.Open("start.mp3");
                player.Play();
            }

            e.Handled          = true;
            e.SuppressKeyPress = true;
        }