Esempio n. 1
0
        public IBaseShape Overlaps(IBaseShape shape, Rect2 target, double radius, IHitTest hitTest, Modifier modifier)
        {
            if (!(shape is PathShape path))
            {
                throw new ArgumentNullException("shape");
            }

            foreach (var pathShape in path.Shapes)
            {
                var result = pathShape.Bounds?.Overlaps(pathShape, target, radius, hitTest, modifier);
                if (result != null)
                {
                    return(result);
                }
            }

            var points = new List <IPointShape>();

            path.GetPoints(points);

            if (points.Count == 0)
            {
                return(null);
            }

            return(HitTestHelper.Overlap(points, target) ? shape : null);
        }
Esempio n. 2
0
        public IBaseShape Contains(IBaseShape shape, Point2 target, double radius, IHitTest hitTest, Modifier modifier)
        {
            if (!(shape is GroupShape group))
            {
                throw new ArgumentNullException("shape");
            }

            foreach (var groupShape in group.Shapes.Reverse())
            {
                var result = groupShape.Bounds?.Contains(groupShape, target, radius, hitTest, modifier);
                if (result != null)
                {
                    if (modifier.HasFlag(Modifier.Shift))
                    {
                        return(result);
                    }
                    else
                    {
                        return(group);
                    }
                }
            }

            var points = new List <IPointShape>();

            group.GetPoints(points);

            if (points.Count == 0)
            {
                return(null);
            }

            return(HitTestHelper.Contains(points, target) ? shape : null);
        }
Esempio n. 3
0
        public IBaseShape Contains(IBaseShape shape, Point2 target, double radius, IHitTest hitTest, Modifier modifier)
        {
            if (!(shape is CanvasContainer container))
            {
                throw new ArgumentNullException("shape");
            }

            foreach (var containerShape in container.Shapes)
            {
                var result = containerShape.Bounds?.Contains(containerShape, target, radius, hitTest, modifier);
                if (result != null)
                {
                    return(container);
                }
            }

            var points = new List <IPointShape>();

            container.GetPoints(points);

            if (points.Count == 0)
            {
                return(null);
            }

            return(HitTestHelper.Contains(points, target) ? shape : null);
        }
Esempio n. 4
0
        public IBaseShape Contains(IBaseShape shape, Point2 target, double radius, IHitTest hitTest, Modifier modifier)
        {
            if (!(shape is PathShape path))
            {
                throw new ArgumentNullException("shape");
            }

            if (modifier.HasFlag(Modifier.Shift))
            {
                if (path.Shapes.Count >= 1)
                {
                    foreach (var pathShape in path.Shapes.Reverse())
                    {
                        var pathShapePoints = new List <IPointShape>();
                        pathShape.GetPoints(pathShapePoints);

                        if (HitTestHelper.Contains(pathShapePoints, target))
                        {
                            if (modifier.HasFlag(Modifier.Alt))
                            {
                                var result = pathShape.Bounds?.Contains(pathShape, target, radius, hitTest, modifier);
                                if (result != null)
                                {
                                    return(result);
                                }
                            }
                            return(pathShape);
                        }
                    }
                }
            }
            else
            {
                foreach (var pathShape in path.Shapes.Reverse())
                {
                    var result = pathShape.Bounds?.Contains(pathShape, target, radius, hitTest, modifier);
                    if (result != null)
                    {
                        if (modifier.HasFlag(Modifier.Alt))
                        {
                            var subResult = result.Bounds?.Contains(result, target, radius, hitTest, Modifier.Shift);
                            if (subResult != null)
                            {
                                return(subResult);
                            }
                        }
                        return(path);
                    }
                }
            }

            var points = new List <IPointShape>();

            path.GetPoints(points);

            return(HitTestHelper.Contains(points, target) ? shape : null);
        }
Esempio n. 5
0
        public IBaseShape Overlaps(IBaseShape shape, Rect2 target, double radius, IHitTest hitTest, Modifier modifier)
        {
            if (!(shape is CubicBezierShape cubicBezier))
            {
                throw new ArgumentNullException("shape");
            }

            var points = new List <IPointShape>();

            cubicBezier.GetPoints(points);

            return(HitTestHelper.Overlap(points, target) ? shape : null);
        }
Esempio n. 6
0
        public IBaseShape Contains(IBaseShape shape, Point2 target, double radius, IHitTest hitTest, Modifier modifier)
        {
            if (!(shape is ConicShape conic))
            {
                throw new ArgumentNullException("shape");
            }

            var points = new List <IPointShape>();

            conic.GetPoints(points);

            return(HitTestHelper.Contains(points, target) ? shape : null);
        }
Esempio n. 7
0
        public IBaseShape Overlaps(IBaseShape shape, Rect2 target, double radius, IHitTest hitTest, Modifier modifier)
        {
            if (!(shape is ConicShape conic))
            {
                throw new ArgumentNullException("shape");
            }

            var points = new List <IPointShape>();

            conic.GetPoints(points);

            if (points.Count == 0)
            {
                return(null);
            }

            return(HitTestHelper.Overlap(points, target) ? shape : null);
        }
Esempio n. 8
0
        public IBaseShape Contains(IBaseShape shape, Point2 target, double radius, IHitTest hitTest, Modifier modifier)
        {
            if (!(shape is QuadraticBezierShape quadraticBezier))
            {
                throw new ArgumentNullException("shape");
            }

            var points = new List <IPointShape>();

            quadraticBezier.GetPoints(points);

            if (points.Count == 0)
            {
                return(null);
            }

            return(HitTestHelper.Contains(points, target) ? shape : null);
        }