public LinguaLinksImportDlg() { InitializeComponent(); // Copied from the LexImportWizard dlg Init (LexImportWizard.cs) // Ensure that we have the default encoding converter (to/from MS Windows Code Page // for Western European languages) SilEncConverters31.EncConverters encConv = new SilEncConverters31.EncConverters(); System.Collections.IDictionaryEnumerator de = encConv.GetEnumerator(); string sEncConvName = "Windows1252<>Unicode"; // REVIEW: SHOULD THIS NAME BE LOCALIZED? bool fMustCreateEncCnv = true; while (de.MoveNext()) { if ((string)de.Key != null && (string)de.Key == sEncConvName) { fMustCreateEncCnv = false; break; } } if (fMustCreateEncCnv) { try { encConv.AddConversionMap(sEncConvName, "1252", ECInterfaces.ConvType.Legacy_to_from_Unicode, "cp", "", "", ECInterfaces.ProcessTypeFlags.CodePageConversion); } catch (SilEncConverters31.ECException exception) { MessageBox.Show(exception.Message, ITextStrings.ksConvMapError, MessageBoxButtons.OK); } } }
public LoginSF() { // // Required for Windows Form Designer support // InitializeComponent(); this.checkedListBoxProjects.ContextMenu = this.contextMenu; EncConverters aECs = new EncConverters(); EncConverters myECs = aECs.FilterByProcessType(SpellingFixerEC.SFProcessType); // disable the list box (and the OK button) if there's nothing in it this.buttonOK.Enabled = this.checkedListBoxProjects.Visible = (myECs.Count > 0); string strPartialName; foreach(IEncConverter aEC in myECs.Values) if( (strPartialName = PartialName(aEC.Name)) != null ) checkedListBoxProjects.Items.Add(strPartialName); // decide which one to select int nIndex = checkedListBoxProjects.Items.Count - 1; try { RegistryKey keyLastSFProject = Registry.CurrentUser.OpenSubKey(cstrProjectMemoryKey); nIndex = checkedListBoxProjects.FindString((string)keyLastSFProject.GetValue(cstrProjectMostRecentProject)); } catch {} // TODO: also, add a new ctor to allow choosing the project programmatically. if( nIndex != -1 ) checkedListBoxProjects.SetItemChecked(nIndex,true); else // if there are no items in the list, then make the "Add New Project" the default button this.AcceptButton = this.buttonAddNewProject; // populate the font name combo box with all the fonts installed (but only if they // do Regular style). That is, on my system, I choose the "Aharoni" (some sort of // hebrew font) as a test and the creation of the "Font" object below failed, // because I was using the ctor that takes only the name and size, but that font // doesn't have a 'Regular' style (which is the default for that ctor). If I // wanted to add a query for the font 'style' to this dialog box as well (c.f. // Word's font dialog box), then this restriction could be removed, but... I'll // wait until someone complains. InstalledFontCollection installedFontCollection = new InstalledFontCollection(); FontFamily[] fontFamilies = installedFontCollection.Families; foreach(FontFamily fontFamily in fontFamilies) if( fontFamily.IsStyleAvailable(FontStyle.Regular) ) comboBoxFont.Items.Add(fontFamily.Name); // start with some defaults. this.listBoxFontSize.SelectedItem = "14"; this.textBoxCP.Text = "1252"; this.textBoxWordBoundaryDelimiter.Text = SpellingFixerEC.cstrDefaultWordBoundaryDelimiter; // start out pessimmistic DialogResult = DialogResult.Cancel; }
public SelectConverter(EncConverters aECs, ConvType eConversionTypeFilter, string strChooseConverterDialogTitle, byte[] abyPreviewData, string strFontName) { m_byPreviewData = abyPreviewData; InitSelectConverter(aECs, eConversionTypeFilter, strChooseConverterDialogTitle, strFontName); // hide the preview box until requested textBoxDataPreview.Hide(); tableLayoutPanel1.RowCount = 4; }
public SelectConverter(EncConverters aECs, ConvType eConversionTypeFilter, string strChooseConverterDialogTitle, string strPreviewData, string strFontName) { m_strPreviewData = strPreviewData; InitSelectConverter(aECs, eConversionTypeFilter, strChooseConverterDialogTitle, strFontName); if (String.IsNullOrEmpty(strPreviewData)) buttonPreview.Visible = false; // hide the preview box until requested textBoxDataPreview.Hide(); tableLayoutPanel1.RowCount = 4; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates and loads a set of dummy converters to test the /// <see cref="CnvtrPropertiesCtrl"/> class. /// </summary> /// ------------------------------------------------------------------------------------ public override void FixtureSetup() { base.FixtureSetup(); m_fileMaker = new TempSFFileMaker(); m_myDlg = new DummyAddCnvtrDlg(); m_myCtrl = new DummyCnvtrPropertiesCtrl(); SilEncConverters31.EncConverters encConverters = new SilEncConverters31.EncConverters(); string[] ccFileContents = { "'c' > 'C'" }; m_ccFileName = m_fileMaker.CreateFileNoID(ccFileContents, "cct"); encConverters.AddConversionMap("ZZZTestCC", m_ccFileName, ConvType.Legacy_to_Unicode, "SIL.cc", "", "", ProcessTypeFlags.UnicodeEncodingConversion); string[] mapFileContents = { "EncodingName 'ZZZText'", "DescriptiveName 'Silly test file'", "ByteDefault '?'", "UniDefault replacement_character", "0x80 <> euro_sign" }; m_mapFileName = m_fileMaker.CreateFileNoID(mapFileContents, "map"); encConverters.AddConversionMap("ZZZTestMap", m_mapFileName, ConvType.Legacy_to_from_Unicode, "SIL.map", "", "", ProcessTypeFlags.UnicodeEncodingConversion); // TODO: Should test a legitimate compiled TecKit file by embedding a zipped // up one in the resources for testing purposes. // This is a randomly chosen ICU converter. The test may break when we reduce the set of // ICU converters we ship. encConverters.AddConversionMap("ZZZTestICU", "ISO-8859-1", ConvType.Legacy_to_from_Unicode, "ICU.conv", "", "", ProcessTypeFlags.UnicodeEncodingConversion); // Add a 1-step compound converter, which won't be any of the types our dialog // recognizes for now. encConverters.AddCompoundConverterStep("ZZZTestCompound", "ZZZTestCC", true, NormalizeFlags.None); // Load all the mappings after the dummy mappings are added, so the Converter // Mapping File combo box won't contain obsolete versions of the mappings referring // to old temp files from a previous run of the tests. m_myCtrl.CnvtrPropertiesCtrl_Load(null, null); encConverters.Remove("Bogus"); }
public void MissingEncodingConverter() { CheckDisposed(); string encFileName = string.Empty; EncConverters converters = new EncConverters(); using (TempSFFileMaker fileMaker = new TempSFFileMaker()) { string fileName = fileMaker.CreateFile("ROM", new string[] {@"\mt 0123456789", @"\c 1", @"\v 1"}, Encoding.GetEncoding(28591), false); m_settings.AddFile(fileName, ImportDomain.Main, null, 0); // Set the vernacular WS to use the MissingEncoder encoder LgWritingSystem wsVern = new LgWritingSystem(Cache, Cache.LangProject.DefaultVernacularWritingSystem); wsVern.LegacyMapping = "MissingEncoder"; ISCTextEnum textEnum = GetTextEnum(ImportDomain.Main, new ScrReference(45, 0, 0, Paratext.ScrVers.English), new ScrReference(45, 1, 1, Paratext.ScrVers.English)); // read the \id segment ISCTextSegment textSeg = textEnum.Next(); Assert.IsNotNull(textSeg, "Unable to read segment"); try { // read the \mt segment which should cause an exception textSeg = textEnum.Next(); } catch (EncodingConverterException e) { Assert.IsTrue(e.Message.StartsWith(@"Encoding converter not found.")); return; } Assert.Fail("Expected exception did not occur"); } }
public FindWordProcessor(string strFindWhat, string strReplaceWith, bool bMatchCase, Font font) { if (m_aECs == null) m_aECs = new EncConverters(true); // for some reason, the text that goes to constructing the 'Find what' part of the CRegexMatcher is // expecting doubly-escaped text (e.g. "\\r" for CR), but the text that goes for the 'Replace with' // (i.e. the CRegex::ReplaceAll) is expecting singly-escaped text. Our text boxes, however, will always // return these as doubly-escaped. So for the 'Replace with' stuff, we need to turn certain doubly- // escaped codes into their single-escaped flavors). int nNumEscapeCodes = astrReplaceDoubleEscapeCodes.Length; for (int i = 0; i < nNumEscapeCodes; i++) strReplaceWith = strReplaceWith.Replace(astrReplaceDoubleEscapeCodes[i], astrReplaceEscapeCodes[i]); m_aECRegex = InitSearchFontConverter(strFindWhat, strReplaceWith, font, bMatchCase); AutoReplaceOnNextFind = false; // we'll take care of this as well // Normally, we search the text one paragraph at a time for the FindWhat string, but if the user // has multiple "\r"s in the search string, it means we're supposed to find stuff beyond paragraph // boundaries. So indicate how many paragraphs we should include in the Search based on the number // of "\r"s in the search string... string[] strTokens = strFindWhat.Split(new string[] { @"\r\n", @"\r" }, StringSplitOptions.None); NumOfParagraphsToSearch = strTokens.Length; IsAnyCRs = (NumOfParagraphsToSearch > 1); // ... however, we don't need to get an extra paragraph if the \r occurs at the end of the FindWhat string if (String.IsNullOrEmpty(strTokens[NumOfParagraphsToSearch - 1])) { NumOfParagraphsToSearch--; } }
/// <summary> /// update the 'encoding converters' combo box with the current values /// </summary> private void LoadEncodingConverters() { /// Added to make the list of encoding converters match the list that is given when /// the add new converter option is selected. (LT-2955) EncConverters encConv = new EncConverters(); System.Collections.IDictionaryEnumerator de = encConv.GetEnumerator(); cbEC.BeginUpdate(); cbEC.Items.Clear(); cbEC.Sorted = true; while (de.MoveNext()) { string name = de.Key as string; if (name != null) cbEC.Items.Add(name); } cbEC.Sorted = false; cbEC.Items.Insert(0, m_blankEC); cbEC.EndUpdate(); }
public void ConvertAsciiToUnicode() { CheckDisposed(); string encFileName = string.Empty; EncConverters converters = new EncConverters(); try { // Define an encoding converter StreamReader reader = new StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream( "SIL.FieldWorks.FDO.Scripture.EncTest.map")); encFileName = Path.Combine(Path.GetTempPath(), "test.map"); StreamWriter writer = new StreamWriter(encFileName); writer.Write(reader.ReadToEnd()); reader.Close(); writer.Close(); converters.Add("MyConverter", encFileName, ConvType.Legacy_to_from_Unicode, string.Empty, string.Empty, ProcessTypeFlags.UnicodeEncodingConversion); using (TempSFFileMaker fileMaker = new TempSFFileMaker()) { string fileName = fileMaker.CreateFile("ROM", new string[] { @"\mt 0123456789", "\\s \u0081\u009a\u0096\u00b5", @"\c 1", @"\v 1"}, Encoding.GetEncoding(28591), false); m_settings.AddFile(fileName, ImportDomain.Main, null, 0); // Set the vernacular WS to use the MyConverter encoder LgWritingSystem wsVern = new LgWritingSystem(Cache, Cache.LangProject.DefaultVernacularWritingSystem); wsVern.LegacyMapping = "MyConverter"; ISCTextEnum textEnum = GetTextEnum(ImportDomain.Main, new ScrReference(45, 0, 0, Paratext.ScrVers.English), new ScrReference(45, 1, 1, Paratext.ScrVers.English)); ISCTextSegment textSeg = textEnum.Next(); Assert.IsNotNull(textSeg, "Unable to read segment"); Assert.AreEqual(@"\id", textSeg.Marker); Assert.AreEqual("ROM ", textSeg.Text); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg, "Unable to read segment"); Assert.AreEqual(@"\mt", textSeg.Marker); Assert.AreEqual("\u0966\u0967\u0968\u0969\u096a\u096b\u096c\u096d\u096e\u096f ", textSeg.Text); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg, "Unable to read segment"); Assert.AreEqual(@"\s", textSeg.Marker); Assert.AreEqual("\u0492\u043a\u2013\u04e9 ", textSeg.Text); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg, "Unable to read segment"); Assert.AreEqual(@"\c", textSeg.Marker); Assert.AreEqual(@" ", textSeg.Text); textSeg = textEnum.Next(); Assert.IsNotNull(textSeg, "Unable to read segment"); Assert.AreEqual(@"\v", textSeg.Marker); Assert.AreEqual(@" ", textSeg.Text); } } finally { converters.Remove("MyConverter"); try { File.Delete(encFileName); } catch {} } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Launches the add transduce processor dialog. /// </summary> /// ------------------------------------------------------------------------------------ internal void launchAddTransduceProcessorDlg() { m_transduceDialogOpen = true; m_suppressAutosave = true; m_cnvtrPropertiesCtrl.EnableEntirePane(false); // save the current converter string selectedConverter = ConverterName; try { // call the v2.2 interface to "AutoConfigure" a converter string strFriendlyName = selectedConverter; EncConverters aEC = new EncConverters(); aEC.AutoConfigure(ConvType.Unknown, ref strFriendlyName); m_outsideDlgChangedCnvtrs = true; if (!String.IsNullOrEmpty(strFriendlyName) && strFriendlyName != selectedConverter) { m_undefinedConverters.Remove(selectedConverter); RefreshListBox(); SelectedConverter = strFriendlyName; } else SelectedConverter = selectedConverter; RefreshTabs(); SetStates(); } finally { m_transduceDialogOpen = false; m_suppressAutosave = false; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Load the Available Encoding Converters. /// </summary> /// ------------------------------------------------------------------------------------ protected void LoadAvailableConverters() { string strSel = FwCoreDlgs.kstidNone; try { // Remember existing selection if one exists. See LT-4045. if (cbEncodingConverter.Items.Count > 0) strSel = (string)cbEncodingConverter.SelectedItem; EncConverters encConverters = new EncConverters(); cbEncodingConverter.Items.Clear(); cbEncodingConverter.Items.Add(strSel); foreach (string convName in encConverters.Keys) cbEncodingConverter.Items.Add(convName); cbEncodingConverter.SelectedItem = strSel; } catch (Exception e) { Debug.WriteLine(e.Message); cbEncodingConverter.Items.Clear(); cbEncodingConverter.Items.Add(strSel); } }
private void menuItemDeleteAll_Click(object sender, System.EventArgs e) { // verify first! if( MessageBox.Show("Are you sure you want to delete all the existing projects?", SpellingFixerEC.cstrCaption, MessageBoxButtons.YesNoCancel) == DialogResult.Yes) { EncConverters aECs = new EncConverters(); foreach(string strProjectName in checkedListBoxProjects.Items) { IEncConverter aEC = aECs[FullName(strProjectName)]; if( aEC != null ) { // if they do this, then don't bother querying about saving the files. if( File.Exists(aEC.ConverterIdentifier) ) File.Delete(aEC.ConverterIdentifier); // remove it from the repository as well. aECs.Remove(aEC.Name); } } // now remove them from the checkbox list while( checkedListBoxProjects.Items.Count > 0 ) checkedListBoxProjects.Items.RemoveAt(0); this.buttonOK.Enabled = this.checkedListBoxProjects.Visible = false; this.AcceptButton = this.buttonAddNewProject; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Constructor. /// </summary> /// <param name="helpTopicProvider">help topic provider for the Help button</param> /// <param name="encConverters"></param> /// <param name="wsInUse"></param> /// ------------------------------------------------------------------------------------ public AddCnvtrDlg(IHelpTopicProvider helpTopicProvider, EncConverters encConverters, Set<string> wsInUse) : this(helpTopicProvider, encConverters, wsInUse, false) { }
private void menuItemEdit_Click(object sender, System.EventArgs e) { // Provide a way to edit the info (in case the user wants to change the // font, size, or delimter. int nIndex = checkedListBoxProjects.IndexFromPoint(m_ptRightClicked); if( nIndex >= 0 ) { string strProjectName = checkedListBoxProjects.Items[nIndex].ToString(); EncConverters aECs = new EncConverters(); IEncConverter aEC = aECs[FullName(strProjectName)]; if( aEC != null ) { m_strEncConverterName = aEC.Name; m_strConverterSpec = aEC.ConverterIdentifier; ECAttributes aECAttrs = aECs.Attributes(aEC.Name,AttributeType.Converter); string strFontName = aECAttrs[SpellingFixerEC.cstrAttributeFontToUse]; string sFontSize = aECAttrs[SpellingFixerEC.cstrAttributeFontSizeToUse]; m_strWordBoundaryDelimiter = aECAttrs[SpellingFixerEC.cstrAttributeWordBoundaryDelimiter]; m_strNonWordCharacters = aECAttrs[SpellingFixerEC.cstrAttributeNonWordChars]; DoEdit(aECs, aEC, strProjectName, strFontName, sFontSize); } // make the "Update" button the default button this.AcceptButton = this.buttonAddNewProject; } }
private void DoEdit(EncConverters aECs, IEncConverter aEC, string strProjectName, string strFontName, string sFontSize) { this.textBoxNewProjectName.Text = strProjectName; this.textBoxWordBoundaryDelimiter.Text = m_strWordBoundaryDelimiter; // new in 1.2 (so it might not exist) this.textBoxAddlPunctuation.Text = this.DecodePunctuationForCC(m_strNonWordCharacters); this.listBoxFontSize.SelectedItem = sFontSize; this.comboBoxFont.SelectedItem = strFontName; m_bLegacy = (aEC.ConversionType == ConvType.Legacy_to_Legacy); this.checkBoxUnicode.Checked = !m_bLegacy; if( m_bLegacy ) { this.labelCP.Visible = this.textBoxCP.Visible = true; this.textBoxCP.Text = aECs.CodePage(strFontName).ToString(); } // update the "Add New Project" button to say "Update Project" this.groupBoxNewProject.Text = "Edit Project Settings"; this.buttonAddNewProject.Text = "Update &Project"; this.toolTips.SetToolTip(this.buttonAddNewProject, "Click to update the project information"); this.textBoxNewProjectName.ReadOnly = true; EnableAddNewProjectButton(); }
private void menuItemDelete_Click(object sender, System.EventArgs e) { int nIndex = checkedListBoxProjects.IndexFromPoint(m_ptRightClicked); if( nIndex >= 0 ) { string strProjectName = checkedListBoxProjects.Items[nIndex].ToString(); if( MessageBox.Show(String.Format("Are you sure you want to delete the '{0}' project?",strProjectName), SpellingFixerEC.cstrCaption, MessageBoxButtons.YesNoCancel) == DialogResult.Yes) { EncConverters aECs = new EncConverters(); IEncConverter aEC = aECs[FullName(strProjectName)]; if( aEC != null ) { DialogResult res = MessageBox.Show(String.Format("Do you also want to delete the associated CC table '{0}'?", aEC.ConverterIdentifier), SpellingFixerEC.cstrCaption, MessageBoxButtons.YesNoCancel); if( res == DialogResult.Yes) { if( File.Exists(aEC.ConverterIdentifier) ) File.Delete(aEC.ConverterIdentifier); } else if( res == DialogResult.Cancel ) return; // remove it from the repository as well. aECs.Remove(aEC.Name); } checkedListBoxProjects.Items.Remove(strProjectName); if( this.checkedListBoxProjects.Items.Count == 0 ) this.AcceptButton = this.buttonAddNewProject; EnableAddNewProjectButton(); } } }
private void checkBoxUnicode_CheckedChanged(object sender, System.EventArgs e) { // check to see if the Add button should be enable. EnableAddNewProjectButton(); bool bIsLegacy = !this.checkBoxUnicode.Checked; this.labelCP.Visible = this.textBoxCP.Visible = bIsLegacy; // if it's a legacy encoding, then see if the repository already has a cp for // this font if( bIsLegacy ) { EncConverters aECs = new EncConverters(); int cp = (this.textBoxCP.Text != "") ? Convert.ToInt32(this.textBoxCP.Text) : 1252; try { if( (comboBoxFont.SelectedItem != null) && (comboBoxFont.SelectedItem.ToString() != "") ) cp = aECs.CodePage(comboBoxFont.SelectedItem.ToString()); } catch {} this.textBoxCP.Text = cp.ToString(); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates and loads a set of dummy converters to test the /// <see cref="CnvtrPropertiesCtrl"/> class. /// </summary> /// ------------------------------------------------------------------------------------ public override void FixtureSetup() { base.FixtureSetup(); m_fileMaker = new TempSFFileMaker(); m_myDlg = new DummyAddCnvtrDlg(); m_myCtrl = new DummyCnvtrPropertiesCtrl(); SilEncConverters31.EncConverters encConverters = new SilEncConverters31.EncConverters(); string[] ccFileContents = {"'c' > 'C'"}; m_ccFileName = m_fileMaker.CreateFileNoID(ccFileContents, "cct"); encConverters.AddConversionMap("ZZZTestCC", m_ccFileName, ConvType.Legacy_to_Unicode, "SIL.cc", "", "", ProcessTypeFlags.UnicodeEncodingConversion); string[] mapFileContents = { "EncodingName 'ZZZText'", "DescriptiveName 'Silly test file'", "ByteDefault '?'", "UniDefault replacement_character", "0x80 <> euro_sign" }; m_mapFileName = m_fileMaker.CreateFileNoID(mapFileContents, "map"); encConverters.AddConversionMap("ZZZTestMap", m_mapFileName, ConvType.Legacy_to_from_Unicode, "SIL.map", "", "", ProcessTypeFlags.UnicodeEncodingConversion); // TODO: Should test a legitimate compiled TecKit file by embedding a zipped // up one in the resources for testing purposes. // This is a randomly chosen ICU converter. The test may break when we reduce the set of // ICU converters we ship. encConverters.AddConversionMap("ZZZTestICU", "ISO-8859-1", ConvType.Legacy_to_from_Unicode, "ICU.conv", "", "", ProcessTypeFlags.UnicodeEncodingConversion); // Add a 1-step compound converter, which won't be any of the types our dialog // recognizes for now. encConverters.AddCompoundConverterStep("ZZZTestCompound", "ZZZTestCC", true, NormalizeFlags.None); // Load all the mappings after the dummy mappings are added, so the Converter // Mapping File combo box won't contain obsolete versions of the mappings referring // to old temp files from a previous run of the tests. m_myCtrl.CnvtrPropertiesCtrl_Load(null, null); encConverters.Remove("Bogus"); }
static void DoMain(string[] args) { // deal with command line arguments string strTargetDir = null; int nArgument = 0; if ((args.Length > nArgument) && (args[nArgument] == "/v")) { m_bVerbose = true; nArgument++; } if (args.Length > nArgument) { strTargetDir = args[0]; nArgument++; // unnecessary, but... } else strTargetDir = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData); // set-up the paths to the source and target folders System.Diagnostics.Debug.Assert(strTargetDir[strTargetDir.Length - 1] != '\\', "Don't pass the target directory with a final slash"); string strCommonApplicationDataSilPath = strTargetDir + cstrSIL; m_strCommonProgramFilesSilPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles) + cstrSIL; // move all the files in the following folders (here the MapsTables and Repository folders) Log(String.Format("Moving files from: {0} to {1}", m_strCommonProgramFilesSilPath + cstrMapsTables, strCommonApplicationDataSilPath + cstrMapsTables)); MoveFolderContents(m_strCommonProgramFilesSilPath + cstrMapsTables, strCommonApplicationDataSilPath + cstrMapsTables); Log(String.Format("Moving files from: {0} to {1}", m_strCommonProgramFilesSilPath + cstrRepository, strCommonApplicationDataSilPath + cstrRepository)); MoveFolderContents(m_strCommonProgramFilesSilPath + cstrRepository, strCommonApplicationDataSilPath + cstrRepository); // update the repository key for where the repository xml file is stored Log(String.Format("Updating RegistryKey {0} from: {1} to {2}", EncConverters.HKLM_PATH_TO_XML_FILE, m_strCommonProgramFilesSilPath, strCommonApplicationDataSilPath)); ReplaceRegistryKeyValue(Registry.LocalMachine, EncConverters.HKLM_PATH_TO_XML_FILE, EncConverters.strRegKeyForStorePath, m_strCommonProgramFilesSilPath, strCommonApplicationDataSilPath); // update the paths used by the options installer (specialized function) Log(String.Format("Fixing up Options Installer Paths from: {0} to {1}", m_strCommonProgramFilesSilPath, strCommonApplicationDataSilPath)); FixupSECConverterOptionsInstallerPaths(m_strCommonProgramFilesSilPath, strCommonApplicationDataSilPath); // the following should come last // set the key that tells EncConverter to do a fixup of the converter specs Log(String.Format("Setting the RegistryKeyValue: {0} to {1}", EncConverters.strRegKeyForMovingRepository, Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData))); SetRegistryKeyValue(Registry.LocalMachine, EncConverters.HKLM_PATH_TO_XML_FILE, EncConverters.strRegKeyForMovingRepository, strTargetDir); // finally, instantiate the EncConverters repository object which will trigger the path fixup // (while we still have administrator privilege) Log("Launching EncConverters to fix-up the repository paths to the new target location"); EncConverters aECs = new EncConverters(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Reloads contents of the Available Converters ListBox /// </summary> /// ------------------------------------------------------------------------------------ public void RefreshListBox() { CheckDisposed(); if (m_outsideDlgChangedCnvtrs) { // after the dialog is closed, we have to "reboot" the list // of encoding converters to detect the new converters m_encConverters = new EncConverters(); m_cnvtrPropertiesCtrl.Converters = m_encConverters; m_converterTest.Converters = m_encConverters; m_advancedEncProps.Converters = m_encConverters; m_outsideDlgChangedCnvtrs = false; } // then we will perform the standard "refresh" of the listbox availableCnvtrsListBox.Items.Clear(); foreach (string convName in m_encConverters.Keys) { if (m_fOnlyUnicode) { IEncConverter conv = m_encConverters[convName]; // Only Unicode-to-Unicode converters are relevant. if (conv.ConversionType == ConvType.Unicode_to_Unicode || conv.ConversionType == ConvType.Unicode_to_from_Unicode) { availableCnvtrsListBox.Items.Add(convName); } } else { availableCnvtrsListBox.Items.Add(convName); } } // Now add the converters that haven't been validated. foreach (EncoderInfo info in m_undefinedConverters.Values) availableCnvtrsListBox.Items.Add(info.m_name); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Load the Available Encoding Converters. /// </summary> /// ------------------------------------------------------------------------------------ protected void LoadAvailableConverters() { // Save the old selection so it can be restored after the combo box is filled string oldSelection = null; if (cbEncodingConverter.SelectedIndex != -1) oldSelection = (string)cbEncodingConverter.SelectedItem; try { EncConverters encConverters = new SilEncConverters31.EncConverters(); cbEncodingConverter.Items.Clear(); cbEncodingConverter.Items.Add(FwCoreDlgs.kstidNone); foreach (string convName in encConverters.Keys) cbEncodingConverter.Items.Add(convName); if (oldSelection != null) cbEncodingConverter.SelectedItem = oldSelection; } catch (Exception e) { // If the encoding converters failed, just put in a None entry Debug.WriteLine(e.Message); cbEncodingConverter.Items.Clear(); cbEncodingConverter.Items.Add(FwCoreDlgs.kstidNone); cbEncodingConverter.SelectedIndex = 0; } }
private void addToSystemRepositoryToolStripMenuItem_Click(object sender, EventArgs e) { // we have to have a file saved to add it if (m_strMapNameReal == null) saveAsToolStripMenuItem_Click(sender, e); // check again, just in case they cancelled. if (m_strMapNameReal != null) { m_aEC = null; // free it so we can re-create it with the "real" content string strFriendlyName = null, strLhsEncodingID = null, strRhsEncodingID = null; if (CompileRealMap()) { m_aEC = new TecEncConverter(); int nProcType = (int)ProcessTypeFlags.DontKnow; m_aEC.Initialize(cstrMyEncConverterName, m_strTecNameReal, ref strLhsEncodingID, ref strRhsEncodingID, ref m_eConvType, ref nProcType, 0, 0, true); } else return; // compile failed, so just quit if (m_aEC != null) { try { strFriendlyName = String.Format("{0}{2}{1}", strLhsEncodingID, strRhsEncodingID, (EncConverters.IsUnidirectional(m_aEC.ConversionType)) ? ">" : "<>"); } catch { } EncConverters aECs = new EncConverters(); IEncConverterConfig rConfigurator = m_aEC.Configurator; // call its Configure method to do the UI rConfigurator.Configure(aECs, strFriendlyName, m_eConvType, strLhsEncodingID, strRhsEncodingID); } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Constructor. /// </summary> /// <param name="helpTopicProvider">help topic provider for the Help button</param> /// <param name="encConverters"></param> /// <param name="wsInUse"></param> /// <param name="onlyUnicodeCnvtrs"></param> /// ------------------------------------------------------------------------------------ public AddCnvtrDlg(IHelpTopicProvider helpTopicProvider, EncConverters encConverters, Set<string> wsInUse, bool onlyUnicodeCnvtrs) : this(helpTopicProvider, encConverters, null, wsInUse, onlyUnicodeCnvtrs) { }
private bool SetFontLhs() { #if false // DEBUG fontDialog.Font = new Font("Annapurna", 12); #else fontDialog.Font = textBoxSample.Font; if (fontDialog.ShowDialog() != DialogResult.Cancel) { #endif textBoxSample.Font = fontDialog.Font; textBoxSampleReverse.Font = fontDialog.Font; SetFontClue(cstrLhsFontClue, fontDialog.Font); if (unicodeValuesWindowToolStripMenuItem.Checked) { if (IsLhsLegacy) { EncConverters aECs = new EncConverters(true); try { m_nCodePageLegacyLhs = aECs.CodePage(fontDialog.Font.Name); } catch { } } m_formDisplayUnicodeNamesLhs.Initialize(IsLhsLegacy, textBoxSample.Font, m_nCodePageLegacyLhs); } return true; #if true // !DEBUG } else return false; #endif }
/// <summary> /// This is the most comprehensive constructor. /// </summary> /// <param name="helpTopicProvider"></param> /// <param name="encConverters"></param> /// <param name="selectConv">Converter to be selected</param> /// <param name="wsInUse"></param> /// <param name="onlyUnicodeCnvtrs">If true, show and create only Unicode converters (both to and to/from).</param> public AddCnvtrDlg(IHelpTopicProvider helpTopicProvider, EncConverters encConverters, string selectConv, Set<string> wsInUse, bool onlyUnicodeCnvtrs) { // Set members m_helpTopicProvider = helpTopicProvider; m_fOnlyUnicode = onlyUnicodeCnvtrs; m_toSelect = selectConv; // Take care of null values if (encConverters == null) m_encConverters = new SilEncConverters31.EncConverters(); else m_encConverters = encConverters; // // Required for Windows Form Designer support // InitializeComponent(); // Things that must happen after InitializeComponent() follow: InitWSInUse(wsInUse); // LT-6927: this is ugly, but could be added back into generated // parts after test tab conversion problems are resolved -- CameronB if (!m_fOnlyUnicode) { this.m_addCnvtrTabCtrl.Controls.Add(this.testTab); this.m_addCnvtrTabCtrl.Controls.Add(this.advancedTab); } m_cnvtrPropertiesCtrl.Converters = m_encConverters; m_cnvtrPropertiesCtrl.UndefinedConverters = m_undefinedConverters; m_converterTest.Converters = m_encConverters; m_advancedEncProps.Converters = m_encConverters; if (m_fOnlyUnicode) // Not really encoding converters in this case. { m_cnvtrPropertiesCtrl.OnlyUnicode = true; this.Text = AddConverterDlgStrings.kstidSetupProcessor; label1.Text = AddConverterDlgStrings.kstidAvailableProcessors; } }
/// ------------------------------------------------------------------------------------ /// <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 bool Convert1() { const int maxSearch = 8; char c; string[] searches = new string[maxSearch]; string buffer, searchBuffer, rieBufferLangData, rieBufferXML; int[] locs = new int[maxSearch]; modes mode; bool bufferIt; int j; bool found; bool okay = true; if (!File.Exists(m_nextInput)) { ReportError(string.Format(ITextStrings.ksInputFileNotFound, m_nextInput), ITextStrings.ksLLEncConv); return false; } m_converters = new EncConverters(); FileStream fsi = new FileStream(m_nextInput, FileMode.Open, FileAccess.Read); FileStream fso = new FileStream(m_sTempDir + "LLPhase1Output.xml", FileMode.Create, FileAccess.Write); BinaryReader br = new BinaryReader(fsi); BinaryWriter bw = new BinaryWriter(fso); buffer = string.Empty; searchBuffer = string.Empty; rieBufferXML = string.Empty; rieBufferLangData = string.Empty; for (int i = 0; i < m_languageMappings.Length; i++) { LanguageMapping mapping = m_languageMappings[i]; if (mapping.FwName == ITextStrings.ksIgnore || mapping.FwCode == string.Empty) { mapping.FwName = "zzzIgnore"; mapping.FwCode = "zzzIgnore"; } } //Start mode = modes.kStart; InitializeSearches(searches); for (j = 0; j < maxSearch; j++) { locs[j] = 0; } bufferIt = false; while (okay && fsi.Position < fsi.Length) { int m_currentProgress = m_phaseProgressStart + (int)Math.Floor((double)((m_phaseProgressEnd - m_phaseProgressStart) * fsi.Position / fsi.Length)); if (m_currentProgress > m_shownProgress && m_currentProgress <= m_phaseProgressEnd) { m_ai.Step(m_currentProgress - m_shownProgress); m_shownProgress = m_currentProgress; } c = (char)br.ReadByte(); found = false; int TempDiff = 0; for (j = 0; j < maxSearch; j++) { if (c == searches[j][locs[j]]) { found = true; locs[j]++; if (locs[j] > TempDiff) { TempDiff = locs[j]; } } else { locs[j] = 0; } } if (found) { searchBuffer += c; TempDiff = searchBuffer.Length - TempDiff; if (TempDiff > 0) { ProcessSearchBuffer(searchBuffer, TempDiff, bufferIt, ref buffer, bw); searchBuffer = searchBuffer.Substring(TempDiff, searchBuffer.Length - TempDiff); } if ((locs[0] == searches[0].Length) && (locs[0] == searchBuffer.Length)) { string s = string.Format(ITextStrings.ksExpectedXButGotY, searches[1], searches[0]); ReportError(s, ITextStrings.ksLLEncConv); s = "</Error>Parsing Error. " + s; for (j = 0; j < s.Length; j++) { bw.Write((byte)s[j]); } bw.Close(); fso.Close(); okay = false; } else if ((locs[1] == searches[1].Length) && (locs[1] == searchBuffer.Length)) { if (mode == modes.kStart) { // <Run ProcessSearchBuffer(searchBuffer, locs[1], bufferIt, ref buffer, bw); searchBuffer = string.Empty; bufferIt = false; for (j = 0; j < maxSearch; j++) { searches[j] = ">Dummy>"; } searches[0] = "</Run>"; searches[1] = "ws=\""; mode = modes.kRun1; } else if (mode == modes.kRun1) { // <Run ws=" ProcessSearchBuffer(searchBuffer, locs[1], bufferIt, ref buffer, bw); searchBuffer = string.Empty; bufferIt = true; buffer = string.Empty; for (j = 0; j < maxSearch; j++) { searches[j] = ">Dummy>"; } searches[0] = "</Run>"; searches[1] = "\""; mode = modes.kRun2; } else if (mode == modes.kRun2) { // <Run ws="en" ProcessLanguageCode(buffer, bw); bufferIt = false; ProcessSearchBuffer(searchBuffer, locs[1], bufferIt, ref buffer, bw); searchBuffer = string.Empty; for (j = 0; j < maxSearch; j++) { searches[j] = ">Dummy>"; } searches[0] = "</Run>"; searches[1] = ">"; mode = modes.kRun3; } else if (mode == modes.kRun3) { // <Run ws="en"> ProcessSearchBuffer(searchBuffer, locs[1], bufferIt, ref buffer, bw); searchBuffer = string.Empty; bufferIt = true; buffer = string.Empty; for (j = 0; j < maxSearch; j++) { searches[j] = ">Dummy>"; } searches[0] = "<Run>"; searches[1] = "</Run>"; mode = modes.kRun4; } else if (mode == modes.kRun4) { // <Run ws="en">Data</Run> ProcessLanguageData(buffer, bw); bufferIt = false; ProcessSearchBuffer(searchBuffer, locs[1], bufferIt, ref buffer, bw); searchBuffer = string.Empty; InitializeSearches(searches); mode = modes.kStart; } else if (mode == modes.kAUni1) { // <AUni ws=" ProcessSearchBuffer(searchBuffer, locs[1], bufferIt, ref buffer, bw); searchBuffer = string.Empty; bufferIt = true; buffer = string.Empty; for (j = 0; j < maxSearch; j++) { searches[j] = ">Dummy>"; } searches[0] = "</AUni>"; searches[1] = "\""; mode = modes.kAUni2; } else if (mode == modes.kAUni2) { // <AUni ws="en" ProcessLanguageCode(buffer, bw); bufferIt = false; ProcessSearchBuffer(searchBuffer, locs[1], bufferIt, ref buffer, bw); searchBuffer = string.Empty; for (j = 0; j < maxSearch; j++) { searches[j] = ">Dummy>"; } searches[0] = "</AUni>"; searches[1] = ">"; mode = modes.kAUni3; } else if (mode == modes.kAUni3) { // <AUni ws="en"> ProcessSearchBuffer(searchBuffer, locs[1], bufferIt, ref buffer, bw); searchBuffer = string.Empty; bufferIt = true; buffer = string.Empty; for (j = 0; j < maxSearch; j++) { searches[j] = ">Dummy>"; } searches[0] = "<AUni>"; searches[1] = "</AUni>"; mode = modes.kAUni4; } else if (mode == modes.kAUni4) { // <AUni ws="en">Data</AUni> ProcessLanguageData(buffer, bw); bufferIt = false; ProcessSearchBuffer(searchBuffer, locs[1], bufferIt, ref buffer, bw); searchBuffer = string.Empty; InitializeSearches(searches); mode = modes.kStart; } else if (mode == modes.kAStr1) { // <AStr ws=" ProcessSearchBuffer(searchBuffer, locs[1], bufferIt, ref buffer, bw); searchBuffer = string.Empty; bufferIt = true; buffer = string.Empty; for (j = 0; j < maxSearch; j++) { searches[j] = ">Dummy>"; } searches[0] = "<Run>"; searches[1] = "\""; mode = modes.kAStr2; } else if (mode == modes.kAStr2) { // <AStr ws="en" ProcessLanguageCode(buffer, bw); bufferIt = false; ProcessSearchBuffer(searchBuffer, locs[1], bufferIt, ref buffer, bw); searchBuffer = string.Empty; for (j = 0; j < maxSearch; j++) { searches[j] = ">Dummy>"; } searches[0] = "<Run>"; searches[1] = ">"; mode = modes.kAStr3; } else if (mode == modes.kAStr3) { // <AStr ws="en"> bufferIt = false; ProcessSearchBuffer(searchBuffer, locs[1], bufferIt, ref buffer, bw); searchBuffer = string.Empty; InitializeSearches(searches); mode = modes.kStart; } else if (mode == modes.kRIE1) { // <ReversalIndexEntry ... <Uni> ProcessSearchBuffer(searchBuffer, locs[1], bufferIt, ref buffer, bw); searchBuffer = string.Empty; bufferIt = true; buffer = string.Empty; for (j = 0; j < maxSearch; j++) { searches[j] = ">Dummy>"; } searches[0] = "</ReversalIndexEntry>"; searches[1] = "</Uni>"; mode = modes.kRIE2; } else if (mode == modes.kRIE2) { // <ReversalIndexEntry ... <Uni>Data</Uni> rieBufferLangData = buffer; bufferIt = true; buffer = string.Empty; ProcessSearchBuffer(searchBuffer, locs[1], bufferIt, ref buffer, bw); searchBuffer = string.Empty; for (j = 0; j < maxSearch; j++) { searches[j] = ">Dummy>"; } searches[0] = "</ReversalIndexEntry>"; searches[1] = "<WritingSystem5053>"; mode = modes.kRIE3; } else if (mode == modes.kRIE3) { // <ReversalIndexEntry ... <Uni>Data</Uni> ... <WritingSystem5053> bufferIt = true; ProcessSearchBuffer(searchBuffer, locs[1], bufferIt, ref buffer, bw); searchBuffer = string.Empty; for (j = 0; j < maxSearch; j++) { searches[j] = ">Dummy>"; } searches[0] = "</ReversalIndexEntry>"; searches[1] = "<Link"; mode = modes.kRIE4; } else if (mode == modes.kRIE4) { // <ReversalIndexEntry ... <Uni>Data</Uni> ... <WritingSystem5053> ... <Link bufferIt = true; ProcessSearchBuffer(searchBuffer, locs[1], bufferIt, ref buffer, bw); searchBuffer = string.Empty; for (j = 0; j < maxSearch; j++) { searches[j] = ">Dummy>"; } searches[0] = "</WritingSystem5053>"; searches[1] = "ws=\""; mode = modes.kRIE5; } else if (mode == modes.kRIE5) { // <ReversalIndexEntry ... <Uni>Data</Uni> ... <WritingSystem5053> ... <ws=" bufferIt = true; ProcessSearchBuffer(searchBuffer, locs[1], bufferIt, ref buffer, bw); rieBufferXML = buffer; buffer = string.Empty; searchBuffer = string.Empty; for (j = 0; j < maxSearch; j++) { searches[j] = ">Dummy>"; } searches[0] = "</WritingSystem5053>"; searches[1] = "\""; mode = modes.kRIE6; } else if (mode == modes.kRIE6) { // <ReversalIndexEntry ... <Uni>Data</Uni> ... <WritingSystem5053> ... <Link ws="en" ProcessLanguageCode2(buffer); if (m_current.FwCode != null) rieBufferXML += m_current.FwCode; ProcessLanguageData(rieBufferLangData, bw); bufferIt = false; ProcessSearchBuffer(rieBufferXML, rieBufferXML.Length, bufferIt, ref buffer, bw); ProcessSearchBuffer(searchBuffer, locs[1], bufferIt, ref buffer, bw); searchBuffer = string.Empty; for (j = 0; j < maxSearch; j++) { searches[j] = ">Dummy>"; } searches[0] = "</Entries5052>"; searches[1] = "</WritingSystem5053>"; mode = modes.kRIE7; } else if (mode == modes.kRIE7) { // <ReversalIndexEntry ... <Uni>Data</Uni> ... <WritingSystem5053> ... <Link ws="en" ... </WritingSystem5053> bufferIt = false; ProcessSearchBuffer(searchBuffer, locs[1], bufferIt, ref buffer, bw); searchBuffer = string.Empty; InitializeSearches(searches); mode = modes.kStart; } else if (mode == modes.kLink1) { // <Link target="XXXXXXX" ws=" ProcessSearchBuffer(searchBuffer, locs[1], bufferIt, ref buffer, bw); searchBuffer = string.Empty; bufferIt = true; buffer = string.Empty; for (j = 0; j < maxSearch; j++) { searches[j] = ">Dummy>"; } searches[0] = "/>"; searches[1] = "\""; mode = modes.kLink2; } else if (mode == modes.kLink2) { // <Link target="XXXXXXX" ws="en" ProcessLanguageCode(buffer, bw); bufferIt = false; ProcessSearchBuffer(searchBuffer, locs[1], bufferIt, ref buffer, bw); searchBuffer = string.Empty; for (j = 0; j < maxSearch; j++) { searches[j] = ">Dummy>"; } searches[1] = "\""; searches[2] = "/>"; mode = modes.kLink3; } else if (mode == modes.kLink3) { // <Link target="XXXXXXX" ws="en" form=" ProcessSearchBuffer(searchBuffer, locs[1], bufferIt, ref buffer, bw); searchBuffer = string.Empty; bufferIt = true; buffer = string.Empty; for (j = 0; j < maxSearch; j++) { searches[j] = ">Dummy>"; } searches[0] = "/>"; searches[1] = "\""; mode = modes.kLink4; } else if (mode == modes.kLink4) { // <Link target="XXXXXXX" ws="en" form="Data" ProcessLanguageData(buffer, bw); bufferIt = false; ProcessSearchBuffer(searchBuffer, locs[1], bufferIt, ref buffer, bw); searchBuffer = string.Empty; for (j = 0; j < maxSearch; j++) { searches[j] = ">Dummy>"; } searches[1] = "\""; searches[2] = "/>"; mode = modes.kLink3; } else if (mode == modes.kLinkA2) { // <Link target="XXXXXXX" wsa="en" ProcessLanguageCode(buffer, bw); bufferIt = false; ProcessSearchBuffer(searchBuffer, locs[1], bufferIt, ref buffer, bw); searchBuffer = string.Empty; for (j = 0; j < maxSearch; j++) { searches[j] = ">Dummy>"; } searches[1] = "\""; searches[2] = "/>"; searches[3] = "wsv=\""; mode = modes.kLinkA3; } else if (mode == modes.kLinkA3) { // <Link target="XXXXXXX" wsa="en" abbr=" ProcessSearchBuffer(searchBuffer, locs[1], bufferIt, ref buffer, bw); searchBuffer = string.Empty; bufferIt = true; buffer = string.Empty; for (j = 0; j < maxSearch; j++) { searches[j] = ">Dummy>"; } searches[0] = "/>"; searches[1] = "\""; mode = modes.kLinkA4; } else if (mode == modes.kLinkA4) { // <Link target="XXXXXXX" wsa="en" form="Data" ProcessLanguageData(buffer, bw); bufferIt = false; ProcessSearchBuffer(searchBuffer, locs[1], bufferIt, ref buffer, bw); searchBuffer = string.Empty; for (j = 0; j < maxSearch; j++) { searches[j] = ">Dummy>"; } searches[1] = "\""; searches[2] = "/>"; searches[3] = "wsv=\""; mode = modes.kLinkA3; } else if (mode == modes.kICU1) { // <ICULocale24> <Uni> ProcessSearchBuffer(searchBuffer, locs[1], bufferIt, ref buffer, bw); searchBuffer = string.Empty; bufferIt = true; buffer = string.Empty; for (j = 0; j < maxSearch; j++) { searches[j] = ">Dummy>"; } searches[0] = "</ICULocale24>"; searches[1] = "</Uni>"; mode = modes.kICU2; } else if (mode == modes.kICU2) { // <ICULocale24> <Uni>en</Uni> ProcessLanguageCode(buffer, bw); bufferIt = false; ProcessSearchBuffer(searchBuffer, locs[1], bufferIt, ref buffer, bw); searchBuffer = string.Empty; InitializeSearches(searches); mode = modes.kStart; } else if (mode == modes.kDtd) { // <!DOCTYPE ... > ProcessSearchBuffer(searchBuffer, locs[1], bufferIt, ref buffer, bw); searchBuffer = string.Empty; bufferIt = false; InitializeSearches(searches); mode = modes.kStart; } for (j = 0; j < maxSearch; j++) { locs[j] = 0; } } else if ((locs[2] == searches[2].Length) && (locs[2] == searchBuffer.Length)) { if (mode == modes.kStart) { // <AUni ProcessSearchBuffer(searchBuffer, locs[2], bufferIt, ref buffer, bw); searchBuffer = string.Empty; bufferIt = false; for (j = 0; j < maxSearch; j++) { searches[j] = ">Dummy>"; } searches[0] = "</AUni>"; searches[1] = "ws=\""; mode = modes.kAUni1; } else if ((mode == modes.kLink1) || (mode == modes.kLink3) || (mode == modes.kLinkA3)) { // <Link ... /> or <Link ... ws="en" ... /> bufferIt = false; ProcessSearchBuffer(searchBuffer, locs[2], bufferIt, ref buffer, bw); searchBuffer = string.Empty; InitializeSearches(searches); mode = modes.kStart; } else if (mode == modes.kRIE1) { // <ReversalIndexEntry ... </ReversalIndexEntry> bufferIt = false; ProcessSearchBuffer(searchBuffer, locs[2], bufferIt, ref buffer, bw); searchBuffer = string.Empty; InitializeSearches(searches); mode = modes.kStart; } for (j = 0; j < maxSearch; j++) { locs[j] = 0; } } else if ((locs[3] == searches[3].Length) && (locs[3] == searchBuffer.Length)) { if (mode == modes.kStart) { // <ReversalIndexEntry ProcessSearchBuffer(searchBuffer, locs[3], bufferIt, ref buffer, bw); searchBuffer = string.Empty; bufferIt = false; for (j = 0; j < maxSearch; j++) { searches[j] = ">Dummy>"; } searches[1] = "<Uni>"; searches[2] = "</ReversalIndexEntry>"; mode = modes.kRIE1; } else if (mode == modes.kLink1) { // <Link target="XXXXXXX" wsa=" ProcessSearchBuffer(searchBuffer, locs[3], bufferIt, ref buffer, bw); searchBuffer = string.Empty; bufferIt = true; buffer = string.Empty; for (j = 0; j < maxSearch; j++) { searches[j] = ">Dummy>"; } searches[0] = "/>"; searches[1] = "\""; mode = modes.kLinkA2; } else if (mode == modes.kLinkA3) { // <Link target="XXXXXXX" wsa="en" abbr="llcr" wsv=" ProcessSearchBuffer(searchBuffer, locs[3], bufferIt, ref buffer, bw); searchBuffer = string.Empty; bufferIt = true; buffer = string.Empty; for (j = 0; j < maxSearch; j++) { searches[j] = ">Dummy>"; } searches[0] = "/>"; searches[1] = "\""; mode = modes.kLinkA2; } for (j = 0; j < maxSearch; j++) { locs[j] = 0; } } else if ((locs[4] == searches[4].Length) && (locs[4] == searchBuffer.Length)) { if (mode == modes.kStart) { // <AStr ProcessSearchBuffer(searchBuffer, locs[4], bufferIt, ref buffer, bw); searchBuffer = string.Empty; bufferIt = false; for (j = 0; j < maxSearch; j++) { searches[j] = ">Dummy>"; } searches[0] = "<Run>"; searches[1] = "ws=\""; mode = modes.kAStr1; } for (j = 0; j < maxSearch; j++) { locs[j] = 0; } } else if ((locs[5] == searches[5].Length) && (locs[5] == searchBuffer.Length)) { if (mode == modes.kStart) { // <Link ProcessSearchBuffer(searchBuffer, locs[5], bufferIt, ref buffer, bw); searchBuffer = string.Empty; bufferIt = false; for (j = 0; j < maxSearch; j++) { searches[j] = ">Dummy>"; } searches[1] = "ws=\""; searches[2] = "/>"; searches[3] = "wsa=\""; mode = modes.kLink1; } for (j = 0; j < maxSearch; j++) { locs[j] = 0; } } else if ((locs[6] == searches[6].Length) && (locs[6] == searchBuffer.Length)) { if (mode == modes.kStart) { // <ICULocale24> ProcessSearchBuffer(searchBuffer, locs[6], bufferIt, ref buffer, bw); searchBuffer = string.Empty; bufferIt = false; for (j = 0; j < maxSearch; j++) { searches[j] = ">Dummy>"; } searches[0] = "</ICULocale24>"; searches[1] = "<Uni>"; mode = modes.kICU1; } for (j = 0; j < maxSearch; j++) { locs[j] = 0; } } else if ((locs[7] == searches[7].Length) && (locs[7] == searchBuffer.Length)) { if (mode == modes.kStart) { // <!DOCTYPE bufferIt = true; ProcessSearchBuffer(searchBuffer, locs[7], bufferIt, ref buffer, bw); searchBuffer = string.Empty; for (j = 0; j < maxSearch; j++) { searches[j] = ">Dummy>"; } searches[0] = "<"; searches[1] = ">"; mode = modes.kDtd; } for (j = 0; j < maxSearch; j++) { locs[j] = 0; } } } else { if (searchBuffer.Length > 0) { ProcessSearchBuffer(searchBuffer, searchBuffer.Length, bufferIt, ref buffer, bw); searchBuffer = string.Empty; } if (bufferIt) { buffer += c; } else { bw.Write((byte)c); } } } if (okay) { if (searchBuffer.Length > 0) { ProcessSearchBuffer(searchBuffer, searchBuffer.Length, bufferIt, ref buffer, bw); } bw.Close(); br.Close(); fsi.Close(); fso.Close(); m_nextInput = m_sTempDir + "LLPhase1Output.xml"; } return okay; }
private void buttonAddNewProject_Click(object sender, System.EventArgs e) { // in case the Add New project button was default, change it to the OK button. this.AcceptButton = this.buttonOK; // get the delimiter for word boundaries and disallow the /"/ character m_strWordBoundaryDelimiter = this.textBoxWordBoundaryDelimiter.Text; if( m_strWordBoundaryDelimiter.IndexOf('"') != -1 ) { MessageBox.Show("Can't use the double-quote character for the word boundary delimiter",SpellingFixerEC.cstrCaption); return; } bool bRewriteCCTable = false; string strPunctuation = EncodePunctuationForCC(this.textBoxAddlPunctuation.Text); if(strPunctuation == null ) return; // it had a bad character else if( strPunctuation != m_strNonWordCharacters ) { // this means the file must be re-written bRewriteCCTable = true; m_strNonWordCharacters = strPunctuation; } if( (!m_bLegacy) != this.checkBoxUnicode.Checked ) { m_bLegacy = !this.checkBoxUnicode.Checked; bRewriteCCTable = true; } // check for existing EncConverter with this same project information string strCCTableSpec = null; string strPartialName = this.textBoxNewProjectName.Text; string strEncConverterName = FullName(strPartialName); EncConverters aECs = new EncConverters(); IEncConverter aEC = aECs[strEncConverterName]; if( aEC != null ) { // if we're *not* in edit mode if( this.buttonAddNewProject.Text == cstrAddNewProjectButtonText ) { if( MessageBox.Show(String.Format("A project already exists by the name {0}. Click 'Yes' to overwrite", this.textBoxNewProjectName.Text),SpellingFixerEC.cstrCaption, MessageBoxButtons.YesNoCancel) == DialogResult.Yes) { // take it out of the check box list checkedListBoxProjects.Items.Remove(strPartialName); strCCTableSpec = aEC.ConverterIdentifier; if( File.Exists(strCCTableSpec) ) { File.Delete(strCCTableSpec); strCCTableSpec = null; } // remove the existing one and we'll add a new one next aECs.Remove(aEC.Name); aEC = null; } else return; } else // edit mode { if( MessageBox.Show(String.Format("Do you want to update the '{0}' project?", this.textBoxNewProjectName.Text),SpellingFixerEC.cstrCaption, MessageBoxButtons.YesNoCancel) == DialogResult.Yes) { // take it out of the check box list checkedListBoxProjects.Items.Remove(strPartialName); // save the spec so that we don't make one below strCCTableSpec = aEC.ConverterIdentifier; // the remove the converter since we'll add it back again next aECs.Remove(aEC.Name); aEC = null; } else { // reset this in case we were just editing it. ResetNewProjectLook(); return; } } } // if we're aren't using the old cc table, then... if( strCCTableSpec == null ) { // now add it (put it in the normal 'MapsTables' folder in \pf\cf\sil\...) string strMapsTableDir = GetMapTableFolderPath; strCCTableSpec = strMapsTableDir + @"\" + strEncConverterName + ".cct"; if( File.Exists(strCCTableSpec) ) { // the converter doesn't exist, but a file with the name we would have // given it does... ask the user if they want to overwrite it. // TODO: this doesn't allow for complete flexibility. It might be nicer to // allow for any arbitrary name, but not if noone complains. if( MessageBox.Show(String.Format("A file exists by the name {0}. Click 'Yes' to overwrite", strCCTableSpec),SpellingFixerEC.cstrCaption, MessageBoxButtons.YesNoCancel) == DialogResult.Yes) { File.Delete(strCCTableSpec); #if WriteOnAdd // if the user goes to add the first record, it'd be better if the file didn't exist because now we do some // preliminary testing whether the CC table already changes a word before adding a new one, but this causes // a non-trapable error if there are no rules in the file. So just create it when it is actually needed CreateCCTable(strCCTableSpec,strEncConverterName,m_strNonWordCharacters, !this.m_bLegacy); #endif } } #if WriteOnAdd else CreateCCTable(strCCTableSpec,strEncConverterName,m_strNonWordCharacters, !this.m_bLegacy); #endif bRewriteCCTable = false; } // now add the EncConverter // TODO: EncConverters needs a new interface to get the defining encodingID from // a FontName (so we can use it in this call) just like we can 'try' to get the // code page given a font name (see 'CodePage' below) ConvType eConvType = (m_bLegacy) ? ConvType.Legacy_to_Legacy : ConvType.Unicode_to_Unicode; aECs.Add(strEncConverterName,strCCTableSpec,eConvType,null,null,SpellingFixerEC.SFProcessType); Font font = null; try { font = new Font(comboBoxFont.SelectedItem.ToString(),Convert.ToSingle(listBoxFontSize.SelectedItem)); } catch { MessageBox.Show("Couldn't create the selected font. Contact support"); return; } // add this 'displaying font' information to the converter as properties/attributes ECAttributes aECAttrs = aECs.Attributes(strEncConverterName,AttributeType.Converter); aECAttrs.Add(SpellingFixerEC.cstrAttributeFontToUse,font.Name); aECAttrs.Add(SpellingFixerEC.cstrAttributeFontSizeToUse, font.Size); aECAttrs.Add(SpellingFixerEC.cstrAttributeWordBoundaryDelimiter, m_strWordBoundaryDelimiter); aECAttrs.Add(SpellingFixerEC.cstrAttributeNonWordChars, m_strNonWordCharacters); // if it's not Unicode, then we need a code page in order to convert from wide to // narrow (when writing to the file). int cp = 0; if( m_bLegacy ) { // try to get the code page from EncConverters try { cp = aECs.CodePage(font.Name); } catch { // if it fails, it means we don't have a mapping, so add one here. // TODO: it would be nice to have an encoding, but I'm loath to query // the user for it here since it isn't extremely relevant to this app. cp = Convert.ToInt32(this.textBoxCP.Text); aECs.AddFont(font.Name,cp,null); } } if(bRewriteCCTable) // we are going to continue using the old file... so we must re-write it. { // if it was legacy encoded, then we need to convert the data to narrow using // the code page the user specified (or we got out of the repository) Encoding enc = null; if( m_bLegacy ) { if (cp == EncConverters.cnSymbolFontCodePage) cp = EncConverters.cnIso8859_1CodePage; enc = Encoding.GetEncoding(cp); } else enc = new UTF8Encoding(); DataTable myTable; if( SpellingFixerEC.InitializeDataTableFromCCTable(strCCTableSpec, enc, m_strWordBoundaryDelimiter, out myTable) ) { ReWriteCCTableHeader(strCCTableSpec,m_strNonWordCharacters,enc); SpellingFixerEC.AppendCCTableFromDataTable(strCCTableSpec, enc, m_strWordBoundaryDelimiter, m_strNonWordCharacters, myTable); } } // finally, add the new project to the now-visible checkbox list this.buttonOK.Enabled = checkedListBoxProjects.Visible = true; ClearClickedItems(); checkedListBoxProjects.Items.Add(strPartialName,CheckState.Checked); // reset this in case we were just editing it. ResetNewProjectLook(); }
internal bool OpenDocument(string strMapName) { if (Program.Modified) CheckForSaveDirtyFile(); InitCharacterMapDialogs(); bool bModified = false; // if we are dealing with a real file... m_strMapNameReal = strMapName; // check to see if it exists (the alternate exception isn't very helpful) if (!File.Exists(m_strMapNameReal)) { MessageBox.Show(String.Format("The file '{0}' doesn't exist!", m_strMapNameReal, cstrCaption)); return false; } // otherwise, determine the .tec filename m_strTecNameReal = m_strMapNameReal.Remove(m_strMapNameReal.Length - 3, 3) + "tec"; Program.AddFilenameToTitle(m_strMapNameReal); // and put it's contents into the editor. this.richTextBoxMapEditor.Lines = File.ReadAllLines(m_strMapNameReal, m_enc); // see if our 'clues' are in the file ConvType eConvType = ConvType.Unknown; bool bLhsFontFound = false; bool bRhsFontFound = false; bool bCodePointFormSizeHasBeenSetLhs = false; bool bCodePointFormSizeHasBeenSetRhs = false; m_nCodePageLegacyLhs = 0; m_nCodePageLegacyRhs = 0; foreach (string strLine in richTextBoxMapEditor.Lines) { int nIndex = strLine.IndexOf(cstrConvTypeClue); if (nIndex != -1) { string strConvType = strLine.Substring(nIndex + cstrConvTypeClue.Length); foreach (string asName in Enum.GetNames(typeof(ConvType))) { if (asName == strConvType) { eConvType = (ConvType)Enum.Parse(typeof(ConvType), strConvType); break; } } } nIndex = strLine.IndexOf(cstrLhsFontClue); if (nIndex != -1) { int nDelimiter = strLine.LastIndexOf(';'); int nLen = nDelimiter - (nIndex + cstrLhsFontClue.Length); string strFontName = strLine.Substring(nIndex + cstrLhsFontClue.Length, nLen); string strFontSize = strLine.Substring(nDelimiter + 1); float emSize = Convert.ToSingle(strFontSize); Font font = Program.GetSafeFont(strFontName, emSize); textBoxSample.Font = font; textBoxSampleReverse.Font = font; bLhsFontFound = true; } nIndex = strLine.IndexOf(cstrRhsFontClue); if (nIndex != -1) { int nDelimiter = strLine.LastIndexOf(';'); int nLen = nDelimiter - (nIndex + cstrRhsFontClue.Length); string strFontName = strLine.Substring(nIndex + cstrRhsFontClue.Length, nLen); string strFontSize = strLine.Substring(nDelimiter + 1); float emSize = Convert.ToSingle(strFontSize); Font font = Program.GetSafeFont(strFontName, emSize); textBoxSampleForward.Font = font; bRhsFontFound = true; } nIndex = strLine.IndexOf(cstrLhsCodePageClue); if (nIndex != -1) { string strCodePage = strLine.Substring(nIndex + cstrLhsCodePageClue.Length); try { m_nCodePageLegacyLhs = Convert.ToInt32(strCodePage); } catch { } } nIndex = strLine.IndexOf(cstrRhsCodePageClue); if (nIndex != -1) { string strCodePage = strLine.Substring(nIndex + cstrRhsCodePageClue.Length); try { m_nCodePageLegacyRhs = Convert.ToInt32(strCodePage); } catch { } } nIndex = strLine.IndexOf(cstrMainFormClue); if (nIndex != -1) { try { string strXYWH = strLine.Substring(nIndex + cstrMainFormClue.Length); string[] aStrBounds = strXYWH.Split(new char[] { ',' }); Rectangle rectBounds = new Rectangle ( Int32.Parse(aStrBounds[0]), Int32.Parse(aStrBounds[1]), Int32.Parse(aStrBounds[2]), Int32.Parse(aStrBounds[3]) ); if (SetBounds(this, ref rectBounds)) SetBoundsClue(cstrMainFormClue, rectBounds); } catch { } } // search for the character map window location (what used to be the 'code point' window) string strClue = cstrCodePointFormClueLhs; nIndex = strLine.IndexOf(cstrCodePointFormClueLhs); if (nIndex != -1) { try { string strXYWH = strLine.Substring(nIndex + strClue.Length); string[] aStrBounds = strXYWH.Split(new char[] { ',' }); Rectangle rectBounds = new Rectangle ( Int32.Parse(aStrBounds[0]), Int32.Parse(aStrBounds[1]), Int32.Parse(aStrBounds[2]), Int32.Parse(aStrBounds[3]) ); if (SetBounds(m_formDisplayUnicodeNamesLhs, ref rectBounds)) SetBoundsClue(strClue, rectBounds); bCodePointFormSizeHasBeenSetLhs = true; } catch { } } nIndex = strLine.IndexOf(cstrCodePointFormClueRhs); if (nIndex != -1) { try { string strXYWH = strLine.Substring(nIndex + cstrCodePointFormClueRhs.Length); string[] aStrBounds = strXYWH.Split(new char[] { ',' }); Rectangle rectBounds = new Rectangle ( Int32.Parse(aStrBounds[0]), Int32.Parse(aStrBounds[1]), Int32.Parse(aStrBounds[2]), Int32.Parse(aStrBounds[3]) ); if (SetBounds(m_formDisplayUnicodeNamesRhs, ref rectBounds)) SetBoundsClue(cstrCodePointFormClueRhs, rectBounds); bCodePointFormSizeHasBeenSetRhs = true; } catch { } } } // if we didn't find the ConvType, then query for it bool bUserCancelled = false; if (eConvType == ConvType.Unknown) bUserCancelled = !QueryConvType(); else ConversionType = eConvType; InitTempVars(); if (!bUserCancelled && !bLhsFontFound) { // for legacy encodings, prompt for the font. MessageBox.Show("Select the font for the left-hand side encoding", cstrCaption); bUserCancelled |= !SetFontLhs(); } else if (unicodeValuesWindowToolStripMenuItem.Checked) { if (IsLhsLegacy && (m_nCodePageLegacyLhs == 0)) { EncConverters aECs = new EncConverters(true); try { m_nCodePageLegacyLhs = aECs.CodePage(textBoxSample.Font.Name); } catch { } } m_formDisplayUnicodeNamesLhs.Initialize(IsLhsLegacy, textBoxSample.Font, m_nCodePageLegacyLhs); } if (!bUserCancelled && !bRhsFontFound) { // for legacy encodings, prompt for the font. MessageBox.Show("Select the font for the right-hand side encoding", cstrCaption); SetFontRhs(); } else if (unicodeValuesWindowToolStripMenuItem.Checked) { if (IsRhsLegacy && (m_nCodePageLegacyRhs == 0)) { EncConverters aECs = new EncConverters(true); try { m_nCodePageLegacyRhs = aECs.CodePage(textBoxSampleForward.Font.Name); } catch { } } m_formDisplayUnicodeNamesRhs.Initialize(IsRhsLegacy, textBoxSampleForward.Font, m_nCodePageLegacyRhs); } if (!bCodePointFormSizeHasBeenSetLhs) { Point ptLocation = new Point(Location.X + Bounds.Size.Width, Location.Y); m_formDisplayUnicodeNamesLhs.Location = ptLocation; } if (!bCodePointFormSizeHasBeenSetRhs) { Point ptLocation = new Point(m_formDisplayUnicodeNamesLhs.Location.X, m_formDisplayUnicodeNamesLhs.Location.Y + m_formDisplayUnicodeNamesLhs.Bounds.Size.Height); m_formDisplayUnicodeNamesRhs.Location = ptLocation; } if (!bLhsFontFound || !bRhsFontFound || !bCodePointFormSizeHasBeenSetLhs || !bCodePointFormSizeHasBeenSetRhs) { // initialize it with our clues string strPrefixHeader = cstrOpeningHeader + String.Format("v{1} on {2}.{0}; {3}{4}{0}; {5}{6};{7}{0}; {8}{9};{10}{0}{11}{0}{12}{0}{13}{0}", Environment.NewLine, Application.ProductVersion, DateTime.Now.ToShortDateString(), cstrConvTypeClue, m_eConvType.ToString(), cstrLhsFontClue, textBoxSample.Font.Name, textBoxSample.Font.Size, cstrRhsFontClue, textBoxSampleForward.Font.Name, textBoxSampleForward.Font.Size, BoundsClueString(cstrMainFormClue, Bounds), BoundsClueString(cstrCodePointFormClueLhs, m_formDisplayUnicodeNamesLhs.Bounds), BoundsClueString(cstrCodePointFormClueRhs, m_formDisplayUnicodeNamesRhs.Bounds)); strPrefixHeader += AddCodePageClue(cstrLhsCodePageClue, m_nCodePageLegacyLhs); strPrefixHeader += AddCodePageClue(cstrRhsCodePageClue, m_nCodePageLegacyRhs); strPrefixHeader += String.Format("{0}", Environment.NewLine); this.richTextBoxMapEditor.Text = strPrefixHeader + SkipPast0900Header; bModified = true; } // so it re-creates for this "new" map m_aEC = null; Program.Modified = bModified; return true; }
internal bool LoadProject(string strProjectName) { // get the EncConverter that should have been added above by 'AddNewProject' button EncConverters aECs = new EncConverters(); IEncConverter aEC = aECs[FullName(strProjectName)]; if( aEC != null ) { m_strEncConverterName = aEC.Name; m_strConverterSpec = aEC.ConverterIdentifier; ECAttributes aECAttrs = aECs.Attributes(aEC.Name,AttributeType.Converter); string strFontName = aECAttrs[SpellingFixerEC.cstrAttributeFontToUse]; string sFontSize = aECAttrs[SpellingFixerEC.cstrAttributeFontSizeToUse]; m_strWordBoundaryDelimiter = aECAttrs[SpellingFixerEC.cstrAttributeWordBoundaryDelimiter]; m_strNonWordCharacters = aECAttrs[SpellingFixerEC.cstrAttributeNonWordChars]; // new in 1.2 (so it might not exist) if( m_strNonWordCharacters == null ) m_strNonWordCharacters = SpellingFixerEC.GetDefaultPunctuation; // if this was added (without having been made on this system), then // these properties doesn't get added automatically. Must go to edit mode! if((strFontName == null) || (sFontSize == null) || (m_strWordBoundaryDelimiter == null) ) { MessageBox.Show("It looks like this project was added to the repository incorrectly because it's missing some important properties. You'll need to edit it again to set the font, and other values."); DoEdit(aECs, aEC, strProjectName, strFontName, sFontSize); // make the "Update" button the default button this.AcceptButton = this.buttonAddNewProject; return false; } float fFontSize = (float)0.0; try { fFontSize = (float)Convert.ToSingle(sFontSize); } catch {} if( (strFontName != "") && (fFontSize != 0.0) ) m_font = new Font(strFontName,fFontSize); m_bLegacy = (aEC.ConversionType == ConvType.Legacy_to_Legacy); if( m_bLegacy ) m_cp = aECs.CodePage(strFontName); RegistryKey keyLastSFProject = Registry.CurrentUser.CreateSubKey(cstrProjectMemoryKey); keyLastSFProject.SetValue(cstrProjectMostRecentProject,strProjectName); return true; } return false; }
private void SetFontRhs() { #if false // DEBUG fontDialog.Font = new Font("Arial Unicode MS", 12); #else fontDialog.Font = textBoxSampleForward.Font; if (fontDialog.ShowDialog() != DialogResult.Cancel) #endif { textBoxSampleForward.Font = fontDialog.Font; SetFontClue(cstrRhsFontClue, fontDialog.Font); // only do this if the lhs is *not* legacy and the rhs is if (unicodeValuesWindowToolStripMenuItem.Checked) { if (IsRhsLegacy) { EncConverters aECs = new EncConverters(true); try { m_nCodePageLegacyRhs = aECs.CodePage(fontDialog.Font.Name); } catch { } } m_formDisplayUnicodeNamesRhs.Initialize(IsRhsLegacy, textBoxSampleForward.Font, m_nCodePageLegacyRhs); } } }
public LinguaLinksImportDlg() { InitializeComponent(); // Copied from the LexImportWizard dlg Init (LexImportWizard.cs) // Ensure that we have the default encoding converter (to/from MS Windows Code Page // for Western European languages) SilEncConverters31.EncConverters encConv = new SilEncConverters31.EncConverters(); System.Collections.IDictionaryEnumerator de = encConv.GetEnumerator(); string sEncConvName = "Windows1252<>Unicode"; // REVIEW: SHOULD THIS NAME BE LOCALIZED? bool fMustCreateEncCnv = true; while (de.MoveNext()) { if ((string)de.Key != null && (string)de.Key == sEncConvName) { fMustCreateEncCnv = false; break; } } if (fMustCreateEncCnv) { try { encConv.AddConversionMap(sEncConvName, "1252", ECInterfaces.ConvType.Legacy_to_from_Unicode, "cp", "", "", ECInterfaces.ProcessTypeFlags.CodePageConversion); } catch (SilEncConverters31.ECException exception) { MessageBox.Show(exception.Message, ITextStrings.ksConvMapError, MessageBoxButtons.OK); } } }