public static PageParameters? ComputePage(BookPage source, Point p, CornerOrigin origin)
        {
            Point point;
            Point point2;
            Point point3;
            Point point4;
            CheckParams(ref source, ref p, origin);
            PageParameters parameters = new PageParameters(source.RenderSize);
            double num = ComputeProgressRatio(source, p, origin);
            if (num > 1.5)
            {
                num = (2.0 - num) / 0.5;
            }
            else
            {
                num = 1.0;
            }
            parameters.Page0ShadowOpacity = num;
            double width = source.RenderSize.Width;
            double height = source.RenderSize.Height;
            switch (origin)
            {
                case CornerOrigin.TopLeft:
                    p.X = width - p.X;
                    p.Y = height - p.Y;
                    break;

                case CornerOrigin.TopRight:
                    p.Y = height - p.Y;
                    break;

                case CornerOrigin.BottomLeft:
                    p.X = width - p.X;
                    break;
            }
            if (p.X >= width)
            {
                return null;
            }
            double num4 = -(p.Y - height) / (p.X - width);
            double x = ((width + p.X) / 2.0) - (num4 * ((height + p.Y) / 2.0));
            double y = (width - x) / num4;
            double num7 = (num4 * height) + x;
            double num8 = (Math.Atan((width - p.X) / (y - p.Y)) * 180.0) / 3.1415926535897931;
            if ((num4 < 0.0) && (p.Y < y))
            {
                num8 -= 180.0;
            }
            switch (origin)
            {
                case CornerOrigin.TopLeft:
                    parameters.Page1RotateAngle = -num8;
                    parameters.Page1RotateCenterX = width - p.X;
                    parameters.Page1RotateCenterY = height - p.Y;
                    parameters.Page1TranslateX = -p.X;
                    parameters.Page1TranslateY = height - p.Y;
                    break;

                case CornerOrigin.TopRight:
                    parameters.Page1RotateAngle = num8;
                    parameters.Page1RotateCenterX = p.X;
                    parameters.Page1RotateCenterY = height - p.Y;
                    parameters.Page1TranslateX = p.X;
                    parameters.Page1TranslateY = height - p.Y;
                    break;

                case CornerOrigin.BottomLeft:
                    parameters.Page1RotateAngle = num8;
                    parameters.Page1RotateCenterX = width - p.X;
                    parameters.Page1RotateCenterY = p.Y;
                    parameters.Page1TranslateX = -p.X;
                    parameters.Page1TranslateY = p.Y - height;
                    break;

                case CornerOrigin.BottomRight:
                    parameters.Page1RotateAngle = -num8;
                    parameters.Page1RotateCenterX = p.X;
                    parameters.Page1RotateCenterY = p.Y;
                    parameters.Page1TranslateX = p.X;
                    parameters.Page1TranslateY = p.Y - height;
                    break;
            }
            switch (origin)
            {
                case CornerOrigin.TopLeft:
                    if (num8 >= 0.0)
                    {
                        parameters.Page1ClippingFigure.StartPoint = new Point(width, height);
                        parameters.Page1ClippingFigure.Segments.Clear();
                        parameters.Page1ClippingFigure.Segments.Add(new LineSegment(new Point(x, height), false));
                        parameters.Page1ClippingFigure.Segments.Add(new LineSegment(new Point(width, height - y), false));
                        break;
                    }
                    parameters.Page1ClippingFigure.StartPoint = new Point(width, 0.0);
                    parameters.Page1ClippingFigure.Segments.Clear();
                    parameters.Page1ClippingFigure.Segments.Add(new LineSegment(new Point(num7, 0.0), false));
                    parameters.Page1ClippingFigure.Segments.Add(new LineSegment(new Point(width, height - y), false));
                    break;

                case CornerOrigin.TopRight:
                    if (num8 >= 0.0)
                    {
                        parameters.Page1ClippingFigure.StartPoint = new Point(0.0, height);
                        parameters.Page1ClippingFigure.Segments.Clear();
                        parameters.Page1ClippingFigure.Segments.Add(new LineSegment(new Point(width - x, height), false));
                        parameters.Page1ClippingFigure.Segments.Add(new LineSegment(new Point(0.0, height - y), false));
                        break;
                    }
                    parameters.Page1ClippingFigure.StartPoint = new Point(0.0, 0.0);
                    parameters.Page1ClippingFigure.Segments.Clear();
                    parameters.Page1ClippingFigure.Segments.Add(new LineSegment(new Point(width - num7, 0.0), false));
                    parameters.Page1ClippingFigure.Segments.Add(new LineSegment(new Point(0.0, height - y), false));
                    break;

                case CornerOrigin.BottomLeft:
                    if (num8 >= 0.0)
                    {
                        parameters.Page1ClippingFigure.StartPoint = new Point(width, 0.0);
                        parameters.Page1ClippingFigure.Segments.Clear();
                        parameters.Page1ClippingFigure.Segments.Add(new LineSegment(new Point(x, 0.0), false));
                        parameters.Page1ClippingFigure.Segments.Add(new LineSegment(new Point(width, y), false));
                        break;
                    }
                    parameters.Page1ClippingFigure.StartPoint = new Point(width, height);
                    parameters.Page1ClippingFigure.Segments.Clear();
                    parameters.Page1ClippingFigure.Segments.Add(new LineSegment(new Point(num7, height), false));
                    parameters.Page1ClippingFigure.Segments.Add(new LineSegment(new Point(width, y), false));
                    break;

                case CornerOrigin.BottomRight:
                    if (num8 >= 0.0)
                    {
                        parameters.Page1ClippingFigure.StartPoint = new Point(0.0, 0.0);
                        parameters.Page1ClippingFigure.Segments.Clear();
                        parameters.Page1ClippingFigure.Segments.Add(new LineSegment(new Point(width - x, 0.0), false));
                        parameters.Page1ClippingFigure.Segments.Add(new LineSegment(new Point(0.0, y), false));
                        break;
                    }
                    parameters.Page1ClippingFigure.StartPoint = new Point(0.0, height);
                    parameters.Page1ClippingFigure.Segments.Clear();
                    parameters.Page1ClippingFigure.Segments.Add(new LineSegment(new Point(width - num7, height), false));
                    parameters.Page1ClippingFigure.Segments.Add(new LineSegment(new Point(0.0, y), false));
                    break;
            }
            parameters.Page2ClippingFigure.StartPoint = new Point(width - parameters.Page1ClippingFigure.StartPoint.X, parameters.Page1ClippingFigure.StartPoint.Y);
            parameters.Page2ClippingFigure.Segments = parameters.Page1ClippingFigure.Segments.Clone();
            ((LineSegment)parameters.Page2ClippingFigure.Segments[0]).Point = new Point(width - ((LineSegment)parameters.Page2ClippingFigure.Segments[0]).Point.X, ((LineSegment)parameters.Page2ClippingFigure.Segments[0]).Point.Y);
            ((LineSegment)parameters.Page2ClippingFigure.Segments[1]).Point = new Point(width - ((LineSegment)parameters.Page2ClippingFigure.Segments[1]).Point.X, ((LineSegment)parameters.Page2ClippingFigure.Segments[1]).Point.Y);
            CornerOrigin topLeft = CornerOrigin.TopLeft;
            switch (origin)
            {
                case CornerOrigin.TopLeft:
                    topLeft = CornerOrigin.TopRight;
                    break;

                case CornerOrigin.TopRight:
                    topLeft = CornerOrigin.TopLeft;
                    break;

                case CornerOrigin.BottomLeft:
                    topLeft = CornerOrigin.BottomRight;
                    break;

                case CornerOrigin.BottomRight:
                    topLeft = CornerOrigin.BottomLeft;
                    break;
            }
            NLinearGradientHelper.ComputePointsFromTop(width, height, width - num7, height - y, 20.0, 20.0, topLeft, out point, out point2);
            parameters.Page1ReflectionStartPoint = point;
            parameters.Page1ReflectionEndPoint = point2;
            double num9 = Math.Sqrt(Math.Pow(p.X - width, 2.0) + Math.Pow(p.Y - height, 2.0));
            double num10 = num9 / 10.0;
            double num11 = num9 / 10.0;
            NLinearGradientHelper.ComputePoints(width, height, width - num7, height - y, num10, num11, origin, out point3, out point4);
            parameters.Page0ShadowStartPoint = point3;
            parameters.Page0ShadowEndPoint = point4;
            return new PageParameters?(parameters);
        }
