private static PageParameters ResetPage(UIElement source, CornerOrigin origin)
        {
            PageParameters _parameters = new PageParameters(source.RenderSize);

            _parameters.Page0ShadowOpacity        = 0;
            _parameters.Page1ClippingFigure       = new PathFigure();
            _parameters.Page1ReflectionStartPoint = new Point(0, 0);
            _parameters.Page1ReflectionEndPoint   = new Point(0, 0);
            _parameters.Page1RotateAngle          = 0;
            _parameters.Page1RotateCenterX        = 0;
            _parameters.Page1RotateCenterY        = 0;
            _parameters.Page1TranslateX           = 0;
            _parameters.Page1TranslateY           = 0;
            _parameters.Page2ClippingFigure       = new PathFigure();
            _parameters.Page0ShadowStartPoint     = new Point(0, 0);
            _parameters.Page0ShadowEndPoint       = new Point(0, 0);

            return(_parameters);
        }
示例#2
0
        private void ApplyParameters(PageParameters parameters)
        {
            pageReflection.Opacity = parameters.Page0ShadowOpacity;

            rectangleRotate.Angle   = parameters.Page1RotateAngle;
            rectangleRotate.CenterX = parameters.Page1RotateCenterX;
            rectangleRotate.CenterY = parameters.Page1RotateCenterY;
            rectangleTranslate.X    = parameters.Page1TranslateX;
            rectangleTranslate.Y    = parameters.Page1TranslateY;

            //PathGeometry clippingFigure = null;
            //if (rectangleVisible.Clip == null)
            //{
            //    clippingFigure = new PathGeometry();
            //    clippingFigure.Figures = new PathFigureCollection();
            //    clippingFigure.Figures.Add(new PathFigure { IsClosed = true });
            //}
            //else
            //    clippingFigure = rectangleVisible.Clip as PathGeometry;

            clippingFigure.Figures.Clear();
            clippingFigure.Figures.Add(parameters.Page1ClippingFigure);

            //RectangleGeometry rg = (RectangleGeometry) clippingPage0.Geometry1;
            //rg.Rect = new Rect(parameters.RenderSize);
            //PathGeometry pg = (PathGeometry) clippingPage0.Geometry2;
            //pg.Figures.Clear();
            //pg.Figures.Add(parameters.Page2ClippingFigure);

            //SL 2 patch to replace WPF CombinedGeometry that does not exist:

            var clippingPage0 = gridPage0.Clip as PathGeometry;

            if (clippingPage0 == null)
            {
                clippingPage0         = new PathGeometry();
                clippingPage0.Figures = new PathFigureCollection();
                gridPage0.Clip        = clippingPage0;
            }

            var pg = clippingPage0 as PathGeometry;

            pg.Figures.Clear();

            var pf = new PathFigure();

            pf.IsClosed = true;
            pf.Segments = new PathSegmentCollection();
            var clip = parameters.Page2ClippingFigure;

            if (clip.Segments.Count == 2)
            {
                switch (origin)
                {
                case CornerOrigin.TopRight:
                    SilverlightParamFix(pf, clip);
                    break;

                case CornerOrigin.TopLeft:
                    PathFigureSwapX(clip);
                    SilverlightParamFix(pf, clip);
                    PathFigureSwapX(pf);
                    break;

                case CornerOrigin.BottomRight:
                    PathFigureSwapY(clip);
                    SilverlightParamFix(pf, clip);
                    PathFigureSwapY(pf);
                    break;

                case CornerOrigin.BottomLeft:
                    PathFigureSwapX(clip);
                    PathFigureSwapY(clip);
                    SilverlightParamFix(pf, clip);
                    PathFigureSwapX(pf);
                    PathFigureSwapY(pf);
                    break;
                }
            }
            else
            {
                gridPage0.Clip = null;
            }
            pg.Figures.Add(pf);

            pageReflection.StartPoint = parameters.Page1ReflectionStartPoint;
            pageReflection.EndPoint   = parameters.Page1ReflectionEndPoint;

            pageShadow.StartPoint = parameters.Page0ShadowStartPoint;
            pageShadow.EndPoint   = parameters.Page0ShadowEndPoint;
        }
