private void LoadTranslation() { var dialogResult = LoadFileDialog.ShowDialog(this); if (dialogResult == DialogResult.OK) { if (!CloseAllDocuments()) { return; } var workForm = new WorkingForm(dockTheme, "Cargar traducción", true); TranslationProject project = null; workForm.DoWork += (sender, args) => { var worker = sender as BackgroundWorker; try { project = TranslationProject.Load(LoadFileDialog.FileName, _pluginManager, worker); } catch (UserCancelException e) { args.Cancel = true; } catch (Exception e) { MessageBox.Show(e.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }; workForm.ShowDialog(this); if (workForm.Cancelled) { return; } _project = project; _currentFile = null; _explorer.LoadTree(_project.FileContainers); _project.Save(); Text = $"Translation Framework 2.0 - {_project.Game.Name} - {_project.WorkPath}"; tsbExportProject.Enabled = true; mniFileExport.Enabled = true; tsbSearchInFiles.Enabled = true; mniEditSearchInFiles.Enabled = true; mniBulkTextsExport.Enabled = true; mniBulkTextsImport.Enabled = true; mniBulkImagesExport.Enabled = true; mniBulkImagesImport.Enabled = true; } }
private void CreateNewTranslation() { var infos = _pluginManager.GetAllGames(); var form = new NewProjectSettings(dockTheme, infos); var formResult = form.ShowDialog(this); if (formResult == DialogResult.Cancel) { return; } if (!CloseAllDocuments()) { return; } var game = _pluginManager.GetGame(form.SelectedGame); var workFolder = form.WorkFolder; var gameFolder = form.GameFolder; if (Directory.Exists(workFolder)) { var files = Directory.GetFiles(workFolder); var directories = Directory.GetDirectories(workFolder); if (files.Length + directories.Length > 0) { #if DEBUG PathHelper.DeleteDirectory(workFolder); #else MessageBox.Show($"La carpeta {workFolder} no está vacía. Debes elegir una carpeta vacía.", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; #endif } } else { Directory.CreateDirectory(workFolder); } var project = new TranslationProject(game, gameFolder, workFolder); var workForm = new WorkingForm(dockTheme, "Nueva traducción"); workForm.DoWork += (sender, args) => { var worker = sender as BackgroundWorker; try { project.ReadTranslationFiles(worker); worker.ReportProgress(-1, "FINALIZADO"); } catch (UserCancelException e) { args.Cancel = true; worker.ReportProgress(-1, "Eliminando ficheros..."); PathHelper.DeleteDirectory(workFolder); worker.ReportProgress(-1, "Terminado"); } #if !DEBUG catch (Exception e) { worker.ReportProgress(0, $"ERROR: {e.Message}\n{e.StackTrace}"); } #endif }; workForm.ShowDialog(this); if (workForm.Cancelled) { return; } _project = project; _explorer.LoadTree(_project.FileContainers); _currentFile = null; _project.Save(); Text = $"Translation Framework 2.0 - {_project.Game.Name} - {_project.WorkPath}"; tsbExportProject.Enabled = true; mniFileExport.Enabled = true; tsbSearchInFiles.Enabled = true; mniEditSearchInFiles.Enabled = true; mniBulkTextsExport.Enabled = true; mniBulkTextsImport.Enabled = true; mniBulkImagesExport.Enabled = true; mniBulkImagesImport.Enabled = true; }