示例#1
0
        protected override void buttonSpellcheck_Click(object sender, RoutedEventArgs e)
        {
            string localeId = null;

            if (LookupISO_3_1_Codes.ContainsKey(curLangCode))
            {
                localeId = LookupISO_3_1_Codes[curLangCode];
            }
            else if (LookupISO_3_1_Codes.ContainsKey(curLangCode.Substring(0, 3)))
            {
                localeId = LookupISO_3_1_Codes[curLangCode.Substring(0, 3)];
            }

            if (localeId == null)
            {
                MessageBox.Show("Need to add an entry in Data/ISO639-1.xml file.", Gui.strProgName, MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            speller = new SpellCheckHelper(this.textBox1, localeId);

            if (this.buttonSpellcheck.IsChecked.Value)
            {
                try
                {
                    speller.EnableSpellCheck();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, Gui.strProgName, MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else
            {
                speller.DisableSpellCheck();
            }
        }