示例#3
0
        private static PageParameters ResetPage(UIElement source, CornerOrigin origin)
        {
            PageParameters _parameters = new PageParameters(source.RenderSize);
            _parameters.Page0ShadowOpacity = 0;
            _parameters.Page1ClippingFigure = new PathFigure();
            _parameters.Page1ReflectionStartPoint = new Point(0, 0);
            _parameters.Page1ReflectionEndPoint = new Point(0, 0);
            _parameters.Page1RotateAngle = 0;
            _parameters.Page1RotateCenterX = 0;
            _parameters.Page1RotateCenterY = 0;
            _parameters.Page1TranslateX = 0;
            _parameters.Page1TranslateY = 0;
            _parameters.Page2ClippingFigure = new PathFigure();
            _parameters.Page0ShadowStartPoint = new Point(0, 0);
            _parameters.Page0ShadowEndPoint = new Point(0, 0);

            return _parameters;
        }
示例#4
0
        private static PageParameters? ComputePage(UIElement source, Point p, CornerOrigin origin)
        {
            CheckParams(ref source, ref p, origin);

            PageParameters _parameters = new PageParameters(source.RenderSize);

            double ratio = 0; // = ComputeProgressRatio(source, p, origin);
            if (ratio > 1.5)
                ratio = (2 - ratio) / 0.5;
            else
                ratio = 1;
            _parameters.Page0ShadowOpacity = ratio;

            double xc = source.RenderSize.Width;
            double yc = source.RenderSize.Height;//5_1_a_s_p_x

            switch (origin)
            {
                case CornerOrigin.TopLeft:
                    p.X = xc - p.X;
                    p.Y = yc - p.Y;
                    break;
                case CornerOrigin.TopRight:
                    p.Y = yc - p.Y;
                    break;
                case CornerOrigin.BottomLeft:
                    p.X = xc - p.X;
                    break;
            }

            if (p.X >= xc)
                return null;

            // x = a * y + b
            double a = -(p.Y - yc) / (p.X - xc);
            double b = (xc + p.X) / 2 - a * ((yc + p.Y) / 2);

            double h1 = (xc - b) / a;
            double l1 = a * yc + b;

            double angle = (Math.Atan((xc - p.X) / (h1 - p.Y))) * 180 / Math.PI;
            if ((a < 0) && (p.Y < h1))
                angle = angle - 180;

            switch (origin)
            {
                case CornerOrigin.BottomRight:
                    _parameters.Page1RotateAngle = -angle;
                    _parameters.Page1RotateCenterX = p.X;
                    _parameters.Page1RotateCenterY = p.Y;
                    _parameters.Page1TranslateX = p.X;
                    _parameters.Page1TranslateY = p.Y - yc;
                    break;
                case CornerOrigin.TopLeft:
                    _parameters.Page1RotateAngle = -angle;
                    _parameters.Page1RotateCenterX = xc - p.X;
                    _parameters.Page1RotateCenterY = yc - p.Y;
                    _parameters.Page1TranslateX = -p.X;
                    _parameters.Page1TranslateY = yc - p.Y;
                    break;
                case CornerOrigin.TopRight:
                    _parameters.Page1RotateAngle = angle;
                    _parameters.Page1RotateCenterX = p.X;
                    _parameters.Page1RotateCenterY = yc - p.Y;
                    _parameters.Page1TranslateX = p.X;
                    _parameters.Page1TranslateY = yc - p.Y;
                    break;
                case CornerOrigin.BottomLeft:
                    _parameters.Page1RotateAngle = angle;
                    _parameters.Page1RotateCenterX = xc - p.X;
                    _parameters.Page1RotateCenterY = p.Y;
                    _parameters.Page1TranslateX = -p.X;
                    _parameters.Page1TranslateY = p.Y - yc;
                    break;
            }

            switch (origin)
            {
                case CornerOrigin.BottomRight:
                    if (angle < 0)
                    {
                        _parameters.Page1ClippingFigure.StartPoint = new Point(0, yc);
                        _parameters.Page1ClippingFigure.Segments.Clear();
                        _parameters.Page1ClippingFigure.Segments.Add(new LineSegment { Point = new Point(xc - l1, yc) });
                        _parameters.Page1ClippingFigure.Segments.Add(new LineSegment { Point = new Point(0, h1) });
                    }
                    else
                    {
                        _parameters.Page1ClippingFigure.StartPoint = new Point(0, 0);
                        _parameters.Page1ClippingFigure.Segments.Clear();
                        _parameters.Page1ClippingFigure.Segments.Add(new LineSegment { Point = new Point(xc - b, 0) });
                        _parameters.Page1ClippingFigure.Segments.Add(new LineSegment { Point = new Point(0, h1) });
                    }
                    break;
                case CornerOrigin.TopLeft:
                    if (angle < 0)
                    {
                        _parameters.Page1ClippingFigure.StartPoint = new Point(xc, 0);
                        _parameters.Page1ClippingFigure.Segments.Clear();
                        _parameters.Page1ClippingFigure.Segments.Add(new LineSegment { Point = new Point(l1, 0) });
                        _parameters.Page1ClippingFigure.Segments.Add(new LineSegment { Point = new Point(xc, yc - h1) });
                    }
                    else
                    {
                        _parameters.Page1ClippingFigure.StartPoint = new Point(xc, yc);
                        _parameters.Page1ClippingFigure.Segments.Clear();
                        _parameters.Page1ClippingFigure.Segments.Add(new LineSegment { Point = new Point(b, yc) });
                        _parameters.Page1ClippingFigure.Segments.Add(new LineSegment { Point = new Point(xc, yc - h1) });
                    }
                    break;
                case CornerOrigin.BottomLeft:
                    if (angle < 0)
                    {
                        _parameters.Page1ClippingFigure.StartPoint = new Point(xc, yc);
                        _parameters.Page1ClippingFigure.Segments.Clear();
                        _parameters.Page1ClippingFigure.Segments.Add(new LineSegment { Point = new Point(l1, yc) });
                        _parameters.Page1ClippingFigure.Segments.Add(new LineSegment { Point = new Point(xc, h1) });
                    }
                    else
                    {
                        _parameters.Page1ClippingFigure.StartPoint = new Point(xc, 0);
                        _parameters.Page1ClippingFigure.Segments.Clear();
                        _parameters.Page1ClippingFigure.Segments.Add(new LineSegment { Point = new Point(b, 0) });
                        _parameters.Page1ClippingFigure.Segments.Add(new LineSegment { Point = new Point(xc, h1) });
                    }
                    break;
                case CornerOrigin.TopRight:
                    if (angle < 0)
                    {
                        _parameters.Page1ClippingFigure.StartPoint = new Point(0, 0);
                        _parameters.Page1ClippingFigure.Segments.Clear();
                        _parameters.Page1ClippingFigure.Segments.Add(new LineSegment { Point = new Point(xc - l1, 0) });
                        _parameters.Page1ClippingFigure.Segments.Add(new LineSegment { Point = new Point(0, yc - h1) });
                    }
                    else
                    {
                        _parameters.Page1ClippingFigure.StartPoint = new Point(0, yc);
                        _parameters.Page1ClippingFigure.Segments.Clear();
                        _parameters.Page1ClippingFigure.Segments.Add(new LineSegment { Point = new Point(xc - b, yc) });
                        _parameters.Page1ClippingFigure.Segments.Add(new LineSegment { Point = new Point(0, yc - h1) });
                    }
                    break;
            }

            _parameters.Page2ClippingFigure.StartPoint = new Point(xc - _parameters.Page1ClippingFigure.StartPoint.X, _parameters.Page1ClippingFigure.StartPoint.Y);

            _parameters.Page2ClippingFigure.Segments = _parameters.Page1ClippingFigure.Segments.Clone();
            ((LineSegment)_parameters.Page2ClippingFigure.Segments[0]).Point
                = new Point(xc - ((LineSegment)_parameters.Page2ClippingFigure.Segments[0]).Point.X,
                    ((LineSegment)_parameters.Page2ClippingFigure.Segments[0]).Point.Y);
            ((LineSegment)_parameters.Page2ClippingFigure.Segments[1]).Point
                = new Point(xc - ((LineSegment)_parameters.Page2ClippingFigure.Segments[1]).Point.X,
                    ((LineSegment)_parameters.Page2ClippingFigure.Segments[1]).Point.Y);

            Point refletStartPoint;
            Point refletEndPoint;

            CornerOrigin oppositeOrigin = CornerOrigin.TopLeft;
            switch (origin)
            {
                case CornerOrigin.BottomLeft:
                    oppositeOrigin = CornerOrigin.BottomRight;
                    break;
                case CornerOrigin.BottomRight:
                    oppositeOrigin = CornerOrigin.BottomLeft;
                    break;
                case CornerOrigin.TopLeft:
                    oppositeOrigin = CornerOrigin.TopRight;
                    break;
                case CornerOrigin.TopRight:
                    oppositeOrigin = CornerOrigin.TopLeft;
                    break;
            }

            LinearGradientHelper.ComputePointsFromTop(xc, yc, xc - l1, yc - h1, 20, 20,
                oppositeOrigin,
                out refletStartPoint,
                out refletEndPoint);

            _parameters.Page1ReflectionStartPoint = refletStartPoint;
            _parameters.Page1ReflectionEndPoint = refletEndPoint; //new Point(1, 1 / Math.Tan((90 - angleClipping) * Math.PI / 180));

            Point startPoint;
            Point endPoint;

            double d = Math.Sqrt(Math.Pow(p.X - xc, 2) + Math.Pow(p.Y - yc, 2));

            double r1 = d / 10;
            double r2 = d / 10;

            LinearGradientHelper.ComputePoints(xc, yc, xc - l1, yc - h1, r1, r2,
                origin, out startPoint, out endPoint);

            _parameters.Page0ShadowStartPoint = startPoint;
            _parameters.Page0ShadowEndPoint = endPoint;

            return _parameters;
        }
        private static PageParameters?ComputePage(UIElement source, Point p, CornerOrigin origin)
        {
            CheckParams(ref source, ref p, origin);

            PageParameters _parameters = new PageParameters(source.RenderSize);

            double ratio = 0; // = ComputeProgressRatio(source, p, origin);

            if (ratio > 1.5)
            {
                ratio = (2 - ratio) / 0.5;
            }
            else
            {
                ratio = 1;
            }
            _parameters.Page0ShadowOpacity = ratio;

            double xc = source.RenderSize.Width;
            double yc = source.RenderSize.Height;

            switch (origin)
            {
            case CornerOrigin.TopLeft:
                p.X = xc - p.X;
                p.Y = yc - p.Y;
                break;

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

            case CornerOrigin.BottomLeft:
                p.X = xc - p.X;
                break;
            }

            if (p.X >= xc)
            {
                return(null);
            }

            // x = a * y + b
            double a = -(p.Y - yc) / (p.X - xc);
            double b = (xc + p.X) / 2 - a * ((yc + p.Y) / 2);

            double h1 = (xc - b) / a;
            double l1 = a * yc + b;

            double angle = (Math.Atan((xc - p.X) / (h1 - p.Y))) * 180 / Math.PI;

            if ((a < 0) && (p.Y < h1))
            {
                angle = angle - 180;
            }

            switch (origin)
            {
            case CornerOrigin.BottomRight:
                _parameters.Page1RotateAngle   = -angle;
                _parameters.Page1RotateCenterX = p.X;
                _parameters.Page1RotateCenterY = p.Y;
                _parameters.Page1TranslateX    = p.X;
                _parameters.Page1TranslateY    = p.Y - yc;
                break;

            case CornerOrigin.TopLeft:
                _parameters.Page1RotateAngle   = -angle;
                _parameters.Page1RotateCenterX = xc - p.X;
                _parameters.Page1RotateCenterY = yc - p.Y;
                _parameters.Page1TranslateX    = -p.X;
                _parameters.Page1TranslateY    = yc - p.Y;
                break;

            case CornerOrigin.TopRight:
                _parameters.Page1RotateAngle   = angle;
                _parameters.Page1RotateCenterX = p.X;
                _parameters.Page1RotateCenterY = yc - p.Y;
                _parameters.Page1TranslateX    = p.X;
                _parameters.Page1TranslateY    = yc - p.Y;
                break;

            case CornerOrigin.BottomLeft:
                _parameters.Page1RotateAngle   = angle;
                _parameters.Page1RotateCenterX = xc - p.X;
                _parameters.Page1RotateCenterY = p.Y;
                _parameters.Page1TranslateX    = -p.X;
                _parameters.Page1TranslateY    = p.Y - yc;
                break;
            }

            switch (origin)
            {
            case CornerOrigin.BottomRight:
                if (angle < 0)
                {
                    _parameters.Page1ClippingFigure.StartPoint = new Point(0, yc);
                    _parameters.Page1ClippingFigure.Segments.Clear();
                    _parameters.Page1ClippingFigure.Segments.Add(new LineSegment {
                        Point = new Point(xc - l1, yc)
                    });
                    _parameters.Page1ClippingFigure.Segments.Add(new LineSegment {
                        Point = new Point(0, h1)
                    });
                }
                else
                {
                    _parameters.Page1ClippingFigure.StartPoint = new Point(0, 0);
                    _parameters.Page1ClippingFigure.Segments.Clear();
                    _parameters.Page1ClippingFigure.Segments.Add(new LineSegment {
                        Point = new Point(xc - b, 0)
                    });
                    _parameters.Page1ClippingFigure.Segments.Add(new LineSegment {
                        Point = new Point(0, h1)
                    });
                }
                break;

            case CornerOrigin.TopLeft:
                if (angle < 0)
                {
                    _parameters.Page1ClippingFigure.StartPoint = new Point(xc, 0);
                    _parameters.Page1ClippingFigure.Segments.Clear();
                    _parameters.Page1ClippingFigure.Segments.Add(new LineSegment {
                        Point = new Point(l1, 0)
                    });
                    _parameters.Page1ClippingFigure.Segments.Add(new LineSegment {
                        Point = new Point(xc, yc - h1)
                    });
                }
                else
                {
                    _parameters.Page1ClippingFigure.StartPoint = new Point(xc, yc);
                    _parameters.Page1ClippingFigure.Segments.Clear();
                    _parameters.Page1ClippingFigure.Segments.Add(new LineSegment {
                        Point = new Point(b, yc)
                    });
                    _parameters.Page1ClippingFigure.Segments.Add(new LineSegment {
                        Point = new Point(xc, yc - h1)
                    });
                }
                break;

            case CornerOrigin.BottomLeft:
                if (angle < 0)
                {
                    _parameters.Page1ClippingFigure.StartPoint = new Point(xc, yc);
                    _parameters.Page1ClippingFigure.Segments.Clear();
                    _parameters.Page1ClippingFigure.Segments.Add(new LineSegment {
                        Point = new Point(l1, yc)
                    });
                    _parameters.Page1ClippingFigure.Segments.Add(new LineSegment {
                        Point = new Point(xc, h1)
                    });
                }
                else
                {
                    _parameters.Page1ClippingFigure.StartPoint = new Point(xc, 0);
                    _parameters.Page1ClippingFigure.Segments.Clear();
                    _parameters.Page1ClippingFigure.Segments.Add(new LineSegment {
                        Point = new Point(b, 0)
                    });
                    _parameters.Page1ClippingFigure.Segments.Add(new LineSegment {
                        Point = new Point(xc, h1)
                    });
                }
                break;

            case CornerOrigin.TopRight:
                if (angle < 0)
                {
                    _parameters.Page1ClippingFigure.StartPoint = new Point(0, 0);
                    _parameters.Page1ClippingFigure.Segments.Clear();
                    _parameters.Page1ClippingFigure.Segments.Add(new LineSegment {
                        Point = new Point(xc - l1, 0)
                    });
                    _parameters.Page1ClippingFigure.Segments.Add(new LineSegment {
                        Point = new Point(0, yc - h1)
                    });
                }
                else
                {
                    _parameters.Page1ClippingFigure.StartPoint = new Point(0, yc);
                    _parameters.Page1ClippingFigure.Segments.Clear();
                    _parameters.Page1ClippingFigure.Segments.Add(new LineSegment {
                        Point = new Point(xc - b, yc)
                    });
                    _parameters.Page1ClippingFigure.Segments.Add(new LineSegment {
                        Point = new Point(0, yc - h1)
                    });
                }
                break;
            }

            _parameters.Page2ClippingFigure.StartPoint = new Point(xc - _parameters.Page1ClippingFigure.StartPoint.X, _parameters.Page1ClippingFigure.StartPoint.Y);

            _parameters.Page2ClippingFigure.Segments = _parameters.Page1ClippingFigure.Segments.Clone();
            ((LineSegment)_parameters.Page2ClippingFigure.Segments[0]).Point
                = new Point(xc - ((LineSegment)_parameters.Page2ClippingFigure.Segments[0]).Point.X,
                            ((LineSegment)_parameters.Page2ClippingFigure.Segments[0]).Point.Y);
            ((LineSegment)_parameters.Page2ClippingFigure.Segments[1]).Point
                = new Point(xc - ((LineSegment)_parameters.Page2ClippingFigure.Segments[1]).Point.X,
                            ((LineSegment)_parameters.Page2ClippingFigure.Segments[1]).Point.Y);

            Point refletStartPoint;
            Point refletEndPoint;

            CornerOrigin oppositeOrigin = CornerOrigin.TopLeft;

            switch (origin)
            {
            case CornerOrigin.BottomLeft:
                oppositeOrigin = CornerOrigin.BottomRight;
                break;

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

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

            case CornerOrigin.TopRight:
                oppositeOrigin = CornerOrigin.TopLeft;
                break;
            }

            LinearGradientHelper.ComputePointsFromTop(xc, yc, xc - l1, yc - h1, 20, 20,
                                                      oppositeOrigin,
                                                      out refletStartPoint,
                                                      out refletEndPoint);

            _parameters.Page1ReflectionStartPoint = refletStartPoint;
            _parameters.Page1ReflectionEndPoint   = refletEndPoint; //new Point(1, 1 / Math.Tan((90 - angleClipping) * Math.PI / 180));

            Point startPoint;
            Point endPoint;

            double d = Math.Sqrt(Math.Pow(p.X - xc, 2) + Math.Pow(p.Y - yc, 2));

            double r1 = d / 10;
            double r2 = d / 10;

            LinearGradientHelper.ComputePoints(xc, yc, xc - l1, yc - h1, r1, r2,
                                               origin, out startPoint, out endPoint);

            _parameters.Page0ShadowStartPoint = startPoint;
            _parameters.Page0ShadowEndPoint   = endPoint;

            return(_parameters);
        }