Exemplo n.º 1
0
        public override void UpdateLayout(Size viewportSize)
        {
            RotationAngle rotationAngle = this.Presenter.Owner.RotationAngle;

            this.pageLayoutInfos.Clear();
            if (this.Document == null)
            {
                this.ContentSize = new Size(0, 0);
                return;
            }

            double height = 0;
            double width  = 0;

            foreach (RadFixedPage page in this.Document.Pages)
            {
                Size pageSize            = this.GetScaledPageSize(page);
                Size rotatedPageSize     = this.RotateSize(pageSize, rotationAngle);
                Size pageSizeWithMargins = new Size(rotatedPageSize.Width + (2 * this.PageMargins.Width), rotatedPageSize.Height + (2 * this.PageMargins.Height));

                if (pageSizeWithMargins.Width > width)
                {
                    width = pageSizeWithMargins.Width;
                }

                double horizontalOffset = ((viewportSize.Width - rotatedPageSize.Width) / 2) - this.PageMargins.Width;
                double verticalOffset   = ((viewportSize.Height - rotatedPageSize.Height) / 2) - this.PageMargins.Height;

                horizontalOffset = Math.Max(0, horizontalOffset);
                verticalOffset   = Math.Max(0, verticalOffset);

                double newHeight = height + pageSizeWithMargins.Height + 2 * verticalOffset;

                Rect positionInView = new Rect(this.PageMargins.Width + horizontalOffset, height + this.PageMargins.Height + verticalOffset, rotatedPageSize.Width, rotatedPageSize.Height);

                TransformGroup transformations = this.CreateTransformations(pageSize, rotationAngle);

                FixedPageLayoutInfo layoutInfo = new FixedPageLayoutInfo(page, positionInView, transformations);

                SinglePageInfo singlePageInfo = new SinglePageInfo(verticalOffset + this.PageMargins.Height, newHeight,
                                                                   rotatedPageSize.Width > viewportSize.Width,
                                                                   rotatedPageSize.Height > viewportSize.Height,
                                                                   layoutInfo.FixedPage, layoutInfo.PositionInView,
                                                                   layoutInfo.Transformations);

                this.pageLayoutInfos.Add(singlePageInfo);

                height = newHeight;
            }

            this.ContentSize = new Size(width, height);
        }
        public override void UpdateLayout(Size viewportSize)
        {
            RotationAngle rotationAngle = this.Presenter.Owner.RotationAngle;

            this.pageLayoutInfos.Clear();
            if (this.Document == null)
            {
                this.ContentSize = new Size(0, 0);
                return;
            }

            double height = 0;
            double width = 0;
            foreach (RadFixedPage page in this.Document.Pages)
            {
                Size pageSize = this.GetScaledPageSize(page);
                Size rotatedPageSize = this.RotateSize(pageSize, rotationAngle);
                Size pageSizeWithMargins = new Size(rotatedPageSize.Width + (2 * this.PageMargins.Width), rotatedPageSize.Height + (2 * this.PageMargins.Height));

                if (pageSizeWithMargins.Width > width)
                {
                    width = pageSizeWithMargins.Width;
                }

                double horizontalOffset = ((viewportSize.Width - rotatedPageSize.Width) / 2) - this.PageMargins.Width;
                double verticalOffset = ((viewportSize.Height - rotatedPageSize.Height) / 2) - this.PageMargins.Height;

                horizontalOffset = Math.Max(0, horizontalOffset);
                verticalOffset = Math.Max(0, verticalOffset);

                double newHeight = height + pageSizeWithMargins.Height + 2 * verticalOffset;

                Rect positionInView = new Rect(this.PageMargins.Width + horizontalOffset, height + this.PageMargins.Height + verticalOffset, rotatedPageSize.Width, rotatedPageSize.Height);

                TransformGroup transformations = this.CreateTransformations(pageSize, rotationAngle);

                FixedPageLayoutInfo layoutInfo = new FixedPageLayoutInfo(page, positionInView, transformations);

                SinglePageInfo singlePageInfo = new SinglePageInfo(verticalOffset + this.PageMargins.Height, newHeight,
                    rotatedPageSize.Width > viewportSize.Width,
                    rotatedPageSize.Height > viewportSize.Height,
                    layoutInfo.FixedPage, layoutInfo.PositionInView,
                    layoutInfo.Transformations);

                this.pageLayoutInfos.Add(singlePageInfo);

                height = newHeight;
            }

            this.ContentSize = new Size(width, height);
        }