Esempio n. 1
0
        /// <summary>
        /// Печать результата.
        /// @todo доделать печать результата
        /// </summary>
        private static void PrintResult()
        {
            throw new NotImplementedException("Не реализовано!");
            var pd = new PrintDialog();

            if (pd.ShowDialog() == true)
            {
                var doc = new PrintDocument();
                doc.DocumentName = "Результаты";

                PrintPageEventHandler ppeh = (sender, e) =>
                {
                    var result = new StringBuilder();

                    result.Append("Creating date - ").Append(DateTime.Now.ToLongDateString()).AppendLine();
                    result.AppendLine($"{"File Name:",-50}{"Plagiarism Result:",10}");


                    foreach (var handledFile in M_Model.HandledFiles)
                    {
                        result.AppendLine(
                            $"{handledFile.FileName,-50}{handledFile.Value.ToString(CultureInfo.CurrentCulture),10}");
                    }

                    int y;
                    var myFont = new Font("Times New Roman", 14, FontStyle.Regular);
                    y = e.MarginBounds.Y;
                    e.Graphics.DrawString(result.ToString(), myFont, Brushes.Black, e.MarginBounds.X, y);
                };

                doc.PrintPage += ppeh;
            }

            throw new NotImplementedException();
        }
Esempio n. 2
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);
        }
        public PrintingDataGridViewProvider(GridDrawer drawer, PrintDocument printDocument)
        {
            _PrintPageEventHandler = new PrintPageEventHandler(PrintDocument_PrintPage);

            _Drawer = drawer;

            this.PrintDocument = printDocument;
        }
        public PrintingDataGridViewProvider(GridDrawer drawer, PrintDocument printDocument)
        {
            _PrintPageEventHandler = new PrintPageEventHandler(PrintDocument_PrintPage);

            _Drawer = drawer;

            this.PrintDocument = printDocument;
        }
        /// <summary>
        /// Extends BeginInvoke so that when a state object is not needed, null does not need to be passed.
        /// <example>
        /// printpageeventhandler.BeginInvoke(sender, e, callback);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginInvoke(this PrintPageEventHandler printpageeventhandler, Object sender, PrintPageEventArgs e, AsyncCallback callback)
        {
            if (printpageeventhandler == null)
            {
                throw new ArgumentNullException("printpageeventhandler");
            }

            return(printpageeventhandler.BeginInvoke(sender, e, callback, null));
        }
Esempio n. 6
0
        /// <summary>Print the graphical view</summary>
        public void GraphicsPrinting()
        {
            PrintPageEventHandler p = new PrintPageEventHandler(pd_PrintPageGraphic);

            pd.PrintPage += p;
            // Print the document.
            pd.Print();
            pd.PrintPage -= p;
        }
Esempio n. 7
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.
     }
 }
Esempio n. 8
0
        public void printpreview()
        {
            PrintPreviewDialog ppv = new PrintPreviewDialog();
            PrintDocument      pdm = new PrintDocument();

            pdm.PrintPage += new PrintPageEventHandler(doprint);
            printpage     += doprint;
            ppv.Document   = pdm;
            ppv.ShowDialog();
        }
Esempio n. 9
0
        public void print()
        {
            PrintDialog   pd  = new PrintDialog();
            PrintDocument pdm = new PrintDocument();

            printpage     += doprint;
            pdm.PrintPage += new PrintPageEventHandler(printpage);
            pd.Document    = pdm;
            pd.ShowDialog();
            pdm.Print();
        }
Esempio n. 10
0
		public Layout()
		{
			///
			/// Required for Windows.Forms Class Composition Designer support
			///
			InitializeComponent();

			printPage = new PrintPageEventHandler(PrintPage);
			beginPrint = new PrintEventHandler(BeginPrint);
			queryPageSettings = new QueryPageSettingsEventHandler(QueryPageSettings);
		}
