示例#1
0
 private void speakersButton_Click(object sender, EventArgs e)
 {
     if (this.speakersButton.BackColor != Color.Green)
     {
         Stereo stereo = new Stereo();
         this.command = new StereoOnWithCDCommand(stereo);
         setCommandAndPress(command);
         this.speakersButton.BackColor = Color.Green;
         myStack.Push(command);
     }
     else if (this.speakersButton.BackColor == Color.Green)
     {
         Stereo stereo = new Stereo();
         this.command = new StereoOffCommand(stereo);
         setCommandAndPress(command);
         this.speakersButton.BackColor = Color.Red;
         myStack.Push(command);
     }
 }
 public StereoOffCommand(Stereo stereo)
 {
     this.stereo = stereo;
 }
 public StereoOnWithCDCommand(Stereo stereo)
 {
     this.stereo = stereo;
 }