Example #1
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);
        }