Пример #1
0
        protected override void RefreshScaleTransform()
        {
            MultiPageTransform trans = (MultiPageTransform)this.myTransform;

            intGraphicsUnit = myPages.GraphicsUnit;
            trans.Rate      = GraphicsUnitConvert.GetRate(intGraphicsUnit, System.Drawing.GraphicsUnit.Pixel);

            //float rate = ( float )( 1.0 / this.ClientToViewXRate );
            //trans.Pages = myPages ;
            //trans.Refresh( rate , this.intPageSpacing );
            System.Drawing.Point sp = this.AutoScrollPosition;
            trans.ClearSourceOffset();
            trans.OffsetSource(sp.X, sp.Y, true);


            //			myClientMargins = new System.Drawing.Printing.Margins(
            //				( int ) ( myPages.LeftMargin * rate ),
            //				( int ) ( myPages.RightMargin * rate ) ,
            //				( int ) ( myPages.TopMargin * rate ),
            //				( int ) ( myPages.BottomMargin * rate ));
            //
            //			myClientPageSize = new System.Drawing.Size(
            //				( int) ( myPages.PaperWidth * rate ) ,
            //				( int ) ( myPages.PaperHeight * rate ));
        }
Пример #2
0
        //
        //		private void UpdateTransform()
        //		{
        //			float rate = ( float )( 1.0 / this.ClientToViewXRate );
        //			MultiPageTransform trans = ( MultiPageTransform ) this.myTransform ;
        //			trans.Pages = myPages ;
        //			trans.Refresh( rate , this.intPageSpacing );
        //		}

        /// <summary>
        /// 根据分页信息更新页面排布
        /// </summary>
        public virtual void UpdatePages()
        {
            if (Common.StackTraceHelper.CheckRecursion())
            {
                return;
            }

            float rate = (float)(1.0 / this.ClientToViewXRate);

            System.Drawing.Size size = new System.Drawing.Size(
                (int)(myPages.PaperWidth * rate),
                (int)(myPages.PaperHeight * rate));

            System.Drawing.Size TotalSize = new System.Drawing.Size(
                size.Width + this.intPageSpacing * 2,
                (size.Height + this.intPageSpacing) * myPages.Count + this.intPageSpacing);

            if (this.AutoScrollMinSize.Equals(TotalSize) == false)
            {
                this.AutoScrollMinSize = TotalSize;
            }


            MultiPageTransform trans = (MultiPageTransform)this.myTransform;

            base.intGraphicsUnit = myPages.GraphicsUnit;

            trans.Pages = myPages;
            trans.Refresh(rate, this.intPageSpacing);

            myClientMargins = new System.Drawing.Printing.Margins(
                (int)(myPages.LeftMargin * rate),
                (int)(myPages.RightMargin * rate),
                (int)(myPages.TopMargin * rate),
                (int)(myPages.BottomMargin * rate));

            myClientPageSize = new System.Drawing.Size(
                (int)(myPages.PaperWidth * rate),
                (int)(myPages.PaperHeight * rate));

            int ClientWidth = this.ClientSize.Width;
            int x           = 0;

            if (ClientWidth <= TotalSize.Width)
            {
                x = this.intPageSpacing;
            }
            else
            {
                x = (ClientWidth - TotalSize.Width) / 2 + intPageSpacing;
            }
            trans.OffsetSource(x, 0, false);

            this.RefreshScaleTransform();

            System.Drawing.Rectangle rect = System.Drawing.Rectangle.Empty;

            for (int iCount = 0; iCount < myPages.Count; iCount++)
            {
                rect.X      = x;
                rect.Y      = (size.Height + this.intPageSpacing) * iCount + this.intPageSpacing;
                rect.Width  = size.Width;
                rect.Height = size.Height;
                myPages[iCount].ClientBounds = rect;
            }
            this.UpdateCurrentPage();
        }