Ejemplo n.º 1
0
        /// <summary>
        /// Note: this should be expected to be significantly slower because it has to convert all the strokes into the same Ink before it can
        /// run the old FindIntersections().
        /// </summary>
        public static float[] OldFindIntersections(this Stroq s, StroqCollection ss)
        {
            Stroke     oldStroke = s.OldStroke();
            Ink        ink       = oldStroke.Ink;
            List <int> ids       = new List <int>();

            foreach (Stroq st in ss)
            {
                if (st != s)
                {
                    ids.Add(st.OldStroke(ink).Id);
                }
            }
            return(oldStroke.FindIntersections(ink.CreateStrokes(ids.ToArray())));
        }
Ejemplo n.º 2
0
        public String Recognizer(String strokesStr, int count)
        {
            List <List <int[]> > strokes = new List <List <int[]> >();
            var array = Regex.Split(strokesStr, ",eb,");

            foreach (var item in array)
            {
                var stroke = new List <int[]>();
                var array2 = item.Split(',');
                for (var i = 0; i < array2.Length; i = i + 2)
                {
                    int[] point = new int[2];
                    point[0] = int.Parse(array2[i]);
                    point[1] = int.Parse(array2[i + 1]);
                    stroke.Add(point);
                }
                strokes.Add(stroke);
            }

            RecognizerContext recognizerContext = new Recognizers().GetDefaultRecognizer().CreateRecognizerContext();
            Ink ink = new Ink();

            recognizerContext.Strokes = ink.CreateStrokes();
            foreach (List <int[]> stroke in strokes)
            {
                Point[] points = new Point[stroke.Count];
                for (int i = 0; i < stroke.Count; i++)
                {
                    points[i] = new Point(stroke[i][0], stroke[i][1]);
                }
                recognizerContext.Strokes.Add(ink.CreateStroke(points));
            }
            RecognitionStatus recognitionStatus = RecognitionStatus.NoError;
            RecognitionResult recognitionResult = recognizerContext.Recognize(out recognitionStatus);
            var text = "";

            if (recognitionStatus == RecognitionStatus.NoError)
            {
                RecognitionAlternates alts = recognitionResult.GetAlternatesFromSelection();
                for (int i = 0; i < alts.Count && i < count; i++)
                {
                    RecognitionAlternate alt = alts[i];
                    text += alt.ToString() + " ";
                }
            }
            return(text.Trim());
        }
Ejemplo n.º 3
0
        private void StroqChanged(Stroq s)
        {
            if (StrokesDeleting != null)
            {
                StrokesDeleting(Ink.CreateStrokes(new int[] { this[s].Id }));
            }
            _map2.Remove(_map[s].Id);
            _ink.DeleteStroke(_map[s]);
            Stroke st = s.OldStroke(Ink);

            _map[s] = st;
            _map2.Add(st.Id, s);
            if (StrokesAdded != null)
            {
                StrokesAdded(Ink.CreateStrokes(new int[] { st.Id }));
            }
        }
Ejemplo n.º 4
0
 public Strokes this[IEnumerable <Stroq> sc] {
     get { return(Ink.CreateStrokes(sc.Select((Stroq s) => this[s].Id).ToArray())); }
 }