Пример #1
0
        static void RemoteControlTestMacro()
        {
            RemoteControl remoteControl = new RemoteControl();

            Light                 livingRoomLight    = new Light("Living Room");
            CeilingFan            ceilingFan         = new CeilingFan("Living Room");
            Stereo                stereo             = new Stereo("Living Room");
            LightOnCommand        livingRoomLightOn  = new LightOnCommand(livingRoomLight);
            LightOffCommand       livingRoomLightOff = new LightOffCommand(livingRoomLight);
            CeilingFanHighCommand ceilingFanOn       = new CeilingFanHighCommand(ceilingFan);
            CeilingFanOffCommand  ceilingFanOff      = new CeilingFanOffCommand(ceilingFan);
            StereoOnWithCdCommand stereoOnWithCd     = new StereoOnWithCdCommand(stereo);
            StereoOffCommand      stereoOff          = new StereoOffCommand(stereo);

            ICommand[] partyOn  = { livingRoomLightOn, ceilingFanOn, stereoOnWithCd };
            ICommand[] partyOff = { livingRoomLightOff, ceilingFanOff, stereoOff };

            MacroCommand partyOnMacro  = new MacroCommand(partyOn);
            MacroCommand partyOffMacro = new MacroCommand(partyOff);

            remoteControl.SetCommand(0, partyOnMacro, partyOffMacro);

            Console.WriteLine(remoteControl);

            remoteControl.OnButtonWasPushed(0);
            remoteControl.UndoButtonWasPushed();
            Console.WriteLine(remoteControl);

            remoteControl.OnButtonWasPushed(0);
            remoteControl.OffButtonWasPushed(0);
            Console.WriteLine(remoteControl);
        }
Пример #2
0
 /// <summary>
 /// Start this service.
 /// </summary>
 protected override void OnStart(string[] args)
 {
     // TODO: Add start code here (if required) to start your service.
     //			eventLog.WriteEntry("In OnStart");
     //			inter.addApp(new Application("uTorrent",@"C:\Users\scott\AppData\Roaming\uTorrent\uTorrent.exe"));
     rc = new RemoteControl();
 }
Пример #3
0
        /// <summary>
        /// This method starts the service.
        /// </summary>
        static void Main()
        {
            // To run more than one service you have to add them here
            //ServiceBase.Run(new ServiceBase[] { new RemoteControlService() });

            XmlWrapper xml = new XmlWrapper("apps.xml");

            rc = new RemoteControl(xml.getApps());
            //Thread.Sleep(10000);
            //rc.stop();
            SetConsoleCtrlHandler(new HandlerRoutine(Handler), true);//new EventHandler(Handler);

            while(true){}
        }
        private static void Main(string[] args)
        {
            RemoteControl remote = new RemoteControl();

            // create devices
            Light      livingRoomLight = new Light("Living Room");
            Light      kitchenLight    = new Light("Kitchen");
            CeilingFan ceilingFan      = new CeilingFan("Living Room");
            GarageDoor garageDoor      = new GarageDoor();
            Stereo     stereo          = new Stereo("Living Room");

            // light commands
            LightOnCommand  livingRoomLightOn  = new LightOnCommand(livingRoomLight);
            LightOffCommand livingRoomLightOff = new LightOffCommand(livingRoomLight);
            LightOnCommand  kitchenLightOn     = new LightOnCommand(kitchenLight);
            LightOffCommand kitchenLightOff    = new LightOffCommand(kitchenLight);

            // fan commands
            CeilingFanOnOrChangeSpeedCommand ceilingFanOn  = new CeilingFanOnOrChangeSpeedCommand(ceilingFan);
            CeilingFanOffCommand             ceilingFanOff = new CeilingFanOffCommand(ceilingFan);

            // garage commands
            GarageDoorOpenCommand  garageDoorOpen  = new GarageDoorOpenCommand(garageDoor);
            GarageDoorCloseCommand garageDoorClose = new GarageDoorCloseCommand(garageDoor);

            // stereo commands
            StereoOnToCDCommand stereoOn  = new StereoOnToCDCommand(stereo);
            StereoOffCommand    stereoOff = new StereoOffCommand(stereo);

            // assign commands to slots
            remote.SetCommand(0, livingRoomLightOn, livingRoomLightOff);
            remote.SetCommand(1, kitchenLightOn, kitchenLightOff);
            remote.SetCommand(2, ceilingFanOn, ceilingFanOff);
            remote.SetCommand(3, stereoOn, stereoOff);

            // print current remote state
            Console.WriteLine(remote);

            // test button presses
            remote.OnButtonWasPushed(0);
            remote.OffButtonWasPushed(0);
            remote.OnButtonWasPushed(1);
            remote.OffButtonWasPushed(1);
            remote.OnButtonWasPushed(2);
            remote.OffButtonWasPushed(2);
            remote.OnButtonWasPushed(3);
            remote.OffButtonWasPushed(3);
        }
