Beispiel #1
0
 public TextSelection(IServiceProvider serviceProvider, LayerContainerViewModel layer, TextShapeViewModel shape, ShapeStyleViewModel style)
 {
     _serviceProvider = serviceProvider;
     _layer           = layer;
     _text            = shape;
     _styleViewModel  = style;
 }
Beispiel #2
0
 public ArcSelection(IServiceProvider serviceProvider, LayerContainerViewModel layer, ArcShapeViewModel shapeViewModel, ShapeStyleViewModel style)
 {
     _serviceProvider = serviceProvider;
     _layer           = layer;
     _arc             = shapeViewModel;
     _styleViewModel  = style;
 }
Beispiel #3
0
 public ImageSelection(IServiceProvider?serviceProvider, LayerContainerViewModel layer, ImageShapeViewModel shape, ShapeStyleViewModel style)
 {
     _serviceProvider = serviceProvider;
     _layer           = layer;
     _image           = shape;
     _styleViewModel  = style;
 }
Beispiel #4
0
 public EllipseDrawNode(EllipseShapeViewModel ellipse, ShapeStyleViewModel style)
     : base()
 {
     Style   = style;
     Ellipse = ellipse;
     UpdateGeometry();
 }
 public BezierSelectionSelection(IServiceProvider serviceProvider, LayerContainerViewModel layer, CubicBezierShapeViewModel shape, ShapeStyleViewModel style)
 {
     _serviceProvider = serviceProvider;
     _layer           = layer;
     _cubicBezier     = shape;
     _styleViewModel  = style;
 }
Beispiel #6
0
 public PointDrawNode(PointShapeViewModel point, ShapeStyleViewModel pointStyleViewModel, double pointSize)
 {
     Style     = pointStyleViewModel;
     Point     = point;
     PointSize = pointSize;
     UpdateGeometry();
 }
 public RectangleDrawNode(RectangleShapeViewModel rectangle, ShapeStyleViewModel style)
     : base()
 {
     Style     = style;
     Rectangle = rectangle;
     UpdateGeometry();
 }
 public RectangleSelection(IServiceProvider serviceProvider, LayerContainerViewModel layer, RectangleShapeViewModel shape, ShapeStyleViewModel style)
 {
     _serviceProvider = serviceProvider;
     _layer           = layer;
     _rectangle       = shape;
     _styleViewModel  = style;
 }
