Example #1
0
        protected override Geometry OnCreateOutlineFillGeometry(RectDouble bounds, IDictionary <string, object> settingValues)
        {
            Geometry ellipseGeometry = this.GetEllipseGeometry(bounds);
            float    num             = (float)settingValues[ToolSettings.Null.Pen.Width.Path];

            System.Drawing.Drawing2D.DashStyle gdipDashStyle = (System.Drawing.Drawing2D.DashStyle)settingValues[ToolSettings.Null.Pen.DashStyle.Path];
            PaintDotNet.UI.Media.DashStyle     style2        = DashStyleUtil.ToMedia(gdipDashStyle);
            StrokeStyle style3 = new StrokeStyle {
                DashStyle = style2
            }.EnsureFrozen <StrokeStyle>();
            WidenedGeometry freezable = new WidenedGeometry {
                Geometry            = ellipseGeometry,
                Thickness           = num,
                StrokeStyle         = style3,
                FlatteningTolerance = 0.0001
            };

            return(freezable.EnsureFrozen <WidenedGeometry>());
        }
Example #2
0
        private static Geometry CreateStrokedLineGeometry(Geometry lineGeometry, double strokeWidth, LineCap2 startCap, LineCap2 endCap, PaintDotNet.UI.Media.DashStyle dashStyle)
        {
            Geometry    geometry;
            Geometry    geometry2;
            Geometry    geometry3;
            Geometry    geometry4;
            Geometry    geometry5;
            double      length      = lineGeometry.GetLength(flatteningTolerance);
            StrokeStyle strokeStyle = new StrokeStyle {
                DashStyle = dashStyle,
                LineJoin  = PenLineJoin.Round
            };
            double num2 = 0.0;

            switch (startCap)
            {
            case LineCap2.Flat:
                geometry = null;
                break;

            case LineCap2.Arrow:
                geometry = CreateArrowGeometry(5.0, 5.0, strokeWidth, 1.0, false, false).EnsureFrozen <Geometry>();
                num2     = 0.5;
                break;

            case LineCap2.ArrowFilled:
                geometry = CreateArrowGeometry(5.0, 5.0, strokeWidth, 1.0, true, true).EnsureFrozen <Geometry>();
                num2     = 1.5;
                break;

            case LineCap2.Rounded:
                strokeStyle.StartLineCap = PenLineCap.Round;
                geometry = null;
                break;

            default:
                throw ExceptionUtil.InvalidEnumArgumentException <LineCap2>(startCap, "startCap");
            }
            double num3 = 0.0;

            switch (endCap)
            {
            case LineCap2.Flat:
                geometry2 = null;
                break;

            case LineCap2.Arrow:
                geometry2 = CreateArrowGeometry(5.0, 5.0, strokeWidth, 1.0, false, false).EnsureFrozen <Geometry>();
                num3      = 0.5;
                break;

            case LineCap2.ArrowFilled:
                geometry2 = CreateArrowGeometry(5.0, 5.0, strokeWidth, 1.0, true, true).EnsureFrozen <Geometry>();
                num3      = 1.5;
                break;

            case LineCap2.Rounded:
                strokeStyle.EndLineCap = PenLineCap.Round;
                geometry2 = null;
                break;

            default:
                throw ExceptionUtil.InvalidEnumArgumentException <LineCap2>(endCap, "endCap");
            }
            strokeStyle.Freeze();
            if (geometry == null)
            {
                geometry3 = null;
            }
            else
            {
                PointAndTangentDouble pointAtLength = lineGeometry.GetPointAtLength(0.0, flatteningTolerance);
                double          radians             = Math.Atan2(pointAtLength.Tangent.Y, pointAtLength.Tangent.X) + 3.1415926535897931;
                Matrix3x2Double num9   = Matrix3x2Double.RotationByRadians(radians);
                Matrix3x2Double num10  = Matrix3x2Double.Translation(pointAtLength.Point.X, pointAtLength.Point.Y);
                Matrix3x2Double matrix = num9 * num10;
                geometry3 = geometry.GetTransformedGeometry(matrix).EnsureFrozen <Geometry>();
            }
            if (geometry2 == null)
            {
                geometry4 = null;
            }
            else
            {
                double num14 = lineGeometry.GetLength(flatteningTolerance);
                PointAndTangentDouble num15 = lineGeometry.GetPointAtLength(num14, flatteningTolerance);
                Matrix3x2Double       num18 = Matrix3x2Double.RotationByRadians(Math.Atan2(num15.Tangent.Y, num15.Tangent.X));
                Matrix3x2Double       num19 = Matrix3x2Double.Translation(num15.Point.X, num15.Point.Y);
                Matrix3x2Double       num20 = num18 * num19;
                geometry4 = geometry2.GetTransformedGeometry(num20).EnsureFrozen <Geometry>();
            }
            double startLength = 0.0;
            double endLength   = length;

            if (num2 != 0.0)
            {
                startLength = strokeWidth * num2;
            }
            if (num3 != 0.0)
            {
                endLength = length - (strokeWidth * num3);
            }
            if ((startLength != 0.0) || (endLength != length))
            {
                geometry5 = GetTrimmedGeometry(lineGeometry, startLength, endLength).EnsureFrozen <Geometry>();
            }
            else
            {
                geometry5 = lineGeometry;
            }
            Geometry item = new WidenedGeometry(geometry5, strokeWidth, strokeStyle)
            {
                FlatteningTolerance = flatteningTolerance
            }.EnsureFrozen <WidenedGeometry>();
            GeometryGroup group = new GeometryGroup {
                FillRule = FillRule.Nonzero
            };

            group.Children.Add(item);
            if (geometry3 != null)
            {
                group.Children.Add(geometry3);
            }
            if (geometry4 != null)
            {
                group.Children.Add(geometry4);
            }
            group.Freeze();
            return(group);
        }
