コード例 #1
0
        internal static LanguageFileContent LoadSelectedLanguage(string filename)
        {
            LanguageFileContent result = null;

            if (string.IsNullOrEmpty(filename) || !File.Exists(filename))
            {
                return(result);
            }

            try
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(filename);

                XmlNodeList nodes = doc.GetElementsByTagName(Constants.LANGUAGE);
                if (nodes.Count > 0)
                {
                    result = new LanguageFileContent(filename, nodes[0]);
                    CreateChildEntries(nodes[0], ref result);
                }
            }
            catch (Exception ex)
            {
                string msg = string.Format(Messages.MSG_ERROR_0_DURING_LOADING_LANGUAGES, ex.Message);
                Messenger.AddError(msg, ex);
                MessageBox.Show(View.ParentForm, msg, Core.Messages.MSG_TITLE_ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(result);
        }
コード例 #2
0
 private static void CreateChildEntries(XmlNode node, ref LanguageFileContent content)
 {
     foreach (XmlNode childNode in node.ChildNodes)
     {
         content.Entries.Add(new LanguageEntry(childNode));
         CreateChildEntries(childNode, ref content);
     }
 }
コード例 #3
0
        private void cbTransToolLanguages_SelectedIndexChanged(object sender, EventArgs e)
        {
            string filename             = GetFilePathByName(cbTransToolLanguages.SelectedItem);
            LanguageFileContent content = TranslationController.LoadSelectedLanguage(filename);

            if (content != null)
            {
                SetEnabledOfAllControls(cbTransToolEdit.Checked);
                LanguageFileContent = content;
            }
            else
            {
                SetEnabledOfAllControls(false);
            }
        }
コード例 #4
0
        private void cbTransToolLanguages_SelectedIndexChanged(object sender, EventArgs e)
        {
            string filename = GetFilePathByName(cbTransToolLanguages.SelectedItem);
            LanguageFileContent content = TranslationController.LoadSelectedLanguage(filename);

            if (content != null)
            {
                SetEnabledOfAllControls(cbTransToolEdit.Checked);
                LanguageFileContent = content;
            }
            else
            {
                SetEnabledOfAllControls(false);
            }
        }
コード例 #5
0
        internal static LanguageFileContent LoadSelectedLanguage(string filename)
        {
            LanguageFileContent result = null;

            if (string.IsNullOrEmpty(filename) || !File.Exists(filename))
                return result;

            try
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(filename);

                XmlNodeList nodes = doc.GetElementsByTagName(Constants.LANGUAGE);
                if (nodes.Count > 0)
                {
                    result = new LanguageFileContent(filename, nodes[0]);
                    CreateChildEntries(nodes[0], ref result);
                }
            }
            catch (Exception ex)
            {
                string msg = string.Format(Messages.MSG_ERROR_0_DURING_LOADING_LANGUAGES, ex.Message);
                Messenger.AddError(msg, ex);
                MessageBox.Show(View.ParentForm, msg, Core.Messages.MSG_TITLE_ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return result;
        }
コード例 #6
0
 private static void CreateChildEntries(XmlNode node, ref LanguageFileContent content)
 {
     foreach (XmlNode childNode in node.ChildNodes)
     {
         content.Entries.Add(new LanguageEntry(childNode));
         CreateChildEntries(childNode, ref content);
     }
 }