Beispiel #9
0
        public void BreakPathFigure(PathFigureViewModel pathFigure, ShapeStyleViewModel style, bool isStroked, bool isFilled, List <BaseShapeViewModel> result)
        {
            var factory = _serviceProvider.GetService <IFactory>();

            var firstPoint = pathFigure.StartPoint;
            var lastPoint  = pathFigure.StartPoint;

            foreach (var segment in pathFigure.Segments)
            {
                switch (segment)
                {
                case LineSegmentViewModel lineSegment:
                {
                    var convertedStyle = style is { } ?
                    (ShapeStyleViewModel)style?.Copy(null) :
                    factory.CreateShapeStyle(ProjectEditorConfiguration.DefaulStyleName);

                    var convertedPathShape = factory.CreateLineShape(
                        lastPoint,
                        lineSegment.Point,
                        convertedStyle,
                        isStroked);

                    lastPoint = lineSegment.Point;

                    result.Add(convertedPathShape);
                }
                break;
 public QuadraticBezierSelection(IServiceProvider?serviceProvider, LayerContainerViewModel layer, QuadraticBezierShapeViewModel shape, ShapeStyleViewModel style)
 {
     _serviceProvider = serviceProvider;
     _layer           = layer;
     _quadraticBezier = shape;
     _styleViewModel  = style;
 }
Beispiel #11
0
 public EllipseSelection(IServiceProvider serviceProvider, LayerContainerViewModel layer, EllipseShapeViewModel shape, ShapeStyleViewModel style)
 {
     _serviceProvider = serviceProvider;
     _layer           = layer;
     _ellipse         = shape;
     _styleViewModel  = style;
 }
Beispiel #12
0
 public ImageDrawNode(ImageShapeViewModel image, ShapeStyleViewModel style, IImageCache imageCache, ICache <string, IDisposable> bitmapCache)
     : base()
 {
     Style       = style;
     Image       = image;
     ImageCache  = imageCache;
     BitmapCache = bitmapCache;
     UpdateGeometry();
 }
    public override object Copy(IDictionary <object, object>?shared)
    {
        var copy = new ShapeStyleViewModel(ServiceProvider)
        {
            Name      = Name,
            Stroke    = _stroke?.CopyShared(shared),
            Fill      = _fill?.CopyShared(shared),
            TextStyle = _textStyle?.CopyShared(shared)
        };

        return(copy);
    }
Beispiel #14
0
 public BoxDecoratorViewModel(IServiceProvider serviceProvider) : base(serviceProvider)
 {
     _factory             = serviceProvider.GetService <IFactory>();
     _sizeLarge           = 4m;
     _sizeSmall           = 4m;
     _rotateDistance      = -16.875m;
     _handleStyle         = _factory.CreateShapeStyle("Handle", 255, 0, 191, 255, 255, 255, 255, 255, 2.0);
     _boundsStyle         = _factory.CreateShapeStyle("Bounds", 255, 0, 191, 255, 255, 255, 255, 255, 1.0);
     _selectedHandleStyle = _factory.CreateShapeStyle("SelectedHandle", 255, 0, 191, 255, 255, 0, 191, 255, 2.0);
     _selectedBoundsStyle = _factory.CreateShapeStyle("SelectedBounds", 255, 0, 191, 255, 255, 255, 255, 255, 1.0);
     _rotateHandle        = _factory.CreateEllipseShape(0, 0, 0, 0, _handleStyle, true, true, name: "_rotateHandle");
     _topLeftHandle       = _factory.CreateEllipseShape(0, 0, 0, 0, _handleStyle, true, true, name: "_topLeftHandle");
     _topRightHandle      = _factory.CreateEllipseShape(0, 0, 0, 0, _handleStyle, true, true, name: "_topRightHandle");
     _bottomLeftHandle    = _factory.CreateEllipseShape(0, 0, 0, 0, _handleStyle, true, true, name: "_bottomLeftHandle");
     _bottomRightHandle   = _factory.CreateEllipseShape(0, 0, 0, 0, _handleStyle, true, true, name: "_bottomRightHandle");
     _topHandle           = _factory.CreateRectangleShape(0, 0, 0, 0, _handleStyle, true, true, name: "_topHandle");
     _bottomHandle        = _factory.CreateRectangleShape(0, 0, 0, 0, _handleStyle, true, true, name: "_bottomHandle");
     _leftHandle          = _factory.CreateRectangleShape(0, 0, 0, 0, _handleStyle, true, true, name: "_leftHandle");
     _rightHandle         = _factory.CreateRectangleShape(0, 0, 0, 0, _handleStyle, true, true, name: "_rightHandle");
     _boundsHandle        = _factory.CreateRectangleShape(0, 0, 0, 0, _boundsStyle, true, false, name: "_boundsHandle");
     _rotateLine          = _factory.CreateLineShape(0, 0, 0, 0, _boundsStyle, true, name: "_rotateLine");
     _handles             = new List <BaseShapeViewModel>
     {
         //_rotateHandle,
         _topLeftHandle,
         _topRightHandle,
         _bottomLeftHandle,
         _bottomRightHandle,
         _topHandle,
         _bottomHandle,
         _leftHandle,
         _rightHandle,
         _boundsHandle,
         //_rotateLine
     };
     _currentHandle            = null;
     _rotateHandle.State      |= ShapeStateFlags.Size | ShapeStateFlags.Thickness;
     _topLeftHandle.State     |= ShapeStateFlags.Size | ShapeStateFlags.Thickness;
     _topRightHandle.State    |= ShapeStateFlags.Size | ShapeStateFlags.Thickness;
     _bottomLeftHandle.State  |= ShapeStateFlags.Size | ShapeStateFlags.Thickness;
     _bottomRightHandle.State |= ShapeStateFlags.Size | ShapeStateFlags.Thickness;
     _topHandle.State         |= ShapeStateFlags.Size | ShapeStateFlags.Thickness;
     _bottomHandle.State      |= ShapeStateFlags.Size | ShapeStateFlags.Thickness;
     _leftHandle.State        |= ShapeStateFlags.Size | ShapeStateFlags.Thickness;
     _rightHandle.State       |= ShapeStateFlags.Size | ShapeStateFlags.Thickness;
     _boundsHandle.State      |= ShapeStateFlags.Thickness;
     _rotateLine.State        |= ShapeStateFlags.Thickness;
 }
Beispiel #15
0
 public ILineDrawNode CreateLineDrawNode(LineShapeViewModel line, ShapeStyleViewModel style)
 {
     return(new LineDrawNode(line, style));
 }
Beispiel #16
0
 public ArcDrawNode(ArcShapeViewModel arc, ShapeStyleViewModel style)
 {
     Style = style;
     Arc   = arc;
     UpdateGeometry();
 }
Beispiel #17
0
 public IRectangleDrawNode CreateRectangleDrawNode(RectangleShapeViewModel rectangle, ShapeStyleViewModel style)
 {
     return(new RectangleDrawNode(rectangle, style));
 }
Beispiel #18
0
 public IEllipseDrawNode CreateEllipseDrawNode(EllipseShapeViewModel ellipse, ShapeStyleViewModel style)
 {
     return(new EllipseDrawNode(ellipse, style));
 }
Beispiel #19
0
 public TextDrawNode(TextShapeViewModel text, ShapeStyleViewModel style)
 {
     Style = style;
     Text  = text;
     UpdateGeometry();
 }
Beispiel #20
0
 public IImageDrawNode CreateImageDrawNode(ImageShapeViewModel image, ShapeStyleViewModel style, IImageCache imageCache, ICache <string, IDisposable> bitmapCache)
 {
     return(new ImageDrawNode(image, style, imageCache, bitmapCache));
 }
Beispiel #21
0
 public ICubicBezierDrawNode CreateCubicBezierDrawNode(CubicBezierShapeViewModel cubicBezier, ShapeStyleViewModel style)
 {
     return(new CubicBezierDrawNode(cubicBezier, style));
 }
Beispiel #22
0
 public PointSelection(LayerContainerViewModel layer, PointShapeViewModel shape, ShapeStyleViewModel style)
 {
     _layer          = layer;
     _shapeViewModel = shape;
     _styleViewModel = style;
 }
Beispiel #23
0
 public IQuadraticBezierDrawNode CreateQuadraticBezierDrawNode(QuadraticBezierShapeViewModel quadraticBezier, ShapeStyleViewModel style)
 {
     return(new QuadraticBezierDrawNode(quadraticBezier, style));
 }
Beispiel #24
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);
            }
            }
        }
Beispiel #25
0
 public LineDrawNode(LineShapeViewModel line, ShapeStyleViewModel style)
 {
     Style = style;
     Line  = line;
     UpdateGeometry();
 }
Beispiel #26
0
 public IPathDrawNode CreatePathDrawNode(PathShapeViewModel path, ShapeStyleViewModel style)
 {
     return(new PathDrawNode(path, style));
 }
Beispiel #27
0
 public PathDrawNode(PathShapeViewModel path, ShapeStyleViewModel style)
 {
     Style = style;
     Path  = path;
     UpdateGeometry();
 }
Beispiel #28
0
 public IArcDrawNode CreateArcDrawNode(ArcShapeViewModel arc, ShapeStyleViewModel style)
 {
     return(new ArcDrawNode(arc, style));
 }
 public QuadraticBezierDrawNode(QuadraticBezierShapeViewModel quadraticBezier, ShapeStyleViewModel style)
 {
     Style           = style;
     QuadraticBezier = quadraticBezier;
     UpdateGeometry();
 }
Beispiel #30
0
 public ITextDrawNode CreateTextDrawNode(TextShapeViewModel text, ShapeStyleViewModel style)
 {
     return(new TextDrawNode(text, style));
 }