private void m_btnAddEC_Click(object sender, EventArgs e) { try { string prevEC = m_cbEC.Text; using (AddCnvtrDlg dlg = new AddCnvtrDlg(m_helpTopicProvider, m_app, null, m_cbEC.Text, null, false)) { dlg.ShowDialog(this); // Reload the converter list in the combo to reflect the changes. LoadEncodingConverters(); // Either select the new one or select the old one if (dlg.DialogResult == DialogResult.OK && !String.IsNullOrEmpty(dlg.SelectedConverter)) m_cbEC.SelectedItem = dlg.SelectedConverter; else if (m_cbEC.Items.Count > 0) m_cbEC.SelectedItem = prevEC; // preserve selection if possible } } catch (Exception ex) { MessageBox.Show(this, String.Format(LexTextControls.ksErrorAccessingEncodingConverters, ex.Message)); return; } }
static void Main() { using (AddCnvtrDlg dlg = new AddCnvtrDlg(FwApp.App, null)) { dlg.ShowDialog(); } }
private void m_transduceSetupButton_Click(object sender, System.EventArgs e) { #pragma warning disable 219 object selItem = m_transduceProcessorCombo.SelectedItem; string selName = (selItem == null) ? "" : selItem.ToString(); #pragma warning restore 219 try { string prevEC = m_transduceProcessorCombo.Text; IApp app = (IApp)m_mediator.PropertyTable.GetValue("App"); using (AddCnvtrDlg dlg = new AddCnvtrDlg(m_mediator.HelpTopicProvider, app, null, m_transduceProcessorCombo.Text, null, true)) { dlg.ShowDialog(); // Reload the converter list in the combo to reflect the changes. this.InitConverterCombo(); // Either select the new one or select the old one if (dlg.DialogResult == DialogResult.OK && !String.IsNullOrEmpty(dlg.SelectedConverter)) m_transduceProcessorCombo.SelectedItem = dlg.SelectedConverter; else if (m_transduceProcessorCombo.Items.Count > 0) m_transduceProcessorCombo.SelectedItem = prevEC; // preserve selection if possible } } catch (Exception ex) { MessageBox.Show(String.Format(XMLViewsStrings.ksCannotAccessEC, ex.Message)); return; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Show New Converter Dialog. Copied to FwCoreDlgs.WritingSystemWizard. /// </summary> /// ------------------------------------------------------------------------------------ private void btnEncodingConverter_Click(object sender, EventArgs e) { ILgWritingSystemFactoryBuilder wsFactBuilder = LgWritingSystemFactoryBuilderClass.Create(); ILgWritingSystemFactory wsFact = wsFactBuilder.GetWritingSystemFactoryNew(m_strServer, m_strDatabase, null); Set<string> wsInUse = ConvertersInUse(wsFact); wsFact.Shutdown(); // Without this we leave a OleDbCommand pointer open. Marshal.ReleaseComObject(wsFactBuilder); wsFactBuilder = null; Marshal.ReleaseComObject(wsFact); wsFact = null; try { string prevEC = cbEncodingConverter.Text; using (AddCnvtrDlg dlg = new AddCnvtrDlg(m_helpTopicProvider, null, cbEncodingConverter.Text, null, false)) { dlg.ShowDialog(); // Reload the converter list in the combo to reflect the changes. LoadAvailableConverters(); // Either select the new one or select the old one if (dlg.DialogResult == DialogResult.OK && !String.IsNullOrEmpty(dlg.SelectedConverter)) cbEncodingConverter.SelectedItem = dlg.SelectedConverter; else if (cbEncodingConverter.Items.Count > 0) cbEncodingConverter.SelectedItem = prevEC; // preserve selection if possible } } catch (Exception ex) { System.Text.StringBuilder sb = new System.Text.StringBuilder(ex.Message); sb.Append(System.Environment.NewLine); sb.Append(FwCoreDlgs.kstidErrorAccessingEncConverters); MessageBox.Show(this, sb.ToString(), ResourceHelper.GetResourceString("kstidCannotModifyWS")); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Show New Converter Dialog. Copied from FwCoreDlgs.WritingSystemPropertiesDialog. /// </summary> /// ------------------------------------------------------------------------------------ private void btnEncodingConverterNew_Click(object sender, System.EventArgs e) { EncConverters converters = new EncConverters(); if (converters == null) { MessageBox.Show(this, FwCoreDlgs.kstidErrorAccessingEncConverters, ResourceHelper.GetResourceString("kstidCannotModifyWS")); return; } Debug.Assert(converters != null); // Make a set of the writing systems currently in use. // As of 12/2/06, the only real user of wsInUse // Only cared about the legMapping, and treated // wsInUse as a Set. // Dictionary<string, string> wsInUse = new Dictionary<string, string>(); Set<string> wsInUse = new Set<string>(); IWritingSystem ws; int wsUser = m_wsf.UserWs; int cws = m_wsf.NumberOfWs; using (ArrayPtr ptr = MarshalEx.ArrayToNative(cws, typeof(int))) { m_wsf.GetWritingSystems(ptr, cws); int[] vws = (int[])MarshalEx.NativeToArray(ptr, cws, typeof(int)); for (int iws = 0; iws < cws; iws++) { if (vws[iws] == 0) continue; ws = m_wsf.get_EngineOrNull(vws[iws]); if (ws == null) continue; string legMapping = ws.LegacyMapping; if (legMapping == null) continue; wsInUse.Add(legMapping); } } try { string prevEC = cbEncodingConverter.Text; using (AddCnvtrDlg dlg = new AddCnvtrDlg(m_helpTopicProvider, null, cbEncodingConverter.Text, null, false)) { dlg.ShowDialog(); // Regenerate the encoding converters list and reload it in the combobox // to reflect any changes from the dialog. LoadAvailableConverters(); // Either select the new one or select the old one if (dlg.DialogResult == DialogResult.OK && !String.IsNullOrEmpty(dlg.SelectedConverter)) cbEncodingConverter.SelectedItem = dlg.SelectedConverter; else if (cbEncodingConverter.Items.Count > 0) cbEncodingConverter.SelectedItem = prevEC; // preserve selection if possible } } catch (Exception ex) { System.Text.StringBuilder sb = new System.Text.StringBuilder(ex.Message); sb.Append(System.Environment.NewLine); sb.Append(FwCoreDlgs.kstidErrorAccessingEncConverters); MessageBox.Show(this, sb.ToString(), ResourceHelper.GetResourceString("kstidCannotModifyWS")); } }
private void btnEncodingConverter_Click(object sender, EventArgs e) { try { string prevEC = cbEncodingConverter.Text; using (var dlg = new AddCnvtrDlg(m_helpTopicProvider, m_app, null, cbEncodingConverter.Text, null, false)) { dlg.ShowDialog(); // Reload the converter list in the combo to reflect the changes. LoadAvailableConverters(); // Either select the new one or select the old one if (dlg.DialogResult == DialogResult.OK && !String.IsNullOrEmpty(dlg.SelectedConverter)) cbEncodingConverter.SelectedItem = dlg.SelectedConverter; else if (cbEncodingConverter.Items.Count > 0) cbEncodingConverter.SelectedItem = prevEC; // preserve selection if possible } } catch (Exception ex) { var sb = new StringBuilder(ex.Message); sb.Append(Environment.NewLine); sb.Append(FwCoreDlgs.kstidErrorAccessingEncConverters); MessageBox.Show(this, sb.ToString(), ResourceHelper.GetResourceString("kstidCannotModifyWS")); } }