public void Add(BasePrinter basePrinter)
        {
            if (ReferenceEquals(basePrinter, null))
            {
                throw new ArgumentNullException(nameof(basePrinter));
            }

            Console.WriteLine("Enter printer name and model");
            basePrinter.Name  = Console.ReadLine();
            basePrinter.Model = Console.ReadLine();

            if (!Printers.Contains(basePrinter))
            {
                Printers.Add(basePrinter);
                Console.WriteLine("Printer added");
            }
        }
Exemple #2
0
        /// <summary>
        /// Print data in printer
        /// </summary>
        /// <param name="printer"></param>
        private static void Print(BasePrinter printer)
        {
            try
            {
                using (var dialog = new OpenFileDialog())
                {
                    dialog.ShowDialog();
                    using (var fileStream = File.OpenRead(dialog.FileName))
                    {
                        printer.Print(fileStream);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                GetMenu();
            }

            GetMenu();
        }
        public void Print(BasePrinter basePrinter, ILogger logger)
        {
            if (ReferenceEquals(basePrinter, null))
            {
                throw new ArgumentNullException(nameof(basePrinter));
            }

            if (ReferenceEquals(logger, null))
            {
                throw new ArgumentNullException(nameof(logger));
            }

            Logger = logger;

            Logger?.Info("Print started");
            var o = new OpenFileDialog();

            o.ShowDialog();
            var f = File.OpenRead(o.FileName);

            basePrinter.Print(f);
            Logger?.Info("Print finished");
        }
 private void Print(BasePrinter epsonPrinter)
 {
     PrinterManager.Print(epsonPrinter, logger);
     logger.Info("Printed on Epson");
 }