コード例 #1
0
        static void Main(string[] args)
        {
            ICompressionMechanism p = new Pump();

            IIndicator GreenLED = new LED("Green");
            IIndicator RedLED   = new LED("Red");
            IIndicator VMotor   = new VibrationMotor();

            var            compressionStockingstocking = new StockingCtrl(new StubCompressionCtrl(p, 5, 2, GreenLED, RedLED, VMotor));
            ConsoleKeyInfo consoleKeyInfo;

            Console.WriteLine("Compression Stocking Control User Interface");
            Console.WriteLine("A:   Compress");
            Console.WriteLine("Z:   Decompress");
            Console.WriteLine("ESC: Terminate application");

            do
            {
                consoleKeyInfo = Console.ReadKey(true); // true = do not echo character
                if (consoleKeyInfo.Key == ConsoleKey.A)
                {
                    compressionStockingstocking.StartBtnPushed();
                }
                if (consoleKeyInfo.Key == ConsoleKey.Z)
                {
                    compressionStockingstocking.StopBtnPushed();
                }
            } while (consoleKeyInfo.Key != ConsoleKey.Escape);
        }
コード例 #2
0
        static void Main(string[] args)
        {
            ConsoleKeyInfo consoleKeyInfo;

            Console.WriteLine("Compression Stocking Configuration");
            Console.WriteLine("A:   Air compression mechanism");
            Console.WriteLine("Z:   Laces compresison mechanism");
            Console.WriteLine("ESC: Terminate application");
            var configOk = false;

            // Read user input and create the applicable compression mechanism
            ICompressionMechanism compressionMechanism = null;  // Will be initiated below according to user's choice

            do
            {
                consoleKeyInfo = Console.ReadKey(true); // true = do not echo character

                if (consoleKeyInfo.Key == ConsoleKey.A)
                {
                    compressionMechanism = new AirCompressionMechanism(new Pump(), 5000, 2000);
                    configOk             = true;
                }
                if (consoleKeyInfo.Key == ConsoleKey.Z)
                {
                    compressionMechanism = new LaceCompressionMechanism(40, 100, new LaceTighteningDevice());
                    configOk             = true;
                }
                if (consoleKeyInfo.Key == ConsoleKey.Escape)
                {
                    return;
                }
            } while (!configOk);

            // Create the Stocking Controller using the factory corresponding to user's choice
            IUserOutput  userOutput   = new UserOutput(new LED(), new LED(), new Vibrator());
            StockingCtrl stockingCtrl = new StockingCtrl(compressionMechanism, userOutput);

            compressionMechanism.CompressionEventListener = stockingCtrl;   // Set up call-back receiver


            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("Compression Stocking Control User Interface");
            Console.WriteLine("A:   Compress");
            Console.WriteLine("Z:   Decompress");
            Console.WriteLine("ESC: Terminate application");

            do
            {
                consoleKeyInfo = Console.ReadKey(true); // true = do not echo character
                if (consoleKeyInfo.Key == ConsoleKey.A)
                {
                    stockingCtrl.StartBtnPushed();
                }
                if (consoleKeyInfo.Key == ConsoleKey.Z)
                {
                    stockingCtrl.StopBtnPushed();
                }
            } while (consoleKeyInfo.Key != ConsoleKey.Escape);
        }
        static void Main(string[] args)
        {
            //var comp = new StubCompressionCtrl(new Timer(), new StubPump());
            var comp = new StubLaceCompressionCtrl(new Timer(), new Lace());

            var progressListener = new CompressorProgressIndicator();

            progressListener.AddCompressionIndicator(new StubLed("GREEN"));
            progressListener.AddDecompressionIndicator(new StubLed("RED"));
            progressListener.AddCompressionIndicator(new StubVibrate());
            progressListener.AddDecompressionIndicator(new StubVibrate());

            comp.SetCompressionProgressListener(progressListener);
            var            compressionStockingstocking = new StockingCtrl(comp, comp);
            ConsoleKeyInfo consoleKeyInfo;

            Console.WriteLine("Compression Stocking Control User Interface");
            Console.WriteLine("A:   Compress");
            Console.WriteLine("Z:   Decompress");
            Console.WriteLine("ESC: Terminate application");

            do
            {
                consoleKeyInfo = Console.ReadKey(true); // true = do not echo character
                if (consoleKeyInfo.Key == ConsoleKey.A)
                {
                    compressionStockingstocking.StartCompression();
                }
                if (consoleKeyInfo.Key == ConsoleKey.Z)
                {
                    compressionStockingstocking.StartDecompression();
                }
            } while (consoleKeyInfo.Key != ConsoleKey.Escape);
        }
