コード例 #1
0
        public void Clone(LineDecoration item)
        {
            LineColor = item.LineColor;
            Thickness = item.Thickness;

            Start = item.Start;
            End   = item.End;

            Curve      = item.Curve;
            CurveDepth = item.CurveDepth;
            CurveStart = item.CurveStart;
        }
コード例 #2
0
        protected override void OnRefresh()
        {
            LineDecoration lineDecoration = Visual as LineDecoration;

            if (lineDecoration != null)
            {
                _pathPen = new Pen(new SolidColorBrush(lineDecoration.LineColor), lineDecoration.Thickness);
                _path    = new PathGeometry();

                Point startPoint = new Point(lineDecoration.Start.X - lineDecoration.Left, lineDecoration.Start.Y - lineDecoration.Top);
                Point endPoint   = new Point(lineDecoration.End.X - lineDecoration.Left, lineDecoration.End.Y - lineDecoration.Top);

                if (lineDecoration.Curve)
                {
                    // Create a vector representing the direction of the line
                    Vector v1     = lineDecoration.End - lineDecoration.Start;
                    double length = v1.Length;

                    // Normalize so it can be used to construct control points
                    v1.Normalize();

                    // Create a matrix to rotate arm perpendicular
                    Matrix m1 = new Matrix();
                    m1.Rotate(-90);

                    Point curvePoint1 = (startPoint + (v1 * (length * lineDecoration.CurveStart))) + ((v1 * (length * lineDecoration.CurveDepth)) * m1);
                    Point curvePoint2 = (endPoint - (v1 * (length * lineDecoration.CurveStart))) + ((v1 * (length * lineDecoration.CurveDepth)) * m1);

                    //_path.Figures.Add(QuadraticBezierFromIntersection(startPoint, curvePoint1, endPoint));
                    _path.Figures.Add(BezierFromIntersection(startPoint, curvePoint1, curvePoint2, endPoint));
                }
                else
                {
                    LineGeometry line = new LineGeometry(startPoint, endPoint);
                    _path.AddGeometry(line);
                }
            }
        }