Пример #1
0
        /// <summary>
        /// Analyze a new stroke.
        /// </summary>
        /// <param name="stroke"></param>
        /// <returns>true if the stroke was recognized as belonging to a graph (and so should be excluded from InkAnalyzer)</returns>
        public bool newStroke(Stroke stroke)
        {
            if (strokes.ContainsKey(stroke))
            {
                // already have it!
                return(true);
            }
            foreach (Graph g in graphs)
            {
                if (g.containsStroke(stroke) && g.takeStroke(stroke))
                {
                    strokes.Add(stroke, g);
                    return(true);
                }
            }
            Stroke copy = stroke.Clone();

            analyzer.AddStroke(copy);

            analyzer.Analyze();

            StrokeCollection      sc       = new StrokeCollection(new Stroke[] { copy });
            ContextNodeCollection ctxNodes = analyzer.FindInkLeafNodes(sc);

            foreach (ContextNode ctxNode in ctxNodes)
            {
                if (ctxNode is InkDrawingNode && (ctxNode as InkDrawingNode).GetShapeName() == "Rectangle")
                {
                    Graph g = new XYGraph(this, stroke);
                    graphs.Add(g);
                    strokes.Add(stroke, g);
                    analyzer.RemoveStroke(copy);
                    return(true);
                }
            }
            analyzer.RemoveStroke(copy);
            return(false);
        }