Beispiel #1
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);
        }
Beispiel #2
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);
        }
Beispiel #3
0
        public IBaseShape Contains(IBaseShape shape, Point2 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.Contains(points, target) ? shape : null);
        }
Beispiel #4
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);

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

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