public void End(float x, float y) { inGesture = false; //Adjust Coor if (Parameter.mode == Parameter.Mode.FixStart || (Lexicon.useRadialMenu && chooseCandidate)) { x = x - beginPoint.x + StartPointRelative.x; y = y - beginPoint.y + StartPointRelative.y; } if (Parameter.mode == Parameter.Mode.FixStart) { cursor.GetComponent <TrailRendererHelper>().Reset(); cursor.transform.localPosition = new Vector3(StartPointRelative.x * Parameter.keyboardWidth, StartPointRelative.y * Parameter.keyboardHeight, -0.2f); } SetAreaDisplay(x, y, false); if (!Lexicon.useRadialMenu && chooseCandidate) { int choose = CandicateListChoose(x, y); if (choose == 0 && listExpanded) { ExpandList(false); server.Send("Cancel", ""); return; } string word = lexicon.Accept(ref choose); if (Parameter.userStudy == Parameter.UserStudy.Study2) { server.Send("Accept", choose.ToString() + " " + word); } ExpandList(false, true); if (choose > 0) { chooseCandidate = false; return; } } if (Vector2.Distance(new Vector2(x, y), stroke[stroke.Count - 1]) > eps) { stroke.Add(new Vector2(x, y)); } if (Parameter.userStudy == Parameter.UserStudy.Study1 || Parameter.userStudy == Parameter.UserStudy.Study1_Train) { textManager.HighLight(+1); return; } if (chooseCandidate) { if (Lexicon.useRadialMenu) { int choose = RadialMenuChoose(x, y); if (choose == 5) { CancelRadialChoose(); } else if (choose >= 0) { string word = lexicon.Accept(ref choose); if (Parameter.userStudy == Parameter.UserStudy.Study2) { server.Send("Accept", choose.ToString() + " " + word); } chooseCandidate = false; lexicon.SetRadialMenuDisplay(false); } else { server.Send("NextCandidatePanel", ""); lexicon.NextCandidatePanel(); } return; } } if ((x <= -0.54f && length - (-0.5f - x) <= 1.0f) || x <= -0.74f) { if (Parameter.userStudy == Parameter.UserStudy.Study2) { server.Send("Delete", "LeftSwipe"); } lexicon.Delete(); chooseCandidate = false; return; } if ((x >= 0.54f && length - (x - 0.5f) <= 1.0f) || x >= 0.74f) { chooseCandidate = false; if (Parameter.userStudy == Parameter.UserStudy.Basic) { if (!chooseCandidate && textManager.InputNumberCorrect() && textManager.GetWords()[0] != "Thanks") { lexicon.ChangePhrase(); } } else if (Parameter.userStudy == Parameter.UserStudy.Study2) { if (!chooseCandidate && textManager.InputNumberCorrect()) { pcControl.FinishStudy2Phrase(); } } return; } if (Lexicon.isCut) { int l = 0, r = stroke.Count - 1; while (OutKeyboard(stroke[l]) && l < r) { ++l; } while (OutKeyboard(stroke[r]) && l < r) { --r; } if (l < r) { stroke.RemoveRange(r + 1, stroke.Count - r - 1); stroke.RemoveRange(0, l); } } for (int i = 0; i < stroke.Count; ++i) { stroke[i] = new Vector2(stroke[i].x * Parameter.keyboardWidth, stroke[i].y * Parameter.keyboardHeight); } Lexicon.Candidate[] candidates = lexicon.Recognize(stroke.ToArray()); chooseCandidate = true; if (Lexicon.useRadialMenu) { cursor.transform.localPosition = new Vector3(StartPointRelative.x * Parameter.keyboardWidth, StartPointRelative.y * Parameter.keyboardHeight, -0.2f); cursor.GetComponent <TrailRendererHelper>().Reset(); lexicon.SetRadialMenuDisplay(true); } lexicon.SetCandidates(candidates); string msg = ""; for (int i = 0; i < candidates.Length; ++i) { if (i < candidates.Length - 1) { msg += candidates[i].word + ","; } else { msg += candidates[i].word; } } server.Send("Candidates", msg); }