/// <summary> /// P 是客户端坐标 /// </summary> /// <param name="p"></param> public void SetAutoScrollPosition(System.Drawing.Point p) { if (StackTraceHelper.CheckRecursion()) { return; } //XDesignerCommon.StackTraceHelper.OutputStackTrace(); bolScrolling = true; this.AutoScrollPosition = p; bolScrolling = false; this.OnScroll(); Debug.WriteLine("End Scroll"); }
/// <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(); } }