예제 #1
0
파일: Stroke2.cs 프로젝트: beda2280/wpf-1
        /// <summary>
        ///
        /// </summary>
        /// <param name="path"></param>
        /// <param name="stylusShape"></param>
        /// <returns></returns>
        public bool HitTest(IEnumerable <Point> path, StylusShape stylusShape)
        {
            // Check the input parameters
            if (path == null)
            {
                throw new System.ArgumentNullException("path");
            }
            if (stylusShape == null)
            {
                throw new System.ArgumentNullException("stylusShape");
            }

            if (IEnumerablePointHelper.GetCount(path) == 0)
            {
                return(false);
            }

            ErasingStroke erasingStroke = new ErasingStroke(stylusShape);

            erasingStroke.MoveTo(path);

            Rect erasingBounds = erasingStroke.Bounds;

            if (erasingBounds.IsEmpty)
            {
                return(false);
            }

            if (erasingBounds.IntersectsWith(this.GetBounds()))
            {
                return(erasingStroke.HitTest(StrokeNodeIterator.GetIterator(this, this.DrawingAttributes)));
            }

            return(false);
        }
예제 #2
0
        /// <summary>
        /// Issue: what's the return value
        /// </summary>
        /// <param name="path"></param>
        /// <param name="stylusShape"></param>
        /// <returns></returns>
        public StrokeCollection HitTest(IEnumerable <Point> path, StylusShape stylusShape)
        {
            // Check the input parameters
            if (stylusShape == null)
            {
                throw new System.ArgumentNullException("stylusShape");
            }
            if (path == null)
            {
                throw new System.ArgumentNullException("path");
            }
            if (IEnumerablePointHelper.GetCount(path) == 0)
            {
                return(new StrokeCollection());
            }

            // validate input
            ErasingStroke erasingStroke = new ErasingStroke(stylusShape, path);
            Rect          erasingBounds = erasingStroke.Bounds;

            if (erasingBounds.IsEmpty)
            {
                return(new StrokeCollection());
            }
            StrokeCollection hits = new StrokeCollection();

            foreach (Stroke stroke in this)
            {
                // samgeo - Presharp issue
                // Presharp gives a warning when get methods might deref a null.  It's complaining
                // here that 'stroke'' could be null, but StrokeCollection never allows nulls to be added
                // so this is not possible
#pragma warning disable 1634, 1691
#pragma warning suppress 6506
                if (erasingBounds.IntersectsWith(stroke.GetBounds()) &&
                    erasingStroke.HitTest(StrokeNodeIterator.GetIterator(stroke, stroke.DrawingAttributes)))
                {
                    hits.Add(stroke);
                }
#pragma warning restore 1634, 1691
            }

            return(hits);
        }