public bool Filter(DisplayFilterRowInfo rowInfo, bool success) { if (!rowInfo.IsSegment) { return(!HasCustomSettings()); } var rowId = rowInfo.SegmentPair.Properties.Id.Id; if (success && _customSettings.EvenNo) { success = SegmentNumbersHelper.IsEven(rowId); } if (success && _customSettings.OddsNo) { success = SegmentNumbersHelper.IsOdd(rowId); } if (success && _customSettings.SplitSegments) { success = SegmentNumbersHelper.IsSplitSegment(rowId, _document); } if (success && (_customSettings.MergedSegments || _customSettings.MergedAcross)) { success = SegmentNumbersHelper.IsMergedSegment(rowId, _document, _customSettings.MergedAcross); } if (success && _customSettings.SourceEqualsTarget) { success = SegmentNumbersHelper.IsSourceEqualsToTarget(rowInfo.SegmentPair, _customSettings.IsEqualsCaseSensitive); } if (success && _customSettings.Grouped && !string.IsNullOrWhiteSpace(_customSettings.GroupedList)) { success = SegmentNumbersHelper.IdInRange(rowId, _customSettings.GroupedList); } if (success && _customSettings.UseRegexCommentSearch && !string.IsNullOrWhiteSpace(_customSettings.CommentRegex)) { var visitor = new CommentDataVisitor(); var commentsList = visitor.GetComments(rowInfo.SegmentPair.Source); commentsList.AddRange(visitor.GetComments(rowInfo.SegmentPair.Target)); success = CommentsHelper.IsCommentTextFoundWithRegex(commentsList, _customSettings.CommentRegex); } if (success && _customSettings.Colors?.Count > 0) { success = ColorPickerHelper.ContainsColor(rowInfo, _customSettings.Colors, _customSettings.ColorsFoundIn); } if (success && !string.IsNullOrWhiteSpace(_customSettings.FuzzyMin) && !string.IsNullOrWhiteSpace(_customSettings.FuzzyMax)) { success = FuzzyHelper.IsInFuzzyRange(rowInfo, _customSettings.FuzzyMin, _customSettings.FuzzyMax); } if (success && _customSettings.ContainsTags) { var containsTagVisitor = new TagVisitor(); success = containsTagVisitor.ContainsTag(rowInfo.SegmentPair.Source); } if (success && _customSettings.CreatedByChecked && !string.IsNullOrWhiteSpace(_customSettings.CreatedBy)) { var userVisitor = new TranslationOriginMetaDataVisitor(); success = userVisitor.CreatedBy(rowInfo.SegmentPair.Source, _customSettings.CreatedBy); } if (success && _customSettings.ModifiedByChecked && !string.IsNullOrWhiteSpace(_customSettings.ModifiedBy)) { var userVisitor = new TranslationOriginMetaDataVisitor(); success = userVisitor.ModifiedBy(rowInfo.SegmentPair.Source, _customSettings.ModifiedBy); } if (success && !string.IsNullOrEmpty(_customSettings.DocumentStructureInformation)) { success = _settings.IsRegularExpression ? DocumentStructureInfoRegexSearch(rowInfo, _customSettings.DocumentStructureInformation, _settings.IsCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase) : DocumentStructureInfoSearch(rowInfo, _customSettings); } return(success); }
private bool Reverse(bool success, DisplayFilterRowInfo rowInfo) { success = false; if (!success && Settings.SegmentReviewTypes != null && Settings.SegmentReviewTypes.Any()) { success = rowInfo.IsSegmentReviewTypes(Settings); } if (!success && Settings.ConfirmationLevels != null && Settings.ConfirmationLevels.Any()) { success = rowInfo.IsConfirmationLevelFound(Settings); } if (!success && Settings.OriginTypes != null && Settings.OriginTypes.Any()) { success = rowInfo.IsOriginTypeFound(Settings); } if (!success && Settings.PreviousOriginTypes != null && Settings.PreviousOriginTypes.Any()) { success = rowInfo.IsPreviousOriginTypeFound(Settings); } if (!success && Settings.RepetitionTypes != null && Settings.RepetitionTypes.Any()) { success = rowInfo.IsRepetitionTypes(Settings); } if (!success && Settings.SegmentLockingTypes != null && Settings.SegmentLockingTypes.Any()) { success = rowInfo.IsSegmentLockingTypes(Settings); } if (!success && Settings.SegmentContentTypes != null && Settings.SegmentContentTypes.Any()) { success = rowInfo.IsSegmentContentTypes(Settings); } if (!success && Settings.SourceText.Trim() != string.Empty) { success = rowInfo.IsTextFoundInSource(Settings); } if (!success && Settings.TargetText.Trim() != string.Empty) { success = rowInfo.IsTextFoundInTarget(Settings); } if (!success && !CustomSettings.UseRegexCommentSearch && Settings.CommentText.Trim() != string.Empty) { success = rowInfo.IsTextFoundInComment(Settings); } if (!success && Settings.CommentAuthor.Trim() != string.Empty) { success = rowInfo.IsAuthorFoundInComment(Settings); } if (!success && Settings.CommentSeverity > 0) { success = rowInfo.IsSeverityFoundInComment(Settings); } if (!success && Settings.ContextInfoTypes.Any()) { success = rowInfo.IsContextInfoTypes(Settings); } // check custom settings var rowId = rowInfo.SegmentPair.Properties.Id.Id; if (!success && CustomSettings.EvenNo) { success = SegmentNumbersHelper.IsEven(rowId); } if (!success && CustomSettings.OddsNo) { success = SegmentNumbersHelper.IsOdd(rowId); } if (!success && CustomSettings.SplitSegments) { success = SegmentNumbersHelper.IsSplitSegment(rowId, ActiveDocument); } if (!success && (CustomSettings.MergedSegments || CustomSettings.MergedAcross)) { success = SegmentNumbersHelper.IsMergedSegment(rowId, ActiveDocument, CustomSettings.MergedAcross); } if (!success && CustomSettings.SourceEqualsTarget) { success = SegmentNumbersHelper.IsSourceEqualsToTarget(rowInfo.SegmentPair, CustomSettings.IsEqualsCaseSensitive); } if (!success && CustomSettings.Grouped && !string.IsNullOrWhiteSpace(CustomSettings.GroupedList)) { success = SegmentNumbersHelper.IdInRange(rowId, CustomSettings.GroupedList); } if (!success && CustomSettings.UseRegexCommentSearch && !string.IsNullOrWhiteSpace(CustomSettings.CommentRegex)) { //create a list with source and target comments var commentsList = rowInfo.SegmentPair.Source.GetComments(); commentsList.AddRange(rowInfo.SegmentPair.Target.GetComments()); success = CommentsHelper.IsCommentTextFoundWithRegex(commentsList, CustomSettings.CommentRegex); } if (!success && CustomSettings.Colors.Count > 0) { try { success = ColorPickerHelper.ContainsColor(rowInfo, CustomSettings.Colors); }catch (Exception e) { } } //fuzzy if (!success && !string.IsNullOrWhiteSpace(CustomSettings.FuzzyMin) && !string.IsNullOrWhiteSpace(CustomSettings.FuzzyMax)) { success = FuzzyHelper.IsInFuzzyRange(rowInfo, CustomSettings.FuzzyMin, CustomSettings.FuzzyMax); } return(!success); }
public bool EvaluateRow(DisplayFilterRowInfo rowInfo) { var success = !(!Settings.ShowAllContent && !rowInfo.IsSegment); if (rowInfo.IsSegment) { if (ReverseSearch) { return(Reverse(success, rowInfo)); } if (success && Settings.SegmentReviewTypes != null && Settings.SegmentReviewTypes.Any()) { success = rowInfo.IsSegmentReviewTypes(Settings); } if (success && Settings.ConfirmationLevels != null && Settings.ConfirmationLevels.Any()) { success = rowInfo.IsConfirmationLevelFound(Settings); } if (success && Settings.OriginTypes != null && Settings.OriginTypes.Any()) { success = rowInfo.IsOriginTypeFound(Settings); } if (success && Settings.PreviousOriginTypes != null && Settings.PreviousOriginTypes.Any()) { success = rowInfo.IsPreviousOriginTypeFound(Settings); } if (success && Settings.RepetitionTypes != null && Settings.RepetitionTypes.Any()) { if (!Settings.RepetitionTypes.Contains("Unique")) { success = rowInfo.IsRepetitionTypes(Settings); } } if (success && Settings.SegmentLockingTypes != null && Settings.SegmentLockingTypes.Any()) { success = rowInfo.IsSegmentLockingTypes(Settings); } if (success && Settings.SegmentContentTypes != null && Settings.SegmentContentTypes.Any()) { success = rowInfo.IsSegmentContentTypes(Settings); } if (success && Settings.SourceText.Trim() != string.Empty) { success = rowInfo.IsTextFoundInSource(Settings); if (Settings.IsRegularExpression) { var textVisitor = new SegmentTextVisitor(); var text = textVisitor.GetText(rowInfo.SegmentPair.Source); success = ContentHelper.SearchContentRegularExpression(text, Settings.SourceText); } } if (success && Settings.TargetText.Trim() != string.Empty) { success = rowInfo.IsTextFoundInTarget(Settings); } if (success && !CustomSettings.UseRegexCommentSearch && Settings.CommentText.Trim() != string.Empty) { success = rowInfo.IsTextFoundInComment(Settings); } if (success && Settings.CommentAuthor.Trim() != string.Empty) { success = rowInfo.IsAuthorFoundInComment(Settings); } if (success && Settings.CommentSeverity > 0) { success = rowInfo.IsSeverityFoundInComment(Settings); } if (success && Settings.ContextInfoTypes.Any()) { success = rowInfo.IsContextInfoTypes(Settings); } // check custom settings var rowId = rowInfo.SegmentPair.Properties.Id.Id; if (success && CustomSettings.EvenNo) { success = SegmentNumbersHelper.IsEven(rowId); } if (success && CustomSettings.OddsNo) { success = SegmentNumbersHelper.IsOdd(rowId); } if (success && CustomSettings.SplitSegments) { success = SegmentNumbersHelper.IsSplitSegment(rowId, ActiveDocument); } if (success && (CustomSettings.MergedSegments || CustomSettings.MergedAcross)) { success = SegmentNumbersHelper.IsMergedSegment(rowId, ActiveDocument, CustomSettings.MergedAcross); } if (success && CustomSettings.SourceEqualsTarget) { success = SegmentNumbersHelper.IsSourceEqualsToTarget(rowInfo.SegmentPair, CustomSettings.IsEqualsCaseSensitive); } if (success && CustomSettings.Grouped && !string.IsNullOrWhiteSpace(CustomSettings.GroupedList)) { success = SegmentNumbersHelper.IdInRange(rowId, CustomSettings.GroupedList); } if (success && CustomSettings.UseRegexCommentSearch && !string.IsNullOrWhiteSpace(CustomSettings.CommentRegex)) { //create a list with source and target comments var commentsList = rowInfo.SegmentPair.Source.GetComments(); commentsList.AddRange(rowInfo.SegmentPair.Target.GetComments()); success = CommentsHelper.IsCommentTextFoundWithRegex(commentsList, CustomSettings.CommentRegex); } if (success && CustomSettings.Colors.Count > 0) { try { success = ColorPickerHelper.ContainsColor(rowInfo, CustomSettings.Colors); }catch (Exception e) { } } //fuzzy if (success && !string.IsNullOrWhiteSpace(CustomSettings.FuzzyMin) && !string.IsNullOrWhiteSpace(CustomSettings.FuzzyMax)) { success = FuzzyHelper.IsInFuzzyRange(rowInfo, CustomSettings.FuzzyMin, CustomSettings.FuzzyMax); } //unique if (success && CustomSettings.Unique) { var settings = new DisplayFilterSettings { RepetitionTypes = new List <string> { "FirstOccurrences" } }; var isFirst = rowInfo.IsRepetitionsFirstOccurrences(settings); if (isFirst) { return(true); } var isRepeted = rowInfo.SegmentPair.Properties.TranslationOrigin.IsRepeated; if (!isRepeted) { return(true); } return(false); } } return(success); }
public bool EvaluateRow(DisplayFilterRowInfo rowInfo) { var success = !(!Settings.ShowAllContent && !rowInfo.IsSegment); if (rowInfo.IsSegment) { if (success && Settings.SegmentReviewTypes != null && Settings.SegmentReviewTypes.Any()) { success = rowInfo.IsSegmentReviewTypes(Settings); } if (success && Settings.ConfirmationLevels != null && Settings.ConfirmationLevels.Any()) { success = rowInfo.IsConfirmationLevelFound(Settings); } if (success && Settings.OriginTypes != null && Settings.OriginTypes.Any()) { success = rowInfo.IsOriginTypeFound(Settings); } if (success && Settings.PreviousOriginTypes != null && Settings.PreviousOriginTypes.Any()) { success = rowInfo.IsPreviousOriginTypeFound(Settings); } if (success && Settings.RepetitionTypes != null && Settings.RepetitionTypes.Any()) { success = rowInfo.IsRepetitionTypes(Settings); } if (success && Settings.SegmentLockingTypes != null && Settings.SegmentLockingTypes.Any()) { success = rowInfo.IsSegmentLockingTypes(Settings); } if (success && Settings.SegmentContentTypes != null && Settings.SegmentContentTypes.Any()) { success = rowInfo.IsSegmentContentTypes(Settings); } // if is revert search use custom helper method if (success && !CustomSettings.RevertSerach) { if (success && Settings.SourceText.Trim() != string.Empty) { success = rowInfo.IsTextFoundInSource(Settings); } if (success && Settings.TargetText.Trim() != string.Empty) { success = rowInfo.IsTextFoundInTarget(Settings); } } if (success && !CustomSettings.UseRegexCommentSearch && Settings.CommentText.Trim() != string.Empty) { success = rowInfo.IsTextFoundInComment(Settings); } if (success && Settings.CommentAuthor.Trim() != string.Empty) { success = rowInfo.IsAuthorFoundInComment(Settings); } if (success && Settings.CommentSeverity > 0) { success = rowInfo.IsSeverityFoundInComment(Settings); } if (success && Settings.ContextInfoTypes.Any()) { success = rowInfo.IsContextInfoTypes(Settings); } // check custom settings var rowId = rowInfo.SegmentPair.Properties.Id.Id; if (success && CustomSettings.EvenNo) { success = SegmentNumbersHelper.IsEven(rowId); } if (success && CustomSettings.OddsNo) { success = SegmentNumbersHelper.IsOdd(rowId); } if (success && CustomSettings.Grouped && !string.IsNullOrWhiteSpace(CustomSettings.GroupedList)) { success = SegmentNumbersHelper.IdInRange(rowId, CustomSettings.GroupedList); } if (success && CustomSettings.UseRegexCommentSearch && !string.IsNullOrWhiteSpace(CustomSettings.CommentRegex)) { //create a list with source and target comments var commentsList = rowInfo.SegmentPair.Source.GetComments(); commentsList.AddRange(rowInfo.SegmentPair.Target.GetComments()); success = CommentsHelper.IsCommentTextFoundWithRegex(commentsList, CustomSettings.CommentRegex); } //revert search if (success && CustomSettings.RevertSerach && Settings.SourceText.Trim() != string.Empty) { success = ContentHelper.ReverseSearch(rowInfo.SegmentPair.Source.GetString(), Settings.SourceText.Trim()); } if (success && CustomSettings.RevertSerach && Settings.TargetText.Trim() != string.Empty) { success = ContentHelper.ReverseSearch(rowInfo.SegmentPair.Target.GetString(), Settings.TargetText.Trim()); } if (success && CustomSettings.Colors.Count > 0) { if (CustomSettings.FileType != null) { if (CustomSettings.FileType.Contains("IDML")) { success = ColorPickerHelper.ContainsColorForIdmlFileType(rowInfo, CustomSettings.Colors); } else { success = ColorPickerHelper.ContainsColor(rowInfo, CustomSettings.Colors); } } } //fuzzy if (success && !string.IsNullOrWhiteSpace(CustomSettings.FuzzyMin) && !string.IsNullOrWhiteSpace(CustomSettings.FuzzyMax)) { success = FuzzyHelper.IsInFuzzyRange(rowInfo, CustomSettings.FuzzyMin, CustomSettings.FuzzyMax); } } return(success); }