Пример #1
0
        /// ------------------------------------------------------------------------------------
        public void SetIgnoredFlagForSegment(AnnotationSegment segment, bool ignore)
        {
            if (segment != null)
            {
                var segmentIndex = TimeTier.GetIndexOfSegment(segment);
                var timeRange    = segment.TimeRange.Copy();
                if (ignore)
                {
                    Action restoreState = GetActionToRestoreStateWhenUndoingAnIgnore(segment);

                    Tiers.MarkSegmentAsIgnored(segmentIndex);
                    _undoStack.Push(new SegmentChange(SegmentChangeType.Ignored, timeRange, timeRange, sc =>
                    {
                        Tiers.MarkSegmentAsUnignored(segmentIndex);
                        restoreState();
                    }));
                }
                else
                {
                    Tiers.MarkSegmentAsUnignored(segmentIndex);
                    _undoStack.Push(new SegmentChange(SegmentChangeType.Unignored, timeRange, timeRange,
                                                      sc => Tiers.MarkSegmentAsIgnored(segmentIndex)));
                }
            }
            else
            {
                if (!ignore)
                {
                    throw new InvalidOperationException("New segment can never be unignored.");
                }
                AddIgnoredSegment(VirtualBoundaryBeyondLastSegment);
            }
        }