コード例 #4
0
        static void Main(string[] args)
        {
            var compressionStockingstocking = new StockingCtrl(new RealCompressionCtrl(new LaceCompression(),
                                                                                       new ColorLed("GREEN"),
                                                                                       new ColorLed("RED"),
                                                                                       new VibrateDevice()));
            ConsoleKeyInfo consoleKeyInfo;

            Console.WriteLine("Compression Stocking Control User Interface");
            Console.WriteLine("A:   Compress");
            Console.WriteLine("Z:   Decompress");
            Console.WriteLine("ESC: Terminate application");

            do
            {
                consoleKeyInfo = Console.ReadKey(true); // true = do not echo character
                if (consoleKeyInfo.Key == ConsoleKey.A)
                {
                    compressionStockingstocking.StartBtnPushed();
                }
                if (consoleKeyInfo.Key == ConsoleKey.Z)
                {
                    compressionStockingstocking.StopBtnPushed();
                }
            } while (consoleKeyInfo.Key != ConsoleKey.Escape);
        }
コード例 #5
0
        static void Main(string[] args)
        {
            IStocking        stocking                    = new Stocking();
            ICompressionCtrl compressionCtrl             = new PumpCompressionCtrl(stocking);
            IBtnHandler      compressionStockingstocking = new StockingCtrl(compressionCtrl);
            ConsoleKeyInfo   consoleKeyInfo;

            Console.WriteLine("Compression Stocking Control User Interface");
            Console.WriteLine("A:   Compress");
            Console.WriteLine("Z:   Decompress");
            Console.WriteLine("ESC: Terminate application");

            do
            {
                consoleKeyInfo = Console.ReadKey(true); // true = do not echo character
                if (consoleKeyInfo.Key == ConsoleKey.A)
                {
                    compressionStockingstocking.StartBtnPushed();
                }
                if (consoleKeyInfo.Key == ConsoleKey.Z)
                {
                    compressionStockingstocking.StopBtnPushed();
                }
            } while (consoleKeyInfo.Key != ConsoleKey.Escape);
        }