Пример #5
0
        /// <summary>
        /// This method starts the service.
        /// </summary>
        static void Main()
        {
            // To run more than one service you have to add them here
            //ServiceBase.Run(new ServiceBase[] { new RemoteControlService() });

            XmlWrapper xml = new XmlWrapper("apps.xml");

            rc = new RemoteControl(xml.getApps());
            //Thread.Sleep(10000);
            //rc.stop();
            SetConsoleCtrlHandler(new HandlerRoutine(Handler), true);            //new EventHandler(Handler);

            while (true)
            {
            }
        }
Пример #6
0
        static void RemoteControlTest()
        {
            RemoteControl remoteControl = new RemoteControl();

            Light      livingRoomLight = new Light("Living Room");
            Light      kitchenLight    = new Light("Kitchen");
            CeilingFan ceilingFan      = new CeilingFan("Living Room");
            GarageDoor garageDoor      = new GarageDoor();
            Stereo     stereo          = new Stereo("Living Room");

            LightOnCommand  livingRoomLightOn  = new LightOnCommand(livingRoomLight);
            LightOffCommand livingRoomLightOff = new LightOffCommand(livingRoomLight);
            LightOnCommand  kitchenLightOn     = new LightOnCommand(kitchenLight);
            LightOffCommand kitchenLightOff    = new LightOffCommand(kitchenLight);

            CeilingFanHighCommand ceilingFanOn  = new CeilingFanHighCommand(ceilingFan);
            CeilingFanOffCommand  ceilingFanOff = new CeilingFanOffCommand(ceilingFan);

            GarageDoorUpCommand   garageDoorUp   = new GarageDoorUpCommand(garageDoor);
            GarageDoorDownCommand garageDoorDown = new GarageDoorDownCommand(garageDoor);

            StereoOnWithCdCommand stereoOnWithCd = new StereoOnWithCdCommand(stereo);
            StereoOffCommand      stereoOff      = new StereoOffCommand(stereo);

            remoteControl.SetCommand(0, livingRoomLightOn, livingRoomLightOff);
            remoteControl.SetCommand(1, kitchenLightOn, kitchenLightOff);
            remoteControl.SetCommand(2, ceilingFanOn, ceilingFanOff);
            remoteControl.SetCommand(3, stereoOnWithCd, stereoOff);
            remoteControl.SetCommand(4, garageDoorUp, garageDoorDown);

            Console.WriteLine(remoteControl);

            remoteControl.OnButtonWasPushed(0);
            remoteControl.OffButtonWasPushed(0);
            Console.WriteLine(remoteControl);
            remoteControl.OnButtonWasPushed(1);
            remoteControl.OffButtonWasPushed(1);
            remoteControl.OnButtonWasPushed(2);
            remoteControl.UndoButtonWasPushed();
            Console.WriteLine(remoteControl);
            remoteControl.UndoButtonWasPushed();
            remoteControl.OffButtonWasPushed(2);
            remoteControl.OnButtonWasPushed(3);
            remoteControl.OffButtonWasPushed(3);
            remoteControl.OnButtonWasPushed(4);
            remoteControl.OffButtonWasPushed(4);
        }
Пример #7
0
        static void RemoteControlTestCeilingFan()
        {
            RemoteControl remoteControl = new RemoteControl();

            CeilingFan ceilingFan = new CeilingFan("Living Room");
            CeilingFanMediumCommand ceilingFanMedium = new CeilingFanMediumCommand(ceilingFan);
            CeilingFanHighCommand   ceilingFanHigh   = new CeilingFanHighCommand(ceilingFan);
            CeilingFanOffCommand    ceilingFanOff    = new CeilingFanOffCommand(ceilingFan);

            remoteControl.SetCommand(0, ceilingFanMedium, ceilingFanOff);
            remoteControl.SetCommand(1, ceilingFanHigh, ceilingFanOff);

            remoteControl.OnButtonWasPushed(0);
            remoteControl.OffButtonWasPushed(0);
            Console.WriteLine(remoteControl);
            remoteControl.UndoButtonWasPushed();

            remoteControl.OnButtonWasPushed(1);
            Console.WriteLine(remoteControl);
            remoteControl.UndoButtonWasPushed();
        }