Пример #1
0
        /// <summary>
        /// 绘制页面框架
        /// </summary>
        /// <param name="myPage">页面对象</param>
        /// <param name="g">图形绘制对象</param>
        /// <param name="Focused">该页是否是当前页</param>
        /// <param name="FillBackGround">是否填充背景</param>
        protected void DrawPageFrame(
            PrintPage myPage,
            System.Drawing.Graphics g,
            bool Focused,
            bool FillBackGround)
        {
            if (myPage == null || myPages.Contains(myPage) == false)
            {
                return;
            }

            System.Drawing.Rectangle bounds = myPage.ClientBounds;
            bounds.Offset(this.AutoScrollPosition);

            PageFrameDrawer pfdraw = new PageFrameDrawer();

            pfdraw.BackColor = this.PageBackColor;
            #region bwy :
            pfdraw.DrawTopMargin    = this.drawtopmargin;
            pfdraw.DrawBottomMargin = this.drawbottommargin;
            #endregion bwy :
            pfdraw.DrawPageFrame(
                bounds,
                this.myClientMargins,
                g,
                System.Drawing.Rectangle.Empty,
                Focused,
                FillBackGround);
        }
Пример #2
0
        /// <summary>
        /// 已重载:绘制文档内容
        /// </summary>
        /// <param name="e">绘制事件参数</param>
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            if (myUpdateLock.Updating)
            {
                return;
            }
            System.Drawing.Rectangle ClipRect = e.ClipRectangle;
            System.Drawing.Point     sp       = this.AutoScrollPosition;
            //int ax = - this.AutoScrollPosition.X ;
            //int ay = - this.AutoScrollPosition.Y ;
            this.RefreshScaleTransform();
            //
            MultiPageTransform trans = (MultiPageTransform)this.myTransform;

            //			trans.ClearSourceOffset();
            //			trans.OffsetSource( sp.X , sp.Y , true );
            System.Drawing.Graphics g = e.Graphics;
            foreach (PrintPage myPage in myPages)
            {
                System.Drawing.Rectangle ClientBounds = myPage.ClientBounds;
                ClientBounds.Offset(sp);
                if (ClientBounds.IntersectsWith(ClipRect))
                {
                    this.SetPageIndex(myPage.Index);

                    System.Drawing.Drawing2D.GraphicsState state = e.Graphics.Save();
                    e.Graphics.ResetTransform();
                    e.Graphics.PageUnit = System.Drawing.GraphicsUnit.Pixel;

                    e.Graphics.ResetClip();

                    PageFrameDrawer pfdraw = new PageFrameDrawer();
                    pfdraw.PageHeaderHeight = (int)(MeasureConvert.DocumentToMillimeter((double)this.myPages.HeadHeight) * 3.776);
                    pfdraw.PageFooterHeight = (int)(MeasureConvert.DocumentToMillimeter((double)this.myPages.FooterHeight) * 3.776);
                    pfdraw.BackColor        = this.PageBackColor;
                    pfdraw.DrawTopMargin    = this.drawtopmargin;
                    pfdraw.DrawBottomMargin = this.drawbottommargin;

                    pfdraw.DrawPageFrame(
                        ClientBounds,
                        this.myClientMargins,
                        e.Graphics,
                        ClipRect,
                        myPage == this.myCurrentPage,
                        true);

                    e.Graphics.Restore(state);

                    foreach (SimpleRectangleTransform item in trans)
                    {
                        if (item.Visible && item.Tag == myPage)
                        {
                            System.Drawing.Rectangle rect = System.Drawing.Rectangle.Intersect(
                                e.ClipRectangle,
                                item.SourceRect);

                            if (!rect.IsEmpty)
                            {
                                TransformPaint(e, item);
                            }
                        }
                    }
                }
            }
            base.OnPaint(e);
        }