Exemple #1
0
        static void Main(string[] args)
        {
            PrinterManager pm = new PrinterManager();

            pm.OnPrinted += OnPrinted;
            pm.Create("myPrinter", "QWERT");
            EpsonPrinter ep = new EpsonPrinter("asdfg");
            CanonPrinter cp = new CanonPrinter("tukufgxcd");

            pm.Add(ep);
            pm.Add(cp);

            while (true)
            {
                System.Console.WriteLine("Select your choice:");
                System.Console.WriteLine("1:Add new printer");
                System.Console.WriteLine("2:Remove printer");
                System.Console.WriteLine("3:Show printers");
                System.Console.WriteLine("Esc to exit");

                var key = System.Console.ReadKey();

                if (key.Key == ConsoleKey.D1)
                {
                    string name = CreateTask("Write name");
                    pm.Create(name, CreateTask("Write model"));
                }

                if (key.Key == ConsoleKey.D2)
                {
                    string name = CreateTask("Write name");
                    pm.Remove(pm.GetPrinter(name, CreateTask("Write model")));
                }

                if (key.Key == ConsoleKey.D3)
                {
                    ShowPrintersSection(pm);
                }

                if (key.Key == ConsoleKey.Escape)
                {
                    break;
                }
            }

            pm.Log("\n\n");
        }