Beispiel #1
0
        public bool FilterAttributeSuccess(DisplayFilterRowInfo rowInfo, bool success)
        {
            if (GetAttributeFilterGroupsCount() == 0)
            {
                return(success);
            }

            if (!rowInfo.IsSegment)
            {
                return(false);
            }

            var isAndOperator = _customSettings.FilterAttributesLogicalOperator == DisplayFilterSettings.LogicalOperators.AND;

            success = isAndOperator;

            if (LogicalSuccess(success) && _settings.SegmentReviewTypes != null && _settings.SegmentReviewTypes.Any())
            {
                _settings.IsAndOperator = isAndOperator;
                success = rowInfo.IsSegmentReviewTypes(_settings);
            }

            if (LogicalSuccess(success) && _settings.ConfirmationLevels != null && _settings.ConfirmationLevels.Any())
            {
                success = rowInfo.IsConfirmationLevelFound(_settings);
            }

            if (LogicalSuccess(success) && _settings.OriginTypes != null && _settings.OriginTypes.Any())
            {
                success = rowInfo.IsOriginTypeFound(_settings);
            }

            if (LogicalSuccess(success) && _settings.PreviousOriginTypes != null && _settings.PreviousOriginTypes.Any())
            {
                success = rowInfo.IsPreviousOriginTypeFound(_settings);
            }

            if (LogicalSuccess(success) && _settings.RepetitionTypes != null && _settings.RepetitionTypes.Any())
            {
                success = rowInfo.IsRepetitionTypes(_settings);
            }

            if (LogicalSuccess(success) && _settings.SegmentLockingTypes != null && _settings.SegmentLockingTypes.Any())
            {
                success = rowInfo.IsSegmentLockingTypes(_settings);
            }

            if (LogicalSuccess(success) && _settings.SegmentContentTypes != null && _settings.SegmentContentTypes.Any())
            {
                success = rowInfo.IsSegmentContentTypes(_settings);
            }

            return(success);
        }
        public bool EvaluateRow(DisplayFilterRowInfo rowInfo)
        {
            var success = Settings.ShowAllContent || rowInfo.IsSegment;

            if (rowInfo.IsSegment)
            {
                if (ReverseSearch)
                {
                    return(CustomFilterHelper.Reverse(Settings, success, rowInfo, CustomSettings, ActiveDocument));
                }

                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())
                {
                    if (!Settings.OriginTypes.Contains("EditedF") && !Settings.OriginTypes.Contains("UneditedF"))
                    {
                        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 && (!string.IsNullOrEmpty(Settings.SourceText) || !string.IsNullOrEmpty(Settings.TargetText)))
                {
                    if (!string.IsNullOrEmpty(Settings.SourceText) && !string.IsNullOrEmpty(Settings.TargetText))
                    {
                        if (CustomSettings.SourceAndTargetLogicalOperator == CustomFilterSettings.LogicalOperators.Or)
                        {
                            var successSearchOnSource = IsExpressionFound(Settings.SourceText, rowInfo.SegmentPair.Source, out var _);

                            var successSearchOnTarget = false;
                            if (!successSearchOnSource)
                            {
                                successSearchOnTarget = IsExpressionFound(Settings.TargetText, rowInfo.SegmentPair.Target, out var _);
                            }

                            success = successSearchOnSource || successSearchOnTarget;
                        }
                        else
                        {
                            var appliedFilter = false;
                            if (CustomSettings.UseBackreferences && Settings.IsRegularExpression)
                            {
                                success = FilterOnSourceAndTargetWithBackreferences(rowInfo, out appliedFilter);
                            }

                            if (!appliedFilter)
                            {
                                success = FilterOnSourceAndTarget(rowInfo, true);
                            }
                        }
                    }
                    else
                    {
                        success = FilterOnSourceAndTarget(rowInfo, true);
                    }
                }

                if (success && !CustomSettings.UseRegexCommentSearch && !string.IsNullOrEmpty(Settings.CommentText))
                {
                    success = rowInfo.IsTextFoundInComment(Settings);
                }

                if (success && !string.IsNullOrEmpty(Settings.CommentAuthor))
                {
                    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
                if (success)
                {
                    success = CustomFilterHelper.Filter(CustomSettings, Settings, rowInfo, true, ActiveDocument);
                }
            }
            return(success);
        }
        public bool EvaluateRow(DisplayFilterRowInfo rowInfo)
        {
            var success = Settings.ShowAllContent || rowInfo.IsSegment;

            if (rowInfo.IsSegment)
            {
                if (ReverseSearch)
                {
                    return(CustomFilterHelper.Reverse(Settings, success, rowInfo, CustomSettings, ActiveDocument));
                }

                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())
                {
                    if (!Settings.OriginTypes.Contains("EditedF") && !Settings.OriginTypes.Contains("UneditedF"))
                    {
                        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
                if (success)
                {
                    success = CustomFilterHelper.Filter(CustomSettings, rowInfo, success, ActiveDocument);
                }
            }
            return(success);
        }
Beispiel #4
0
        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 (success && Settings.SourceText.Trim() != string.Empty)
                {
                    success = rowInfo.IsTextFoundInSource(Settings);
                }


                if (success && Settings.TargetText.Trim() != string.Empty)
                {
                    success = rowInfo.IsTextFoundInTarget(Settings);
                }


                if (success && 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);
                }
            }

            return(success);
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        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 static bool Reverse(DisplayFilterSettings settings, bool success, DisplayFilterRowInfo rowInfo, CustomFilterSettings customSettings, Document activeDocument)
        {
            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);
            }
            //tags
            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 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)
            {
                if (FuzzyHelper.ContainsFuzzy(rowInfo.SegmentPair.Target))
                {
                    success = FuzzyHelper.IsEditedFuzzy(rowInfo.SegmentPair.Target);
                }
                else
                {
                    return(false);
                }
            }
            if (!success && customSettings.UnEditedFuzzy)
            {
                if (FuzzyHelper.ContainsFuzzy(rowInfo.SegmentPair.Target))
                {
                    success = !FuzzyHelper.IsEditedFuzzy(rowInfo.SegmentPair.Target);
                }
                else
                {
                    return(false);
                }
            }
            return(!success);
        }
Beispiel #8
0
        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);
        }