Esempio n. 11
0
        private void InitInstance()
        {
            PrintPageEventHandler pdoc_page_handler  = new PrintPageEventHandler(this.pdoc_PrintPage);
            PrintEventHandler     pdoc_event_handler = new PrintEventHandler(this.pdoc_BeginPrint);

            if (this.pdoc != null)
            {
                this.pdoc.PrintPage  += pdoc_page_handler;
                this.pdoc.BeginPrint += pdoc_event_handler;
            }
        }
Esempio n. 12
0
		public Layout(System.ComponentModel.IContainer container)
		{
			///
			/// Required for Windows.Forms Class Composition Designer support
			///
			container.Add(this);
			InitializeComponent();

			printPage = new PrintPageEventHandler(PrintPage);
			beginPrint = new PrintEventHandler(BeginPrint);
			queryPageSettings = new QueryPageSettingsEventHandler(QueryPageSettings);
		}
Esempio n. 13
0
        void printMessage(NetworkStream str1)
        {
            EventLog myLog = new EventLog();

            try
            {
                myLog.Source = "Печать заявок";
                myLog.WriteEntry("Печать на принтер 1.", EventLogEntryType.Warning, 1, 1);
                streamToPrint = new StreamReader("C:\\CDrive.txt");
                myLog.WriteEntry("Печать на принтер 2.", EventLogEntryType.Warning, 1, 1);
                //        streamToPrint = str1;
                try
                {
                    printFont = new Font("Arial", 10);
                    PrintDocument pd = new PrintDocument();
                    //pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage);
                    PrintPageEventHandler eh = new PrintPageEventHandler(pd_PrintPage);
                    //pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
                    pd.PrintPage += eh;


                    myLog.WriteEntry("PrintPageEventHandler: " + eh.ToString(), EventLogEntryType.Warning, 1, 1);
                    myLog.WriteEntry("Печать на принтер 3: " + pd.DocumentName, EventLogEntryType.Warning, 1, 1);
                    //            pd.Print();
                    pd.PrintController = new PrintControllerWithStatusDialog(pd.PrintController);
                    myLog.WriteEntry("PrinterName: " + pd.PrinterSettings.PrinterName, EventLogEntryType.Warning, 1, 1);
                    myLog.WriteEntry("PrintFileName: " + pd.PrinterSettings.PrintFileName, EventLogEntryType.Warning, 1, 1);
                    myLog.WriteEntry("PrintToFile? " + pd.PrinterSettings.PrintToFile, EventLogEntryType.Warning, 1, 1);
                    myLog.WriteEntry("PrinterSettings: " + pd.PrinterSettings.ToString(), EventLogEntryType.Warning, 1, 1);
                    try
                    {
                        //							pd.Print();
                        PrintEventArgs ev = new PrintEventArgs();
                        //ev.PrintAction = PrintAction.PrintToFile;
                        pd.PrintController.OnStartPrint(pd, ev);
                        //pd.Print();
                        //pd.PrintController
                    }
                    catch (Exception ex)
                    {
                        myLog.WriteEntry("Ошибка начала печати: " + ex.Message, EventLogEntryType.Error, 1, 1);
                    }
                    myLog.WriteEntry("Печать на принтер 4.", EventLogEntryType.Warning, 1, 1);
                }
                finally { streamToPrint.Close(); }
            }
            catch (Exception ex)
            {/*MessageBox.Show(ex.Message);*/
                myLog.WriteEntry("Ошибка печати: " + ex.Message, EventLogEntryType.Error, 1, 1);
            }
            myLog.WriteEntry("Конец печати printMessage");
        }
Esempio n. 14
0
        /// <summary>
        /// Called when [print page].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="ea">The
        /// <see cref="T:System.Drawing.Printing.PrintPageEventArgs"/>
        /// instance containing the event data.</param>
        protected virtual void OnPrintPage
        (
            object sender,
            PrintPageEventArgs ea
        )
        {
            PrintPageEventHandler handler = PrintPage;

            if (handler != null)
            {
                handler(this, ea);
            }
        }
