/// <summary> /// A selection has been made in the combo box. Load the section /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cbSections_SelectedIndexChanged(object sender, EventArgs e) { // The event gets fired, when we fill the combo and we don't have a culture yet. if (culture == null) { return; } // Save previous section saveToolStripMenuItem_Click(null, new EventArgs()); string secs = (string)cbSections.SelectedItem; XmlHandler.InitializeXmlValues(secs); originalTranslations = LoadSection(null); LoadTranslation(); }
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(); }