예제 #1
0
 ///<summary>Gets a PrintDocument that has some added functionality.  All printing in Open Dental should use this method (or an ODprintout object) for printing.</summary>
 ///<param name="printPageEventHandler">The handler that will get invoked when printing.  This defines how to draw each page.</param>
 ///<param name="printSit">ODprintout does not do anything with this field. But when ValidationDelegate is invoked we will provide the information if needed.</param>
 ///<param name="auditPatNum">ODprintout does not do anything with this field. But when ValidationDelegate is invoked we will provide the information if needed.</param>
 ///<param name="auditDescription">ODprintout does not do anything with this field. But when ValidationDelegate is invoked we will provide the information if needed.</param>
 ///<param name="margins">When set, this will override the default margins of "new Margins(25,25,40,40)".</param>
 ///<param name="printoutOrigin">Defaults to printer default.  Set to AtMargin if the graphics origin starts at the page margins; AtZero if the graphics origin is at the top-left corner of the printable page.</param>
 ///<param name="paperSize">When set, this will override the default paperSize of "new PaperSize("default",850,1100)".</param>
 ///<param name="totalPages">When creating an ODprintout for print previewing, this defines the total number of pages.</param>
 ///<param name="printoutOrientation">Defaults to printers default value.  Otherwise specify a value for either landscape or portrait.</param>
 ///<param name="duplex">Typically set when performing double-sided printing.</param>
 ///<param name="copies">Gets or sets the number of copies of the document to print.</param>
 ///<param name="totalPages">ODprintout does not do anything with this field. But when ValidationDelegate is invoked we will provide the information if needed. Defaults to 1.</param>
 ///<param name="printOrPreviewExceptionDelegate">Any custom delegate that the calling method wants to happen when printing or previewing throws an exception.</param>
 ///<param name="tryPreviewDelegate">Required to be implemented if the calling method needs the ability to preview.</param>
 ///<param name="tryPrintOrDebugPreviewDelegate">Same as tryPreviewDelegate, but defines isPreview based on if program is in DEBUG mode.</param>
 ///<returns>A new ODprintout with the given args that serves as a conduit safe printing and previewing methods.</returns>
 public ODprintout(PrintPageEventHandler printPageEventHandler = null, PrintSituation printSit = PrintSituation.Default, long auditPatNum = 0, string auditDescription   = ""
                   , Margins margins = null, PrintoutOrigin printoutOrigin = PrintoutOrigin.Default, PaperSize paperSize = null, PrintoutOrientation printoutOrientation = PrintoutOrientation.Default
                   , Duplex duplex   = Duplex.Default, short copies        = 1, int totalPages = 1) : base()
 {
     CurPrintout = this;
     _printDoc   = new PrintDocument();
     //if(InitPrintSettings!=null) {
     //	_printDoc.PrinterSettings=InitPrintSettings;
     //	InitPrintSettings=null;
     //}
     Situation        = printSit;
     AuditPatNum      = auditPatNum;
     AuditDescription = auditDescription;
     TotalPages       = totalPages;
     if (!HasValidSettings)
     {
         return;
     }
     _printDoc.PrintPage += printPageEventHandler;
     if (printoutOrientation != PrintoutOrientation.Default)
     {
         _printDoc.DefaultPageSettings.Landscape = (printoutOrientation == PrintoutOrientation.Landscape)?true:false;
     }
     if (printoutOrigin != PrintoutOrigin.Default)
     {
         _printDoc.OriginAtMargins = (printoutOrigin == PrintoutOrigin.AtMargin)?true:false;
     }
     _printDoc.DefaultPageSettings.Margins = (margins ?? new Margins(25, 25, 40, 40));
     if (paperSize == null)
     {
         //This prevents a bug caused by some printer drivers not reporting their papersize.
         //But remember that other countries use A4 paper instead of 8 1/2 x 11.
         if ((InvalidMinDefaultPageWidth != -1 && _printDoc.DefaultPageSettings.PrintableArea.Width <= InvalidMinDefaultPageWidth) ||
             (InvalidMinDefaultPageHeight != -1 && _printDoc.DefaultPageSettings.PrintableArea.Height <= InvalidMinDefaultPageHeight))
         {
             _printDoc.DefaultPageSettings.PaperSize = new PaperSize("default", 850, 1100);
         }
         InvalidMinDefaultPageHeight = 0;
         InvalidMinDefaultPageWidth  = -1;
     }
     else
     {
         _printDoc.DefaultPageSettings.PaperSize = paperSize;
     }
     _printDoc.PrinterSettings.Copies = copies;
     if (duplex != Duplex.Default)
     {
         _printDoc.PrinterSettings.Duplex = duplex;
     }
     if (ODBuild.IsWeb())
     {
         //https://referencesource.microsoft.com/#System.Drawing/commonui/System/Drawing/Printing/PrintDocument.cs,3f3c2622b65be86a
         //The PrintController property will create a PrintControllerWithStatusDialog if no print controller is explictly set.
         _printDoc.PrintController = new StandardPrintController();              //Default PrintController shows a dialog that locks up web.
     }
 }
