private void tabControl_Selected(object sender, TabControlEventArgs e) { Util.DebugWriteLine(this, "BEGIN"); if (e.TabPage == tabPageSetup) { buttonSaveInRepository.Visible = SetupTabSelected_MakeSaveInRepositoryVisible; SetupTabSelected(e); } // if it was modified, then we need to apply it or switch back to // the setup tab (unless it was the about tab that was selected) else if (e.TabPage != tabPageAbout) { // Test or Advanced tab. // If the configuration was modified, then make the user go back if (IsModified && !OnApply()) { MessageBox.Show("You must configure the conversion process on the Setup tab first", EncConverters.cstrCaption); tabControl.SelectTab(tabPageSetup); } else { System.Diagnostics.Debug.Assert(!IsModified); IEncConverter aEC = InitializeEncConverter; if (aEC != null) { if (e.TabPage == tabPageTestArea) { string strLhsFont, strRhsFont; if (GetFontMapping(aEC.Name, out strLhsFont, out strRhsFont)) { if (!String.IsNullOrEmpty(strLhsFont)) { ecTextBoxInput.Font = new Font(strLhsFont, 14); } if (!String.IsNullOrEmpty(strRhsFont)) { ecTextBoxOutput.Font = new Font(strRhsFont, 14); } } TestTabInputChanged(); // doesn't happen automatically the first time for some reason checkBoxTestReverse.Visible = !EncConverters.IsUnidirectional(aEC.ConversionType); } else // if (e.TabPage == tabPageAdvanced) { m_bAdvancedTabVisited = true; dataGridViewProperties.Visible = labelProperties.Visible = false; // pessimistic if (String.IsNullOrEmpty(FriendlyName)) { textBoxFriendlyName.Text = DefaultFriendlyName; IsModified = true; } else { textBoxFriendlyName.Text = FriendlyName; // we shouldn't get here with a temporary converter... System.Diagnostics.Debug.Assert(FriendlyName.IndexOf(EncConverters.cstrTempConverterPrefix) != 0); // load the grid with any existing converter property keys and their values // (but only do this if this is already in the collection object (or there // won't be any properties by definition) and if there *are* any properties // (because many sub-classes don't have any properties) EncConverters aECs = (EncConverters)m_aECs; ECAttributes attrs = null; if (aECs.ContainsKey(FriendlyName) && ((attrs = m_aECs.Attributes(FriendlyName, AttributeType.Converter)) != null) && (attrs.Count > 0)) { dataGridViewProperties.Visible = labelProperties.Visible = true; dataGridViewProperties.Rows.Clear(); foreach (DictionaryEntry kvp in attrs) { object[] aos = new object[] { kvp.Key, kvp.Value }; dataGridViewProperties.Rows.Add(aos); } } } // certain sub-classes don't allow the friendly name to be modified (e.g. spellfixer) textBoxFriendlyName.ReadOnly = ShouldFriendlyNameBeReadOnly; // load the combo boxes with the existing Encoding names comboBoxEncodingNamesLhs.Items.Clear(); comboBoxEncodingNamesRhs.Items.Clear(); foreach (string strEncodingName in m_aECs.Encodings) { comboBoxEncodingNamesLhs.Items.Add(strEncodingName); comboBoxEncodingNamesRhs.Items.Add(strEncodingName); } // if the left-hand side Encoding name is already configured, then select that if (!String.IsNullOrEmpty(LhsEncodingId)) { if (!comboBoxEncodingNamesLhs.Items.Contains(LhsEncodingId)) { comboBoxEncodingNamesLhs.Items.Add(LhsEncodingId); } comboBoxEncodingNamesLhs.SelectedItem = LhsEncodingId; } // if the right-hand side Encoding name is already configured, then select that if (!String.IsNullOrEmpty(RhsEncodingId)) { if (!comboBoxEncodingNamesRhs.Items.Contains(RhsEncodingId)) { comboBoxEncodingNamesRhs.Items.Add(RhsEncodingId); } comboBoxEncodingNamesRhs.SelectedItem = RhsEncodingId; } // initialize the check boxes for the Process Types checkBoxUnicodeEncodingConversion.Checked = ((ProcessType & (int)ProcessTypeFlags.UnicodeEncodingConversion) != 0); checkBoxTransliteration.Checked = ((ProcessType & (int)ProcessTypeFlags.Transliteration) != 0); checkBoxICUTransliteration.Checked = ((ProcessType & (int)ProcessTypeFlags.ICUTransliteration) != 0); checkBoxICUConverter.Checked = ((ProcessType & (int)ProcessTypeFlags.ICUConverter) != 0); checkBoxCodePage.Checked = ((ProcessType & (int)ProcessTypeFlags.CodePageConversion) != 0); checkBoxNonUnicodeEncodingConversion.Checked = ((ProcessType & (int)ProcessTypeFlags.NonUnicodeEncodingConversion) != 0); checkBoxSpellingFixerProject.Checked = ((ProcessType & (int)ProcessTypeFlags.SpellingFixerProject) != 0); checkBoxICURegularExpression.Checked = ((ProcessType & (int)ProcessTypeFlags.ICURegularExpression) != 0); checkBoxPythonScript.Checked = ((ProcessType & (int)ProcessTypeFlags.PythonScript) != 0); checkBoxPerlExpression.Checked = ((ProcessType & (int)ProcessTypeFlags.PerlExpression) != 0); checkBoxSpare1.Checked = ((ProcessType & (int)ProcessTypeFlags.UserDefinedSpare1) != 0); checkBoxSpare2.Checked = ((ProcessType & (int)ProcessTypeFlags.UserDefinedSpare2) != 0); } } } } }