private async void selectOneImage() { Images.Shuffle(); LImagesMots tmpSeclected = Images[0]; imageSelected = new LImageMotReadMatching(tmpSeclected.ImageSource, tmpSeclected.ImageText, true); wordCandidates.Clear(); wordCandidates.Add(imageSelected); for (int i = 1; i < localSetting_m.LeonceReconnaitWordCount; i++) { tmpSeclected = Images[i]; LImageMotReadMatching falseWordSelected = new LImageMotReadMatching(tmpSeclected.ImageSource, tmpSeclected.ImageText, false); wordCandidates.Add(falseWordSelected); } wordCandidates.Shuffle(); await Task.Delay(1000); await letterPlayer_m.speachAsync(imageSelected.word); }
private async void ButtonValid_Click(object sender, RoutedEventArgs e) { string inputString = myInputTextBox.Text; LImagesMots selectedImage = Images[flipView.SelectedIndex]; string[] lines = inputString.Split('\r'); string voiceString = inputString; double ratingResult = 0.0; foreach (var L in lines) { var l = new NormalizedLevenshtein(); double distance = l.Similarity(L, selectedImage.ImageText); // distance est entre 0 [PERFECT] et 1 if (distance > ratingResult) { ratingResult = distance; } log.Trace("Compare " + L + ", " + selectedImage.ImageText); log.Trace("results =" + l.Similarity(L, selectedImage.ImageText)); if (L == selectedImage.ImageText) { voiceString = L; } } // transformation du result 0..1 en 0..5 (5 est 5 etoile) log.Trace("ratingResults =" + ratingResult + " ---"); log.Trace("5*ratingResult =" + 5 * (ratingResult) + " ---"); ratingResult = 5 * ratingResult; int ratingResultInt = (int)ratingResult; log.Trace(" (int)ratingResult =" + ratingResult + " ---"); string bravoText = ""; switch (ratingResultInt) { case 5: bravoText = " BRAVO !!, "; break; case 4: bravoText = " PRESQUE !!"; break; case 2: case 3: bravoText = " ESSAYE ENCORE !!"; break; case 0: case 1: bravoText = " RECOMMENCE !!"; myInputTextBox.Text = ""; break; default: bravoText = " DEFAULT !!"; break; } Flyout tmpFlyout = Resources["MyFlyout"] as Flyout; MyRating.Value = ratingResultInt; MyResultText.Text = bravoText; voiceString = string.Concat(bravoText + ",", voiceString); myInputTextBox.Focus(FocusState.Programmatic); myInputTextBox.IsTextScaleFactorEnabled = false; await letterPlayer_m.speachAsync(voiceString); tmpFlyout.ShowAt(myInputTextBox); // rend le focus a la text box myInputTextBox.Focus(FocusState.Programmatic); }