Exemple #1
0
 public void SafeRemoveInputTmxFile(InputTmxFile tmxFile)
 {
     Application.Current.Dispatcher.Invoke(new Action(() =>
     {
         InputTmxFiles.Remove(tmxFile);
     }));
 }
Exemple #2
0
        public void CreateProcessingSteps()
        {
            ProcessingSteps.Clear();
            ProcessingContext context = new ProcessingContext();

            context.Settings = Settings;
            InputTmxFile existingTmtmxFile = null;

            if (Mode == WizardMode.CleanExistingTranslationMemory)
            {
                existingTmtmxFile = new InputTmxFile(new TmxFile(context.GetTempTmxFile()));
                existingTmtmxFile.CleanTmxFile = new TmxFile(context.GetTempTmxFile());

                // export TM
                ProcessingSteps.Add(new ExportStudioTmStep(InputTranslationMemory.TranslationMemory, existingTmtmxFile.TmxFile));
                // strip workbench TUs
                ProcessingSteps.Add(new StripWorkbenchTusStep(InputTranslationMemory.TranslationMemory.Name, existingTmtmxFile.TmxFile, existingTmtmxFile.CleanTmxFile));
            }

            foreach (InputTmxFile inputTmxFile in InputTmxFiles)
            {
                // clean TMX
                inputTmxFile.CleanTmxFile = new TmxFile(context.GetTempTmxFile());
                ProcessingSteps.Add(new CleanWorkbenchTmxStep(inputTmxFile.TmxFile, inputTmxFile.CleanTmxFile, null));
            }

            TranslationMemoryReference outputTranslationMemory;

            if (OutputMethod == OutputMethod.CreateNewTranslationMemory)
            {
                outputTranslationMemory = new TranslationMemoryReference {
                    FilePath = NewOutputTranslationMemoryFilePath
                };
                // create output TM
                ProcessingSteps.Add(new CreateStudioTmStep(outputTranslationMemory, SourceLanguage, TargetLanguage, InputTranslationMemory));
            }
            else
            {
                outputTranslationMemory = OutputTranslationMemory;
            }

            foreach (InputTmxFile inputTmxFile in InputTmxFiles)
            {
                // import clean TMX
                ProcessingSteps.Add(new ImportStudioTmStep(outputTranslationMemory, Path.GetFileName(inputTmxFile.TmxFile.FilePath), inputTmxFile.CleanTmxFile));
            }

            if (existingTmtmxFile != null)
            {
                ProcessingSteps.Add(new ImportStudioTmStep(outputTranslationMemory, Path.GetFileName(InputTranslationMemory.FilePath), existingTmtmxFile.CleanTmxFile));
            }

            ProcessingSteps.Add(new DeleteTempFilesStep());

            // set context of all steps
            foreach (ProcessingStep step in ProcessingSteps)
            {
                step.Context = context;
            }
        }
Exemple #3
0
        public void AddTmxInputFile()
        {
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.Title       = "Select TMX files to clean up";
            dlg.DefaultExt  = ".tmx";
            dlg.Filter      = "TRADOS Workbench TMX (.tmx)|*.tmx";
            dlg.Multiselect = true;

            if (dlg.ShowDialog() == true)
            {
                string[] tmxFiles = dlg.FileNames;
                _worker         = new BackgroundWorker();
                _worker.DoWork += (sender, e) =>
                {
                    foreach (string fileName in tmxFiles)
                    {
                        InputTmxFile tmxFile = new InputTmxFile(new TmxFile(fileName));

                        try
                        {
                            SafeAddInputTmxFile(tmxFile);
                            tmxFile.TmxFile.Detect();
                        }
                        catch (Exception ex)
                        {
                            DisplayError(ex);
                            SafeRemoveInputTmxFile(tmxFile);
                        }
                    }
                };
                _worker.RunWorkerCompleted += (sender, e) =>
                {
                };

                _worker.RunWorkerAsync();
            }
        }