// Displays only the cumstom templates (except 'Default' and 'SDL Trados' templates which are not custom) private void DisplayCustomTemplates(ComboBox cb, CellEditEventArgs e) { if (_controller?.ProjectTemplates == null || _controller?.ProjectTemplates.Count() <= 0) { _messageBoxService.ShowWarningMessage(PluginResources.ImportCustomTemplate_Message, string.Empty); e.Cancel = true; } else { foreach (var projectTemplate in _controller.ProjectTemplates) { if (!projectTemplate.Name.Equals("Default") && !projectTemplate.Name.Equals("SDL Trados")) { cb.Items.Add(projectTemplate); } } if (cb.Items.Count > 0) { cb.SelectedIndex = 0; } else { _messageBoxService.ShowWarningMessage(PluginResources.ImportCustomTemplate_Message, string.Empty); e.Cancel = true; } e.Control = cb; } }
protected override void Execute() { _messageBoxService = new MessageBoxService(); Utils.EnsureApplicationResources(); var returnService = new ReturnPackageService(); var returnPackage = returnService.GetReturnPackage(); if (!string.IsNullOrEmpty(returnPackage?.Item2)) { _messageBoxService.ShowWarningMessage(returnPackage.Item2, "Warning"); } else if (returnPackage?.Item1?.FileBasedProject != null && returnPackage?.Item1?.TargetFiles.Count > 0) { var xliffFiles = returnPackage?.Item1?.TargetFiles?.Any(file => file.Name.EndsWith(".sdlxliff")); if (xliffFiles.Value) { var window = new ReturnPackageMainWindow(returnPackage?.Item1); window.ShowDialog(); } else { _messageBoxService.ShowWarningMessage("The target file(s) has already been returned. In order to repeat the process, you need to revert to .sdlxliff(s) from the Files view.", "Warning"); } } }
public StudioAnalysisReport(string pathToXmlReport) { try { _messageBoxService = new MessageBoxService(); var reportsPath = Path.GetDirectoryName(pathToXmlReport); var reportName = Path.GetFileName(pathToXmlReport); var directoryInfo = new DirectoryInfo(reportsPath); if (directoryInfo != null) { var fileName = Path.GetFileNameWithoutExtension(reportName); var fileInfo = directoryInfo .GetFiles() .OrderByDescending(f => f.LastWriteTime) .FirstOrDefault(n => n.Name.StartsWith(fileName)); ReportFile = fileInfo != null ? fileInfo.FullName : pathToXmlReport; if (!File.Exists(ReportFile)) { _messageBoxService.ShowWarningMessage($"Analysis report not found for file {ReportFile}", string.Empty); } var langPairCode = GetLanguagePairCode(fileName); var xDoc = XDocument.Load(ReportFile); AnalyzedFiles = from f in xDoc.Root.Descendants("file") select new AnalyzedFile($"{langPairCode}_{f.Attribute("name").Value}", f.Attribute("guid").Value) { Results = from r in f.Element("analyse").Elements() select new BandResult(r.Name.LocalName) { Segments = r.Attribute("segments") != null?int.Parse(r.Attribute("segments").Value) : 0, Words = r.Attribute("words") != null?int.Parse(r.Attribute("words").Value) : 0, Characters = r.Attribute("characters") != null?int.Parse(r.Attribute("characters").Value) : 0, Placeables = r.Attribute("placeables") != null?int.Parse(r.Attribute("placeables").Value) : 0, Tags = r.Attribute("tags") != null?int.Parse(r.Attribute("tags").Value) : 0, Min = r.Attribute("min") != null?int.Parse(r.Attribute("min").Value) : 0, Max = r.Attribute("max") != null?int.Parse(r.Attribute("max").Value) : 0, FullRecallWords = r.Attribute("fullRecallWords") != null?int.Parse(r.Attribute("fullRecallWords").Value) : 0, } }; if (!AnalyzedFiles.Any()) { _messageBoxService.ShowWarningMessage($"No analyzed files in the report!", string.Empty); } } } catch (Exception ex) { Log.Logger.Error($"StudioAnalysisReport: {ex.Message}\n {ex.StackTrace}"); throw; } }
public void PrepareAnalysisReport(string pathToXmlReport) { try { var reportsPath = Path.GetDirectoryName(pathToXmlReport); if (reportsPath == null) { return; } var reportName = Path.GetFileName(pathToXmlReport); var directoryInfo = new DirectoryInfo(reportsPath); { var fileName = Path.GetFileNameWithoutExtension(reportName); var fileInfo = directoryInfo.GetFiles().OrderByDescending(f => f.LastWriteTime).FirstOrDefault(n => n.Name.StartsWith(fileName, StringComparison.CurrentCultureIgnoreCase) && n.Name.EndsWith(".xml", StringComparison.InvariantCultureIgnoreCase)); _reportFile = fileInfo != null ? fileInfo.FullName : pathToXmlReport; if (!File.Exists(_reportFile)) { _messageBoxService.ShowWarningMessage(string.Format(PluginResources.ReportNotFound_Message, _reportFile), string.Empty); } var langPairCode = GetLanguagePairCode(fileName); var xDoc = XDocument.Load(_reportFile); _analyzedFiles = from f in xDoc.Root.Descendants("file") select new AnalyzedFile($"{langPairCode}_{f.Attribute("name").Value}", f.Attribute("guid").Value) { Results = from r in f.Element("analyse").Elements() select new BandResult(r.Name.LocalName) { Segments = r.Attribute("segments") != null?int.Parse(r.Attribute("segments").Value) : 0, Words = r.Attribute("words") != null?int.Parse(r.Attribute("words").Value) : 0, Characters = r.Attribute("characters") != null?int.Parse(r.Attribute("characters").Value) : 0, Placeables = r.Attribute("placeables") != null?int.Parse(r.Attribute("placeables").Value) : 0, Tags = r.Attribute("tags") != null?int.Parse(r.Attribute("tags").Value) : 0, Min = r.Attribute("min") != null?int.Parse(r.Attribute("min").Value) : 0, Max = r.Attribute("max") != null?int.Parse(r.Attribute("max").Value) : 0, FullRecallWords = r.Attribute("fullRecallWords") != null?int.Parse(r.Attribute("fullRecallWords").Value) : 0, } }; if (!_analyzedFiles.Any()) { _messageBoxService.ShowWarningMessage(PluginResources.NoAnalyzeFiles_Message, string.Empty); } } } catch (Exception ex) { _logger.Error($"PrepareAnalysisReport method: {ex.Message}\n {ex.StackTrace}"); } }
public async Task <bool> SetTables(Dictionary <string, List <string> > schemas) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); Schemas.Clear(); if (schemas.Keys.Count == 0) { await _messageBoxService.ShowWarningMessage(Strings.MessageNotTablesInDatabase); return(false); } foreach (var schema in schemas.OrderBy(s => s.Key)) { var node = new SchemaNodeViewModel( schema.Key, schema.Value, s => NotifyPropertyChanged(() => IsValid)); Schemas.Add(node); } NotifyPropertyChanged(() => IsValid); return(true); }
public ReturnFilesViewModel(ReturnPackage returnPackage) { _messageBoxService = new MessageBoxService(); _returnPackage = returnPackage; _title = "Please select files for the return package"; if (returnPackage?.TargetFiles != null && returnPackage.TargetFiles.Count > 0) { var xliffFiles = returnPackage.TargetFiles.Where(file => file.Name.EndsWith(".sdlxliff")).ToList(); if (xliffFiles.Count() != 0) { foreach (var project in xliffFiles) { var item = new CellViewModel { Id = project.Id, Name = project.Name, Checked = false }; _listView.Add(item); } ProjectFiles = xliffFiles; } else { ProjectFiles = new List <ProjectFile>(); } Title = _title; } else { _messageBoxService.ShowWarningMessage("Please select a StarTransit project!", "Warning"); } }
// Create the project based on the project request private FileBasedProject CreateProject(ProjectRequest request) { try { if (request?.ProjectTemplate != null) { var projectInfo = GetProjectInfo(request); var isProjectInfoValid = IsProjectInfoValid(projectInfo, request); if (!isProjectInfoValid) { return(null); } var project = new FileBasedProject(projectInfo, new ProjectTemplateReference(request.ProjectTemplate.Uri)); OnMessageReported(project, $"Creating project {request.Name}"); if (request.Files != null) { //path to subdirectory var subdirectoryPath = Path.GetDirectoryName(request.Files[0]); var projectFiles = project.AddFolderWithFiles(subdirectoryPath, true); project.RunAutomaticTask(projectFiles.GetIds(), AutomaticTaskTemplateIds.Scan); ExecuteTaskSequence(project, projectFiles, request); } return(project); } _messageBoxService.ShowWarningMessage(PluginResources.ProjectTemplateSelection_Message, PluginResources.MissingProjectTemplate_Message); } catch (Exception e) { _logger.Error($"ProjectCreator-> CreateProject method: {e.Message}\n {e.StackTrace}"); } return(null); }
protected override void Execute() { _messageBoxService = new MessageBoxService(); _projectsController = SdlTradosStudio.Application?.GetController <ProjectsController>(); _projectsControllerService = new ProjectsControllerService(_projectsController); var returnService = new ReturnPackageService(_projectsControllerService); var dialogService = new DialogService(); var returnPackage = returnService.GetPackage(); if (returnPackage.Item1 is null) { return; } if (!string.IsNullOrEmpty(returnPackage.Item2)) { _messageBoxService.ShowWarningMessage(returnPackage.Item2, "Warning"); } else if (returnPackage.Item1.FileBasedProject != null && returnPackage.Item1.TargetFiles.Count > 0) { var xliffFiles = returnPackage.Item1.TargetFiles?.Any(file => file.Name.EndsWith(".sdlxliff")); if (xliffFiles.Value) { using (var returnPackageWindow = new ReturnPackageWindow(_eventAggregatorService)) { var returnViewModel = new ReturnPackageWindowViewModel(returnPackage.Item1, returnService, dialogService, _eventAggregatorService); returnPackageWindow.DataContext = returnViewModel; returnPackageWindow.ShowDialog(); } } else { _messageBoxService.ShowWarningMessage("The target file(s) has already been returned. In order to repeat the process, you need to revert to .sdlxliff(s) from the Files view.", "Warning"); } } }
public async Task AddTermToDictionary(Term term) { CheckConnection(); var model = GetCorrespondingLanguageMappingModel(); var dictionaryId = model.SelectedDictionary.DictionaryId; if (string.IsNullOrWhiteSpace(dictionaryId)) { _messageService.ShowWarningMessage(PluginResources.No_dictionary_has_been_selected, PluginResources.Operation_failed); return; } var uri = new Uri($@"{Constants.MTCloudTranslateAPIUri}/v4/accounts/{ConnectionService.Credential.AccountId}/dictionaries/{dictionaryId}/terms"); var request = GetRequestMessage(HttpMethod.Post, uri); var content = JsonConvert.SerializeObject(term); request.Content = new StringContent(content, new UTF8Encoding(), "application/json"); var httpResponseMessage = await _httpClient.SendRequest(request); if (httpResponseMessage is not null) { if (httpResponseMessage.IsSuccessStatusCode) { _messageService.ShowInformationMessage(PluginResources.The_term_has_been_successfully_added_to_the_current_dictionary, PluginResources.Operation_complete); } else { _messageService.ShowWarningMessage(httpResponseMessage.Content.ReadAsStringAsync().Result, PluginResources.Operation_failed); } } }
private void TimeTextBox_TextChanged(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(intervalTextBox.Text) && Regex.IsMatch(intervalTextBox.Text, "^[0-9]*$")) { _timerSettings.Minutes = int.Parse(intervalTextBox.Text); _persistence.SaveTimerSettings(_timerSettings); _timeLeft = _timerSettings.Minutes; ConfigureLabel(remainingTimeLbl, $"{_timeLeft} {PluginResources.RemainingMinutes_Message}", Color.Empty); Timer.Enabled = true; } else { _messageBoxService.ShowWarningMessage(PluginResources.TimerNumberSetup_Message, string.Empty); } }
protected override void Execute() { _messageBoxService = new MessageBoxService(); Utils.EnsureApplicationResources(); var returnService = new ReturnPackageService(); var returnPackage = returnService.GetReturnPackage(); if (!string.IsNullOrEmpty(returnPackage?.Item2)) { _messageBoxService.ShowWarningMessage(returnPackage.Item2, "Warning"); } else { var window = new ReturnPackageMainWindow(returnPackage?.Item1); window.ShowDialog(); } }