Ejemplo n.º 1
0
        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 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);
        }