FirstIntersectionWith() private method

private FirstIntersectionWith ( Circle circle ) : Point?
circle Circle
return Point?
            private static Point Find(Ray ray, double strokeThickness, Ellipse ellipse)
            {
                var ip = ray.FirstIntersectionWith(ellipse);

                if (ip != null)
                {
                    return(ip.Value + strokeThickness * ray.Direction);
                }

                return(FindTangentPoint(ray, ellipse));
            }
Esempio n. 2
0
            private static Point FindForRotated(Ray ray, double strokeThickness, Rect rectangle, CornerRadius cornerRadius)
            {
                var ip = ray.FirstIntersectionWith(rectangle);

                if (ip == null)
                {
                    return(FindTangentPoint(ray, rectangle, cornerRadius));
                }

                Circle corner;

                if (TryGetCorner(ip.Value, rectangle, cornerRadius, out corner))
                {
                    ip = ray.FirstIntersectionWith(corner);
                    if (ip == null)
                    {
                        return(FindTangentPoint(ray, rectangle, cornerRadius));
                    }

                    return(ip.Value + strokeThickness * ray.Direction);
                }

                return(ip.Value + strokeThickness * ray.Direction);
            }
Esempio n. 3
0
        protected override Geometry GetOrCreateConnectorGeometry(Size renderSize)
        {
            var rectangle = new Rect(new Point(0, 0), renderSize);

            if (rectangle.Width <= 0 || rectangle.Height <= 0)
            {
                return(Geometry.Empty);
            }

            var fromCenter = new Ray(rectangle.CenterPoint(), this.ConnectorOffset);
            var ip         = fromCenter.FirstIntersectionWith(rectangle);

            if (ip == null)
            {
                Debug.Assert(false, $"Line {fromCenter} does not intersect rectangle {rectangle}");
                // ReSharper disable once HeuristicUnreachableCode
                return(Geometry.Empty);
            }

            var cr          = this.AdjustedCornerRadius();
            var vertexPoint = ip.Value + this.ConnectorOffset;
            var toCenter    = new Ray(vertexPoint, this.ConnectorOffset.Negated());
            var p1          = ConnectorPoint.Find(toCenter, this.ConnectorAngle / 2, this.StrokeThickness, rectangle, cr);
            var p2          = ConnectorPoint.Find(toCenter, -this.ConnectorAngle / 2, this.StrokeThickness, rectangle, cr);

            this.SetValue(ConnectorVertexPointProperty, vertexPoint);
            this.SetValue(ConnectorPoint1Property, p1);
            this.SetValue(ConnectorPoint2Property, p2);
            if (this.ConnectorGeometry is PathGeometry)
            {
                return(this.ConnectorGeometry);
            }

            var figure = this.CreatePathFigureStartingAt(ConnectorPoint1Property);

            figure.Segments.Add(this.CreateLineSegmentTo(ConnectorVertexPointProperty));
            figure.Segments.Add(this.CreateLineSegmentTo(ConnectorPoint2Property));
            var geometry = new PathGeometry();

            geometry.Figures.Add(figure);
            return(geometry);
        }
            private static Point Find(Ray ray, double strokeThickness, Ellipse ellipse)
            {
                var ip = ray.FirstIntersectionWith(ellipse);
                if (ip != null)
                {
                    return ip.Value + strokeThickness * ray.Direction;
                }

                return FindTangentPoint(ray, ellipse);
            }
Esempio n. 5
0
        protected override Geometry GetOrCreateConnectorGeometry(Size renderSize)
        {
            var rectangle = new Rect(new Point(0, 0), renderSize);
            if (rectangle.Width <= 0 || rectangle.Height <= 0)
            {
                return Geometry.Empty;
            }

            var fromCenter = new Ray(rectangle.CenterPoint(), this.ConnectorOffset);
            var ip = fromCenter.FirstIntersectionWith(rectangle);
            if (ip == null)
            {
                Debug.Assert(false, $"Line {fromCenter} does not intersect rectangle {rectangle}");

                // ReSharper disable once HeuristicUnreachableCode
                return Geometry.Empty;
            }

            var cr = this.AdjustedCornerRadius();
            var vertexPoint = ip.Value + this.ConnectorOffset;
            var toCenter = new Ray(vertexPoint, this.ConnectorOffset.Negated());
            var p1 = ConnectorPoint.Find(toCenter, this.ConnectorAngle / 2, this.StrokeThickness, rectangle, cr);
            var p2 = ConnectorPoint.Find(toCenter, -this.ConnectorAngle / 2, this.StrokeThickness, rectangle, cr);
            this.SetCurrentValue(ConnectorVertexPointProperty, vertexPoint);
            this.SetCurrentValue(ConnectorPoint1Property, p1);
            this.SetCurrentValue(ConnectorPoint2Property, p2);
            if (this.ConnectorGeometry is PathGeometry)
            {
                return this.ConnectorGeometry;
            }

            var figure = this.CreatePathFigureStartingAt(ConnectorPoint1Property);
            figure.Segments.Add(this.CreateLineSegmentTo(ConnectorVertexPointProperty));
            figure.Segments.Add(this.CreateLineSegmentTo(ConnectorPoint2Property));
            var geometry = new PathGeometry();
            geometry.Figures.Add(figure);
            return geometry;
        }
Esempio n. 6
0
            private static Point FindForRotated(Ray ray, double strokeThickness, Rect rectangle, CornerRadius cornerRadius)
            {
                var ip = ray.FirstIntersectionWith(rectangle);
                if (ip == null)
                {
                    return FindTangentPoint(ray, rectangle, cornerRadius);
                }

                Circle corner;
                if (TryGetCorner(ip.Value, rectangle, cornerRadius, out corner))
                {
                    ip = ray.FirstIntersectionWith(corner);
                    if (ip == null)
                    {
                        return FindTangentPoint(ray, rectangle, cornerRadius);
                    }

                    return ip.Value + strokeThickness * ray.Direction;
                }

                return ip.Value + strokeThickness * ray.Direction;
            }