/// <summary> /// 将文档视图区域中的坐标转换为控件客户区中的坐标 /// </summary> /// <param name="x">视图坐标值</param> /// <param name="y">视图坐标值</param> /// <param name="mode">转换模式</param> /// <returns>转换结果</returns> public PointF ViewPointToClient(float x, float y, ViewTransformMode mode) { this.RefreshScaleTransform(); SimpleRectangleTransform item = null; switch (mode) { case ViewTransformMode.Normal: item = this.PagesTransform.GetBySourcePoint(x, y); break; case ViewTransformMode.Absolute: item = this.PagesTransform.GetBySourcePointAbsolute(x, y); break; case Printing.ViewTransformMode.LimitedCurrentItem: item = this.CurrentTransformItem; break; } if (item != null) { return(item.TransformPointF(x, y)); } else { return(new PointF(float.NaN, float.NaN)); } }
public System.Drawing.PointF AbsUnTransformPoint(float x, float y) { SimpleRectangleTransform pre = null; SimpleRectangleTransform next = null; SimpleRectangleTransform cur = null; foreach (SimpleRectangleTransform item in this) { if (item.Enable == false) { continue; } if (intLimitedPageIndex >= 0 && item.PageIndex != intLimitedPageIndex) { continue; } if (item.DescRectF.Contains(x, y)) { return(item.UnTransformPointF(x, y)); } if (y >= item.DescRectF.Top && y < item.DescRectF.Bottom) { cur = item; break; } if (y < item.DescRectF.Top) { if (next == null || item.DescRectF.Top < next.DescRectF.Top) { next = item; } } if (y > item.DescRectF.Bottom) { if (pre == null || item.DescRectF.Bottom > pre.DescRectF.Bottom) { pre = item; } } }//foreach if (cur == null) { if (pre != null) { cur = pre; } else { cur = next; } } if (cur == null) { return(System.Drawing.PointF.Empty); } System.Drawing.PointF p = new System.Drawing.PointF(x, y); p = RectangleCommon.MoveInto(p, cur.DescRectF); return(cur.UnTransformPointF(p)); }
public System.Drawing.Point AbsTransformPoint(int x, int y) { SimpleRectangleTransform pre = null; SimpleRectangleTransform next = null; SimpleRectangleTransform cur = null; foreach (SimpleRectangleTransform item in this) { if (item.Enable == false) { continue; } if (item.SourceRect.Contains(x, y)) { return(item.TransformPoint(x, y)); } if (y >= item.SourceRectF.Top && y <= item.SourceRectF.Bottom) { cur = item; break; } if (y < item.SourceRectF.Top) { if (next == null || item.SourceRectF.Top < next.SourceRectF.Top) { next = item; } } if (y > item.SourceRectF.Bottom) { if (pre == null || item.SourceRectF.Bottom > pre.SourceRectF.Bottom) { pre = item; } } } if (cur == null) { if (pre != null) { cur = pre; } else { cur = next; } } if (cur == null) { return(System.Drawing.Point.Empty); } System.Drawing.Point p = new System.Drawing.Point(x, y); p = Common.RectangleCommon.MoveInto(p, cur.SourceRect); return(cur.TransformPoint(p)); }
private int SetSourceRect(SimpleRectangleTransform item, float ZoomRate, int left, int Top) { System.Drawing.RectangleF rect = System.Drawing.Rectangle.Empty; rect.X = left; rect.Y = Top; rect.Width = (item.DescRectF.Width * ZoomRate); rect.Height = (item.DescRectF.Height * ZoomRate); item.SourceRectF = rect; return((int)Math.Ceiling(Top + rect.Height)); }
private int SetSourceRect(SimpleRectangleTransform item, float zoomRate, int left, int top) { System.Drawing.RectangleF rect = System.Drawing.Rectangle.Empty; rect.X = left; rect.Y = top; rect.Width = (int)(item.DescRectF.Width * zoomRate); rect.Height = (int)(item.DescRectF.Height * zoomRate); // 映射到控件客户区 item.SourceRectF = rect; return((int)rect.Bottom);// ( int ) Math.Ceiling( top + rect.Height ); }
/// <summary> /// 将控件客户区域中的坐标转换为文档视图区中的坐标 /// </summary> /// <param name="x">控件客户区坐标值</param> /// <param name="y">控件客户区坐标值</param> /// <param name="mode">转换模式</param> /// <returns>转换结果</returns> public PointF ClientPointToView(float x, float y, ViewTransformMode mode) { SimpleRectangleTransform item = GetTransformItem(x, y, mode); if (item != null) { return(item.UnTransformPointF(x, y)); } else { return(new PointF(float.NaN, float.NaN)); } }
public override System.Drawing.Point UnTransformPoint(int x, int y) { if (this.bolUseAbsTransformPoint) { System.Drawing.PointF p = AbsUnTransformPoint(x, y); return(new System.Drawing.Point((int)p.X, (int)p.Y)); } else { System.Drawing.Point p = System.Drawing.Point.Empty; for (int iCount = this.Count - 1; iCount >= 0; iCount--) { SimpleRectangleTransform item = this[iCount]; if (item.Enable && item.DescRect.Contains(x, y)) { p = item.UnTransformPoint(x, y); return(p); } } return(p); } }
private void cap_Draw(object sender, CaptureMouseMoveEventArgs e) { DragPointStyle hit = (DragPointStyle)e.Sender.Tag; System.Drawing.Rectangle rect = Rectangle.Ceiling(this.AbsBounds); System.Drawing.Point p1 = e.StartPosition; System.Drawing.Point p2 = e.CurrentPosition; SimpleRectangleTransform trans = this.OwnerDocument.EditorControl.GetTransformItemByDescPoint(rect.Left, rect.Top); if (trans != null) { p1 = trans.TransformPoint(p1); p2 = trans.TransformPoint(p2); rect = DragRectangle.CalcuteDragRectangle( (int)(p2.X - p1.X), (int)(p2.Y - p1.Y), hit, Rectangle.Ceiling(this.AbsBounds)); if (rect.Width > (int)this.OwnerDocument.Width) { rect.Width = (int)this.OwnerDocument.Width; } if (this.WidthHeightRate > 0.1) { rect.Height = (int)(rect.Width / this.WidthHeightRate); } LastDragBounds = rect; rect = trans.UnTransformRectangle(rect); using (ReversibleDrawer drawer = ReversibleDrawer.FromHwnd(this.OwnerDocument.EditorControl.Handle)) { drawer.PenStyle = PenStyle.PS_DOT; drawer.PenColor = System.Drawing.Color.Red; drawer.DrawRectangle(rect); } } }
/// <summary> /// 获得指定客户区坐标点所在的坐标转换对象 /// </summary> /// <param name="clientX">客户区X坐标</param> /// <param name="clientY">客户区Y坐标</param> /// <param name="mode">转换模式</param> /// <returns>获得的转换对象</returns> public SimpleRectangleTransform GetTransformItem( float clientX, float clientY, ViewTransformMode mode) { this.RefreshScaleTransform(); SimpleRectangleTransform item = null; switch (mode) { case ViewTransformMode.Normal: item = this.PagesTransform.GetByDescPoint(clientX, clientY); break; case ViewTransformMode.Absolute: item = this.PagesTransform.GetByDescPointAbsolute(clientX, clientY); break; case Printing.ViewTransformMode.LimitedCurrentItem: item = this.CurrentTransformItem; break; } return(item); }
/// <summary> /// 根据页面位置添加矩形区域转换关系 /// </summary> /// <param name="myTransform">转换列表</param> /// <param name="ForPrint">是否为打印进行填充</param> public void AddPage(PrintPage page, int PageTop, float ZoomRate) { System.Drawing.Rectangle rect = System.Drawing.Rectangle.Empty; int leftmargin = (int)(myPages.LeftMargin * ZoomRate); int topmargin = (int)(myPages.TopMargin * ZoomRate); int rightmargin = (int)(myPages.RightMargin * ZoomRate); int bottommargin = (int)(myPages.BottomMargin * ZoomRate); int pagewidth = (int)(myPages.PaperWidth * ZoomRate); int pageheight = (int)(myPages.PaperHeight * ZoomRate); int Top = PageTop + topmargin; SimpleRectangleTransform item = null; if (myPages.HeadHeight > 0) { item = new SimpleRectangleTransform(); item.PageIndex = page.Index; item.Flag2 = 0; item.Tag = page; item.DescRect = new System.Drawing.Rectangle( 0, 0, page.Width, myPages.HeadHeight); Top = SetSourceRect(item, ZoomRate, leftmargin, Top); this.Add(item); } item = new SimpleRectangleTransform(); item.PageIndex = page.Index; item.Flag2 = 1; item.Tag = page; item.DescRect = new System.Drawing.Rectangle( 0, page.Top, page.Width, page.Height); Top = SetSourceRect(item, ZoomRate, leftmargin, Top); this.Add(item); if (myPages.FooterHeight > 0) { item = new SimpleRectangleTransform(); item.PageIndex = page.Index; item.Flag2 = 2; item.Tag = page; item.DescRect = new System.Drawing.Rectangle( 0, myPages.DocumentHeight - myPages.FooterHeight, page.Width, myPages.FooterHeight); SetSourceRect(item, ZoomRate, leftmargin, Top); rect = item.SourceRect; Top = PageTop + pageheight - bottommargin - rect.Height; item.SourceRect = new System.Drawing.Rectangle(leftmargin, Top, rect.Width, rect.Height); this.Add(item); } }
/// <summary> /// 根据分页信息更新页面排布 /// </summary> public virtual void UpdatePages() { if (StackTraceHelper.CheckRecursion()) { // 检查递归 return; } float rate = ( float )(1.0 / this.ClientToViewXRate); if (this.ViewMode == PageViewMode.Normal) { this.PagesTransform.Clear(); this.PagesTransform.ClearSourceOffset(); SimpleRectangleTransform item = new SimpleRectangleTransform(); item.PageIndex = 0; item.DescRectF = new RectangleF(0, 0, this.Pages.GetPageMaxWidth(), this.Pages.Height); item.SourceRectF = new RectangleF(0, 0, item.DescRectF.Width * rate, item.DescRectF.Height * rate); item.PageObject = this.Pages[0]; item.ContentStyle = PageContentPartyStyle.Body; item.Enable = true; item.DocumentObject = this.Pages[0].Document; this.PagesTransform.Add(item); this.PagesTransform.ClearSourceOffset(); this.RefreshScaleTransform(); Size msize = new Size( ( int )Math.Ceiling(item.SourceRectF.Width), ( int )Math.Ceiling(item.SourceRectF.Height)); if (this.AutoScrollMinSize.Equals(msize) == false) { this.AutoScrollMinSize = msize; } this.CurrentPage = this.Pages[0]; int topCount = 0; foreach (PrintPage page in this.Pages) { page.ClientBounds = new Rectangle( 0, (int )(topCount * rate), (int)(page.Bounds.Width * rate), (int)(page.Bounds.Height * rate)); topCount = topCount + page.Bounds.Height; } //int ClientWidth = this.ClientSize.Width; //int x = 0; //if (ClientWidth <= this.AutoScrollMinSize.Width) //{ // x = 0;// this.PageSpacing / 2; //} //else //{ // x = (ClientWidth - this.AutoScrollMinSize.Width) / 2; //} //this.PagesTransform.OffsetSource(x, 0, false); } else { Size TotalSize = new Size(0, 0); foreach (PrintPage page in this.Pages) { TotalSize.Height = (int)(TotalSize.Height + this.PageSpacing + page.PageSettings.ViewPaperHeight * rate); if (TotalSize.Width < page.PageSettings.ViewPaperWidth * rate) { TotalSize.Width = (int)(page.PageSettings.ViewPaperWidth * rate); } //page.OwnerPages = this.Pages; } TotalSize.Width += this.PageSpacing * 2; TotalSize.Height += this.PageSpacing; foreach (PrintPage page in this.Pages) { page.ClientLeftFix = (int)(TotalSize.Width - page.PageSettings.ViewPaperWidth * rate) / 2; } if (this.AutoScrollMinSize.Equals(TotalSize) == false) { this.AutoScrollMinSize = TotalSize; } MultiPageTransform trans = (MultiPageTransform)this.Transform; base.intGraphicsUnit = this.Pages.GraphicsUnit; trans.Pages = this.Pages; trans.Refresh(rate, this.PageSpacing); int ClientWidth = this.ClientSize.Width; int x = 0; if (ClientWidth <= TotalSize.Width) { x = 0;// this.PageSpacing / 2; } else { x = (ClientWidth - TotalSize.Width) / 2; } trans.OffsetSource(x, 0, false); this.RefreshScaleTransform(); //System.Drawing.Rectangle rect = System.Drawing.Rectangle.Empty ; int topCount = this.PageSpacing; foreach (PrintPage page in this.Pages) { System.Drawing.Rectangle clientRect = System.Drawing.Rectangle.Empty; clientRect.X = x + page.ClientLeftFix; clientRect.Y = topCount; clientRect.Width = (int)(page.PageSettings.ViewPaperWidth * rate); clientRect.Height = (int)(page.PageSettings.ViewPaperHeight * rate); //page.ClientLocation = new Point(this.AutoScrollPosition.X, this.AutoScrollPosition.Y); page.ClientBounds = clientRect; page.ClientMargins = new System.Drawing.Printing.Margins( (int)(page.ViewLeftMargin * rate), (int)(page.ViewRightMargin * rate), (int)(page.ViewTopMargin * rate), (int)(page.ViewBottomMargin * rate)); topCount = topCount + clientRect.Height + this.PageSpacing; }//foreach this.UpdateCurrentPage(); } }
/// <summary> /// 已重载:绘制文档内容 /// </summary> /// <param name="e">绘制事件参数</param> protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { //if (this.DesignMode) { base.OnPaint(e); } if (this.IsUpdating) { return; } System.Drawing.Rectangle clipRect = e.ClipRectangle; clipRect.Height += 1; System.Drawing.Point sp = this.AutoScrollPosition; //int ax = - this.AutoScrollPosition.X ; //int ay = - this.AutoScrollPosition.Y ; this.RefreshScaleTransform(); if (this.PagesTransform == null || this.PagesTransform.Count == 0) { // 没有任何内容可以绘制 return; } if (this.ViewMode == PageViewMode.Normal) { using (SolidBrush b = new SolidBrush(this.PageBackColor)) { e.Graphics.FillRectangle(b, e.ClipRectangle); } SimpleRectangleTransform item = this.PagesTransform[0]; PrintPage myPage = (PrintPage)item.PageObject; Rectangle rect = item.SourceRect; rect.Width = rect.Width + 30; rect = Rectangle.Intersect( clipRect, rect); if (rect.IsEmpty == false) { // 保存状态 System.Drawing.Drawing2D.GraphicsState state2 = e.Graphics.Save(); //try { PaintEventArgs e2 = this.CreatePaintEventArgs(e, item); if (e2 != null) { PageDocumentPaintEventArgs e3 = new PageDocumentPaintEventArgs( e2.Graphics, e2.ClipRectangle, myPage.Document, myPage, item.ContentStyle); e3.ContentBounds = item.DescRect; e3.RenderMode = ContentRenderMode.Paint; e3.PageIndex = myPage.PageIndex; e3.NumberOfPages = this.Pages.Count; //e3.EditMode = this.EditMode; if (myPage.Document != null) { myPage.Document.DrawContent(e3); }//if } } //catch (Exception ext) //{ // System.Console.WriteLine(ext.ToString()); //} // 恢复状态 e.Graphics.Restore(state2); } return; } // MultiPageTransform trans = ( MultiPageTransform )this.Transform; // trans.ClearSourceOffset(); // trans.OffsetSource( sp.X , sp.Y , true ); System.Drawing.Graphics g = e.Graphics; //System.Drawing.Drawing2D.GraphicsState stateBack = e.Graphics.Save(); foreach (PrintPage myPage in this.Pages) { System.Drawing.Rectangle ClientBounds = myPage.ClientBounds; ClientBounds.Offset(sp); ClientBounds.Width = ClientBounds.Width + 20; //if( clipRect.Top <= ClientBounds.Bottom + 5 // && clipRect.Bottom >= ClientBounds.Top ) if (clipRect.IntersectsWith( new Rectangle( ClientBounds.Left, ClientBounds.Top, ClientBounds.Width + 5, ClientBounds.Height + 5))) { //this.SetPageIndex( myPage.Index ); //e.Graphics.Restore(stateBack); //e.Graphics.ResetClip(); DrawPageFrame( myPage, e.Graphics, clipRect, true); for (int iCount = trans.Count - 1; iCount >= 0; iCount--) { SimpleRectangleTransform item = trans[iCount]; if (item.Visible && item.PageObject == myPage) { // 显示页眉页脚标记文本 if (item.ContentStyle == PageContentPartyStyle.Header) { if (this.HeaderFooterFlagVisible == HeaderFooterFlagVisible.Header || this.HeaderFooterFlagVisible == HeaderFooterFlagVisible.HeaderFooter) { // 绘制页眉标记 //e.Graphics.Restore(stateBack); DrawHeaderFooterFlag( PrintingResources.Header, item.PartialAreaSourceBounds, e.Graphics); } } else if (item.ContentStyle == PageContentPartyStyle.Footer) { if (this.HeaderFooterFlagVisible == HeaderFooterFlagVisible.Footer || this.HeaderFooterFlagVisible == HeaderFooterFlagVisible.HeaderFooter) { // 绘制页脚标记 //e.Graphics.Restore(stateBack); DrawHeaderFooterFlag( PrintingResources.Footer, item.PartialAreaSourceBounds, e.Graphics); } } Rectangle rect = item.SourceRect; rect = Rectangle.Intersect( clipRect, rect); if (rect.IsEmpty == false) { System.Drawing.Drawing2D.GraphicsState state2 = e.Graphics.Save(); PaintEventArgs e2 = this.CreatePaintEventArgs(e, item); if (e2 != null) { PageDocumentPaintEventArgs e3 = new PageDocumentPaintEventArgs( e2.Graphics, e2.ClipRectangle, myPage.Document, myPage, item.ContentStyle); e3.ContentBounds = item.DescRect; e3.RenderMode = ContentRenderMode.Paint; e3.PageIndex = myPage.PageIndex; e3.NumberOfPages = this.Pages.Count; //e3.EditMode = this.EditMode; if (myPage.Document != null) { myPage.Document.DrawContent(e3); }//if } e.Graphics.Restore(state2); if (item.Enable == false) { // 若区域无效则用白色半透明进行覆盖,以作标记 using (System.Drawing.SolidBrush maskBrush = new SolidBrush(Color.FromArgb(140, this.PageBackColor))) { e.Graphics.FillRectangle( maskBrush, rect.Left, rect.Top, rect.Width + 2, rect.Height + 2); } } } //if // ClipRect.Height -= 1; } } //foreach } //if } //foreach DrawHeadShadow(); //base.OnPaint( e ); //e.Graphics.Flush(System.Drawing.Drawing2D.FlushIntention.Sync); //System.Threading.Thread.Sleep(100); }
/// <summary> /// 根据页面位置添加矩形区域转换关系 /// </summary> /// <param name="myTransform">转换列表</param> /// <param name="ForPrint">是否为打印进行填充</param> public override void AddPage(PrintPage page, float pageTop, float zoomRate) { //XPageSettings pageSettings = page.PageSettings; XPageSettings ps = page.PageSettings; System.Drawing.Rectangle rect = System.Drawing.Rectangle.Empty; int leftmargin = (int)(page.ViewLeftMargin * zoomRate); int topmargin = (int)(page.ViewTopMargin * zoomRate); int rightmargin = (int)(page.ViewRightMargin * zoomRate); int bottommargin = (int)(page.ViewBottomMargin * zoomRate); int pagewidth = (int)(page.ViewPaperWidth * zoomRate); int pageheight = (int)(page.ViewPaperHeight * zoomRate); int top = (int)pageTop + topmargin; SimpleRectangleTransform headerItem = null; SimpleRectangleTransform bodyItem = null; SimpleRectangleTransform footerItem = null; DomDocument document = (DomDocument)page.Document; // 添加文档页眉视图映射 headerItem = new SimpleRectangleTransform(); headerItem.Enable = (document.CurrentContentPartyStyle == PageContentPartyStyle.Header); headerItem.PageIndex = page.PageIndex; headerItem.ContentStyle = PageContentPartyStyle.Header; headerItem.PageObject = page; headerItem.DocumentObject = page.Document; // 映射到文档视图 //if (document.CurrentContentElement == document.Header) { headerItem.DescRectF = new System.Drawing.RectangleF( 0, 0, page.Width, // 如果当前编辑区域是页眉则设置页眉可视区域的高度为页眉内容高度和页眉标准高度的较大者 Math.Max(ps.ViewHeaderHeight - 1, document.Header.Height)); } if (document.Header.Height > ps.ViewHeaderHeight) { top = top + (int)((document.Header.Height - ps.ViewHeaderHeight) * zoomRate); } //else //{ // headerItem.DescRectF = new System.Drawing.RectangleF( // 0, // 0, // page.Width, // page.ViewTopMargin - ps.ViewHeaderDistance - 1); //} SetSourceRect( headerItem, zoomRate, leftmargin + page.ClientLeftFix, (int)(pageTop + ps.ViewHeaderDistance * zoomRate)); headerItem.PartialAreaSourceBounds = new Rectangle( headerItem.SourceRect.Left, headerItem.SourceRect.Top, headerItem.SourceRect.Width, headerItem.SourceRect.Height); //(int)( headerItem.DescRectF.Height * zoomRate )); // 添加正文文档映射 bodyItem = new SimpleRectangleTransform(); bodyItem.Enable = (document.CurrentContentPartyStyle == PageContentPartyStyle.Body); bodyItem.PageIndex = page.PageIndex; bodyItem.ContentStyle = PageContentPartyStyle.Body; bodyItem.PageObject = page; bodyItem.DocumentObject = page.Document; // 映射到文档视图 bodyItem.DescRectF = new System.Drawing.RectangleF( 0, page.Top, page.Width, page.Height); int spacing = 0; if (document.Header.Height > ps.ViewHeaderHeight - 10) { spacing = 5;// 当页眉实际高度大于标准页眉高度,页眉内容突出了标准区域,此时为了美观,页眉和页身之间留点空隙 } top = SetSourceRect( bodyItem, zoomRate, leftmargin + page.ClientLeftFix, headerItem.PartialAreaSourceBounds.Bottom + spacing); bodyItem.PartialAreaSourceBounds = new Rectangle( bodyItem.SourceRect.Left, bodyItem.SourceRect.Top, bodyItem.SourceRect.Width, (int)(document.GetStandartPapeViewHeight(ps) * zoomRate)); // 添加页脚文档视图映射 footerItem = new SimpleRectangleTransform(); footerItem.Enable = (document.CurrentContentPartyStyle == PageContentPartyStyle.Footer); footerItem.PageIndex = page.PageIndex; footerItem.ContentStyle = PageContentPartyStyle.Footer; footerItem.PageObject = page; footerItem.DocumentObject = page.Document; // 映射到文档视图 //if (document.CurrentContentElement == document.Footer) { footerItem.DescRectF = new System.Drawing.RectangleF( 0, 0, page.Width, // 如果当前编辑区域是页脚则设置页脚可视区域的高度为页脚内容高度和页脚标准高度的较大者 document.Footer.Height); } //else //{ // footerItem.DescRectF = new System.Drawing.RectangleF( // 0, // 0, // page.Width, // page.ViewBottomMargin - ps.ViewFooterDistance - 1); //} SetSourceRect( footerItem, zoomRate, leftmargin + page.ClientLeftFix, ( int )(pageTop + pageheight - ps.ViewFooterDistance * zoomRate - document.Footer.Height * zoomRate)); //bodyItem.PartialAreaSourceBounds.Bottom + 2);// 为了美观,页身和页脚之间留点空隙,由于页身实际高度经常小于页身标准高度,因此留的空隙小一些。 footerItem.PartialAreaSourceBounds = new Rectangle( footerItem.SourceRect.Left, (int )(pageTop + pageheight - bottommargin), footerItem.SourceRect.Width, ( int )(footerItem.SourceRect.Bottom - (pageTop + pageheight - bottommargin))); // footerItem.SourceRect.Height ); //(int)( footerItem.DescRectF.Height * zoomRate)); switch (document.CurrentContentPartyStyle) { case PageContentPartyStyle.Header: if (headerItem != null) { this.Add(headerItem); } this.Add(bodyItem); if (footerItem != null) { this.Add(footerItem); } break; case PageContentPartyStyle.Body: this.Add(bodyItem); if (headerItem != null) { this.Add(headerItem); } if (footerItem != null) { this.Add(footerItem); } break; case PageContentPartyStyle.Footer: if (footerItem != null) { this.Add(footerItem); } if (headerItem != null) { this.Add(headerItem); } this.Add(bodyItem); break; }//switch }
/// <summary> /// 根据页面位置添加矩形区域转换关系 /// </summary> /// <param name="myTransform">转换列表</param> /// <param name="ForPrint">是否为打印进行填充</param> public virtual void AddPage(PrintPage page, float pageTop, float zoomRate) { //XPageSettings pageSettings = page.PageSettings; System.Drawing.Rectangle rect = System.Drawing.Rectangle.Empty; int leftmargin = (int)(page.ViewLeftMargin * zoomRate); int topmargin = (int)(page.ViewTopMargin * zoomRate); int rightmargin = (int)(page.ViewRightMargin * zoomRate); int bottommargin = (int)(page.ViewBottomMargin * zoomRate); int pagewidth = (int)(page.ViewPaperWidth * zoomRate); int pageheight = (int)(page.ViewPaperHeight * zoomRate); int top = (int)pageTop + topmargin; SimpleRectangleTransform item = null; if (page.HeaderHeight > 0) { // 添加文档页眉视图映射 item = new SimpleRectangleTransform(); item.PageIndex = page.GlobalIndex; item.ContentStyle = PageContentPartyStyle.Header; item.PageObject = page; item.DocumentObject = page.Document; // 映射到文档视图 item.DescRectF = new System.Drawing.RectangleF( 0, 0, page.Width, page.HeaderHeight - 1); top = SetSourceRect( item, zoomRate, leftmargin + page.ClientLeftFix, top); this.Add(item); } // 添加正文文档映射 item = new SimpleRectangleTransform(); item.PageIndex = page.GlobalIndex; item.ContentStyle = PageContentPartyStyle.Body; item.PageObject = page; item.DocumentObject = page.Document; // 映射到文档视图 item.DescRectF = new System.Drawing.RectangleF( 0, page.Top, page.Width, page.Height); top = SetSourceRect( item, zoomRate, leftmargin + page.ClientLeftFix, top); this.Add(item); if (page.FooterHeight > 0) { // 添加页脚文档视图映射 item = new SimpleRectangleTransform(); item.PageIndex = page.GlobalIndex; item.ContentStyle = PageContentPartyStyle.Footer; item.PageObject = page; item.DocumentObject = page.Document; // 映射到文档视图 item.DescRectF = new System.Drawing.RectangleF( 0, page.DocumentHeight - page.FooterHeight + 1, page.Width, page.FooterHeight - 1); SetSourceRect(item, zoomRate, leftmargin, top); rect = item.SourceRect; top = (int)(pageTop + pageheight - bottommargin - rect.Height); item.SourceRectF = new System.Drawing.RectangleF( leftmargin + page.ClientLeftFix, top, rect.Width, rect.Height); this.Add(item); } }