Esempio n. 15
0
        /// <summary>
        /// method wich send to the correct event by the department
        /// </summary>
        /// <param name="department"></param>
        void CreateDocToPrintByDepartment(PrintPageEventHandler department)
        {
            PrintDialog pd = new PrintDialog();

            pdoc = new PrintDocument();
            PrinterSettings ps = new PrinterSettings();

            pd.Document = pdoc;
            pd.Document.DefaultPageSettings.PaperSize = psize;
            pdoc.DefaultPageSettings.PaperSize.Height = 3000;
            pdoc.DefaultPageSettings.PaperSize.Width  = 500;
            pdoc.PrintPage += new PrintPageEventHandler(department);
            pdoc.Print();
        }
Esempio n. 16
0
 /// <summary>
 /// Prints a text view of the current map.
 /// </summary>
 /// <param name="dummy"></param>
 /// <param name="a"></param>
 /// <param name="rangeStart"></param>
 /// <param name="rangeFinish"></param>
 /// <param name="showPageNumber"></param>
 public PrintTree(bool dummy, ArgMapInterface a, int rangeStart, int rangeFinish, bool showPageNumber)
 {
     index = 0;
     a.CurrentArg.referenceTree();
     pd         = a.Pd;       // set print document/setup
     pageNumber = 1;
     flatTree   = new ArrayList();
     flattenTree(a.getTreeView().Nodes[0]);
     printFont           = new Font("Arial", 10);
     this.printevent     = new PrintPageEventHandler(pd_PrintPage);
     pd.PrintPage       += printevent;
     this.rangeStart     = rangeStart;
     this.rangeFinish    = rangeFinish;
     this.firstPage      = true;
     this.showPageNumber = showPageNumber;
 }
Esempio n. 17
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));
        }
Esempio n. 18
0
        public void ImprimeDuasVezes(PrintPageEventHandler evento)
        {
            PrintDocument printDoc = new PrintDocument();

            //printDoc.PrinterSettings.PrinterName = "Epson";
            printDoc.DocumentName = "Cupom";

            if (!printDoc.PrinterSettings.IsValid)
            {
                throw new Exception("Não foi possível localizar a impressora");
            }

            printDoc.PrintPage += evento;

            printDoc.Print();
            printDoc.Print();
        }
Esempio n. 19
0
        /// <summary>
        /// Prints the graphical view of the current map
        /// </summary>
        /// <param name="a"></param>
        /// <param name="rangeStart">First page</param>
        /// <param name="rangeFinish">Last page</param>
        /// <param name="showPageNumber">Displays the word Page and the page number.</param>
        /// <param name="scaleToPage">Scale the map to the current page size.</param>
        public PrintTree(ArgMapInterface a, int rangeStart, int rangeFinish, bool showPageNumber, bool scaleToPage)
        {
            this.a        = a;
            pd            = a.Pd;
            pagesHigh     = 0;
            pagesWide     = 0;
            cpx           = cpy = 0;
            pageNumber    = 1;
            printevent    = new PrintPageEventHandler(pd_PrintPageGraphic);
            pd.PrintPage += printevent;

            this.rangeStart     = rangeStart;
            this.rangeFinish    = rangeFinish;
            this.firstPage      = true;
            this.showPageNumber = showPageNumber;
            this.scaleToPage    = scaleToPage;
        }
Esempio n. 20
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));
        }
Esempio n. 21
0
        public void PrintPage_SetValue_ReturnsExpected()
        {
            bool flag             = false;
            var  printPageHandler = new PrintPageEventHandler((sender, e) => flag = true);

            using (var document = new PrintDocument())
            {
                document.PrintController = new TestPrintController();
                document.PrintPage      += printPageHandler;
                document.Print();
                Assert.True(flag);

                flag = false;
                document.PrintPage -= printPageHandler;
                document.Print();
                Assert.False(flag);
            }
        }
Esempio n. 22
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));
        }
