/// <summary> /// Iterpreter client context /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button5_Click(object sender, EventArgs e) { Context ctx = new Context(textBox1.Text.ToString().ToLower()); string context = textBox1.Text.ToString().ToLower(); AbstractExpression background = new TerminalExpression("background"); AbstractExpression operation = new TerminalExpression("color"); if (ctx.Input.Length == 0) { textBox1.ForeColor = Color.Red; textBox1.Text = "Bad Command!"; textBox1.ForeColor = Color.Black; } else { AbstractExpression command = new BackGroundColorExpression(background, operation, _Form1); if (command.Interpreter(ctx.Input)) { textBox1.Text = string.Empty; } else { textBox1.Text = "Bad Command!"; } } caretaker.Backup(); originator.SetState(_Form1.BackColor.Name); }
private void button3_Click(object sender, EventArgs e) { AbstractExpression background = new TerminalExpression("background"); AbstractExpression operation = new TerminalExpression("color"); AbstractExpression command = new BackGroundColorExpression(background, operation, _Form1); caretaker.Undo(); string context = "background color " + originator.State; command.Interpreter(context); commandLogger.logMessage(AbstractLogger.COMMAND, "\nBackground color restored to: " + originator.State); //richTextBox1.AppendText("\nBackground color restored to: "+originator.State ); }