コード例 #6
0
        static void Main(string[] args)
        {
            ConsoleKeyInfo consoleKeyInfo;
            ICompressionStockingFactory factory = null;

            Console.WriteLine("Compression Stocking Configuration");
            Console.WriteLine("A:   Air compression mechanism");
            Console.WriteLine("Z:   Laces compresison mechanism");
            Console.WriteLine("ESC: Terminate application");
            var configOk = false;

            do
            {
                consoleKeyInfo = Console.ReadKey(true); // true = do not echo character

                // Create the correct kind of factory
                if (consoleKeyInfo.Key == ConsoleKey.A)
                {
                    factory  = new AirCompressionStockingFactory();
                    configOk = true;
                }
                if (consoleKeyInfo.Key == ConsoleKey.Z)
                {
                    factory  = new LaceCompressionStockingFactory();
                    configOk = true;
                }
            } while (!configOk);

            // Create the Stocking Controller using the factory corresponding to user's choice
            var stockingCtrl = new StockingCtrl(factory);

            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("Compression Stocking Control User Interface");
            Console.WriteLine("A:   Compress");
            Console.WriteLine("Z:   Decompress");
            Console.WriteLine("ESC: Terminate application");

            do
            {
                consoleKeyInfo = Console.ReadKey(true); // true = do not echo character
                if (consoleKeyInfo.Key == ConsoleKey.A)
                {
                    stockingCtrl.StartBtnPushed();
                }
                if (consoleKeyInfo.Key == ConsoleKey.Z)
                {
                    stockingCtrl.StopBtnPushed();
                }
            } while (consoleKeyInfo.Key != ConsoleKey.Escape);
        }
        static void Main(string[] args)
        {
            IPump  Pump_      = new Pump();
            ITimer Timer_     = new Timer();
            IPump  Pump_Lace  = new Lace();
            ITimer Timer_lace = new LaceTimer();

            IFeatures GreenLED = new LED("Green");
            IFeatures RedLED   = new LED("Red");
            IFeatures VDevice  = new VibratingDevice();

            var compressionStockingstocking      = new StockingCtrl(new CompressionCtrl(Pump_, Timer_, GreenLED, RedLED, VDevice));
            var compressionStockingstocking_Lace = new StockingCtrl(new CompressionCtrl(Pump_Lace, Timer_lace, GreenLED, RedLED, VDevice));

            ConsoleKeyInfo consoleKeyInfo;



            Console.WriteLine("Compression Stocking Control User Interface");
            Console.WriteLine("A:   Compress");
            Console.WriteLine("Z:   Decompress");
            Console.WriteLine("P:   Pump");
            Console.WriteLine("L:   Lace");
            Console.WriteLine("ESC: Terminate application");

            StockingCtrl Pumpy = compressionStockingstocking;

            do
            {
                consoleKeyInfo = Console.ReadKey(true); // true = do not echo character
                if (consoleKeyInfo.Key == ConsoleKey.P)
                {
                    Pumpy = compressionStockingstocking;
                }
                if (consoleKeyInfo.Key == ConsoleKey.L)
                {
                    Pumpy = compressionStockingstocking_Lace;
                }
                if (consoleKeyInfo.Key == ConsoleKey.A)
                {
                    Pumpy.StartBtnPushed();
                }
                if (consoleKeyInfo.Key == ConsoleKey.Z)
                {
                    Pumpy.StopBtnPushed();
                }
            } while (consoleKeyInfo.Key != ConsoleKey.Escape);
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: joachimda/I4SWD
        static void Main(string[] args)
        {
            IPump            myPump            = new Pump();
            ITightner        myTightner        = new Tightner();
            ICompressionCtrl myCompressionCtrl = new LaceCompressionCtrl(myTightner);

            INotificationDevice myGreenLed     = new LedGreen();
            INotificationDevice myReDevice     = new LedRed();
            INotificationDevice myVibrator     = new Vibrator();
            INotification       myNotification = new Notification(myGreenLed, myReDevice, myVibrator);

            IButtonHandler           myStockingCtrl = new StockingCtrl(myCompressionCtrl, myNotification);
            ICompressionEventHandler myEventHandler = new StockingCtrl(myCompressionCtrl, myNotification);

            myCompressionCtrl.AddNotificationCenter(myEventHandler);

            ConsoleKeyInfo consoleKeyInfo;

            Console.WriteLine("Compression Stocking Control User Interface");
            Console.WriteLine("A:   Compress");
            Console.WriteLine("Z:   Decompress");
            Console.WriteLine("ESC: Terminate application");

            do
            {
                consoleKeyInfo = Console.ReadKey(true); // true = do not echo character

                if (consoleKeyInfo.Key == ConsoleKey.A)
                {
                    myStockingCtrl.StartButtonPushed();
                }

                if (consoleKeyInfo.Key == ConsoleKey.Z)
                {
                    myStockingCtrl.StopButtonPushed();
                }
            } while (consoleKeyInfo.Key != ConsoleKey.Escape);
        }