/// <summary> /// Moves up or down the engine. /// </summary> /// <param name="engineIndex">Index of the engine.</param> /// <param name="moveUp"> /// <b>true</b> - the specified engine must be moved up; /// <b>false</b> - the specified engine must be moved down. /// </param> private void MoveEngine(int engineIndex, bool moveUp) { // get the engine ISpellCheckEngine engine = _spellCheckManager.Engines[engineIndex]; // create engine list for reordering List <ISpellCheckEngine> engines = new List <ISpellCheckEngine>( _spellCheckManager.Engines); // get the engine name string engineName = enginesCheckedListBox.GetItemText( enginesCheckedListBox.Items[engineIndex]); // remove engine engines.RemoveAt(engineIndex); // new index of removed engne int newEngineIndex; // if engine must be moved up if (moveUp) { newEngineIndex = engineIndex - 1; } // if engine must be moved down else { newEngineIndex = engineIndex + 1; } // insert the engine engines.Insert(newEngineIndex, engine); // update engines in spell check manager _spellCheckManager.Engines = engines; // begin update of the list box with engines enginesCheckedListBox.BeginUpdate(); // remove old item enginesCheckedListBox.Items.RemoveAt(engineIndex); // insert new item enginesCheckedListBox.Items.Insert( newEngineIndex, engineName); // update check state of item enginesCheckedListBox.SetItemChecked( newEngineIndex, engine.IsEnabled); // set the selected item enginesCheckedListBox.SelectedIndex = newEngineIndex; // end update of the list box with engines enginesCheckedListBox.EndUpdate(); }
/// <summary> /// Enable/disable the selected engine. /// </summary> private void enginesCheckedListBox_ItemCheck(object sender, ItemCheckEventArgs e) { bool isEnabled = false; if (e.NewValue == CheckState.Checked) { isEnabled = true; } ISpellCheckEngine engine = _spellCheckManager.Engines[e.Index]; if (isEnabled) { _spellCheckManager.EnableEngine(engine); } else { _spellCheckManager.DisableEngine(engine); } }