public static void printAllLabels(string sPrinter, LabelSet lsLabels) { if (sPrinter == null) { return; } if (sPrinter.Length == 0 || lsLabels.getCount() == 0) { return; } sPrinter = sPrinter; lPageList = lsLabels.lPages; PrintDocument pd = new PrintDocument(); pd.PrintController = new StandardPrintController(); pd.PrinterSettings.PrinterName = sPrinter; setPaperSize(pd); setPageInfo(pd); pd.PrintPage += new PrintPageEventHandler(printLabelEvent); pd.Print(); }
public static void printTestLabel(string sPrinter, string sLabelFormat) { LabelSet lsLabels = new LabelSet(); lsLabels.addPages(sLabelFormat, null); lPageList = lsLabels.lPages; PrintDocument pd = new PrintDocument(); pd.PrinterSettings.PrinterName = sPrinter; setPaperSize(pd); setPageInfo(pd); pd.PrintPage += new PrintPageEventHandler(printLabelEvent); pd.Print(); }
/* * When To Print Labels: * * Main Label: Always printed for members and guests regardless of size * * Security Label: Same for all label sizes only when needed, can have more than 1 printed via securitylabelsperchild * * Guest Label: Gets put on the roles and has allergies (greater than or equal to 2 inch) * Allergy Label (less than 2 inch): Try to not use this one * * Location Label: For guest only * * NameTag label: Prints if not security label is requested * * If Member (2 inch): Only 1 Label if label * If Guest (2 inch): Main, Guest, Security, Location (multiples of each can happen on request) * * If Member (1 inch): Only 1 label unless more than 1 class * If Guess (1 inch): Main, Guest, Security, Location (multiples */ public static void doPrinting(IEnumerable <LabelInfo> q, bool bPrintSingle = false) { LabelSet lsLabels = new LabelSet(); int iLabelSize = PrinterHelper.getPageHeight(Program.Printer); // Adjust all records that are not members to have a "G" for Guest. Fix for iPad sending a "V" instead of a "G" foreach (var u in (from c in q where c.mv != "M" select c)) { u.mv = "G"; } var q2 = from c in q where c.n > 0 orderby c.first ascending, c.hour descending group c by new { c.pid } into g select from c in g select c; if (bPrintSingle) { string[] sFormats = PrinterHelper.SINGLE; foreach (var li in q2) { foreach (string sItem in sFormats) { lsLabels.addPages(PrinterHelper.fetchLabelFormat(sItem, iLabelSize), li.ToList <LabelInfo>()); } } } else { var extras = from e in q where e.n > 1 where e.requiressecuritylabel == true orderby e.first ascending, e.hour ascending group e by new { e.pid, e.org } into eg select from e in eg select e; var locs = from c in q where c.mv != "M" where c.age < 18 where c.n > 0 orderby c.first ascending, c.hour ascending group c by c.securitycode into g select from c in g select c; foreach (var li in q2) { int iPersonSecurityCount = PrinterHelper.getSecurityCount(li); if (iPersonSecurityCount > 0 || li.First().age < 18) { string[] sFormats = PrinterHelper.MAIN; foreach (string sItem in sFormats) { lsLabels.addPages(PrinterHelper.fetchLabelFormat(sItem, iLabelSize), li.ToList <LabelInfo>()); } var guestIn = from gi in li where gi.mv != "M" select gi; foreach (var guestLabel in guestIn) { string[] sGuestFormats = PrinterHelper.GUEST; IEnumerable <LabelInfo> iGuestLabels = new [] { guestLabel }; foreach (string sItem in sGuestFormats) { lsLabels.addPages(PrinterHelper.fetchLabelFormat(sItem, iLabelSize), iGuestLabels.ToList <LabelInfo>()); } } } else { string[] sFormats = PrinterHelper.NAMETAG; foreach (string sItem in sFormats) { lsLabels.addPages(PrinterHelper.fetchLabelFormat(sItem, iLabelSize), li.ToList <LabelInfo>()); } } } foreach (var le in extras) { int iLabels = le.FirstOrDefault().n - 1; for (int iX = 0; iX < iLabels; iX++) { lsLabels.addPages(PrinterHelper.fetchLabelFormat("Extra", iLabelSize), le.ToList <LabelInfo>()); } } if (lsLabels.getCount() > 0) { int iSecurityCount = PrinterHelper.getSecurityCount(q); if (iSecurityCount > 0) { var s = q2.First().Take(1).ToList <LabelInfo>(); for (int iX = 0; iX < iSecurityCount; iX++) { lsLabels.addPages(PrinterHelper.fetchLabelFormat("Security", iLabelSize), s); } } if (Program.DisableLocationLabels == false) { foreach (var lc in locs) { lsLabels.addPages(PrinterHelper.fetchLabelFormat("Location", iLabelSize), lc.ToList <LabelInfo>()); } } } } if (Settings1.Default.ExtraBlankLabel == true && q.Count() > 0) { lsLabels.addBlank(); } PrinterHelper.printAllLabels(Program.Printer, lsLabels); }
/* * When To Print Labels: * * Main Label: Always printed for members and guests regardless of size * * Security Label: Same for all label sizes only when needed, can have more than 1 printed via securitylabelsperchild * * Guest Label: Gets put on the roles and has allergies (greater than or equal to 2 inch) * Allergy Label (less than 2 inch): Try to not use this one * * Location Label: For guest only * * NameTag label: Prints if not security label is requested * * If Member (2 inch): Only 1 Label if label * If Guest (2 inch): Main, Guest, Security, Location (multiples of each can happen on request) * * If Member (1 inch): Only 1 label unless more than 1 class * If Guess (1 inch): Main, Guest, Security, Location (multiples */ public static void doPrinting(IEnumerable<LabelInfo> q, bool bPrintSingle = false) { LabelSet lsLabels = new LabelSet(); int iLabelSize = PrinterHelper.getPageHeight(Program.Printer); // Adjust all records that are not members to have a "G" for Guest. Fix for iPad sending a "V" instead of a "G" foreach (var u in (from c in q where c.mv != "M" select c)) { u.mv = "G"; } var q2 = from c in q where c.n > 0 orderby c.first ascending, c.hour descending group c by new { c.pid } into g select from c in g select c; if (bPrintSingle) { string[] sFormats = PrinterHelper.SINGLE; foreach (var li in q2) { foreach (string sItem in sFormats) { lsLabels.addPages(PrinterHelper.fetchLabelFormat(sItem, iLabelSize), li.ToList<LabelInfo>()); } } } else { var extras = from e in q where e.n > 1 where e.requiressecuritylabel == true orderby e.first ascending, e.hour ascending group e by new { e.pid, e.org } into eg select from e in eg select e; var locs = from c in q where c.mv != "M" where c.age < 13 where c.n > 0 orderby c.first ascending, c.hour ascending group c by c.securitycode into g select from c in g select c; foreach (var li in q2) { int iPersonSecurityCount = PrinterHelper.getSecurityCount(li); if (iPersonSecurityCount > 0 || li.First().age < 13) { string[] sFormats = PrinterHelper.MAIN; foreach (string sItem in sFormats) { lsLabels.addPages(PrinterHelper.fetchLabelFormat(sItem, iLabelSize), li.ToList<LabelInfo>()); } var guestIn = from gi in li where gi.mv != "M" select gi; foreach (var guestLabel in guestIn) { string[] sGuestFormats = PrinterHelper.GUEST; IEnumerable<LabelInfo> iGuestLabels = new[] { guestLabel }; foreach (string sItem in sGuestFormats) { lsLabels.addPages(PrinterHelper.fetchLabelFormat(sItem, iLabelSize), iGuestLabels.ToList<LabelInfo>()); } } } else { string[] sFormats = PrinterHelper.NAMETAG; foreach (string sItem in sFormats) { lsLabels.addPages(PrinterHelper.fetchLabelFormat(sItem, iLabelSize), li.ToList<LabelInfo>()); } } } foreach (var le in extras) { int iLabels = le.FirstOrDefault().n - 1; for (int iX = 0; iX < iLabels; iX++) { lsLabels.addPages(PrinterHelper.fetchLabelFormat("Extra", iLabelSize), le.ToList<LabelInfo>()); } } if (lsLabels.getCount() > 0) { int iSecurityCount = PrinterHelper.getSecurityCount(q); if (iSecurityCount > 0) { var s = q2.First().Take(1).ToList<LabelInfo>(); for (int iX = 0; iX < iSecurityCount; iX++) { lsLabels.addPages(PrinterHelper.fetchLabelFormat("Security", iLabelSize), s); } } if (Program.DisableLocationLabels == false) { foreach (var lc in locs) { lsLabels.addPages(PrinterHelper.fetchLabelFormat("Location", iLabelSize), lc.ToList<LabelInfo>()); } } } } if (Settings1.Default.ExtraBlankLabel == true && q.Count() > 0) lsLabels.addBlank(); PrinterHelper.printAllLabels(Program.Printer, lsLabels); }
public static void printTestLabel(string sPrinter, string sLabelFormat) { LabelSet lsLabels = new LabelSet(); lsLabels.addPages(sLabelFormat, null); lPageList = lsLabels.lPages; PrintDocument pd = new PrintDocument(); pd.PrinterSettings.PrinterName = sPrinter; setPaperSize(pd); setPageInfo(pd); pd.PrintPage += new PrintPageEventHandler(printLabelEvent); pd.Print(); }
public static void printAllLabels(string sPrinter, LabelSet lsLabels) { if (sPrinter == null) return; if (sPrinter.Length == 0 || lsLabels.getCount() == 0) return; lPageList = lsLabels.lPages; PrintDocument pd = new PrintDocument(); pd.PrintController = new StandardPrintController(); pd.PrinterSettings.PrinterName = sPrinter; setPaperSize(pd); setPageInfo(pd); pd.PrintPage += new PrintPageEventHandler(printLabelEvent); pd.Print(); }