static void Main(string[] args) { PrinterBase printer; try { printer = PrinterManager.GetPrinter("Star TUP900 Presenter (TUP992)"); // Use the following lines to manually specify the printer type // printer = PrinterManager.GetPrinter("Star TUP900 Presenter (TUP992)", PrinterType.TUP900); // printer = PrinterManager.GetPrinter("NII ExD NP-K205", PrinterType.Nii); } catch (InvalidOperationException) { Console.WriteLine("The printer type could not be guessed, please specify it manually."); Console.ReadKey(); return; } var printerStatus = printer.GetStatus(); WritePrinterStatus(printerStatus); // To get notified whenever the status of the printer changes, subscribe to the PrinterStatusChanged event. // printer.PrinterStatusChanged += Printer_PrinterStatusChanged; // printer.StartPoolingStatus(); // Prints a text, feeds 5 lines, and then cuts the paper printer.Print("Hello world"); printer.FeedLines(5); printer.CutPaper(CutPaperType.Full); Console.ReadKey(); }
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"); }
public ConfigurationModule(ConfigurationManager configurationManager, PrinterManager printerManager, UserManager userManager) : base("config") { this.RequiresMSOwinAuthentication(); Get["/printers"] = p => printerManager.GetPrinters(); Get["/printers/{id:int}"] = p => printerManager.GetPrinter(p.id); Put["/printers", true] = async(p, ct) => await printerManager.CreatePrinter(this.Bind <Printer>()); Post["/printers", true] = async(p, ct) => await printerManager.UpdatePrinter(this.Bind <Printer>()); Delete["/printers/{id:int}"] = p => this.Ok((Action)(() => printerManager.DeletePrinter(p.id))); Get["/settings/bundle"] = p => new { Printers = printerManager.GetPrinters(), Users = userManager.GetUsers(), Settings = configurationManager.GetApplicationSettings() }; Get["/settings"] = p => configurationManager.GetApplicationSettings(); Post["/settings"] = p => configurationManager.UpdateApplicationSettings(this.Bind <ApplicationSettings>()); Get["/users"] = p => userManager.GetUsers(); Get["/users/{id:int}"] = p => userManager.GetUser(p.id); Put["/users"] = p => { var model = this.Bind <UserAuthentication>(); return(userManager.CreateUser(model.Username, model.Password, model.SessionLifetime)); }; Post["/users"] = p => userManager.UpdateUser(this.Bind <UserAuthentication>()); Delete["/users/{id:int}"] = p => this.Ok((Action)(() => userManager.DeleteUser(p.id))); Put["/certificate"] = p => this.Ok(() => configurationManager.AddCertificateException(this.Bind <CertificateException>())); Get["/about"] = p => AppInfo.Instance; }