Beispiel #1
0
        /// <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);
        }
Beispiel #2
0
        /// <summary>
        /// Erases all ink hit by the contour of an erasing stroke
        /// </summary>
        /// <param name="eraserShape">Shape of the eraser</param>
        /// <param name="eraserPath">a path making the spine of the erasing stroke </param>
        public void Erase(IEnumerable <Point> eraserPath, StylusShape eraserShape)
        {
            // Check the input parameters
            if (eraserShape == null)
            {
                throw new System.ArgumentNullException(SR.Get(SRID.SCEraseShape));
            }
            if (eraserPath == null)
            {
                throw new System.ArgumentNullException(SR.Get(SRID.SCErasePath));
            }
            if (IEnumerablePointHelper.GetCount(eraserPath) == 0)
            {
                return;
            }

            ErasingStroke erasingStroke = new ErasingStroke(eraserShape, eraserPath);

            for (int i = 0; i < this.Count; i++)
            {
                Stroke stroke = this[i];

                List <StrokeIntersection> intersections = new List <StrokeIntersection>();
                erasingStroke.EraseTest(StrokeNodeIterator.GetIterator(stroke, stroke.DrawingAttributes), intersections);
                StrokeCollection eraseResult = stroke.Erase(intersections.ToArray());

                UpdateStrokeCollection(stroke, eraseResult, ref i);
            }
        }
Beispiel #3
0
        /// <summary>
        /// C-tor
        /// </summary>
        /// <param name="strokes">strokes to hit-test for erasing</param>
        /// <param name="eraserShape">erasing shape</param>
        internal IncrementalStrokeHitTester(StrokeCollection strokes, StylusShape eraserShape)
            : base(strokes)
        {
            System.Diagnostics.Debug.Assert(eraserShape != null);

            // Create an ErasingStroke objects that implements the actual hit-testing
            _erasingStroke = new ErasingStroke(eraserShape);
        }
Beispiel #4
0
 internal TextContext(StrokeNodeIterator iterator, ErasingStroke erasingStroke,
                      List <StrokeIntersection> intersectionList, ErasingStrokeTest erasingStrokeTest)
 {
     Iterator          = iterator;
     ErasingStroke     = erasingStroke;
     IntersectionList  = intersectionList;
     ErasingStrokeTest = erasingStrokeTest;
 }
Beispiel #5
0
        /// <summary>Hit tests all segments within a contour generated with shape and path</summary>
        /// <param name="shape"></param>
        /// <param name="path"></param>
        /// <returns>StrokeIntersection array for these segments</returns>
        internal StrokeIntersection[] EraseTest(IEnumerable <Point> path, StylusShape shape)
        {
            System.Diagnostics.Debug.Assert(shape != null);
            System.Diagnostics.Debug.Assert(path != null);
            if (IEnumerablePointHelper.GetCount(path) == 0)
            {
                return(Array.Empty <StrokeIntersection>());
            }

            ErasingStroke             erasingStroke = new ErasingStroke(shape, path);
            List <StrokeIntersection> intersections = new List <StrokeIntersection>();

            erasingStroke.EraseTest(StrokeNodeIterator.GetIterator(this, this.DrawingAttributes), intersections);
            return(intersections.ToArray());
        }
Beispiel #6
0
        public TextContext GetErasingStroke(Point[] pointList)
        {
            var erasingStroke = new ErasingStroke(new RectangleStylusShape(10, 10));

            erasingStroke.MoveTo(pointList);

            var strokeNodeIterator = StrokeNodeIterator.GetIterator(new StylusPointCollection(pointList.Select(temp => new Point(temp.X, temp.Y))),
                                                                    new DrawingAttributes()
            {
                Width  = 5,
                Height = 5
            });

            return(new TextContext(strokeNodeIterator, erasingStroke, new List <StrokeIntersection>(4096), this));
        }
Beispiel #7
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);
        }