public static bool IsUniqueRepetition(this DisplayFilterRowInfo rowInfo, DisplayFilterSettings settings) { if (!rowInfo.IsSegment) { return(false); } if (settings.RepetitionTypes.Any(a => a == DisplayFilterSettings.RepetitionType.UniqueOccurrences.ToString())) { var isFirst = rowInfo.IsRepetitionsFirstOccurrences(new DisplayFilterSettings { RepetitionTypes = new List <string> { DisplayFilterSettings.RepetitionType.FirstOccurrences.ToString() } }); if (isFirst) { return(true); } if (rowInfo.SegmentPair.Properties.TranslationOrigin != null) { var isRepeated = rowInfo.SegmentPair.Properties.TranslationOrigin.IsRepeated; return(!isRepeated); } } return(false); }
public static bool IsRepetitionTypes(this DisplayFilterRowInfo rowInfo, DisplayFilterSettings settings) { var success = rowInfo.IsRepetitionsAll(settings) || rowInfo.IsRepetitionsFirstOccurrences(settings) || rowInfo.IsRepetitionsExcludingFirstOccurrences(settings); return(success); }
public static bool IsRepetitionTypes(this DisplayFilterRowInfo rowInfo, DisplayFilterSettings settings) { if (!rowInfo.IsSegment) { return(false); } var success = rowInfo.IsRepetitionsAll(settings) || rowInfo.IsRepetitionsFirstOccurrences(settings) || rowInfo.IsRepetitionsExcludingFirstOccurrences(settings); if (!success) { success = rowInfo.IsUniqueRepetition(settings); } 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 static bool Filter(CustomFilterSettings customSettings, DisplayFilterRowInfo rowInfo, bool success, Document activeDocument) { 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); } if (success && customSettings.ContainsTags) { var containsTagVisitor = new TagVisitor(); success = containsTagVisitor.ContainsTag(rowInfo.SegmentPair.Source); } //unique if (success && customSettings.Unique) { var settings = new DisplayFilterSettings { RepetitionTypes = new List <string> { "FirstOccurrences" } }; var isFirst = rowInfo.IsRepetitionsFirstOccurrences(settings); if (isFirst) { return(true); } if (rowInfo.SegmentPair.Properties.TranslationOrigin != null) { var isRepeated = rowInfo.SegmentPair.Properties.TranslationOrigin.IsRepeated; return(!isRepeated); } return(false); } //created by if (success && customSettings.CreatedByChecked && !string.IsNullOrWhiteSpace(customSettings.CreatedBy)) { var userVisitor = new UserVisitor(); success = userVisitor.CreatedBy(rowInfo.SegmentPair.Source, customSettings.CreatedBy); } //modify by if (success && customSettings.ModifiedByChecked && !string.IsNullOrWhiteSpace(customSettings.ModifiedBy)) { var userVisitor = new UserVisitor(); success = userVisitor.ModifiedBy(rowInfo.SegmentPair.Source, customSettings.ModifiedBy); } if (success && customSettings.EditedFuzzy) { success = FuzzyHelper.ContainsFuzzy(rowInfo.SegmentPair.Target) && FuzzyHelper.IsEditedFuzzy(rowInfo.SegmentPair.Target); } if (success && customSettings.UnEditedFuzzy) { success = FuzzyHelper.ContainsFuzzy(rowInfo.SegmentPair.Target) && !FuzzyHelper.IsEditedFuzzy(rowInfo.SegmentPair.Target); } return(success); }