示例#2
0
 protected virtual void ApplyParameters(PageParameters parameters)
 {
     if (this.m_refPART_ReflectionBackground != null)
         this.m_refPART_ReflectionBackground.Opacity = parameters.Page0ShadowOpacity;
     if (this.m_refPART_TransformRotate != null)
     {
         this.m_refPART_TransformRotate.Angle = parameters.Page1RotateAngle;
         this.m_refPART_TransformRotate.CenterX = parameters.Page1RotateCenterX;
         this.m_refPART_TransformRotate.CenterY = parameters.Page1RotateCenterY;
     }
     if (this.m_refPART_TransformTranslate != null)
     {
         this.m_refPART_TransformTranslate.X = parameters.Page1TranslateX;
         this.m_refPART_TransformTranslate.Y = parameters.Page1TranslateY;
     }
     if (this.m_refPART_ClippingBackPage != null)
     {
         this.m_refPART_ClippingBackPage.Figures.Clear();
         this.m_refPART_ClippingBackPage.Figures.Add(parameters.Page1ClippingFigure);
     }
     if (this.m_refPART_ClippingFrontPage != null)
     {
         ((RectangleGeometry)this.m_refPART_ClippingFrontPage.Geometry1).Rect = new Rect(parameters.RenderSize);
         PathGeometry pathGeometry = (PathGeometry)this.m_refPART_ClippingFrontPage.Geometry2;
         pathGeometry.Figures.Clear();
         pathGeometry.Figures.Add(parameters.Page2ClippingFigure);
     }
     if (this.m_refPART_ReflectionBackground != null)
     {
         this.m_refPART_ReflectionBackground.StartPoint = parameters.Page1ReflectionStartPoint;
         this.m_refPART_ReflectionBackground.EndPoint = parameters.Page1ReflectionEndPoint;
     }
     if (this.m_refPART_ShadowBackground == null)
         return;
     this.m_refPART_ShadowBackground.StartPoint = parameters.Page0ShadowStartPoint;
     this.m_refPART_ShadowBackground.EndPoint = parameters.Page0ShadowEndPoint;
 }