/// <summary> /// Load the section /// </summary> /// <param name="languageID"></param> /// <returns></returns> private DataTable LoadSection(string languageID) { return(XmlHandler.Load(languageID, out originalMapping)); }
private void InvokeXml() { string tmpFileName = XmlHandler.BuildFileName(null, false); folderBrowserDialog1.Description = "Please select a path where [" + tmpFileName + "] can be found:"; folderBrowserDialog1.SelectedPath = Application.StartupPath; folderBrowserDialog1.RootFolder = Environment.SpecialFolder.Desktop; if (folderBrowserDialog1.ShowDialog() == DialogResult.Cancel) { return; } languagePath = folderBrowserDialog1.SelectedPath; // check if selected path contains the default translation file // if not show folderbrowserdlg until user cancels or selects a path that contains it while (!System.IO.File.Exists(System.IO.Path.Combine(languagePath, tmpFileName))) { MessageBox.Show( "The file [" + tmpFileName + "] could not be found.\nThe LanguageTool does not work without it.", "MPLanguageTool -- Error", MessageBoxButtons.OK, MessageBoxIcon.Error); if (folderBrowserDialog1.ShowDialog() == DialogResult.Cancel) { return; } languagePath = folderBrowserDialog1.SelectedPath; } switch (LangType) { case StringsType.MpTagThat: case StringsType.MediaPortal_II: FillSectionsCombbo(); cbSections.Enabled = true; string secs = (string)cbSections.SelectedItem; XmlHandler.InitializeXmlValues(secs); break; default: XmlHandler.InitializeXmlValues(); break; } // check if selected path contains a valid default translation file originalTranslations = LoadSection(null); // if not show folderbrowserdlg until user cancels or selects a path with a valid one while (originalTranslations == null) { MessageBox.Show("The file [" + tmpFileName + "] is invalid.\nPlease select a correct working one.", "MPLanguageTool -- Error", MessageBoxButtons.OK, MessageBoxIcon.Error); if (folderBrowserDialog1.ShowDialog() == DialogResult.Cancel) { return; } languagePath = folderBrowserDialog1.SelectedPath; originalTranslations = XmlHandler.Load(null, out originalMapping); } gv.Dock = DockStyle.None; gv2.Dock = DockStyle.Fill; gv2.Visible = true; DisableMenuItems(); SelectCulture dlg = new SelectCulture(); if (dlg.ShowDialog() != DialogResult.OK) { return; } culture = dlg.GetSelectedCulture(); tmpFileName = XmlHandler.BuildFileName(culture.Name, false); Text = "MPLanguageTool -- Current language: " + culture.NativeName + " -- File: " + tmpFileName; ToolStripText("Loading \"" + tmpFileName + "\"..."); LoadTranslation(); }