예제 #2
0
        ///<summary>Attempts to preview (FormPrintPreview) a PrintDocument that has some added functionality.  All printing in Open Dental should use this method (or an ODprintout object) for printing.</summary>
        ///<param name="printPageHandler">The handler that will get invoked when printing.  This defines how to draw each page.</param>
        ///<param name="auditDescription">ODprintout does not do anything with this field.  But when PrinterL.TrySetPrinter() is invoked we will provide the information if needed.</param>
        ///<param name="printSit">ODprintout does not do anything with this field.  But when PrinterL.TrySetPrinter() is invoked we will provide the information if needed.</param>
        ///<param name="margins">When set, this will override the default margins of "new Margins(25,25,40,40)".</param>
        ///<param name="printoutOrigin">Defaults to printer default.  Set to AtMargin if the graphics origin starts at the page margins; AtZero if the graphics origin is at the top-left corner of the printable page.</param>
        ///<param name="paperSize">When set, this will override the default paperSize of "new PaperSize("default",850,1100)".</param>
        ///<param name="totalPages">When creating an ODprintout for print previewing, this defines the total number of pages.</param>
        ///<param name="printoutOrientation">Defaults to printers default value.  Otherwise specify a value for either landscape or portrait.</param>
        ///<returns>Returns true if preview is shown and OK is clicked.</returns>
        public static bool TryPreview(PrintPageEventHandler printPageHandler, string auditDescription, PrintSituation printSit = PrintSituation.Default
                                      , Margins margins = null, PrintoutOrigin printoutOrigin = PrintoutOrigin.Default, PaperSize paperSize = null, PrintoutOrientation printoutOrientation = PrintoutOrientation.Default
                                      , int totalPages  = 1)
        {
            ODprintout printout = new ODprintout(
                printPageHandler,
                printSit,
                auditDescription: auditDescription,
                margins: margins,
                printoutOrigin: printoutOrigin,
                paperSize: paperSize,
                printoutOrientation: printoutOrientation,
                totalPages: totalPages
                );

            return(PreviewClassic(printout));
        }
