public InstallPUACharacters ( string filename ) : void | ||
filename | string | Our XML file containing our PUA Defintions |
Результат | void |
private static void CreateAndInstallAA6B(string sCustomCharsFile) { using (var writer = new StreamWriter(sCustomCharsFile)) { writer.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); writer.WriteLine("<PuaDefinitions>"); writer.WriteLine("<CharDef code=\"AA6B\" data=\"MYANMAR LETTER KHAMTI NA;Ll;0;L;;;;;N;;;;;\"/>"); writer.WriteLine("</PuaDefinitions>"); writer.Close(); } var inst = new PUAInstaller(); inst.InstallPUACharacters(sCustomCharsFile); }
/// <summary> /// Migrate and/or install any custom character definitions found. /// </summary> public void Run() { // Read any existing custom character data. var customCharsFile = CharEditorWindow.CustomCharsFile; if (File.Exists(customCharsFile)) { ReadCustomCharData(customCharsFile); m_fDirty = false; } // If there is any old custom character data (from FieldWorks 6.0 or earlier), read it // as well, adding any new characters found. string[] files = GetLangFiles(); if (files != null) { foreach (string filename in files) { // I don't really trust Microsoft's pattern matching for files, so make sure we // don't get any edit backup files or the like. if (!filename.ToLowerInvariant().EndsWith(".xml")) { continue; } try { // Surprisingly, the read method is the same even though the details of // the two XML files are quite different apart from the CharDef elements. ReadCustomCharData(filename); } catch { // ignore any exceptions. we'll just skip that file. } } } if (m_fDirty) { WriteCustomCharData(customCharsFile); } // Now, if we have any custom character data, install it! if (File.Exists(customCharsFile)) { var inst = new PUAInstaller(); inst.InstallPUACharacters(customCharsFile); } }
private static void RestoreIcuData(string sCustomCharsFile, string sCustomCharsBackup) { if (File.Exists(sCustomCharsFile)) { File.Delete(sCustomCharsFile); } if (File.Exists(sCustomCharsBackup)) { File.Move(sCustomCharsBackup, sCustomCharsFile); } InitializeIcuData(); if (File.Exists(sCustomCharsFile)) { var inst = new PUAInstaller(); inst.InstallPUACharacters(sCustomCharsFile); } }
private static void CreateAndInstallOurCustomChars(string sCustomCharsFile) { using (var writer = new StreamWriter(sCustomCharsFile)) { writer.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); writer.WriteLine("<PuaDefinitions>"); writer.WriteLine("<CharDef code=\"E000\" data=\"MY SPECIAL CHARACTER;Ll;0;R;;;;;N;;;E001;;\"/>"); writer.WriteLine("<CharDef code=\"E001\" data=\"MY UPPERCASE CHARACTER;Lu;0;R;;;;;N;;;;E000;\"/>"); writer.WriteLine("<CharDef code=\"" + kChar3S + "\" data=\"NEW PUNCTUATION MARK;Po;0;ON;;;;;N;;;;;\"/>"); writer.WriteLine("<CharDef code=\"DDDDD\" data=\"NEW DIGIT NINE;Nd;0;EN;;9;9;9;N;;;;;\"/>"); writer.WriteLine("</PuaDefinitions>"); writer.Close(); } var inst = new PUAInstaller(); inst.InstallPUACharacters(sCustomCharsFile); }
/// <summary> /// Migrate and/or install any custom character definitions found. /// </summary> public void Run() { // Read any existing custom character data. var customCharsFile = CharEditorWindow.CustomCharsFile; if (File.Exists(customCharsFile)) { ReadCustomCharData(customCharsFile); m_fDirty = false; } // If there is any old custom character data (from FieldWorks 6.0 or earlier), read it // as well, adding any new characters found. string[] files = GetLangFiles(); if (files != null) { foreach (string filename in files) { // I don't really trust Microsoft's pattern matching for files, so make sure we // don't get any edit backup files or the like. if (!filename.ToLowerInvariant().EndsWith(".xml")) continue; try { // Surprisingly, the read method is the same even though the details of // the two XML files are quite different apart from the CharDef elements. ReadCustomCharData(filename); } catch { // ignore any exceptions. we'll just skip that file. } } } if (m_fDirty) WriteCustomCharData(customCharsFile); // Now, if we have any custom character data, install it! if (File.Exists(customCharsFile)) { var inst = new PUAInstaller(); inst.InstallPUACharacters(customCharsFile); } }
private static void RestoreIcuData(string sCustomCharsFile, string sCustomCharsBackup) { if (File.Exists(sCustomCharsFile)) File.Delete(sCustomCharsFile); if (File.Exists(sCustomCharsBackup)) File.Move(sCustomCharsBackup, sCustomCharsFile); InitializeIcuData(); if (File.Exists(sCustomCharsFile)) { var inst = new PUAInstaller(); inst.InstallPUACharacters(sCustomCharsFile); } }
private static void CreateAndInstallAA6B(string sCustomCharsFile) { using (var writer = new StreamWriter(sCustomCharsFile)) { writer.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); writer.WriteLine("<PuaDefinitions>"); writer.WriteLine("<CharDef code=\"AA6B\" data=\"MYANMAR LETTER KHAMTI NA;Ll;0;L;;;;;N;;;;;\"/>"); writer.WriteLine("</PuaDefinitions>"); writer.Close(); } var inst = new PUAInstaller(); inst.InstallPUACharacters(sCustomCharsFile); }
private static void CreateAndInstallOurCustomChars(string sCustomCharsFile) { using (var writer = new StreamWriter(sCustomCharsFile)) { writer.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); writer.WriteLine("<PuaDefinitions>"); writer.WriteLine("<CharDef code=\"E000\" data=\"MY SPECIAL CHARACTER;Ll;0;R;;;;;N;;;E001;;\"/>"); writer.WriteLine("<CharDef code=\"E001\" data=\"MY UPPERCASE CHARACTER;Lu;0;R;;;;;N;;;;E000;\"/>"); writer.WriteLine("<CharDef code=\"" + kChar3S + "\" data=\"NEW PUNCTUATION MARK;Po;0;ON;;;;;N;;;;;\"/>"); writer.WriteLine("<CharDef code=\"DDDDD\" data=\"NEW DIGIT NINE;Nd;0;EN;;9;9;9;N;;;;;\"/>"); writer.WriteLine("</PuaDefinitions>"); writer.Close(); } var inst = new PUAInstaller(); inst.InstallPUACharacters(sCustomCharsFile); }
private void m_btnSave_Click(object sender, EventArgs e) { if (m_dictCustomChars.Count == 0) return; var customCharsFile = CustomCharsFile; string oldFile = null; if (File.Exists(customCharsFile)) { oldFile = customCharsFile + "-bak"; if (!m_fBakFileCreated) { if (File.Exists(oldFile)) File.Delete(oldFile); File.Move(customCharsFile, oldFile); m_fBakFileCreated = true; } } // Loop until you succeed or cancel. for (;;) { try { using (var writer = new StreamWriter(customCharsFile, false, Encoding.UTF8)) { writer.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); writer.WriteLine("<PuaDefinitions>"); foreach (var spec in m_dictCustomChars.Values) { writer.Write("<CharDef code=\""); writer.Write(spec.CodePoint); writer.Write("\" data=\""); for (int i = 0; i < spec.Data.Length; ++i) { if (!String.IsNullOrEmpty(spec.Data[i])) writer.Write(XmlUtils.MakeSafeXmlAttribute(spec.Data[i])); if (i + 1 < spec.Data.Length) writer.Write(";"); } writer.WriteLine("\"/>"); } writer.WriteLine("</PuaDefinitions>"); } var inst = new PUAInstaller(); inst.InstallPUACharacters(customCharsFile); if (!String.IsNullOrEmpty(oldFile) && File.Exists(oldFile)) File.Delete(oldFile); m_fBakFileCreated = false; m_fDirty = false; return; } catch { DialogResult res = MessageBox.Show(Properties.Resources.ksErrorOccurredInstalling, Properties.Resources.ksMsgHeader, MessageBoxButtons.RetryCancel); if (res == DialogResult.Cancel) return; } } }
private void m_btnSave_Click(object sender, EventArgs e) { if (m_dictCustomChars.Count == 0) { return; } var customCharsFile = CustomCharsFile; string oldFile = null; if (File.Exists(customCharsFile)) { oldFile = customCharsFile + "-bak"; if (!m_fBakFileCreated) { if (File.Exists(oldFile)) { File.Delete(oldFile); } File.Move(customCharsFile, oldFile); m_fBakFileCreated = true; } } // Loop until you succeed or cancel. for (;;) { try { using (var writer = new StreamWriter(customCharsFile, false, Encoding.UTF8)) { writer.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); writer.WriteLine("<PuaDefinitions>"); foreach (var spec in m_dictCustomChars.Values) { writer.Write("<CharDef code=\""); writer.Write(spec.CodePoint); writer.Write("\" data=\""); for (int i = 0; i < spec.Data.Length; ++i) { if (!String.IsNullOrEmpty(spec.Data[i])) { writer.Write(XmlUtils.MakeSafeXmlAttribute(spec.Data[i])); } if (i + 1 < spec.Data.Length) { writer.Write(";"); } } writer.WriteLine("\"/>"); } writer.WriteLine("</PuaDefinitions>"); } var inst = new PUAInstaller(); inst.InstallPUACharacters(customCharsFile); if (!String.IsNullOrEmpty(oldFile) && File.Exists(oldFile)) { File.Delete(oldFile); } m_fBakFileCreated = false; m_fDirty = false; return; } catch (IcuLockedException) { var res = MessageBox.Show(Properties.Resources.ksErrorOccurredInstalling, Properties.Resources.ksMsgHeader, MessageBoxButtons.RetryCancel); if (res == DialogResult.Cancel) { return; } } catch (Exception ex) { var res = MessageBox.Show(ex.Message, Properties.Resources.ksMsgHeader, MessageBoxButtons.RetryCancel); if (res == DialogResult.Cancel) { return; } } } }