Esempio n. 23
0
        /// <summary>
        /// 打印
        /// </summary>
        /// <param name="handler">绘制事件</param>
        private void Print(PrintPageEventHandler handler)
        {
            var document = new PrintDocument();

            document.PrintPage += handler;
            var dialog = new PrintDialog()
            {
                UseEXDialog      = true,
                AllowPrintToFile = false,
                ShowNetwork      = false,
                Document         = document
            };

            // 打印设置和开始打印
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                float printWidth  = Convert.ToSingle(tbWidth.Text);
                float printHeight = Convert.ToSingle(tbHeight.Text);
                document.DefaultPageSettings.PaperSize = new PaperSize("Custom", CmToPrint_int(printWidth), CmToPrint_int(printHeight));
                document.Print();
            }
        }
Esempio n. 24
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));
        }
Esempio n. 25
0
 public override bool ShowPrintPreviewDialog(PrintPageEventHandler printPageEventHandler, QueryPageSettingsEventHandler queryPageSettingsEventHandler)
 {
     try
     {
         System.Windows.Forms.PrintPreviewDialog dlg = new System.Windows.Forms.PrintPreviewDialog();
         Current.PrintingService.PrintDocument.PrintPage         += printPageEventHandler;
         Current.PrintingService.PrintDocument.QueryPageSettings += queryPageSettingsEventHandler;
         dlg.Document = Current.PrintingService.PrintDocument;
         dlg.ShowDialog(MainWindow);
         dlg.Dispose();
         return(true);
     }
     catch (Exception ex)
     {
         Current.Gui.ErrorMessageBox(ex.ToString());
     }
     finally
     {
         Current.PrintingService.PrintDocument.PrintPage         -= printPageEventHandler;
         Current.PrintingService.PrintDocument.QueryPageSettings -= queryPageSettingsEventHandler;
     }
     return(false);
 }
Esempio n. 26
0
        public void ImprimeUmaVez(PrintPageEventHandler eventoEpson, PrintPageEventHandler eventoCIS, string nomeImpressora)
        {
            PrintDocument printDoc = new PrintDocument();

            printDoc.DocumentName = "Cupom";

            if (nomeImpressora.ToLower() == "epson")
            {
                printDoc.PrinterSettings.PrinterName = Epson;
                printDoc.PrintPage += eventoEpson;
            }
            else if (nomeImpressora.ToLower() == "cis")
            {
                //printDoc.OriginAtMargins = true;
                printDoc.PrinterSettings.PrinterName = CS;
                printDoc.PrintPage += eventoCIS;
            }
            else if (!printDoc.PrinterSettings.IsValid)
            {
                throw new Exception("Não foi possível localizar a impressora");
            }

            printDoc.Print();
        }
Esempio n. 27
0
 public PrintHelper(PrintPageEventHandler printPageEventHandler)
 {
     printDocument.PrintPage += printPageEventHandler;
 }
Esempio n. 28
0
 public void SetPrintPageEvenHandler(PrintPageEventHandler handler)
 {
     printDocument.PrintPage += handler;
 }
Esempio n. 29
0
 public override bool ShowPrintPreviewDialog(PrintPageEventHandler printPageEventHandler, QueryPageSettingsEventHandler queryPageSettingsEventHandler)
 {
   try
   {
     System.Windows.Forms.PrintPreviewDialog dlg = new System.Windows.Forms.PrintPreviewDialog();
     Current.PrintingService.PrintDocument.PrintPage += printPageEventHandler;
     Current.PrintingService.PrintDocument.QueryPageSettings += queryPageSettingsEventHandler;
     dlg.Document = Current.PrintingService.PrintDocument;
     dlg.ShowDialog(MainWindow);
     dlg.Dispose();
     return true;
   }
   catch (Exception ex)
   {
     Current.Gui.ErrorMessageBox(ex.ToString());
   }
   finally
   {
     Current.PrintingService.PrintDocument.PrintPage -= printPageEventHandler;
     Current.PrintingService.PrintDocument.QueryPageSettings -= queryPageSettingsEventHandler;
   }
   return false;
 }
