Ejemplo n.º 1
0
        private void tvButton_Click(object sender, EventArgs e)
        {
            if (this.tvButton.BackColor != Color.Green)
            {
                //creare iteme ad-hoc.
                //Aceasta functionalitate este implementata cu OpenCloseItem
                //  metoda care faciliteaza crearea de obiecte noi si integrarea acestora
                //  in design pattern-ul command. Acestea impartasesc aceleasi metode
                //  ItemClose si ItemOpen care au la baza un obiect de tipul OpenCloseItem
                //  la restul claselor putem adauga metode particulare -> speaker/stereo
                OpenCloseItem television = new OpenCloseItem("Televizorul");

                this.command = new ItemOpenCommand(television);
                setCommandAndPress(command);

                this.tvButton.BackColor = Color.Green;
                myStack.Push(command);
            }
            else if (this.tvButton.BackColor == Color.Green)
            {
                OpenCloseItem television = new OpenCloseItem("Televizorul");
                this.command = new ItemCloseCommand(television);
                setCommandAndPress(command);
                this.tvButton.BackColor = Color.Red;
                myStack.Push(command);
            }
        }
Ejemplo n.º 2
0
 private void gatesButton_Click(object sender, EventArgs e)
 {
     if (this.gatesButton.BackColor != Color.Green)
     {
         OpenCloseItem gate = new OpenCloseItem("Poarta");
         this.command = new ItemOpenCommand(gate);
         setCommandAndPress(command);
         this.gatesButton.BackColor = Color.Green;
         myStack.Push(command);
     }
     else if (this.gatesButton.BackColor == Color.Green)
     {
         OpenCloseItem gate = new OpenCloseItem("Poarta");
         this.command = new ItemCloseCommand(gate);
         setCommandAndPress(command);
         this.gatesButton.BackColor = Color.Red;
         myStack.Push(command);
     }
 }
Ejemplo n.º 3
0
 private void windowsButton_Click(object sender, EventArgs e)
 {
     if (this.windowsButton.BackColor != Color.Green)
     {
         OpenCloseItem window = new OpenCloseItem("Geamul");
         this.command = new ItemOpenCommand(window);
         setCommandAndPress(command);
         this.windowsButton.BackColor = Color.Green;
         myStack.Push(command);
     }
     else if (this.windowsButton.BackColor == Color.Green)
     {
         OpenCloseItem window = new OpenCloseItem("Geamul");
         this.command = new ItemCloseCommand(window);
         setCommandAndPress(command);
         this.windowsButton.BackColor = Color.Red;
         myStack.Push(command);
     }
 }
Ejemplo n.º 4
0
 public ItemOpenCommand(OpenCloseItem item)
 {
     this.item = item;
 }