Esempio n. 1
0
        internal override UIElement CreateAnnotation()
        {
            if (AnnotationElement != null && AnnotationElement.Children.Count == 0)
            {
                LineCanvas = new Canvas();
                if (IsWithCap)
                {
                    shape     = new Path();
                    arrowLine = new ArrowLine();
                }
                else
                {
                    shape = new Line();
                }
                shape.Tag = this;
                if (ShowLine)
                {
                    if (CanResize)
                    {
                        AddThumb();
                    }
                    LineCanvas.Children.Add(TextElement);
                    LineCanvas.Children.Add(shape);
                }

                SetBindings();
                AnnotationElement.Children.Add(LineCanvas);
            }

            return(AnnotationElement);
        }
Esempio n. 2
0
        /// <summary>
        /// Calculates the arrow points.
        /// </summary>
        /// <param name="pathfigure">The Path Figure</param>
        /// <param name="point1">The First Point</param>
        /// <param name="point2">The Second Point</param>
        /// <returns>Returns the <see cref="PathFigure"/> for the arrow.</returns>
        private PathFigure CalculateArrow(PathFigure pathfigure, Point point1, Point point2)
        {
            Matrix matx = new Matrix();

            // To made the matx as identity matrix
            matx.M11 = 1;
            matx.M22 = 1;

            // Find the width and height
            Point vectPoint = new Point(point1.X - point2.X, point1.Y - point2.Y);

            // To find the vector normalization for the width and height , arrow length
            vectPoint = ArrowLine.FindNormalization(vectPoint, arrowLength);

            PolyLineSegment polyseg = pathfigure.Segments[0] as PolyLineSegment;

            polyseg.Points.Clear();

            // Rotation matrix calculation and start point calculation of the arrow
            var angleRadians = (2 * Math.PI * (arrowAngle / 2)) / 360;
            var sine         = Math.Sin(angleRadians);
            var cosine       = Math.Cos(angleRadians);
            var matrix       = new Matrix(cosine, sine, -sine, cosine, 0, 0);

            matx = ArrowLine.MultiplyMatrixes(matx, matrix);
            Point tempPoint = ArrowLine.MultiplyMatrixVector(vectPoint, matx);

            pathfigure.StartPoint = new Point(point2.X + tempPoint.X, point2.Y + tempPoint.Y);

            polyseg.Points.Add(point2);

            // Rotation matrix calculation and end point calculation of the arrow
            angleRadians = (2 * Math.PI * -arrowAngle) / 360;
            sine         = Math.Sin(angleRadians);
            cosine       = Math.Cos(angleRadians);
            matrix       = new Matrix(cosine, sine, -sine, cosine, 0, 0);
            matx         = ArrowLine.MultiplyMatrixes(matx, matrix);
            tempPoint    = ArrowLine.MultiplyMatrixVector(vectPoint, matx);
            polyseg.Points.Add(new Point(point2.X + tempPoint.X, point2.Y + tempPoint.Y));
            pathfigure.IsClosed = true;
            return(pathfigure);
        }