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 MockWorkingForms() { WorkingForm workingForm; DesignShopWorkingForm designShopWorkingForm; // We'll add 5 workingforms to the saved designshop // The fourth workingform will act as the current workingform for (var i = 1; i < 6; i++) { workingForm = new WorkingForm() { Description = $"Workingform {i}" }; _applicationTestDbContext.WorkingForm.Add(workingForm); designShopWorkingForm = new DesignShopWorkingForm() { DesignShop = _designShopWithCurrentWorkingForm, WorkingForm = workingForm, Order = i }; _applicationTestDbContext.DesignShopWorkingForm.Add(designShopWorkingForm); if (i == 4) { _currentWorkingForm = designShopWorkingForm; } } _designShopWithCurrentWorkingForm.CurrentDesignShopWorkingForm = _currentWorkingForm; _applicationTestDbContext.SaveChanges(); }
private void SearchInFiles() { if (_project != null) { var form = new SearchInFilesForm(dockTheme); var formResult = form.ShowDialog(this); if (formResult == DialogResult.Cancel) { return; } var searchString = form.SearchString; var workForm = new WorkingForm(dockTheme, "Buscar en ficheros", true); IList <Tuple <TranslationFileContainer, TranslationFile> > filesFound = null; workForm.DoWork += (sender, args) => { var worker = sender as BackgroundWorker; try { filesFound = _project.SearchInFiles(searchString, worker); worker.ReportProgress(-1, "FINALIZADO"); } catch (UserCancelException e) { args.Cancel = true; } catch (Exception e) { worker.ReportProgress(0, $"ERROR: {e.Message}"); } }; workForm.ShowDialog(this); if (workForm.Cancelled) { return; } _searchResults.LoadItems(searchString, filesFound); if (_searchResults.VisibleState == DockState.DockBottomAutoHide) { dockPanel.ActiveAutoHideContent = _searchResults; } } }
private void ImportFromPoFiles() { if (_project != null) { FolderBrowserDialog.Description = "Selecciona la carpeta raiz con los ficheros Po"; FolderBrowserDialog.ShowNewFolderButton = false; var formResult = FolderBrowserDialog.ShowDialog(this); if (formResult == DialogResult.Cancel) { return; } var workForm = new WorkingForm(dockTheme, "Importar Po"); workForm.DoWork += (sender, args) => { var worker = sender as BackgroundWorker; try { _project.ImportPo(FolderBrowserDialog.SelectedPath, worker); worker.ReportProgress(-1, "FINALIZADO"); worker.ReportProgress(-1, string.Empty); } catch (UserCancelException e) { args.Cancel = true; } #if !DEBUG catch (Exception e) { worker.ReportProgress(0, $"ERROR: {e.Message}"); } #endif }; workForm.ShowDialog(this); } }
private void ImportImages() { if (_project != null) { if (_currentFile != null) { if (_currentFile.NeedSaving) { var result = MessageBox.Show( "Es necesario guardar los cambios antes de continuar.\n¿Quieres guardarlos?", "Guardar cambios", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.No) { return; } if (result == DialogResult.Yes) { _currentFile.SaveChanges(); } } } FolderBrowserDialog.Description = "Selecciona la carpeta raiz con las imágenes"; FolderBrowserDialog.ShowNewFolderButton = false; var formResult = FolderBrowserDialog.ShowDialog(this); if (formResult == DialogResult.Cancel) { return; } var openFile = _currentFile; ExplorerOnFileChanged(null); var workForm = new WorkingForm(dockTheme, "Importar Imágenes"); workForm.DoWork += (sender, args) => { var worker = sender as BackgroundWorker; try { _project.ImportImages(FolderBrowserDialog.SelectedPath, worker); worker.ReportProgress(-1, "FINALIZADO"); worker.ReportProgress(-1, string.Empty); } catch (UserCancelException e) { args.Cancel = true; } #if !DEBUG catch (Exception e) { worker.ReportProgress(0, $"ERROR: {e.Message}"); } #endif }; workForm.ShowDialog(this); ExplorerOnFileChanged(openFile); } }
private void ExportTexts() { if (_project != null) { if (_currentFile != null) { if (_currentFile.NeedSaving) { var result = MessageBox.Show( "Es necesario guardar los cambios antes de continuar.\n¿Quieres guardarlos?", "Guardar cambios", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.No) { return; } if (result == DialogResult.Yes) { _currentFile.SaveChanges(); } } } FolderBrowserDialog.Description = "Selecciona la carpeta en la que se guardarán los ficheros Po"; FolderBrowserDialog.ShowNewFolderButton = true; var formResult = FolderBrowserDialog.ShowDialog(this); if (formResult == DialogResult.Cancel) { return; } var workForm = new WorkingForm(dockTheme, "Exportar a Po"); workForm.DoWork += (sender, args) => { var worker = sender as BackgroundWorker; #if !DEBUG try { #endif _project.ExportPo(FolderBrowserDialog.SelectedPath, worker); worker.ReportProgress(-1, "FINALIZADO"); worker.ReportProgress(-1, string.Empty); worker.ReportProgress(-1, $"Los ficheros exportados están en {FolderBrowserDialog.SelectedPath}"); #if !DEBUG } catch (UserCancelException e) { args.Cancel = true; } catch (Exception e) { worker.ReportProgress(0, $"ERROR: {e.Message}"); } #endif }; workForm.ShowDialog(this); } }
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; }
private void ExportProject() { if (_project != null) { if (_currentFile != null) { if (_currentFile.NeedSaving) { var result = MessageBox.Show( "Es necesario guardar los cambios antes de continuar.\n¿Quieres guardarlos?", "Guardar cambios", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.No) { return; } if (result == DialogResult.Yes) { _currentFile.SaveChanges(); } } } var form = new ExportProjectForm(dockTheme, _project.FileContainers); var formResult = form.ShowDialog(this); if (formResult == DialogResult.Cancel) { return; } var selectedContainers = form.SelectedContainers; var options = form.Options; var workForm = new WorkingForm(dockTheme, "Exportar traducción"); workForm.DoWork += (sender, args) => { var worker = sender as BackgroundWorker; try { _project.Export(selectedContainers, options, worker); worker.ReportProgress(-1, "FINALIZADO"); worker.ReportProgress(-1, string.Empty); worker.ReportProgress(-1, $"Los ficheros exportados están en {_project.ExportFolder}"); } catch (UserCancelException e) { args.Cancel = true; } #if !DEBUG catch (Exception e) { worker.ReportProgress(0, $"ERROR: {e.Message}"); } #endif }; workForm.ShowDialog(this); } }
public void FillWorkerID() { WorkingForm.GetWorkerID(cboWorkerID); }
public static void ActivateReflector(MemberHelpInfo hi) { string assemblyPath = hi.get_AssemblyLocation(); if (ReflectorPath == null) { MessageBox.Show("Unable to invoke .NET Reflector (is it installed?)", "LINQPad", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { if (!IsReflectorRunning()) { WorkingForm.FlashForm("Working...", 0x5dc); } new Thread(delegate { try { if (((!string.IsNullOrEmpty(assemblyPath) && File.Exists(assemblyPath)) && !assemblyPath.ToLowerInvariant().Contains(@"\microsoft\framework\")) && !assemblyPath.ToLowerInvariant().Contains(@"\gac_")) { bool flag; string arguments = "/share \"" + assemblyPath + "\""; ProcessStartInfo startInfo = new ProcessStartInfo(ReflectorPath, arguments) { WorkingDirectory = Path.GetDirectoryName(ReflectorPath) }; if (flag = IsReflectorRunning()) { ShowReflectorWindow(); } Process process = Process.Start(startInfo); try { if (!flag) { if (!process.WaitForInputIdle(0x3a98)) { return; } Thread.Sleep(200); } else if (!process.WaitForExit(0x3a98)) { return; } } catch { } finally { if (process != null) { process.Dispose(); } } } NavigateReflector(hi.get_ReflectorCodeUri()); Thread.Sleep(100); ShowReflectorWindow(); } catch (Exception exception) { MessageBox.Show("Unable to invoke .NET Reflector: " + exception.Message); } }) { Name = "Reflector Invoker", IsBackground = true }.Start(); } }