private void StartParsingProcess(string folderName) { try { // start the process WaitingForm.ShowForm(this); var tc = TranslationManager.GetGridData(new DirectoryInfo(folderName)); if (tc == null) { WaitingForm.CloseForm(); MessageBox.Show(Resources.GridUI_No_stringtable_xml_files_found); return; } SuspendLayout(); tabControl1.Hide(); _gridUiHelper = new GridUiHelper(this); _gridUiHelper.Cleanup(); _gridUiHelper.ShowData(tc); ResumeLayout(); tabControl1.Show(); WaitingForm.CloseForm(); saveToolStripMenuItem.Enabled = true; findToolStripMenuItem.Enabled = true; addLanguageToolStripMenuItem.Enabled = true; statisticsToolStripMenuItem.Enabled = true; _configHelper.SetLastPathOfDataFiles(new DirectoryInfo(folderName)); _stringtablesLoaded = true; } catch (AggregateException ae) { foreach (var ex in ae.Flatten().InnerExceptions) { if (ex is DuplicateKeyException duplicateKeyException) { MessageBox.Show(string.Format(Resources.GridUI_Duplicate_key_found, duplicateKeyException.KeyName, duplicateKeyException.FileName, duplicateKeyException.EntryName), Resources.GridUI_Duplicate_key_found_title); } if (ex is GenericXmlException xmlException) { MessageBox.Show(string.Format(Resources.GridUI_Generic_xml_exception, xmlException.KeyName, xmlException.FileName, xmlException.EntryName), Resources.GridUI_Generic_xml_exception_title); } } } }
private void openModFolderToolStripMenuItem_Click(object sender, EventArgs e) { string curPath = ""; DirectoryInfo lastPath = ConfigHelper.GetLastPathOfDataFiles(); if (lastPath != null) { curPath = lastPath.FullName; } if (string.IsNullOrEmpty(curPath) == false) { folderBrowserDialog1.SelectedPath = curPath; } folderBrowserDialog1.ShowNewFolderButton = true; if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) { m_tbModFolder.Text = folderBrowserDialog1.SelectedPath; try { // start the process TranslationComponents tc = TranslationManager.GetGridData(new DirectoryInfo(folderBrowserDialog1.SelectedPath)); if (tc == null) { MessageBox.Show("No 'stringtable.xml' files found."); return; } _gridUiHelper = new GridUiHelper(this); _gridUiHelper.ShowData(tc); openModFolderToolStripMenuItem.Enabled = false; saveToolStripMenuItem.Enabled = true; addLanguageToolStripMenuItem.Enabled = true; statisticsToolStripMenuItem.Enabled = true; ConfigHelper.SetLastPathOfDataFiles(new DirectoryInfo(folderBrowserDialog1.SelectedPath)); } catch (DuplicateKeyException duplicateKeyException) { MessageBox.Show(String.Format("Duplicate Key found.\nName: \"{0}\" \nFile: \"{1}\"", duplicateKeyException.KeyName, duplicateKeyException.FileName), "Duplicate Key Error"); } } }
private void openModFolderToolStripMenuItem_Click(object sender, EventArgs e) { string curPath = ""; DirectoryInfo lastPath = ConfigHelper.GetLastPathOfDataFiles(); if (lastPath != null) { curPath = lastPath.FullName; } if (string.IsNullOrEmpty(curPath) == false) { folderBrowserDialog1.SelectedPath = curPath; } folderBrowserDialog1.ShowNewFolderButton = true; if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) { m_tbModFolder.Text = folderBrowserDialog1.SelectedPath; try { // start the process TranslationComponents tc = TranslationManager.GetGridData(new DirectoryInfo(folderBrowserDialog1.SelectedPath)); if (tc == null) { MessageBox.Show(Resources.GridUI_No_stringtable_xml_files_found); return; } _gridUiHelper = new GridUiHelper(this); _gridUiHelper.ShowData(tc); openModFolderToolStripMenuItem.Enabled = false; saveToolStripMenuItem.Enabled = true; addLanguageToolStripMenuItem.Enabled = true; statisticsToolStripMenuItem.Enabled = true; ConfigHelper.SetLastPathOfDataFiles(new DirectoryInfo(folderBrowserDialog1.SelectedPath)); } catch (DuplicateKeyException duplicateKeyException) { MessageBox.Show(String.Format(Resources.GridUI_Duplicate_key_found, duplicateKeyException.KeyName, duplicateKeyException.FileName, duplicateKeyException.EntryName), Resources.GridUI_Duplicate_key_found_title); } catch (GenericXmlException xmlException) { MessageBox.Show(String.Format(Resources.GridUI_Generic_xml_exception, xmlException.KeyName, xmlException.FileName, xmlException.EntryName), Resources.GridUI_Generic_xml_exception_title); } } }