Example #3
0
        public RotateCursorDrawing()
        {
            this.ellipseCenter.SetArgInput(1, this, new PaintDotNet.ObjectModel.PropertyPath(AngleProperty.Name, Array.Empty <object>()));
            this.ellipseCenter.SetArgInput(2, this, new PaintDotNet.ObjectModel.PropertyPath(BigRadiusProperty.Name, Array.Empty <object>()));
            this.ellipseGeometry.SetBinding(EllipseGeometry.CenterProperty, this.ellipseCenter, new PaintDotNet.ObjectModel.PropertyPath(this.ellipseCenter.GetValueProperty().Name, Array.Empty <object>()), BindingMode.OneWay);
            this.ellipseGeometry.SetBinding(EllipseGeometry.RadiusXProperty, this, new PaintDotNet.ObjectModel.PropertyPath(BigRadiusProperty.Name, Array.Empty <object>()), BindingMode.OneWay);
            this.ellipseGeometry.SetBinding(EllipseGeometry.RadiusYProperty, this, new PaintDotNet.ObjectModel.PropertyPath(BigRadiusProperty.Name, Array.Empty <object>()), BindingMode.OneWay);
            this.arrowGeometry = new PathGeometry();
            PathFigure item = new PathFigure {
                IsClosed = true
            };
            LineSegment targetObject = new LineSegment();

            targetObject.SetBinding <double, PointDouble>(LineSegment.PointProperty, this, new PaintDotNet.ObjectModel.PropertyPath(HandleDrawing.ThicknessProperty.Name, Array.Empty <object>()), BindingMode.OneWay, t => new PointDouble(3.0 * t, -1.5 * t));
            item.Segments.Add(targetObject);
            LineSegment segment2 = new LineSegment();

            segment2.SetBinding <double, PointDouble>(LineSegment.PointProperty, this, new PaintDotNet.ObjectModel.PropertyPath(HandleDrawing.ThicknessProperty.Name, Array.Empty <object>()), BindingMode.OneWay, t => new PointDouble(3.0 * t, 1.5 * t));
            item.Segments.Add(segment2);
            this.arrowGeometry.Figures.Add(item);
            this.cwArrowGeometry = new GeometryGroup();
            this.cwArrowGeometry.Children.Add(this.arrowGeometry);
            TransformGroup  group     = new TransformGroup();
            RotateTransform transform = new RotateTransform {
                Angle = 90.0
            };

            group.Children.Add(transform);
            RotateTransform transform2 = new RotateTransform();

            transform2.SetBinding(RotateTransform.AngleProperty, this, new PaintDotNet.ObjectModel.PropertyPath(AngleProperty.Name, Array.Empty <object>()), BindingMode.OneWay);
            group.Children.Add(transform2);
            RotateTransform transform3 = new RotateTransform();

            transform3.SetBinding <double, double>(RotateTransform.AngleProperty, this, new PaintDotNet.ObjectModel.PropertyPath(BigRadiusProperty.Name, Array.Empty <object>()), BindingMode.OneWay, br => - GetArrowAngleDelta(br));
            group.Children.Add(transform3);
            RotateTransform transform4 = new RotateTransform {
                Angle = 16.0
            };

            transform4.SetBinding <PointDouble, double>(RotateTransform.CenterXProperty, this.ellipseCenter, new PaintDotNet.ObjectModel.PropertyPath(this.ellipseCenter.GetValueProperty().Name, Array.Empty <object>()), BindingMode.OneWay, c => c.X);
            transform4.SetBinding <PointDouble, double>(RotateTransform.CenterYProperty, this.ellipseCenter, new PaintDotNet.ObjectModel.PropertyPath(this.ellipseCenter.GetValueProperty().Name, Array.Empty <object>()), BindingMode.OneWay, c => c.Y);
            group.Children.Add(transform4);
            this.cwArrowGeometry.Transform = group;
            this.ccwArrowGeometry          = new GeometryGroup();
            this.ccwArrowGeometry.Children.Add(this.arrowGeometry);
            TransformGroup  group2     = new TransformGroup();
            RotateTransform transform5 = new RotateTransform {
                Angle = -90.0
            };

            group2.Children.Add(transform5);
            RotateTransform transform6 = new RotateTransform();

            transform6.SetBinding(RotateTransform.AngleProperty, this, new PaintDotNet.ObjectModel.PropertyPath(AngleProperty.Name, Array.Empty <object>()), BindingMode.OneWay);
            group2.Children.Add(transform6);
            RotateTransform transform7 = new RotateTransform();

            transform7.SetBinding <double, double>(RotateTransform.AngleProperty, this, new PaintDotNet.ObjectModel.PropertyPath(BigRadiusProperty.Name, Array.Empty <object>()), BindingMode.OneWay, br => GetArrowAngleDelta(br));
            group2.Children.Add(transform7);
            RotateTransform transform8 = new RotateTransform {
                Angle = -16.0
            };

            transform8.SetBinding <PointDouble, double>(RotateTransform.CenterXProperty, this.ellipseCenter, new PaintDotNet.ObjectModel.PropertyPath(this.ellipseCenter.GetValueProperty().Name, Array.Empty <object>()), BindingMode.OneWay, c => c.X);
            transform8.SetBinding <PointDouble, double>(RotateTransform.CenterYProperty, this.ellipseCenter, new PaintDotNet.ObjectModel.PropertyPath(this.ellipseCenter.GetValueProperty().Name, Array.Empty <object>()), BindingMode.OneWay, c => c.Y);
            group2.Children.Add(transform8);
            this.ccwArrowGeometry.Transform = group2;
            this.arrowsGeometry             = new CombinedGeometry(GeometryCombineMode.Xor, this.cwArrowGeometry, this.ccwArrowGeometry);
            this.wedgeClipGeometry          = new PathGeometry();
            PathFigure figure2 = new PathFigure {
                IsClosed = true
            };

            figure2.SetBinding(PathFigure.StartPointProperty, this.ellipseGeometry, new PaintDotNet.ObjectModel.PropertyPath(EllipseGeometry.CenterProperty.Name, Array.Empty <object>()), BindingMode.OneWay);
            LineSegment segment3 = new LineSegment();

            segment3.SetBinding <PointDouble, PointDouble>(LineSegment.PointProperty, this.ellipseGeometry, new PaintDotNet.ObjectModel.PropertyPath(EllipseGeometry.CenterProperty.Name, Array.Empty <object>()), BindingMode.OneWay, c => GetWedgePathPoint(c, thetaDelta));
            figure2.Segments.Add(segment3);
            LineSegment segment4 = new LineSegment();

            segment4.SetBinding <PointDouble, PointDouble>(LineSegment.PointProperty, this.ellipseGeometry, new PaintDotNet.ObjectModel.PropertyPath(EllipseGeometry.CenterProperty.Name, Array.Empty <object>()), BindingMode.OneWay, c => GetWedgePathPoint(c, -thetaDelta));
            figure2.Segments.Add(segment4);
            this.wedgeClipGeometry.Figures.Add(figure2);
            this.backgroundDrawing = new GeometryDrawing();
            this.backgroundDrawing.SetBinding(GeometryDrawing.BrushProperty, this, new PaintDotNet.ObjectModel.PropertyPath(HandleDrawing.BackgroundProperty.Name, Array.Empty <object>()), BindingMode.OneWay);
            WidenedGeometry geometry = new WidenedGeometry(this.ellipseGeometry);

            geometry.SetBinding <double, double>(WidenedGeometry.ThicknessProperty, this, new PaintDotNet.ObjectModel.PropertyPath(HandleDrawing.ThicknessProperty.Name, Array.Empty <object>()), BindingMode.OneWay, t => t + 2.5);
            CombinedGeometry geometry2 = new CombinedGeometry(GeometryCombineMode.Intersect, geometry, this.wedgeClipGeometry);
            WidenedGeometry  geometry3 = new WidenedGeometry(this.arrowsGeometry);

            geometry3.SetBinding <double, double>(WidenedGeometry.ThicknessProperty, this, new PaintDotNet.ObjectModel.PropertyPath(HandleDrawing.ThicknessProperty.Name, Array.Empty <object>()), BindingMode.OneWay, t => t + 2.5);
            CombinedGeometry geometry4 = new CombinedGeometry(GeometryCombineMode.Union, this.arrowsGeometry, geometry3);
            CombinedGeometry geometry5 = new CombinedGeometry(GeometryCombineMode.Union, geometry2, geometry4);

            this.backgroundDrawing.Geometry = geometry5;
            base.DrawingGroup.Children.Add(this.backgroundDrawing);
            this.foregroundDrawing = new GeometryDrawing();
            this.foregroundDrawing.SetBinding(GeometryDrawing.BrushProperty, this, new PaintDotNet.ObjectModel.PropertyPath(HandleDrawing.ForegroundProperty.Name, Array.Empty <object>()), BindingMode.OneWay);
            WidenedGeometry geometry6 = new WidenedGeometry(this.ellipseGeometry);

            geometry6.SetBinding(WidenedGeometry.ThicknessProperty, this, new PaintDotNet.ObjectModel.PropertyPath(HandleDrawing.ThicknessProperty), BindingMode.OneWay);
            CombinedGeometry geometry7 = new CombinedGeometry(GeometryCombineMode.Intersect, geometry6, this.wedgeClipGeometry);
            WidenedGeometry  geometry8 = new WidenedGeometry(this.arrowsGeometry);

            geometry8.SetBinding(WidenedGeometry.ThicknessProperty, this, new PaintDotNet.ObjectModel.PropertyPath(HandleDrawing.ThicknessProperty), BindingMode.OneWay);
            CombinedGeometry geometry9  = new CombinedGeometry(GeometryCombineMode.Union, this.arrowsGeometry, geometry8);
            CombinedGeometry geometry10 = new CombinedGeometry(GeometryCombineMode.Union, geometry7, geometry9);

            this.foregroundDrawing.Geometry = geometry10;
            base.DrawingGroup.Children.Add(this.foregroundDrawing);
        }