private void EditUserWord() { var item = MainPage.Current.SelectedDictionaryItem; var settingsModel = (EditDictionaryListFlyout.Current.DataContext as HandwritingSettingsViewModel). SettingsModel; var list = settingsModel.DictionaryList; var position = 0; foreach (var listItem in list) { if (listItem.Equals(item)) { list.Remove(listItem); list.Insert(position, DictionaryWord.Text); break; } position += 1; } WritePadAPI.HWR_NewUserDict(WritePadAPI.getRecoHandle()); foreach (var listItem in list) { WritePadAPI.addWordToUserDictionary(listItem); } WritePadAPI.saveRecognizerDataOfType(WritePadAPI.USERDATA_DICTIONARY); }
private void DeleteButton_OnClick(object sender, RoutedEventArgs e) { var item = MainPage.Current.SelectedDictionaryItem; var settingsModel = (EditDictionaryListFlyout.Current.DataContext as HandwritingSettingsViewModel). SettingsModel; var list = settingsModel.DictionaryList; foreach (var listItem in list.Where(listItem => listItem.Equals(item))) { list.Remove(listItem); break; } WritePadAPI.HWR_NewUserDict(WritePadAPI.getRecoHandle()); foreach (var listItem in list) { WritePadAPI.addWordToUserDictionary(listItem); } WritePadAPI.saveRecognizerDataOfType(WritePadAPI.USERDATA_DICTIONARY); GoBack(); }
private void Options_Load(object sender, EventArgs e) { flags = WritePadAPI.HWR_GetRecognitionFlags(WritePadAPI.getRecoHandle()); SeparateLetters.Checked = WritePadAPI.isRecoFlagSet(flags, WritePadAPI.FLAG_SEPLET); DisableSegmentation.Checked = WritePadAPI.isRecoFlagSet(flags, WritePadAPI.FLAG_SINGLEWORDONLY); AutoLearner.Checked = WritePadAPI.isRecoFlagSet(flags, WritePadAPI.FLAG_ANALYZER); AutoCorrector.Checked = WritePadAPI.isRecoFlagSet(flags, WritePadAPI.FLAG_CORRECTOR); UserDictionary.Checked = WritePadAPI.isRecoFlagSet(flags, WritePadAPI.FLAG_USERDICT); DictionaryOnly.Checked = WritePadAPI.isRecoFlagSet(flags, WritePadAPI.FLAG_ONLYDICT); }
private void Options_OnLoaded(object sender, RoutedEventArgs e) { recoFlags = WritePadAPI.HWR_GetRecognitionFlags(WritePadAPI.getRecoHandle()); separate_letters.IsChecked = WritePadAPI.isRecoFlagSet(recoFlags, WritePadAPI.FLAG_SEPLET); single_word.IsChecked = WritePadAPI.isRecoFlagSet(recoFlags, WritePadAPI.FLAG_SINGLEWORDONLY); autocorrector.IsChecked = WritePadAPI.isRecoFlagSet(recoFlags, WritePadAPI.FLAG_CORRECTOR); autolearner.IsChecked = WritePadAPI.isRecoFlagSet(recoFlags, WritePadAPI.FLAG_ANALYZER); user_dictionary.IsChecked = WritePadAPI.isRecoFlagSet(recoFlags, WritePadAPI.FLAG_USERDICT); dict_words.IsChecked = WritePadAPI.isRecoFlagSet(recoFlags, WritePadAPI.FLAG_ONLYDICT); var langId = WritePadAPI.getLanguage(); UpdateSelectedLanguage(langId); }
private void SaveAutoCorrectionWordClick() { if (string.IsNullOrEmpty(AutoCorrectionFirstWord.Text) || string.IsNullOrEmpty(AutoCorrectionSecondWord.Text)) { return; } var firstWord = AutoCorrectionFirstWord.Text; var secondWord = AutoCorrectionSecondWord.Text; var isAlwaysReplace = AutoCorrectionAlwaysReplace.IsOn; var isIgnoreCase = AutoCorrectionIgnoreCase.IsOn; var isDisabled = AutoCorrectionDisabled.IsOn; var settingsModel = (EditAutoCorrectorListFlyout.Current.DataContext as HandwritingSettingsViewModel).SettingsModel; var list = settingsModel.AutoCorrectionList; list.Add(new HandwritingSettingsModel.CorrectionStructure { FirstWord = firstWord, SecondWord = secondWord, IsAlwaysReplace = isAlwaysReplace, IsDisabled = isDisabled, IsIgnoreCase = isIgnoreCase }); var flags = 0; if (isIgnoreCase) { flags |= WritePadAPI.FLAG_IGNORECASE; } if (isAlwaysReplace) { flags |= WritePadAPI.FLAG_ALWAYS_REPLACE; } if (isDisabled) { flags |= WritePadAPI.FLAG_DISABLED; } WritePadAPI.HWR_AddWordToWordList(WritePadAPI.getRecoHandle(), firstWord, secondWord, flags, 0); WritePadAPI.saveRecognizerDataOfType(WritePadAPI.USERDATA_AUTOCORRECTOR); settingsModel.OnPropertyChanged("AutoCorrectionList"); }
private async void OnDictionaryChanged() { StorageFolder userpath = null; WritePadAPI.resetRecognizer(); try { userpath = await ApplicationData.Current.LocalFolder.CreateFolderAsync("Dictionaries"); } catch (Exception) { } if (userpath == null) { userpath = await ApplicationData.Current.LocalFolder.GetFolderAsync("Dictionaries"); } var flags = WritePadAPI.HWR_GetRecognitionFlags(WritePadAPI.getRecoHandle()); WritePadAPI.initRecognizerForLanguage((int)WritePadAPI.language, userpath.Path, Package.Current.InstalledLocation.Path, flags); }
private void DeleteAutoCorrectionWordClick(object sender, RoutedEventArgs e) { var item = SelectedCorrectionStructure; var settingsModel = (EditAutoCorrectorListFlyout.Current.DataContext as HandwritingSettingsViewModel).SettingsModel; var list = settingsModel.AutoCorrectionList; WritePadAPI.HWR_EmptyWordList(WritePadAPI.getRecoHandle()); foreach (var listItem in list.Where(listItem => listItem.Equals(item))) { list.Remove(listItem); break; } foreach (var listItem in list) { var flags = 0; if (listItem.IsIgnoreCase) { flags |= WritePadAPI.FLAG_IGNORECASE; } if (listItem.IsAlwaysReplace) { flags |= WritePadAPI.FLAG_ALWAYS_REPLACE; } if (listItem.IsDisabled) { flags |= WritePadAPI.FLAG_DISABLED; } WritePadAPI.HWR_AddWordToWordList(WritePadAPI.getRecoHandle(), listItem.FirstWord, listItem.SecondWord, flags, 0); } WritePadAPI.saveRecognizerDataOfType(WritePadAPI.USERDATA_AUTOCORRECTOR); settingsModel.OnPropertyChanged("AutoCorrectionList"); AddAutoCorrectionWordLightDismissAnimatedPopup.IsOpen = false; }
private void AutoLearner_OnClick(object sender, RoutedEventArgs e) { flags = WritePadAPI.setRecoFlag(flags, AutoLearner.IsChecked ?? false, WritePadAPI.FLAG_ANALYZER); WritePadAPI.HWR_SetRecognitionFlags(WritePadAPI.getRecoHandle(), flags); }
private void DictionaryOnly_CheckedChanged(object sender, EventArgs e) { flags = WritePadAPI.setRecoFlag(flags, DictionaryOnly.Checked, WritePadAPI.FLAG_ONLYDICT); WritePadAPI.HWR_SetRecognitionFlags(WritePadAPI.getRecoHandle(), flags); }
private void AutoCorrector_CheckedChanged(object sender, EventArgs e) { flags = WritePadAPI.setRecoFlag(flags, AutoCorrector.Checked, WritePadAPI.FLAG_CORRECTOR); WritePadAPI.HWR_SetRecognitionFlags(WritePadAPI.getRecoHandle(), flags); }
private void AutoLearner_CheckedChanged(object sender, EventArgs e) { flags = WritePadAPI.setRecoFlag(flags, AutoLearner.Checked, WritePadAPI.FLAG_ANALYZER); WritePadAPI.HWR_SetRecognitionFlags(WritePadAPI.getRecoHandle(), flags); }
private void DisableSegmentation_CheckedChanged(object sender, EventArgs e) { flags = WritePadAPI.setRecoFlag(flags, DisableSegmentation.Checked, WritePadAPI.FLAG_SINGLEWORDONLY); WritePadAPI.HWR_SetRecognitionFlags(WritePadAPI.getRecoHandle(), flags); }
private void SeparateLetters_CheckedChanged(object sender, EventArgs e) { flags = WritePadAPI.setRecoFlag(flags, SeparateLetters.Checked, WritePadAPI.FLAG_SEPLET); WritePadAPI.HWR_SetRecognitionFlags(WritePadAPI.getRecoHandle(), flags); }
private void Single_word_OnClick(object sender, RoutedEventArgs e) { recoFlags = WritePadAPI.setRecoFlag(recoFlags, single_word.IsChecked ?? false, WritePadAPI.FLAG_SINGLEWORDONLY); WritePadAPI.HWR_SetRecognitionFlags(WritePadAPI.getRecoHandle(), recoFlags); }
/// <summary>n /// Recognizes a collection of Polyline objects into text. Words are recognized with alternatives, eash weighted with probability. /// </summary> /// <param name="strokes">Strokes to recognize</param> /// <returns></returns> public string RecognizeStrokes(List <List <Point> > strokes, bool bLearn) { WritePadAPI.HWR_Reset(WritePadAPI.getRecoHandle()); if (InkData != IntPtr.Zero) { WritePadAPI.INK_Erase(InkData); InkData = IntPtr.Zero; } InkData = WritePadAPI.INK_InitData(); foreach (var polyline in strokes) { WritePadAPI.AddStroke(InkData, polyline); } var res = ""; var resultStringList = new List <string>(); var wordList = new List <List <WordAlternative> >(); var defaultResultPtr = WritePadAPI.recognizeInkData(InkData, 0); var defaultResult = Marshal.PtrToStringUni(defaultResultPtr); resultStringList.Add(defaultResult); var wordCount = WritePadAPI.HWR_GetResultWordCount(WritePadAPI.getRecoHandle()); for (var i = 0; i < wordCount; i++) { var wordAlternativesList = new List <WordAlternative>(); var altCount = WritePadAPI.HWR_GetResultAlternativeCount(WritePadAPI.getRecoHandle(), i); for (var j = 0; j < altCount; j++) { var wordPtr = WritePadAPI.getResultWord(i, j); var word = Marshal.PtrToStringUni(wordPtr); if (word == "<--->") { word = "*Error*"; } if (string.IsNullOrEmpty(word)) { continue; } uint flags = WritePadAPI.HWR_GetRecognitionFlags(WritePadAPI.getRecoHandle()); var weight = WritePadAPI.HWR_GetResultWeight(WritePadAPI.getRecoHandle(), i, j); if (weight == 0) { continue; } if (j == 0 && bLearn && weight > 75 && 0 != (flags & WritePadAPI.FLAG_ANALYZER)) { // if learner is enabled, learn default word(s) when the Return gesture is used WritePadAPI.recoLearnWord(word, weight); } if (wordAlternativesList.All(x => x.Word != word)) { wordAlternativesList.Add(new WordAlternative { Word = word, Weight = weight } ); } while (resultStringList.Count < j + 2) { var emptyStr = ""; for (int k = 0; k < i; k++) { emptyStr += "\t"; } resultStringList.Add(emptyStr); } 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); }
private void User_dictionary_OnClick(object sender, RoutedEventArgs e) { recoFlags = WritePadAPI.setRecoFlag(recoFlags, user_dictionary.IsChecked ?? false, WritePadAPI.FLAG_USERDICT); WritePadAPI.HWR_SetRecognitionFlags(WritePadAPI.getRecoHandle(), recoFlags); }
private void DisableSegmentation_OnClick(object sender, RoutedEventArgs e) { flags = WritePadAPI.setRecoFlag(flags, DisableSegmentation.IsChecked ?? false, WritePadAPI.FLAG_SINGLEWORDONLY); WritePadAPI.HWR_SetRecognitionFlags(WritePadAPI.getRecoHandle(), flags); }
private void SeparateLetters_OnClick(object sender, RoutedEventArgs e) { flags = WritePadAPI.setRecoFlag(flags, SeparateLetters.IsChecked ?? false, WritePadAPI.FLAG_SEPLET); WritePadAPI.HWR_SetRecognitionFlags(WritePadAPI.getRecoHandle(), flags); }
private void Dict_words_OnClick(object sender, RoutedEventArgs e) { recoFlags = WritePadAPI.setRecoFlag(recoFlags, dict_words.IsChecked ?? false, WritePadAPI.FLAG_ONLYDICT); WritePadAPI.HWR_SetRecognitionFlags(WritePadAPI.getRecoHandle(), recoFlags); }
private void AutoCorrector_OnClick(object sender, RoutedEventArgs e) { flags = WritePadAPI.setRecoFlag(flags, AutoCorrector.IsChecked ?? false, WritePadAPI.FLAG_CORRECTOR); WritePadAPI.HWR_SetRecognitionFlags(WritePadAPI.getRecoHandle(), flags); }
private void DictionaryOnly_OnClick(object sender, RoutedEventArgs e) { flags = WritePadAPI.setRecoFlag(flags, DictionaryOnly.IsChecked ?? false, WritePadAPI.FLAG_ONLYDICT); WritePadAPI.HWR_SetRecognitionFlags(WritePadAPI.getRecoHandle(), flags); }
private void LanguagesCombo_SelectedIndexChanged(object sender, EventArgs e) { var selIndex = (sender as ComboBox).SelectedIndex; var language = WritePadAPI.LanguageType.en; switch (selIndex) { case 0: language = WritePadAPI.LanguageType.en; break; case 1: language = WritePadAPI.LanguageType.en_uk; break; case 2: language = WritePadAPI.LanguageType.de; break; case 3: language = WritePadAPI.LanguageType.fr; break; case 4: language = WritePadAPI.LanguageType.es; break; case 5: language = WritePadAPI.LanguageType.pt_PT; break; case 6: language = WritePadAPI.LanguageType.pt_BR; break; case 7: language = WritePadAPI.LanguageType.nl; break; case 8: language = WritePadAPI.LanguageType.it; break; case 9: language = WritePadAPI.LanguageType.fi; break; case 10: language = WritePadAPI.LanguageType.sv; break; case 11: language = WritePadAPI.LanguageType.nb; break; case 12: language = WritePadAPI.LanguageType.da; break; case 13: language = WritePadAPI.LanguageType.id; break; } var flags = WritePadAPI.HWR_GetRecognitionFlags(WritePadAPI.getRecoHandle()); ClearInk(); WritePadAPI.releaseRecognizer(); WritePadAPI.language = language; DictionaryChanged(); WritePadAPI.HWR_SetRecognitionFlags(WritePadAPI.getRecoHandle(), flags); }
private void EditAutoCorrectionWordClick() { if (string.IsNullOrEmpty(AutoCorrectionFirstWord.Text) || string.IsNullOrEmpty(AutoCorrectionSecondWord.Text)) { return; } var item = MainPage.Current.SelectedCorrectionStructure; var settingsModel = (EditAutoCorrectorListFlyout.Current.DataContext as HandwritingSettingsViewModel).SettingsModel; var list = settingsModel.AutoCorrectionList; WritePadAPI.HWR_EmptyWordList(WritePadAPI.getRecoHandle()); var position = 0; foreach (var listItem in list) { if (listItem.Equals(item)) { list.Remove(listItem); list.Insert(position, new HandwritingSettingsModel.CorrectionStructure { FirstWord = AutoCorrectionFirstWord.Text, SecondWord = AutoCorrectionSecondWord.Text, IsAlwaysReplace = AutoCorrectionAlwaysReplace.IsOn, IsDisabled = AutoCorrectionDisabled.IsOn, IsIgnoreCase = AutoCorrectionIgnoreCase.IsOn }); var flags = 0; if (AutoCorrectionIgnoreCase.IsOn) { flags |= WritePadAPI.FLAG_IGNORECASE; } if (AutoCorrectionAlwaysReplace.IsOn) { flags |= WritePadAPI.FLAG_ALWAYS_REPLACE; } if (AutoCorrectionDisabled.IsOn) { flags |= WritePadAPI.FLAG_DISABLED; } break; } position += 1; } foreach (var listItem in list) { var flags = 0; if (listItem.IsIgnoreCase) { flags |= WritePadAPI.FLAG_IGNORECASE; } if (listItem.IsAlwaysReplace) { flags |= WritePadAPI.FLAG_ALWAYS_REPLACE; } if (listItem.IsDisabled) { flags |= WritePadAPI.FLAG_DISABLED; } WritePadAPI.HWR_AddWordToWordList(WritePadAPI.getRecoHandle(), listItem.FirstWord, listItem.SecondWord, flags, 0); } WritePadAPI.saveRecognizerDataOfType(WritePadAPI.USERDATA_AUTOCORRECTOR); }