예제 #3
0
        ///<summary>Attempts to print if in RELEASE mode or if in DEBUG mode will open ODprintout in FormRpPrintPreview.</summary>
        ///<param name="printPageHandler">The handler that will get invoked when printing.  This defines how to draw each page.</param>
        ///<param name="auditDescription">ODprintout does not do anything with this field.  But when PrinterL.TrySetPrinter() is invoked we will provide the information if needed.</param>
        ///<param name="printSit">ODprintout does not do anything with this field.  But when PrinterL.TrySetPrinter() is invoked we will provide the information if needed.</param>
        ///<param name="auditPatNum">ODprintout does not do anything with this field.  But when PrinterL.TrySetPrinter() is invoked we will provide the information if needed.</param>
        ///<param name="margins">When set, this will override the default margins of "new Margins(25,25,40,40)".</param>
        ///<param name="printoutOrigin">Defaults to printer default.  Set to AtMargin if the graphics origin starts at the page margins; AtZero if the graphics origin is at the top-left corner of the printable page.</param>
        ///<param name="printoutOrientation">Defaults to printers default value.  Otherwise specify a value for either landscape or portrait.</param>
        ///<returns>Returns true if succesfully printed, or if preview is shown and OK is clicked.</returns>
        public static bool TryPrintOrDebugRpPreview(PrintPageEventHandler printPageHandler, string auditDescription
                                                    , PrintoutOrientation printoutOrientation = PrintoutOrientation.Default, PrintSituation printSit = PrintSituation.Default, long auditPatNum = 0
                                                    , Margins margins = null, PrintoutOrigin printoutOrigin = PrintoutOrigin.Default, bool isForcedPreview = false)
        {
            ODprintout printout = new ODprintout(
                printPageHandler,
                printSit,
                auditPatNum,
                auditDescription,
                margins,
                printoutOrigin,
                printoutOrientation: printoutOrientation,
                duplex: Duplex.Default
                );

            if (ODBuild.IsDebug() || isForcedPreview)
            {
                return(RpPreview(printout));
            }
            return(TryPrint(printout));
        }
예제 #4
0
        ///<summary>Attempts to print if in RELEASE mode or if in DEBUG mode will open ODprintout in FormPrintPreview.</summary>
        ///<param name="printPageEventHandler">The handler that will get invoked when printing.  This defines how to draw each page.</param>
        ///<param name="auditDescription">ODprintout does not do anything with this field.  But when PrinterL.TrySetPrinter() is invoked we will provide the information if needed.</param>
        ///<param name="printSit">ODprintout does not do anything with this field.  But when PrinterL.TrySetPrinter() is invoked we will provide the information if needed.</param>
        ///<param name="margins">When set, this will override the default margins of "new Margins(25,25,40,40)".</param>
        ///<param name="printoutOrigin">Defaults to printer default.  Set to AtMargin if the graphics origin starts at the page margins; AtZero if the graphics origin is at the top-left corner of the printable page.</param>
        ///<param name="printoutOrientation">Defaults to printers default value.  Otherwise specify a value for either landscape or portrait.</param>
        ///<returns>Returns true if succesfully printed, or if preview is shown and OK is clicked.</returns>
        public static bool TryPrintOrDebugClassicPreview(PrintPageEventHandler printPageEventHandler, string auditDescription, Margins margins = null
                                                         , int totalPages = 1, PrintSituation printSit = PrintSituation.Default, PrintoutOrigin printoutOrigin = PrintoutOrigin.Default
                                                         , PrintoutOrientation printoutOrientation = PrintoutOrientation.Default, bool isForcedPreview = false, long auditPatNum = 0, PaperSize paperSize = null)
        {
            ODprintout printout = new ODprintout(
                printPageEventHandler,
                printSit,
                auditPatNum,
                auditDescription,
                margins,
                printoutOrigin,
                paperSize,
                printoutOrientation,
                totalPages: totalPages
                );

            if (ODBuild.IsDebug() || isForcedPreview)
            {
                return(PreviewClassic(printout));
            }
            return(TryPrint(printout));
        }
