Example #1
0
 public EllipseDrawNode(EllipseShapeViewModel ellipse, ShapeStyleViewModel style)
     : base()
 {
     Style   = style;
     Ellipse = ellipse;
     UpdateGeometry();
 }
        public void BeginDown(InputArgs args)
        {
            var factory = _serviceProvider.GetService <IFactory>();
            var editor  = _serviceProvider.GetService <ProjectEditorViewModel>();

            (decimal sx, decimal sy) = editor.TryToSnap(args);
            switch (_currentState)
            {
            case State.TopLeft:
            {
                editor.IsToolIdle = false;
                if (_currentMode == Mode.Circle)
                {
                    _centerX = sx;
                    _centerY = sy;
                }

                var style = editor.Project.CurrentStyleLibrary?.Selected is { } ?
                editor.Project.CurrentStyleLibrary.Selected :
                editor.Factory.CreateShapeStyle(ProjectEditorConfiguration.DefaulStyleName);
                _ellipse = factory.CreateEllipseShape(
                    (double)sx, (double)sy,
                    (ShapeStyleViewModel)style.Copy(null),
                    editor.Project.Options.DefaultIsStroked,
                    editor.Project.Options.DefaultIsFilled);

                editor.SetShapeName(_ellipse);

                var result = editor.TryToGetConnectionPoint((double)sx, (double)sy);
                if (result is { })
Example #3
0
 public EllipseSelection(IServiceProvider serviceProvider, LayerContainerViewModel layer, EllipseShapeViewModel shape, ShapeStyleViewModel style)
 {
     _serviceProvider = serviceProvider;
     _layer           = layer;
     _ellipse         = shape;
     _styleViewModel  = style;
 }
Example #4
0
        public static AM.Geometry ToGeometry(EllipseShapeViewModel ellipse)
        {
            var rect2 = Rect2.FromPoints(ellipse.TopLeft.X, ellipse.TopLeft.Y, ellipse.BottomRight.X, ellipse.BottomRight.Y);
            var rect  = new A.Rect(rect2.X, rect2.Y, rect2.Width, rect2.Height);
            var g     = new AM.EllipseGeometry(rect);

            return(g);
        }
Example #5
0
        public void ToStatePoint2()
        {
            _ellipse        = _serviceProvider.GetService <IFactory>().CreateEllipseShape(0, 0, _styleViewModel);
            _ellipse.State |= ShapeStateFlags.Thickness;

            _p1HelperPoint     = _serviceProvider.GetService <IFactory>().CreatePointShape(0, 0);
            _p2HelperPoint     = _serviceProvider.GetService <IFactory>().CreatePointShape(0, 0);
            _centerHelperPoint = _serviceProvider.GetService <IFactory>().CreatePointShape(0, 0);

            _layer.Shapes = _layer.Shapes.Add(_ellipse);
            _layer.Shapes = _layer.Shapes.Add(_p1HelperPoint);
            _layer.Shapes = _layer.Shapes.Add(_p2HelperPoint);
            _layer.Shapes = _layer.Shapes.Add(_centerHelperPoint);
        }
Example #6
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;
 }
Example #7
0
    public override object Copy(IDictionary <object, object>?shared)
    {
        var copy = new EllipseShapeViewModel(ServiceProvider)
        {
            Name        = Name,
            State       = State,
            Style       = _style?.CopyShared(shared),
            IsStroked   = IsStroked,
            IsFilled    = IsFilled,
            Properties  = _properties.CopyShared(shared).ToImmutable(),
            Record      = _record,
            TopLeft     = _topLeft?.CopyShared(shared),
            BottomRight = _bottomRight?.CopyShared(shared)
        };

        return(copy);
    }
Example #8
0
 public void Bind(EllipseShapeViewModel ellipse, object db, object r)
 {
 }
Example #9
0
 public IEllipseDrawNode CreateEllipseDrawNode(EllipseShapeViewModel ellipse, ShapeStyleViewModel style)
 {
     return(new EllipseDrawNode(ellipse, style));
 }