private void setDefaultConverterToolStripMenuItem_Click(object sender, EventArgs e) { EncConverters aECs = OfficeApp.GetEncConverters; if (aECs != null) { IEncConverter aIEC = aECs.AutoSelectWithTitle(ConvType.Unknown, "Select Default Converter"); if (aIEC != null) { DirectableEncConverter aEC = new DirectableEncConverter(aIEC.Name, aIEC.DirectionForward, aIEC.NormalizeOutput); foreach (DataGridViewRow aRow in dataGridViewFontsConverters.Rows) { string strFontName = (string)aRow.Cells[nColumnFontNames].Value; if (!m_mapEncConverters.ContainsKey(strFontName)) { m_mapEncConverters.Add(strFontName, aEC); // add it DataGridViewCell cellConverter = aRow.Cells[nColumnConverterNames]; cellConverter.Value = aEC.Name; cellConverter.ToolTipText = aEC.ToString(); } } // clear the last one selected so that a right-click can be used to cancel the selection m_aECLast = null; } } }
private void setDefaultConverterToolStripMenuItem_Click(object sender, EventArgs e) { m_aEcDefault = null; EncConverters aECs = GetEncConverters; if (aECs != null) { IEncConverter aIEC = aECs.AutoSelectWithTitle(ConvType.Unknown, "Choose Default Converter"); if (aIEC != null) { m_aEcDefault = new DirectableEncConverter(aIEC); foreach (DataGridViewRow aRow in dataGridViewConverterMapping.Rows) { string strXmlPath = (string)aRow.Cells[cnXmlPathsColumn].Value; if (!IsConverterDefined(strXmlPath)) { DataGridViewCell cellConverter = aRow.Cells[cnEncConverterColumn]; cellConverter.Value = m_aEcDefault.Name; cellConverter.ToolTipText = m_aEcDefault.ToString(); string strInput = (string)aRow.Cells[cnExampleDataColumn].Value; aRow.Cells[cnExampleOutputColumn].Value = CallSafeConvert(m_aEcDefault, strInput); DefineConverter(strXmlPath, m_aEcDefault); } } m_aECLast = null; } } }
protected void InitConverterDetails(string strXmlPath, out string strConverterName, out string strTooltip) { strConverterName = (m_mapEncConverters.Count > 0) ? cstrDots : cstrClickMsg; strTooltip = null; if (IsConverterDefined(strXmlPath)) { DirectableEncConverter aEC = (DirectableEncConverter)m_mapEncConverters[strXmlPath]; strConverterName = aEC.Name; strTooltip = aEC.ToString(); } }
protected void InitConverterDetails(string strFontName, out string strConverterName, out string strTooltip, out string strFontNameOutput) { strConverterName = (UsingSameEncConverter) ? m_strApplyEC : cstrClickMsg; strTooltip = strConverterName; strFontNameOutput = (UsingSameEncConverter) ? strFontName : cstrFontClickMsg; // if there is no converted selected, then see if the repository has a suggestion if (!m_mapEncConverters.ContainsKey(strFontName) && (strConverterName == cstrClickMsg)) { EncConverters aECs = OfficeApp.GetEncConverters; if (aECs != null) { string strMappingName = aECs.GetMappingNameFromFont(strFontName); if (!String.IsNullOrEmpty(strMappingName)) { strConverterName = strMappingName; IEncConverter aIEC = aECs[strConverterName]; if (aIEC != null) { DirectableEncConverter aEC = new DirectableEncConverter(aIEC); m_mapEncConverters.Add(strFontName, aEC); } } } } if (m_mapEncConverters.ContainsKey(strFontName)) { DirectableEncConverter aEC = (DirectableEncConverter)m_mapEncConverters[strFontName]; strConverterName = aEC.Name; strTooltip = aEC.ToString(); if (aEC.TargetFont != null) { strFontNameOutput = aEC.TargetFont.Name; } else // otherwise, the repository might be able to tell us what font to use { EncConverters aECs = OfficeApp.GetEncConverters; if (aECs != null) { string[] astrFontnames = aECs.GetFontMapping(aEC.Name, strFontName); if (astrFontnames.Length > 0) { strFontNameOutput = astrFontnames[0]; aEC.TargetFont = new Font(strFontNameOutput, 14); } } } } }
protected void UpdateConverterCellValue(DataGridViewCell theCell, DirectableEncConverter aEC) { if (aEC == null) { theCell.Value = (m_mapEncConverters.Count > 0) ? cstrDots : cstrClickMsg; theCell.ToolTipText = null; } else { string strName = aEC.Name; if (strName.Length > cnMaxConverterName) { strName = strName.Substring(0, cnMaxConverterName); } theCell.Value = strName; theCell.ToolTipText = aEC.ToString(); } }