Exemple #1
0
        static void Main(string[] args)
        {
            IElectronicDevice tv;
            var remote = TvRemote.GetDevice(DeviceType.TV);

            PowerButton pb = new PowerButton(remote);

            pb.Execute();
            pb.Execute();
            for (int i = 0; i < 30; i++)
            {
                pb.Volup();
            }
            pb.Undo();
        }
        private static void Sample2()
        {
            // We are now modeling the act of
            // picking up a remote, aiming it
            // at the TV, clicking the power
            // button and then watching as
            // the TV turns on and off

            // Pick up the TV remote
            IElectronicDevice TV = TvRemote.GetDevice();

            // Create the power button
            PowerButton powBut = new PowerButton(TV);

            // Turn the TV on and off with each
            // press
            powBut.Execute();
            TV.VolumeUp();
            powBut.Undo();
        }