public void AddStroke(WrittenStroke stroke) { // TO-DO: enforce substroke count limit // Otherwise BuildCharacterDescriptor will overindex // CharacterDescriptor.MAX_CHARACTER_STROKE_COUNT // CharacterDescriptor.MAX_CHARACTER_SUB_STROKE_COUNT strokeList.Add(stroke); }
/// <summary> /// Start recognizing a character in a BG thread after strokes have changed. /// </summary> private void startNewCharRecog(IEnumerable<WritingPad.Stroke> strokes) { // If there are other matchers running, stop them now lock (runningMatchers) { foreach (StrokesMatcher sm in runningMatchers) sm.Stop(); } // Convert stroke data to HanziLookup's format WrittenCharacter wc = new WrittenCharacter(); foreach (WritingPad.Stroke stroke in strokes) { WrittenStroke ws = new WrittenStroke(); foreach (PointF p in stroke.Points) { WrittenPoint wp = new WrittenPoint((int)(p.X), (int)(p.Y)); ws.AddPoint(wp, ref wc.LeftX, ref wc.RightX, ref wc.TopY, ref wc.BottomY); } wc.AddStroke(ws); } if (wc.StrokeList.Count == 0) { // Don't bother doing anything if nothing has been input yet (number of strokes == 0). ctrlCharPicker.SetItems(null); return; } ThreadPool.QueueUserWorkItem(recognize, wc); }