public SpellingPreferencesPanel(SpellingPreferences preferences)
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            _labelDictionaryLanguage.Text = Res.Get(StringId.DictionaryLanguageLabel);
            _groupBoxGeneralOptions.Text = Res.Get(StringId.SpellingPrefOptions);
            _checkBoxRealTimeChecking.Text = Res.Get(StringId.SpellingPrefReal);
            _checkBoxCheckBeforePublish.Text = Res.Get(StringId.SpellingPrefPub);
            _checkBoxAutoCorrect.Text = Res.Get(StringId.SpellingPrefAuto);
            PanelName = Res.Get(StringId.SpellingPrefName);

            // set panel bitmap
            PanelBitmap = _spellingPanelBitmap;

            // initialize preferences
            spellingPreferences = preferences;
            spellingPreferences.PreferencesModified += new EventHandler(spellingPreferences_PreferencesModified);

            // core options
            _checkBoxCheckBeforePublish.Checked = spellingPreferences.CheckSpellingBeforePublish;
            _checkBoxRealTimeChecking.Checked = spellingPreferences.RealTimeSpellChecking;
            _checkBoxAutoCorrect.Checked = spellingPreferences.EnableAutoCorrect;

            // initialize language combo
            _comboBoxLanguage.BeginUpdate();
            _comboBoxLanguage.Items.Clear();
            string currentLanguage = spellingPreferences.Language;

            SpellingLanguageEntry[] languages = SpellingSettings.GetInstalledLanguages();
            Array.Sort(languages, new SentryLanguageEntryComparer(CultureInfo.CurrentUICulture));

            _comboBoxLanguage.Items.Add(new SpellingLanguageEntry(string.Empty, Res.Get(StringId.DictionaryLanguageNone)));

            foreach (SpellingLanguageEntry language in languages)
            {
                int index = _comboBoxLanguage.Items.Add(language);
                if (language.BCP47Code == currentLanguage)
                    _comboBoxLanguage.SelectedIndex = index;
            }
            // defend against invalid value
            if (_comboBoxLanguage.SelectedIndex == -1)
            {
                if (!string.IsNullOrEmpty(currentLanguage))
                {
                    Debug.Fail("Language in registry not supported!");
                }
                _comboBoxLanguage.SelectedIndex = 0; // "None"
            }
            _comboBoxLanguage.EndUpdate();

            ManageSpellingOptions();

            // hookup to changed events to update preferences
            _checkBoxCheckBeforePublish.CheckedChanged += new EventHandler(checkBoxCheckBeforePublish_CheckedChanged);
            _checkBoxRealTimeChecking.CheckedChanged += new EventHandler(checkBoxRealTimeChecking_CheckedChanged);
            _checkBoxAutoCorrect.CheckedChanged += new EventHandler(checkBoxAutoCorrect_CheckedChanged);

            _comboBoxLanguage.SelectedIndexChanged += new EventHandler(comboBoxLanguage_SelectedIndexChanged);
        }
示例#2
0
        public SpellingPreferencesPanel(SpellingPreferences preferences)
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            _labelDictionaryLanguage.Text    = Res.Get(StringId.DictionaryLanguageLabel);
            _groupBoxGeneralOptions.Text     = Res.Get(StringId.SpellingPrefOptions);
            _checkBoxRealTimeChecking.Text   = Res.Get(StringId.SpellingPrefReal);
            _checkBoxIgnoreNumbers.Text      = Res.Get(StringId.SpellingPrefNum);
            _checkBoxIgnoreUppercase.Text    = Res.Get(StringId.SpellingPrefUpper);
            _checkBoxCheckBeforePublish.Text = Res.Get(StringId.SpellingPrefPub);
            _checkBoxAutoCorrect.Text        = Res.Get(StringId.SpellingPrefAuto);
            PanelName = Res.Get(StringId.SpellingPrefName);

            // set panel bitmap
            PanelBitmap = _spellingPanelBitmap;

            // initialize preferences
            spellingPreferences = preferences;
            spellingPreferences.PreferencesModified += new EventHandler(spellingPreferences_PreferencesModified);

            // core options
            _checkBoxIgnoreUppercase.Checked    = spellingPreferences.IgnoreUppercase;
            _checkBoxIgnoreNumbers.Checked      = spellingPreferences.IgnoreWordsWithNumbers;
            _checkBoxCheckBeforePublish.Checked = spellingPreferences.CheckSpellingBeforePublish;
            _checkBoxRealTimeChecking.Checked   = spellingPreferences.RealTimeSpellChecking;
            _checkBoxAutoCorrect.Checked        = spellingPreferences.EnableAutoCorrect;

            // initialize language combo
            _comboBoxLanguage.BeginUpdate();
            _comboBoxLanguage.Items.Clear();
            SpellingCheckerLanguage currentLanguage = spellingPreferences.Language;

            SpellingLanguageEntry[] languages = SpellingSettings.GetInstalledLanguages();
            Array.Sort(languages, new SentryLanguageEntryComparer(CultureInfo.CurrentUICulture));

            foreach (SpellingLanguageEntry language in languages)
            {
                int index = _comboBoxLanguage.Items.Add(language);
                if (language.Language == currentLanguage)
                {
                    _comboBoxLanguage.SelectedIndex = index;
                }
            }
            // defend against invalid value
            if (_comboBoxLanguage.SelectedIndex == -1)
            {
                Debug.Fail("Language in registry not supported!");
            }
            _comboBoxLanguage.EndUpdate();

            ManageSpellingOptions();

            // hookup to changed events to update preferences
            _checkBoxIgnoreUppercase.CheckedChanged    += new EventHandler(checkBoxIgnoreUppercase_CheckedChanged);
            _checkBoxIgnoreNumbers.CheckedChanged      += new EventHandler(checkBoxIgnoreNumbers_CheckedChanged);
            _checkBoxCheckBeforePublish.CheckedChanged += new EventHandler(checkBoxCheckBeforePublish_CheckedChanged);
            _checkBoxRealTimeChecking.CheckedChanged   += new EventHandler(checkBoxRealTimeChecking_CheckedChanged);
            _checkBoxAutoCorrect.CheckedChanged        += new EventHandler(checkBoxAutoCorrect_CheckedChanged);

            _comboBoxLanguage.SelectedIndexChanged += new EventHandler(comboBoxLanguage_SelectedIndexChanged);
        }