public ActionResult Print(Guid?id, bool Print = false) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Item item = db.Items.Find(id); if (item == null) { return(HttpNotFound()); } if (Print) { //<input type="file" accept="image/*" capture="camera"> <--- Awesome! Printers x = new Printers(); var printer = x.First(); ILabel label = Label.Open("barcode.label"); label.SetObjectText("BARCODE", item.NonExclusiveRef); label.Print(printer); return(RedirectToAction("Index")); // printed } else { return(View(item)); } }
public FrmBadges() { InitializeComponent(); DoRefresh(); _checkTimer = new System.Threading.Timer(delegate { try { if (_closing) { return; } var printers = new Printers(); if (printers.Any()) { if (printers.First().IsConnected) { LblStatus.Invoke(new MethodInvoker(delegate { LblStatus.ForeColor = System.Drawing.Color.DarkGreen; LblStatus.Text = "Connected"; })); } else { LblStatus.Invoke(new MethodInvoker(delegate { LblStatus.ForeColor = System.Drawing.Color.Red; LblStatus.Text = "Disconnected"; })); } } else { LblStatus.Invoke(new MethodInvoker(delegate { LblStatus.ForeColor = System.Drawing.Color.Red; LblStatus.Text = "Disconnected"; })); } } catch { try { LblStatus.Invoke(new MethodInvoker(delegate { LblStatus.ForeColor = System.Drawing.Color.Red; LblStatus.Text = "Error (No Drivers?)"; })); } catch { } } }, null, 0, 1000); }
private void button4_Click(object sender, EventArgs e) { Printers x = new Printers(); var printer = x.First(); ILabel label = DYMO.Label.Framework.Label.Open("barcode.label"); label.SetObjectText("BARCODE", Item.Id); label.Print(printer); }
public virtual void InitializeProperties() { try { Printers = PrintUtility.GetPrinters(); SetLocalPrinter(); var defaultPrintQueue = PrintUtility.GetDefaultPrintQueue(string.Empty); IsMarkPageNumbers = true; var defaultPrinterFullName = defaultPrintQueue.FullName; var defaultExists = false; foreach (var printer in Printers) { if (printer.Name == defaultPrintQueue.Name) { defaultExists = true; break; } } if (!defaultExists) { Printers.Add(defaultPrintQueue); var temp = Printers; Printers = null; Printers = temp; } CurrentPrinterName = defaultPrinterFullName; CurrentPrinter = Printers.First(e => e.FullName == defaultPrinterFullName); PrintOptionsSetterIsEnable(false); SetPrintError(false); var userPrintTicket = PrintUtility.GetUserPrintTicket(CurrentPrinter.FullName); if (userPrintTicket != null) { CurrentPrinter.UserPrintTicket = userPrintTicket; } SetCurrentPaper(CurrentPrinter.UserPrintTicket.PageMediaSize); SetPageOrientation(CurrentPrinter.UserPrintTicket.PageOrientation); ExecuteSetPrintingOptions(false); } catch (Exception ex) { SetPrintError(true); } }
private void button1_Click(object sender, EventArgs e) { // "85fdbd26-0a86-4ce4-944c-14b5546e7283" var key = Guid.NewGuid().ToString().ToUpper().Substring(0, 8); while (DAL.Db.Context.Items.Count(n => n.Id == key) > 0) { key = Guid.NewGuid().ToString().Substring(0, 8); } Printers x = new Printers(); var printer = x.First(); ILabel label = DYMO.Label.Framework.Label.Open("barcode.label"); label.SetObjectText("BARCODE", key); label.Print(printer); }
public ShellDTVM() : base(new DesignTimeRepository()) { Initialize(); SelectedPrinter = Printers.First(); }