Пример #1
0
        /// <summary>
        /// Central routine for painting the graph. The painting can either be on the screen (bForPrinting=false), or
        /// on a printer or file (bForPrinting=true).
        /// </summary>
        /// <param name="g">The graphics context painting to.</param>
        /// <param name="bForPrinting">If true, margins and background are not painted, as is usefull for printing.
        /// Also, if true, the scale is temporarely set to 1.</param>
        private void DoPaintUnbuffered(Graphics g, bool bForPrinting)
        {
            try
            {
                ScaleForPaint(g, bForPrinting);

                if (!bForPrinting)
                {
                    g.Clear(this._nonPageAreaColor);
                    // Fill the page with its own color
                    //g.FillRectangle(_pageGroundBrush,_doc.PageBounds);
                    //g.FillRectangle(m_PrintableAreaBrush,m_Graph.PrintableBounds);
                    g.FillRectangle(_graphAreaBrush, -GraphViewOffset.X, -GraphViewOffset.Y, Doc.Layers.GraphSize.Width, Doc.Layers.GraphSize.Height);
                    // DrawMargins(g);
                }

                // Paint the graph now
                //g.TranslateTransform(m_Graph.PrintableBounds.X,m_Graph.PrintableBounds.Y); // translate the painting to the printable area
                g.TranslateTransform(-GraphViewOffset.X, -GraphViewOffset.Y);
                Doc.DoPaint(g, bForPrinting);
            }
            catch (System.Exception ex)
            {
                g.PageUnit  = GraphicsUnit.Point;
                g.PageScale = 1;

                g.DrawString(ex.ToString(),
                             new System.Drawing.Font("Arial", 10),
                             System.Drawing.Brushes.Black,
                             Doc.PrintableBounds);
            }
        }