Esempio n. 30
0
        public TileableImagePrinter(PrintDocument document, Image image)
        {
            _image = image;

            /* calculate imageable area = page area - margins */
            Rectangle bounds = document.DefaultPageSettings.Bounds;
            Margins margins = document.DefaultPageSettings.Margins;
            Rectangle pageBounds = new Rectangle(
                bounds.Location + new Size(margins.Left, margins.Right),
                bounds.Size - new Size(margins.Left + margins.Right, margins.Top + margins.Bottom));
            _pageSize = pageBounds.Size;
            _pageRegion = new Region(pageBounds);

            /* calculate image size in 1/100 of an inch */
            _imageSize = new SizeF(image.Size.Width * HUNDREDTH_INCH_PER_PIXEL,
                image.Size.Height * HUNDREDTH_INCH_PER_PIXEL);

            /* calculate how many page columns + rows required to tile out the image */
            _pageColumnCount = ((int)(_imageSize.Width / _pageSize.Width)) + 1;
            _pageRowCount = ((int)(_imageSize.Height / _pageSize.Height)) + 1;

            /* calculate the offset of the image on the first page, from page margins + 1/2 of difference between image size and total page size */
            _imageOffset = new PointF(
                pageBounds.Left + (_pageColumnCount * _pageSize.Width - _imageSize.Width) / 2.0f,
                pageBounds.Top + (_pageRowCount * _pageSize.Height - _imageSize.Height) / 2.0f);

            /* start at page 0 */
            _page = 0;

            _printPage = delegate(object sender, PrintPageEventArgs eventArgs)
            {
                /* which page column + row we are printing */
                int pageColumn = _page % _pageColumnCount;
                int pageRow = _page / _pageColumnCount;

                /* clip to the imageable area and draw the offset image into it */
                eventArgs.Graphics.Clip = _pageRegion;
                eventArgs.Graphics.DrawImage(_image, new RectangleF(
                    _imageOffset - new SizeF(pageColumn * _pageSize.Width, pageRow * _pageSize.Height),
                    _imageSize));

                /* only print column * row pages */
                eventArgs.HasMorePages = ++_page < _pageColumnCount * _pageRowCount;
            };

            _endPrint = delegate(object sender, PrintEventArgs eventArgs)
            {
                /* detach handlers from the print document */
                PrintDocument printDocument = (PrintDocument)sender;
                printDocument.PrintPage -= _printPage;
                printDocument.EndPrint -= _endPrint;
            };

            /* attach handlers to the print document */
            document.PrintPage += _printPage;
            document.EndPrint += _endPrint;
        }
