private void touch_up(float x, float y) { var gesture = WritePadAPI.detectGesture(WritePadAPI.GEST_RETURN | WritePadAPI.GEST_CUT | WritePadAPI.GEST_BACK, currentStroke); AddPixelsXY(x, y, true); AddCurrentPoint(mX, mY); mCurrStroke = -1; mMoved = false; if (!mMoved) { mX++; } mPath.LineTo(mX, mY); mPathList.AddLast(mPath); mPath = new Path(); Invalidate(); switch (gesture) { case WritePadAPI.GEST_RETURN: if (OnReturnGesture != null) { mPathList.RemoveLast(); WritePadAPI.recoDeleteLastStroke(); Invalidate(); OnReturnGesture(); return; } break; case WritePadAPI.GEST_CUT: if (OnCutGesture != null) { mPathList.RemoveLast(); WritePadAPI.recoDeleteLastStroke(); Invalidate(); OnCutGesture(); return; } break; case WritePadAPI.GEST_BACK_LONG: mPathList.RemoveLast(); WritePadAPI.recoDeleteLastStroke(); if (WritePadAPI.recoStrokeCount() > 0) { mPathList.RemoveLast(); WritePadAPI.recoDeleteLastStroke(); } Invalidate(); return; } }
public string Recognize(bool bLearn) { var res = ""; var resultStringList = new List <string>(); var wordList = new List <List <WordAlternative> >(); var count = WritePadAPI.recoStrokeCount(); string defaultResult = WritePadAPI.recoInkData(count, false, false, false, false); // can also use the default result resultStringList.Add(defaultResult); var wordCount = WritePadAPI.recoResultColumnCount(); for (var i = 0; i < wordCount; i++) { var wordAlternativesList = new List <WordAlternative>(); var altCount = WritePadAPI.recoResultRowCount(i); for (var j = 0; j < altCount; j++) { var word = WritePadAPI.recoResultWord(i, j); if (word == "<--->") { word = "*Error*"; } if (string.IsNullOrEmpty(word)) { continue; } var weight = WritePadAPI.recoResultWeight(i, j); var flags = WritePadAPI.recoGetFlags(); if (j == 0 && bLearn && weight > 75 && 0 != (flags & WritePadAPI.FLAG_ANALYZER)) { WritePadAPI.recoLearnWord(word, weight); } if (wordAlternativesList.All(x => x.Word != word)) { wordAlternativesList.Add(new WordAlternative { Word = word, Weight = weight }); } while (resultStringList.Count < j + 2) { resultStringList.Add(""); } if (resultStringList[j + 1].Length > 0) { resultStringList[j + 1] += "\t\t"; } resultStringList[j + 1] += word + "\t[" + weight + "%]"; } wordList.Add(wordAlternativesList); } foreach (var line in resultStringList) { if (string.IsNullOrEmpty(line)) { continue; } if (res.Length > 0) { res += Environment.NewLine; } res += line; } return(res); }