private void butPrint_Click(object sender, EventArgs e) { pagesPrinted = 0; pd = new PrintDocument(); pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage); pd.DefaultPageSettings.Margins = new Margins(25, 25, 40, 40); //pd.OriginAtMargins=true; pd.DefaultPageSettings.Landscape = true; if (pd.DefaultPageSettings.PrintableArea.Height == 0) { pd.DefaultPageSettings.PaperSize = new PaperSize("default", 850, 1100); } headingPrinted = false; #if DEBUG FormPrintPreview printPreview = new FormPrintPreview(PrintSituation.Default, pd, 1, 0, "Audit trail printed"); printPreview.ShowDialog(); #else try { if (PrinterL.SetPrinter(pd, PrintSituation.Default, 0, "Audit trail printed")) { pd.Print(); } } catch { MessageBox.Show(Lan.g(this, "Printer not available")); } #endif }
///<summary>Launches FormPrintPreview for the given printDoc. Returns true if dialog result was OK; Otherwise false.</returns> private static bool PreviewClassic(ODprintout printout) { if (ControlPreviewOverride != null) { return(IsControlPreviewOverrideValid(printout)); } FormPrintPreview formPreview = new FormPrintPreview(printout); //This form is self validating. formPreview.ShowDialog(); formPreview.BringToFront(); return(formPreview.DialogResult == DialogResult.OK); }
public void OnEvent(object MapEvent) { FormPrintPreview dlg = new FormPrintPreview(); //PrintPreviewDialog dlg = new PrintPreviewDialog(); dlg.Document = PrinterPage.Document; PrinterMap map = new PrinterMap((Map)((MapEvent)MapEvent).Map); PrinterPage page = new PrinterPage(map, ((MapEvent)MapEvent).Map.Display.Envelope); //dlg.ShowDialog(); page.Release(); }
private void but3A_Click(object sender, EventArgs e) //TODO: Implement ODprintout pattern { if (!DateIsValid()) { return; } Cursor.Current = Cursors.WaitCursor; PrintDocument pd = new PrintDocument(); pd.PrintPage += new PrintPageEventHandler(this.pdAgeGender_PrintPage); FormPrintPreview printPreview = new FormPrintPreview(PrintSituation.Default, pd, 1, 0, "UDS reporting 3A-AgeGender printed"); printPreview.ShowDialog(); }
///<summary>Surround with try/catch.</summary> public static void PrintBatch(List <Sheet> sheetBatch) { //currently no validation for parameters in a batch because of the way it was created. //could validate field names here later. SheetList = sheetBatch; sheetsPrinted = 0; PrintDocument pd = new PrintDocument(); pd.OriginAtMargins = true; pd.PrintPage += new PrintPageEventHandler(pd_PrintPage); if (sheetBatch[0].Width > 0 && sheetBatch[0].Height > 0) { pd.DefaultPageSettings.PaperSize = new PaperSize("Default", sheetBatch[0].Width, sheetBatch[0].Height); } PrintSituation sit = PrintSituation.Default; pd.DefaultPageSettings.Landscape = sheetBatch[0].IsLandscape; switch (sheetBatch[0].SheetType) { case SheetTypeEnum.LabelPatient: case SheetTypeEnum.LabelCarrier: case SheetTypeEnum.LabelReferral: sit = PrintSituation.LabelSingle; break; case SheetTypeEnum.ReferralSlip: sit = PrintSituation.Default; break; } //later: add a check here for print preview. #if DEBUG pd.DefaultPageSettings.Margins = new Margins(20, 20, 0, 0); FormPrintPreview printPreview = new FormPrintPreview(sit, pd, SheetList.Count, 0, "Batch of " + sheetBatch[0].Description + " printed"); printPreview.ShowDialog(); #else try { if (!PrinterL.SetPrinter(pd, sit, 0, "Batch of " + sheetBatch[0].Description + " printed")) { return; } pd.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0); pd.Print(); } catch (Exception ex) { throw ex; //MessageBox.Show(Lan.g("Sheet","Printer not available")); } #endif }
public Task <bool> OnEvent(object MapEvent) { FormPrintPreview dlg = new FormPrintPreview(); //PrintPreviewDialog dlg = new PrintPreviewDialog(); dlg.Document = PrinterPage.Document; PrinterMap map = new PrinterMap((Map)((MapEvent)MapEvent).Map); PrinterPage page = new PrinterPage(map, ((MapEvent)MapEvent).Map.Display.Envelope); //dlg.ShowDialog(); page.Release(); return(Task.FromResult(true)); }
private void butPrint_Click(object sender, EventArgs e) { LogTextPrint = textLog.Text; pd2 = new PrintDocument(); pd2.PrintPage += new PrintPageEventHandler(this.pd2_PrintPage); pd2.DefaultPageSettings.Margins = new Margins(40, 50, 50, 60); try { #if DEBUG FormPrintPreview printPreview = new FormPrintPreview(PrintSituation.Default, pd2, 0, 0, "Database Maintenance log printed"); printPreview.ShowDialog(); #else pd2.Print(); #endif } catch { MessageBox.Show("Printer not available"); } }
private void butLabelPreview_Click(object sender, EventArgs e) { if (gridMain.SelectedIndices.Length == 0) { MsgBox.Show(this, "Please select patient(s) first."); return; } pagesPrinted = 0; patientsPrinted = 0; pd = new PrintDocument(); pd.PrintPage += new PrintPageEventHandler(this.pdLabels_PrintPage); pd.OriginAtMargins = true; pd.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0); FormPrintPreview printPreview = new FormPrintPreview(PrintSituation.LabelSheet , pd, (int)Math.Ceiling((double)gridMain.SelectedIndices.Length / 30), 0, "Treatment finder labels printed"); printPreview.ShowDialog(); }
///<Summary></Summary> public static void Print(Sheet sheet, int copies, bool isRxControlled) { //parameter null check moved to SheetFiller. //could validate field names here later. SheetList = new List <Sheet>(); for (int i = 0; i < copies; i++) { SheetList.Add(sheet.Copy()); } sheetsPrinted = 0; PrintDocument pd = new PrintDocument(); pd.OriginAtMargins = true; pd.PrintPage += new PrintPageEventHandler(pd_PrintPage); if (pd.DefaultPageSettings.PrintableArea.Width == 0) { //prevents bug in some printers that do not specify paper size pd.DefaultPageSettings.PaperSize = new PaperSize("paper", 850, 1100); } if (sheet.SheetType == SheetTypeEnum.LabelPatient || sheet.SheetType == SheetTypeEnum.LabelCarrier || sheet.SheetType == SheetTypeEnum.LabelAppointment || sheet.SheetType == SheetTypeEnum.LabelReferral) { //I think this causes problems for non-label sheet types. if (sheet.Width > 0 && sheet.Height > 0) { pd.DefaultPageSettings.PaperSize = new PaperSize("Default", sheet.Width, sheet.Height); } } PrintSituation sit = PrintSituation.Default; pd.DefaultPageSettings.Landscape = sheet.IsLandscape; switch (sheet.SheetType) { case SheetTypeEnum.LabelPatient: case SheetTypeEnum.LabelCarrier: case SheetTypeEnum.LabelReferral: case SheetTypeEnum.LabelAppointment: sit = PrintSituation.LabelSingle; break; case SheetTypeEnum.ReferralSlip: sit = PrintSituation.Default; break; case SheetTypeEnum.Rx: if (isRxControlled) { sit = PrintSituation.RxControlled; } else { sit = PrintSituation.Rx; } break; } //later: add a check here for print preview. #if DEBUG pd.DefaultPageSettings.Margins = new Margins(20, 20, 0, 0); FormPrintPreview printPreview; printPreview = new FormPrintPreview(sit, pd, SheetList.Count, sheet.PatNum, sheet.Description + " sheet from " + sheet.DateTimeSheet.ToShortDateString() + " printed"); printPreview.ShowDialog(); #else try { if (sheet.PatNum != null) { if (!PrinterL.SetPrinter(pd, sit, sheet.PatNum, sheet.Description + " sheet from " + sheet.DateTimeSheet.ToShortDateString() + " printed")) { return; } } else { if (!PrinterL.SetPrinter(pd, sit, 0, sheet.Description + " sheet from " + sheet.DateTimeSheet.ToShortDateString() + " printed")) { return; } } pd.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0); pd.Print(); } catch (Exception ex) { throw ex; //MessageBox.Show(Lan.g("Sheet","Printer not available")); } #endif }