Esempio n. 31
0
		/// <summary>
		/// Initializes a new instance of the FlowChart class.
		/// </summary>
		public FlowChart()
		{
			license = LicenseManager.Validate(typeof(FlowChart), this);

			measureUnit = GraphicsUnit.Millimeter;

			// set control styles for flicker-free redraw
			SetStyle(ControlStyles.UserPaint, true);
			SetStyle(ControlStyles.AllPaintingInWmPaint, true);
			SetStyle(ControlStyles.Opaque, true);
			SetStyle(ControlStyles.ResizeRedraw, true);

			// we want to process keyboard input
			SetStyle(ControlStyles.Selectable, true);
     
			// init static objects
			lock (syncRoot)
			{
				Arrow.initHeadTemplates();
				CustomCursors.Init(new ResourceManager(
					"MindFusion.FlowChartX.Cursors", typeof(ChartObject).Assembly));
			}

			mouseMoved = false;

			boxFillColor = Color.FromArgb(220, 220, 255);
			boxFrameColor = Color.Black;
			arrowColor = Color.Black;
			arrowTextStyle = ArrowTextStyle.Center;
			arrowFillColor = Color.FromArgb(120, 220, 255);
			tableFrameColor = Color.Black;
			tableFillColor = Color.FromArgb(180, 160, 160);
			penDashStyle = DashStyle.Solid;
			penWidth = 0;
			BackColor = Color.FromArgb(170, 170, 200);

			// grid properties
			alignToGrid = true;
			showGrid = false;
			gridColor = Color.FromArgb(140, 140, 150);
			gridSizeX = 4;
			gridSizeY = 4;
			gridStyle = GridStyle.Points;

			// shadows properties
			shadowOffsetX = 1;
			shadowOffsetY = 1;
			shadowColor = Color.FromArgb(110, 110, 140);
			shadowsStyle = ShadowsStyle.OneLevel;

			activeMnpColor = Color.White;
			selMnpColor = Color.FromArgb(170, 170, 170);
			disabledMnpColor = Color.FromArgb(200, 0, 0);

			textFormat = new StringFormat();
			textFormat.Alignment = StringAlignment.Center;
			textFormat.LineAlignment = StringAlignment.Center;

			// Set some flags, because otherwise the serializer
			// generates noncompilable code
			textFormat.FormatFlags = StringFormatFlags.NoFontFallback;

			imagePos = ImageAlign.Document;

			boxStyle = BoxStyle.RoundedRectangle;
			tableStyle = TableStyle.Rectangle;

			boxPen = new Pen(boxFrameColor, penWidth);
			boxBrush = new SolidBrush(boxFillColor);
			boxBrush.AddRef();
			arrowPen = new Pen(arrowColor, penWidth);
			arrowBrush = new SolidBrush(arrowFillColor);
			arrowBrush.AddRef();
			tablePen = new Pen(tableFrameColor, penWidth);
			tableBrush = new SolidBrush(tableFillColor);
			tableBrush.AddRef();

			exteriorBrush = null;
			brush = new SolidBrush(BackColor);
			brush.AddRef();

			boxes = new BoxCollection();
			controlHosts = new ControlHostCollection();
			tables = new TableCollection();
			arrows = new ArrowCollection();
			selection = new Selection(this);
			selectionOnTop = true;

			groups = new GroupCollection();

			zOrder = new ChartObjectCollection();

			textColor = Color.Black;
			arrowStyle = MindFusion.FlowChartX.ArrowStyle.Polyline;
			arrowSegments = 1;
			activeObject = null;

			modificationStart = ModificationStyle.SelectedOnly;
			autoHandlesObj = null;
			autoAnchorsObj = null;

			interaction = null;

			scrollX = scrollY = 0;
			zoomFactor = 100.0f;
			allowRefLinks = true;
			Behavior = BehaviorType.FlowChart;
			arrowEndsMovable = true;
			selectAfterCreate = true;

			// init default custom draw properties
			boxCustomDraw = CustomDraw.None;
			tableCustomDraw = CustomDraw.None;
			cellCustomDraw = CustomDraw.None;
			arrowCustomDraw = CustomDraw.None;

			restrObjsToDoc = RestrictToDoc.Intersection;
			dynamicArrows = false;
			arrowsSnapToBorders = false;
			arrowsRetainForm = false;
			arrowCascadeOrientation = Orientation.Auto;

			curPointer = Cursors.Arrow;
			curCannotCreate = Cursors.No;
			curModify = Cursors.SizeAll;
			curArrowStart = Cursors.Hand;
			curArrowEnd = Cursors.Hand;
			curArrowCannotCreate = Cursors.No;
			curHorzResize = Cursors.SizeWE;
			curVertResize = Cursors.SizeNS;
			curMainDgnlResize = Cursors.SizeNWSE;
			curSecDgnlResize = Cursors.SizeNESW;
			curRotateShape = CustomCursors.Rotate;
			panCursor = Cursors.NoMove2D;

			tableRowsCount = 4;
			tableColumnsCount = 2;
			tableRowHeight = 6;
			tableColWidth = 18;
			tableCaptionHeight = 5;
			tableCaption = "Table";
			tableCellBorders = CellFrameStyle.System3D;

			selHandleSize = 2;

			showDisabledHandles = true;
			arrowSelStyle = HandlesStyle.SquareHandles;
			boxSelStyle = HandlesStyle.SquareHandles;
			chostSelStyle = HandlesStyle.HatchHandles;
			tableSelStyle = HandlesStyle.DashFrame;

			recursiveExpand = false;
			expandOnIncoming = false;
			boxesExpandable = false;
			tablesScrollable = false;
			tablesExpandable = false;
			controlHostsExpandable = false;

			arrowHead = ArrowHead.Arrow;
			arrowBase = ArrowHead.None;
			arrowInterm = ArrowHead.None;

			arrowHeadSize = 5;
			arrowBaseSize = 5;
			arrowIntermSize = 5;

			ShowScrollbars = true;
			DocExtents = new RectangleF(0, 0, 210, 297);

			autoScroll = true;
			autoScrDX = autoScrDY = 0;

			dirty = false;
			antiAlias = SmoothingMode.None;
			textRendering = TextRenderingHint.SystemDefault;
			sortGroupsByZ = false;

			// tooltips
			showToolTips = true;
			toolTip = "";
			toolTipCtrl = new ToolTip();
			toolTipCtrl.Active = showToolTips;

			shapeRotation = 0;
			DefaultShape = ShapeTemplate.FromId("Cylinder");

			inplaceEditAllowed = false;
			inplaceObject = null;
			nowEditing = false;
			inplaceEditFont = (Font)Font.Clone();
			inplaceAcceptOnEnter = false;
			inplaceCancelOnEsc = true;

			allowSplitArrows = false;

			printOptions = new PrintOptions(this);
			printOptions.EnableBackground = false;
			printOptions.EnableBackgroundImage = false;
			printOptions.PaintControls = true;

			displayOptions = new PrintOptions(this);
			renderOptions = displayOptions;

			previewOptions = new PreviewOptions();

			allowLinksRepeat = true;
			showAnchors = ShowAnchors.Auto;
			snapToAnchor = SnapToAnchor.OnCreate;

			beginPrintHandler = new PrintEventHandler(this.BeginPrint);
			printPageHandler = new PrintPageEventHandler(this.PrintPage);
			printRect = new RectangleF(0, 0, 1, 1);

			usePolyTextLt = false;

			userAction = false;

			tableLinkStyle = TableLinkStyle.Rows;

			undoManager = new UndoManager(this);

			defaultControlType = typeof(System.Windows.Forms.Button);
			hostedCtrlMouseAction = HostMouseAction.SelectHost;

			dummy = new DummyNode(this);
			allowUnconnectedArrows = false;
			allowUnanchoredArrows = true;

			autoSizeDoc = MindFusion.FlowChartX.AutoSize.None;
			panMode = false;

			enableStyledText = false;

			expandBtnPos = ExpandButtonPosition.OuterRight;
			focusLost = false;

			hitTestPriority = HitTestPriority.NodesBeforeArrows;

			boxText = arrowText = "";

			// arrow crossings
			arrowCrossings = ArrowCrossings.Straight;
			crossRadius = 1.5f;
			redrawNonModified = false;

			roundRectFactor = 1;

			scriptHelper = new ScriptHelper(this);

			// link routing options
			routingOptions = new RoutingOptions(this);
			routingGrid = new RoutingGrid(this);
			routeArrows = false;
			dontRouteForAwhile = false;

			validityChecks = true;
			_modifierKeyActions = new ModifierKeyActions();
			middleButtonAction = MouseButtonAction.None;
			forceCacheRedraw = false;

			showHandlesOnDrag = true;
			mergeThreshold = 0;

			expandButtonAction = ExpandButtonAction.ExpandTreeBranch;
		}
Esempio n. 32
0
		private void InitializeSimpleLayout()
		{
			line = new Line();
			
			// Preparing events handlers
			beginPrint	= new PrintEventHandler(BeginPrint);
			printPage	= new PrintPageEventHandler(PrintPage);
		}
		public static void PrintTicket()
		{
			PrintDocument pd = new PrintDocument();
			PaperSize ps = new PaperSize("", 780, 530);
			PrintPageEventHandler ciao = new PrintPageEventHandler(PrintPage);
			pd.PrintPage += new PrintPageEventHandler(PrintPage);
			pd.PrintController = new StandardPrintController();
			pd.DefaultPageSettings.Margins.Left = 0;
			pd.DefaultPageSettings.Margins.Right = 0;
			pd.DefaultPageSettings.Margins.Top = 0;
			pd.DefaultPageSettings.Margins.Bottom = 0;
			pd.DefaultPageSettings.PaperSize = ps;
			pd.Print();
		}