예제 #5
0
        ///<summary>Gets a PrintDocument that has some added functionality.  All printing in Open Dental should use this method (or an ODprintout object) for printing.</summary>
        ///<param name="printPageHandler">The handler that will get invoked when printing.  This defines how to draw each page.</param>
        ///<param name="printSit">ODprintout does not do anything with this field.  But when PrinterL.TrySetPrinter() is invoked we will provide the information if needed.</param>
        ///<param name="auditPatNum">ODprintout does not do anything with this field.  But when PrinterL.TrySetPrinter() is invoked we will provide the information if needed.</param>
        ///<param name="auditDescription">ODprintout does not do anything with this field.  But when PrinterL.TrySetPrinter() is invoked we will provide the information if needed.</param>
        ///<param name="margins">When set, this will override the default margins of "new Margins(25,25,40,40)".</param>
        ///<param name="printoutOrigin">Defaults to printer default.  Set to AtMargin if the graphics origin starts at the page margins; AtZero if the graphics origin is at the top-left corner of the printable page.</param>
        ///<param name="paperSize">When set, this will override the default paperSize of "new PaperSize("default",850,1100)".</param>
        ///<param name="totalPages">When creating an ODprintout for print previewing, this defines the total number of pages.  Required if multiple pages needed when using Classic printing in FormPrintPreview.</param>
        ///<param name="printoutOrientation">Defaults to printers default value.  Otherwise specify a value for either landscape or portrait.</param>
        ///<param name="duplex">Use default unless double-sided printing is required.</param>
        ///<param name="copies">Gets or sets the number of copies of the document to print.</param>
        ///<returns>A new ODprintout with the given args that serves as a conduit for centralized printing and previewing methods with nice error messages.</returns>
        public static ODprintout CreateODprintout(PrintPageEventHandler printPageHandler = null, string auditDescription = ""
                                                  , PrintSituation printSit = PrintSituation.Default, long auditPatNum   = 0, Margins margins   = null, PrintoutOrigin printoutOrigin        = PrintoutOrigin.Default
                                                  , PaperSize paperSize     = null, int totalPages = 1, PrintoutOrientation printoutOrientation = PrintoutOrientation.Default, Duplex duplex = Duplex.Default, short copies = 1
                                                  , bool isErrorSuppressed  = false)
        {
            ODprintout printout = new ODprintout(
                printPageHandler,
                printSit,
                auditPatNum,
                auditDescription,
                margins,
                printoutOrigin,
                paperSize,
                printoutOrientation,
                duplex,
                copies,
                totalPages
                );

            if (!isErrorSuppressed && printout.SettingsErrorCode != PrintoutErrorCode.Success)
            {
                ShowError(printout);
            }
            return(printout);
        }
예제 #6
0
        ///<summary>Attempts to print a PrintDocument that has some added functionality.  All printing in Open Dental should use this method (or an ODprintout object) for printing.</summary>
        ///<param name="printPageEventHandler">The handler that will get invoked when printing.  This defines how to draw each page.</param>
        ///<param name="printSit">ODprintout does not do anything with this field.  But when PrinterL.TrySetPrinter() is invoked we will provide the information if needed.</param>
        ///<param name="auditPatNum">ODprintout does not do anything with this field.  But when PrinterL.TrySetPrinter() is invoked we will provide the information if needed.</param>
        ///<param name="auditDescription">ODprintout does not do anything with this field.  But when PrinterL.TrySetPrinter() is invoked we will provide the information if needed.</param>
        ///<param name="margins">When set, this will override the default margins of "new Margins(25,25,40,40)".</param>
        ///<param name="printoutOrigin">Defaults to printer default.  Set to AtMargin if the graphics origin starts at the page margins; AtZero if the graphics origin is at the top-left corner of the printable page.</param>
        ///<param name="printoutOrientation">Defaults to printers default value.  Otherwise specify a value for either landscape or portrait.</param>
        ///<param name="duplex">Use default unless double-sided printing is required.</param>
        ///<returns>Returns true if succesfully printed.</returns>
        public static bool TryPrint(PrintPageEventHandler printPageEventHandler, string auditDescription = "", long auditPatNum = 0
                                    , PrintSituation printSit = PrintSituation.Default, Margins margins = null, PrintoutOrigin printoutOrigin = PrintoutOrigin.Default
                                    , PrintoutOrientation printoutOrientation = PrintoutOrientation.Default, Duplex duplex = Duplex.Default)
        {
            ODprintout printout = new ODprintout(
                printPageEventHandler,
                printSit,
                auditPatNum,
                auditDescription,
                margins,
                printoutOrigin,
                printoutOrientation: printoutOrientation,
                duplex: duplex
                );

            return(TryPrint(printout));
        }