public override object Copy(IDictionary <object, object>?shared)
    {
        var copy = new ArrowStyleViewModel(ServiceProvider)
        {
            Name      = Name,
            ArrowType = _arrowType,
            RadiusX   = _radiusX,
            RadiusY   = _radiusY
        };

        return(copy);
    }
Exemple #2
0
        private MarkerBase CreateArrowMarker(double x, double y, double angle, ShapeStyleViewModel shapeStyleViewModel, ArrowStyleViewModel style)
        {
            switch (style.ArrowType)
            {
            default:
            case ArrowType.None:
            {
                var marker = new NoneMarker();

                marker.ShapeViewModel      = Line;
                marker.ShapeStyleViewModel = shapeStyleViewModel;
                marker.Style = style;
                marker.Point = new SKPoint((float)x, (float)y);

                return(marker);
            }

            case ArrowType.Rectangle:
            {
                double rx = style.RadiusX;
                double ry = style.RadiusY;
                double sx = 2.0 * rx;
                double sy = 2.0 * ry;

                var marker = new RectangleMarker();

                marker.ShapeViewModel      = Line;
                marker.ShapeStyleViewModel = shapeStyleViewModel;
                marker.Style    = style;
                marker.Rotation = MatrixHelper.Rotation(angle, new SKPoint((float)x, (float)y));
                marker.Point    = MatrixHelper.TransformPoint(marker.Rotation, new SKPoint((float)(x - sx), (float)y));

                var rect2 = new Rect2(x - sx, y - ry, sx, sy);
                marker.Rect = SKRect.Create((float)rect2.X, (float)rect2.Y, (float)rect2.Width, (float)rect2.Height);

                return(marker);
            }

            case ArrowType.Ellipse:
            {
                double rx = style.RadiusX;
                double ry = style.RadiusY;
                double sx = 2.0 * rx;
                double sy = 2.0 * ry;

                var marker = new EllipseMarker();

                marker.ShapeViewModel      = Line;
                marker.ShapeStyleViewModel = shapeStyleViewModel;
                marker.Style    = style;
                marker.Rotation = MatrixHelper.Rotation(angle, new SKPoint((float)x, (float)y));
                marker.Point    = MatrixHelper.TransformPoint(marker.Rotation, new SKPoint((float)(x - sx), (float)y));

                var rect2 = new Rect2(x - sx, y - ry, sx, sy);
                marker.Rect = SKRect.Create((float)rect2.X, (float)rect2.Y, (float)rect2.Width, (float)rect2.Height);

                return(marker);
            }

            case ArrowType.Arrow:
            {
                double rx = style.RadiusX;
                double ry = style.RadiusY;
                double sx = 2.0 * rx;
                double sy = 2.0 * ry;

                var marker = new ArrowMarker();

                marker.ShapeViewModel      = Line;
                marker.ShapeStyleViewModel = shapeStyleViewModel;
                marker.Style    = style;
                marker.Rotation = MatrixHelper.Rotation(angle, new SKPoint((float)x, (float)y));
                marker.Point    = MatrixHelper.TransformPoint(marker.Rotation, new SKPoint((float)x, (float)y));

                marker.P11 = MatrixHelper.TransformPoint(marker.Rotation, new SKPoint((float)(x - sx), (float)(y + sy)));
                marker.P21 = MatrixHelper.TransformPoint(marker.Rotation, new SKPoint((float)x, (float)y));
                marker.P12 = MatrixHelper.TransformPoint(marker.Rotation, new SKPoint((float)(x - sx), (float)(y - sy)));
                marker.P22 = MatrixHelper.TransformPoint(marker.Rotation, new SKPoint((float)x, (float)y));

                return(marker);
            }
            }
        }
Exemple #3
0
    private MarkerBase CreateArrowMarker(double x, double y, double angle, ShapeStyleViewModel shapeStyleViewModel, ArrowStyleViewModel style)
    {
        switch (style.ArrowType)
        {
        default:
        {
            var marker = new NoneMarker();

            marker.ShapeViewModel      = Line;
            marker.ShapeStyleViewModel = shapeStyleViewModel;
            marker.Style = style;
            marker.Point = new A.Point(x, y);

            return(marker);
        }

        case ArrowType.Rectangle:
        {
            double rx = style.RadiusX;
            double ry = style.RadiusY;
            double sx = 2.0 * rx;
            double sy = 2.0 * ry;

            var marker = new RectangleMarker();

            marker.ShapeViewModel      = Line;
            marker.ShapeStyleViewModel = shapeStyleViewModel;
            marker.Style    = style;
            marker.Rotation = ACP.MatrixHelper.Rotation(angle, new A.Vector(x, y));
            marker.Point    = ACP.MatrixHelper.TransformPoint(marker.Rotation, new A.Point(x - sx, y));

            var rect2 = new Rect2(x - sx, y - ry, sx, sy);
            marker.Rect = new A.Rect(rect2.X, rect2.Y, rect2.Width, rect2.Height);

            return(marker);
        }

        case ArrowType.Ellipse:
        {
            double rx = style.RadiusX;
            double ry = style.RadiusY;
            double sx = 2.0 * rx;
            double sy = 2.0 * ry;

            var marker = new EllipseMarker();

            marker.ShapeViewModel      = Line;
            marker.ShapeStyleViewModel = shapeStyleViewModel;
            marker.Style    = style;
            marker.Rotation = ACP.MatrixHelper.Rotation(angle, new A.Vector(x, y));
            marker.Point    = ACP.MatrixHelper.TransformPoint(marker.Rotation, new A.Point(x - sx, y));

            var rect2 = new Rect2(x - sx, y - ry, sx, sy);
            var rect  = new A.Rect(rect2.X, rect2.Y, rect2.Width, rect2.Height);
            marker.EllipseGeometry = new AM.EllipseGeometry(rect);

            return(marker);
        }

        case ArrowType.Arrow:
        {
            double rx = style.RadiusX;
            double ry = style.RadiusY;
            double sx = 2.0 * rx;
            double sy = 2.0 * ry;

            var marker = new ArrowMarker();

            marker.ShapeViewModel      = Line;
            marker.ShapeStyleViewModel = shapeStyleViewModel;
            marker.Style    = style;
            marker.Rotation = ACP.MatrixHelper.Rotation(angle, new A.Vector(x, y));
            marker.Point    = ACP.MatrixHelper.TransformPoint(marker.Rotation, new A.Point(x, y));

            marker.P11 = ACP.MatrixHelper.TransformPoint(marker.Rotation, new A.Point(x - sx, y + sy));
            marker.P21 = ACP.MatrixHelper.TransformPoint(marker.Rotation, new A.Point(x, y));
            marker.P12 = ACP.MatrixHelper.TransformPoint(marker.Rotation, new A.Point(x - sx, y - sy));
            marker.P22 = ACP.MatrixHelper.TransformPoint(marker.Rotation, new A.Point(x, y));

            return(marker);
        }
        }
    }