// Token: 0x06007C92 RID: 31890 RVA: 0x00230870 File Offset: 0x0022EA70
        internal void RemoveRange(IHighlightRange highlightRange)
        {
            if (highlightRange.Range.Start.CompareTo(highlightRange.Range.End) == 0)
            {
                return;
            }
            int num;
            int num2;

            this.GetSpannedSegments(highlightRange.Range.Start, highlightRange.Range.End, out num, out num2);
            ITextPointer start = this._segments[num].Segment.Start;
            ITextPointer end   = this._segments[num2].Segment.End;
            int          i     = num;

            while (i <= num2)
            {
                AnnotationHighlightLayer.HighlightSegment highlightSegment = this._segments[i];
                if (highlightSegment.RemoveOwner(highlightRange) == 0)
                {
                    this._segments.Remove(highlightSegment);
                    num2--;
                }
                else
                {
                    i++;
                }
            }
            if (this.Changed != null && this.IsFixedContainer)
            {
                this.Changed(this, new AnnotationHighlightLayer.AnnotationHighlightChangedEventArgs(start, end));
            }
        }
        //------------------------------------------------------ 
        //
        //  Internal Methods 
        //
        //-----------------------------------------------------

        #region Internal Methods 

        /// <summary> 
        /// Adds a new text range to the layer 
        /// </summary>
        /// <remarks> 
        /// If the range does not overlap any of the existing segments it is added on the appropriate position
        /// in the _segments array - the _segments array contains non overlapping HighlightSegments sorted by ITextPointers.
        /// If the range overlaps some of the existing segments its IHighlightRange is added to the list of owners
        /// for those segments. If the input range overlaps partially some of the existing segments they will be split into 
        /// new segments by the corresponding range end points. For the overlapping parts the IHighlightRange of the new
        /// range will be added. If the new range overlaps parts of existing segments and some nonhighlighted areas, new 
        /// HighlightSegments will be generated for the nonhighlighted areas. Example: 
        /// 1. text "1234567" has 2 HighlightSegments covereing "234" and "67"
        /// 2. Add a range that covers "3456" 
        /// 3.The result will be 5 HighlightSegments - "2", "34", "5", "6" and "7". "2" and "7" will keep their original owners array.
        ///   "5" will have only one owner - the new IHighlightRange, "34" and "6" will have their previous owners + the new one.
        /// </remarks>
        /// <param name="highlightRange">the highlight range owner</param> 
        internal void AddRange(IHighlightRange highlightRange)
        { 
            Invariant.Assert(highlightRange != null, "the owner is null"); 
            ITextPointer start = highlightRange.Range.Start;
            ITextPointer end = highlightRange.Range.End; 
            //check input data
            Debug.Assert(start != null, "start pointer is null");
            Debug.Assert(end != null, "end pointer is null");
            Debug.Assert(start.CompareTo(end) <= 0, "end pointer before start"); 

            if (start.CompareTo(end) == 0) 
            { 
                //it is a 0 length highlight - do not render it
                return; 
            }

            if (_segments.Count == 0)
            { 
                //set container type
                object textContainer = start.TextContainer; 
                IsFixedContainer = textContainer is FixedTextContainer || textContainer is DocumentSequenceTextContainer; 
            }
 
            ITextPointer invalidateStart;
            ITextPointer invalidateEnd;

            ProcessOverlapingSegments(highlightRange, out invalidateStart, out invalidateEnd); 

            //fire event - do it only for fixed to avoid disposing of the page in flow. Needs to be changed in V2. 
            if ((Changed != null) && IsFixedContainer) 
            {
                Changed(this, new AnnotationHighlightChangedEventArgs(invalidateStart, invalidateEnd)); 
            }

        }
        // Token: 0x06007C94 RID: 31892 RVA: 0x00230A2C File Offset: 0x0022EC2C
        internal void ActivateRange(IHighlightRange highlightRange, bool activate)
        {
            Invariant.Assert(highlightRange != null, "null range data");
            if (highlightRange.Range.Start.CompareTo(highlightRange.Range.End) == 0)
            {
                return;
            }
            int num;
            int num2;

            this.GetSpannedSegments(highlightRange.Range.Start, highlightRange.Range.End, out num, out num2);
            ITextPointer start = this._segments[num].Segment.Start;
            ITextPointer end   = this._segments[num2].Segment.End;

            for (int i = num; i <= num2; i++)
            {
                if (activate)
                {
                    this._segments[i].AddActiveOwner(highlightRange);
                }
                else
                {
                    this._segments[i].RemoveActiveOwner(highlightRange);
                }
            }
            if (this.Changed != null && this.IsFixedContainer)
            {
                this.Changed(this, new AnnotationHighlightLayer.AnnotationHighlightChangedEventArgs(start, end));
            }
        }
 // Token: 0x06008E53 RID: 36435 RVA: 0x0025B99E File Offset: 0x00259B9E
 internal void RemoveActiveOwner(IHighlightRange owner)
 {
     if (this._activeOwners.Contains(owner))
     {
         this._activeOwners.Remove(owner);
         this.UpdateOwners();
     }
 }
 // Token: 0x06008E51 RID: 36433 RVA: 0x0025B968 File Offset: 0x00259B68
 internal void AddActiveOwner(IHighlightRange owner)
 {
     if (this._owners.Contains(owner))
     {
         this._activeOwners.Add(owner);
         this.UpdateOwners();
     }
 }
            // Token: 0x06008E4C RID: 36428 RVA: 0x0025B7AC File Offset: 0x002599AC
            internal HighlightSegment(ITextPointer start, ITextPointer end, IHighlightRange owner)
            {
                List <IHighlightRange> list = new List <IHighlightRange>(1);

                list.Add(owner);
                this.Init(start, end, list);
                this._owners = list;
                this.UpdateOwners();
            }
Пример #7
0
        // Token: 0x06007CE8 RID: 31976 RVA: 0x002324A8 File Offset: 0x002306A8
        private void CheckPosition(ITextPointer position)
        {
            IHighlightRange highlightAnchor = this._highlightAnchor;
            bool            flag            = highlightAnchor.Range.Contains(position);
            bool            flag2           = (bool)this._DPHost.GetValue(StickyNoteControl.IsMouseOverAnchorProperty);

            if (flag != flag2)
            {
                this._DPHost.SetValue(StickyNoteControl.IsMouseOverAnchorPropertyKey, flag);
            }
        }
 // Token: 0x06008E50 RID: 36432 RVA: 0x0025B914 File Offset: 0x00259B14
 internal int RemoveOwner(IHighlightRange owner)
 {
     if (this._owners.Contains(owner))
     {
         if (this._activeOwners.Contains(owner))
         {
             this._activeOwners.Remove(owner);
         }
         this._owners.Remove(owner);
         this.UpdateOwners();
     }
     return(this._owners.Count);
 }
 // Token: 0x06008E4F RID: 36431 RVA: 0x0025B8B0 File Offset: 0x00259AB0
 internal void AddOwner(IHighlightRange owner)
 {
     for (int i = 0; i < this._owners.Count; i++)
     {
         if (this._owners[i].Priority < owner.Priority)
         {
             this._owners.Insert(i, owner);
             this.UpdateOwners();
             return;
         }
     }
     this._owners.Add(owner);
     this.UpdateOwners();
 }
        // Token: 0x06007C93 RID: 31891 RVA: 0x00230958 File Offset: 0x0022EB58
        internal void ModifiedRange(IHighlightRange highlightRange)
        {
            Invariant.Assert(highlightRange != null, "null range data");
            if (highlightRange.Range.Start.CompareTo(highlightRange.Range.End) == 0)
            {
                return;
            }
            int num;
            int num2;

            this.GetSpannedSegments(highlightRange.Range.Start, highlightRange.Range.End, out num, out num2);
            for (int i = num; i < num2; i++)
            {
                this._segments[i].UpdateOwners();
            }
            ITextPointer start = this._segments[num].Segment.Start;
            ITextPointer end   = this._segments[num2].Segment.End;

            if (this.Changed != null && this.IsFixedContainer)
            {
                this.Changed(this, new AnnotationHighlightLayer.AnnotationHighlightChangedEventArgs(start, end));
            }
        }
        // Token: 0x06007C91 RID: 31889 RVA: 0x002307D4 File Offset: 0x0022E9D4
        internal void AddRange(IHighlightRange highlightRange)
        {
            Invariant.Assert(highlightRange != null, "the owner is null");
            ITextPointer start = highlightRange.Range.Start;
            ITextPointer end   = highlightRange.Range.End;

            if (start.CompareTo(end) == 0)
            {
                return;
            }
            if (this._segments.Count == 0)
            {
                object textContainer = start.TextContainer;
                this.IsFixedContainer = (textContainer is FixedTextContainer || textContainer is DocumentSequenceTextContainer);
            }
            ITextPointer start2;
            ITextPointer end2;

            this.ProcessOverlapingSegments(highlightRange, out start2, out end2);
            if (this.Changed != null && this.IsFixedContainer)
            {
                this.Changed(this, new AnnotationHighlightLayer.AnnotationHighlightChangedEventArgs(start2, end2));
            }
        }
Пример #12
0
            /// <summary>
            /// Splits HighlightSegment in two positions 
            /// </summary>
            /// <param name="ps1">first splitting position</param> 
            /// <param name="ps2">second splitting position</param> 
            /// <param name="newOwner">Guid of a new owner to be added in the middle. May be null</param>
            /// <returns>A list of resulting HighlightSegments. They have same list of owners as this</returns> 
            internal IList<HighlightSegment> Split(ITextPointer ps1, ITextPointer ps2, IHighlightRange newOwner)
            {
                Debug.Assert((ps1 != null) && (ps2 != null) && (ps1.CompareTo(ps2) <= 0), "invalid splitting points");
 
                IList<HighlightSegment> res = new List<HighlightSegment>();
 
                if (ps1.CompareTo(ps2) == 0) 
                {
                    //special processing for equal splitting points 
                    if ((_segment.Start.CompareTo(ps1) > 0) || (_segment.End.CompareTo(ps1) < 0))
                        return res;

                    if (_segment.Start.CompareTo(ps1) < 0) 
                    {
                        res.Add(new HighlightSegment(_segment.Start, ps1, _owners)); 
                    } 

                    //add 0-length segment 
                    res.Add(new HighlightSegment(ps1, ps1, _owners));

                    if (_segment.End.CompareTo(ps1) > 0)
                    { 
                        res.Add(new HighlightSegment(ps1, _segment.End, _owners));
                    } 
 
                    //add active owners as well
                    foreach (HighlightSegment seg in res) 
                    {
                        seg.AddActiveOwners(_activeOwners);
                    }
                } 
                else if (_segment.Contains(ps1))
                { 
                    IList<HighlightSegment> r1 = Split(ps1, LogicalDirection.Forward); 
                    for (int i = 0; i < r1.Count; i++)
                    { 
                        if (r1[i].Segment.Contains(ps2))
                        {
                            IList<HighlightSegment> r2 = r1[i].Split(ps2, LogicalDirection.Backward);
                            for (int j = 0; j < r2.Count; j++) 
                                res.Add(r2[j]);
 
                            //check if r1[i] needs to be discarded (it can be included in the split result 
                            // so we should not discard it in that case)
                            if (!r2.Contains(r1[i])) 
                                r1[i].Discard();
                        }
                        else
                        { 
                            res.Add(r1[i]);
                        } 
 
                    }
                } 
                else
                {
                    res = Split(ps2, LogicalDirection.Backward);
                } 

                if ((res != null) && (res.Count > 0) && (newOwner != null)) 
                { 
                    //add owner
                    if (res.Count == 3) 
                    {
                        //if we have 3 segments the new owner will go to the middle one
                        res[1].AddOwner(newOwner);
                    } 
                    else if ((res[0].Segment.Start.CompareTo(ps1) == 0) ||
                             (res[0].Segment.End.CompareTo(ps2) == 0)) 
                    { 
                        //if one of the splitting points is on the corresponding end of the first
                        //segment it will have the new owner 
                        res[0].AddOwner(newOwner);
                    }
                    else
                    { 
                        //if we have 1 segment we should go through the else above, so they must be 2
                        Debug.Assert(res.Count == 2, "unexpected resulting segment count after split"); 
                        res[1].AddOwner(newOwner); 
                    }
                } 

                return res;
            }
Пример #13
0
            /// <summary>
            /// Removes one owner from the _activeOwners list
            /// </summary> 
            /// <param name="owner">owner data</param>
            /// <returns>the number of owners left for this HighlightSegment</returns> 
            internal void RemoveActiveOwner(IHighlightRange owner) 
            {
                if (_activeOwners.Contains(owner)) 
                {
                    _activeOwners.Remove(owner);
                    UpdateOwners();
                } 

            } 
Пример #14
0
 /// <summary>
 /// Adds an owner to_activeOwners list 
 /// </summary>
 /// <param name="owner">owner data</param> 
 /// <returns>the number of owners left for this HighlightSegment</returns> 
 internal void AddActiveOwner(IHighlightRange owner)
 { 
     //this must be a valid owner
     if (_owners.Contains(owner))
     {
         _activeOwners.Add(owner); 
         UpdateOwners();
     } 
 } 
Пример #15
0
            /// <summary>
            /// Removes one owner from the _owners list 
            /// </summary>
            /// <param name="owner">owner data</param> 
            /// <returns>the number of owners left for this HighlightSegment</returns> 
            internal int RemoveOwner(IHighlightRange owner)
            { 
                if (_owners.Contains(owner))
                {
                    if (_activeOwners.Contains(owner))
                        _activeOwners.Remove(owner); 
                    _owners.Remove(owner);
                    UpdateOwners(); 
                } 

                return _owners.Count; 
            }
Пример #16
0
            //------------------------------------------------------
            // 
            //  Internal methods
            //
            //-----------------------------------------------------
 
            #region Internal methods
            /// <summary> 
            /// Adds one owner to the _owners list 
            /// </summary>
            /// <param name="owner">owner data</param> 
            /// <returns></returns>
            internal void AddOwner(IHighlightRange owner)
            {
                //Find the right place in the list according to TimeStamp and the priority 
                //Note: - currently we care only about priority
                for (int i = 0; i < _owners.Count; i++) 
                { 
                    if (_owners[i].Priority < owner.Priority)
                    { 
                        _owners.Insert(i, owner);
                        UpdateOwners();
                        return;
                    } 
                }
 
                //every body has higher priority - add this at the end 
                _owners.Add(owner);
                UpdateOwners(); 
            }
Пример #17
0
            //------------------------------------------------------ 
            // 
            //  Constructors
            // 
            //-----------------------------------------------------

            #region Constructors
 
            /// <summary>
            /// Creates a new HighlightSegment with one owner 
            /// </summary> 
            /// <param name="start">start segment position</param>
            /// <param name="end">end segment position</param> 
            /// <param name="owner">Owners data. Used to find the right place of this owner in the list</param>
            internal HighlightSegment(ITextPointer start, ITextPointer end, IHighlightRange owner)
                : base()
            { 
                List<IHighlightRange> list = new List<IHighlightRange>(1);
                list.Add(owner); 
                Init(start, end, list); 
                _owners = list;
                UpdateOwners(); 
            }
Пример #18
0
        //-----------------------------------------------------
        // 
        //  Private Methods 
        //
        //----------------------------------------------------- 

        #region Private Methods

        /// <summary> 
        /// Checks if the input range overlaps existing segments and splits them if needed
        /// </summary> 
        /// <param name="highlightRange">range data</param> 
        /// <param name="invalidateStart">start pointer of the invalid area</param>
        /// <param name="invalidateEnd">end pointer of the invalid area</param> 
        /// <remarks>This method requires ordered nonoverlaped input segments. Otherwise it will assert.</remarks>
        private void ProcessOverlapingSegments(IHighlightRange highlightRange, out ITextPointer invalidateStart, out ITextPointer invalidateEnd)
        {
            Debug.Assert(highlightRange != null, " null highlight range"); 
            ReadOnlyCollection<TextSegment> rangeSegments = highlightRange.Range.TextSegments;
            Debug.Assert((rangeSegments != null) && (rangeSegments.Count > 0), "invalid rangeSegments"); 
 

            invalidateStart = null; 
            invalidateEnd = null;
            int ind = 0;
            IEnumerator<TextSegment> rangeEnumerator = rangeSegments.GetEnumerator();
            TextSegment rangeSegment = rangeEnumerator.MoveNext() ? rangeEnumerator.Current : TextSegment.Null; 
            while ((ind < _segments.Count) && (!rangeSegment.IsNull))
            { 
                HighlightSegment highlightSegment = _segments[ind]; 
                Debug.Assert(highlightSegment != null, "null highlight segment");
 
                if (highlightSegment.Segment.Start.CompareTo(rangeSegment.Start) <= 0)
                {
                    if (highlightSegment.Segment.End.CompareTo(rangeSegment.Start) > 0)
                    { 
                        //split highlightSegment
                        //the split method is smart enough to take care of edge cases - point on start/end of the 
                        //segment, points outside the segment etc 
                        IList<HighlightSegment> res = highlightSegment.Split(rangeSegment.Start, rangeSegment.End, highlightRange);
 
                        //if the result does not contain the original segment we need to clear the owners
                        if (!res.Contains(highlightSegment))
                            highlightSegment.ClearOwners();
 
                        _segments.Remove(highlightSegment);
                        _segments.InsertRange(ind, res); 
                        ind = ind + res.Count - 1; 

                        //check if we need to move to next range segment 
                        if (rangeSegment.End.CompareTo(highlightSegment.Segment.End) <= 0)
                        {
                            //get next one
                            bool next = rangeEnumerator.MoveNext(); 
                            Debug.Assert(rangeEnumerator.Current.IsNull || !next ||
                                         (rangeSegment.End.CompareTo(rangeEnumerator.Current.Start) <= 0), 
                                         "overlapped range segments"); 
                            rangeSegment = next ? rangeEnumerator.Current : TextSegment.Null;
                        } 
                        else
                        {
                            //get the piece that is left
                            rangeSegment = new TextSegment(highlightSegment.Segment.End, rangeSegment.End); 
                        }
 
                        //set invalidateStart if needed 
                        if (invalidateStart == null)
                            invalidateStart = highlightSegment.Segment.Start; 

                    }
                    else
                    { 
                        //move to next highlightsegment
                        ind++; 
                    } 
                }
                else 
                {
                    //set invalidateStart if needed
                    if (invalidateStart == null)
                        invalidateStart = rangeSegment.Start; 

                    if (rangeSegment.End.CompareTo(highlightSegment.Segment.Start) > 0) 
                    { 
                        //add the piece before the highlight segment
                        HighlightSegment temp = new HighlightSegment(rangeSegment.Start, highlightSegment.Segment.Start, highlightRange); 
                        _segments.Insert(ind++, temp);

                        //now our current segment is the rest of the range segment
                        rangeSegment = new TextSegment(highlightSegment.Segment.Start, rangeSegment.End); 

                    } 
                    else 
                    {
                        //just insert this range segment - it does not cover any highlight segnments. Increment ind 
                        //so it points to the same highlight segment
                        _segments.Insert(ind++, new HighlightSegment(rangeSegment.Start, rangeSegment.End, highlightRange));
                        //get next range segment
                        rangeSegment = rangeEnumerator.MoveNext() ? rangeEnumerator.Current : TextSegment.Null; 
                    }
 
                } 
            }
 
            //
            if (!rangeSegment.IsNull)
            {
                if (invalidateStart == null) 
                    invalidateStart = rangeSegment.Start;
                _segments.Insert(ind++, new HighlightSegment(rangeSegment.Start, rangeSegment.End, highlightRange)); 
            } 

            //check if there are more rangeSegments 
            while (rangeEnumerator.MoveNext())
            {
                _segments.Insert(ind++, new HighlightSegment(rangeEnumerator.Current.Start, rangeEnumerator.Current.End, highlightRange));
            } 

            //set invalidateEnd 
            if (invalidateStart != null) 
            {
                if (ind == _segments.Count) ind--; 
                invalidateEnd = _segments[ind].Segment.End;
            }
        }
Пример #19
0
        /// <summary> 
        /// Activate/Deactivate highlight range 
        /// </summary>
        /// <param name="highlightRange">the text range to be modified</param> 
        /// <param name="activate">true - activate, false - deactivate</param>
        internal void ActivateRange(IHighlightRange highlightRange, bool activate)
        {
            Invariant.Assert(highlightRange != null, "null range data"); 

            //if range is 0 length do nothing 
            if (highlightRange.Range.Start.CompareTo(highlightRange.Range.End) == 0) 
                return;
 
            int startSeg;
            int endSeg;
            GetSpannedSegments(highlightRange.Range.Start, highlightRange.Range.End, out startSeg, out endSeg);
 
            //get invalidate start and end point
            ITextPointer invalidateStart = _segments[startSeg].Segment.Start; 
            ITextPointer invalidateEnd = _segments[endSeg].Segment.End; 

            //set them as active 
            for (int i = startSeg; i <= endSeg; i++)
            {
                if (activate)
                    _segments[i].AddActiveOwner(highlightRange); 
                else
                    _segments[i].RemoveActiveOwner(highlightRange); 
            } 

            //fire event - do it only for fixed to avoid disposing of the page in flow. Needs to be changed in V2. 
            if ((Changed != null) && IsFixedContainer)
            {
                Changed(this, new AnnotationHighlightChangedEventArgs(invalidateStart, invalidateEnd));
            } 

        } 
Пример #20
0
        /// <summary> 
        /// Notifies segments and listeners that a IHighlightRange colors have been modified 
        /// </summary>
        /// <param name="highlightRange">the highlight range to be modified</param> 
        /// <returns>true if successfuly modified</returns>
        internal void ModifiedRange(IHighlightRange highlightRange)
        {
            Invariant.Assert(highlightRange != null, "null range data"); 

            //if range is 0 length do nothing 
            if (highlightRange.Range.Start.CompareTo(highlightRange.Range.End) == 0) 
                return;
 
            int startSeg;
            int endSeg;
            GetSpannedSegments(highlightRange.Range.Start, highlightRange.Range.End, out startSeg, out endSeg);
 
            //update colors
            for (int seg = startSeg; seg < endSeg; seg++) 
            { 
                //the owners have not changed so this will only update the colors
                _segments[seg].UpdateOwners(); 
            }

            //get invalidate start and end point
            ITextPointer invalidateStart = _segments[startSeg].Segment.Start; 
            ITextPointer invalidateEnd = _segments[endSeg].Segment.End;
 
            //fire event - do it only for fixed to avoid disposing of the page in flow. Needs to be changed in V2. 
            if ((Changed != null) && IsFixedContainer)
            { 
                Changed(this, new AnnotationHighlightChangedEventArgs(invalidateStart, invalidateEnd));
            }

        } 
Пример #21
0
        /// <summary>
        /// RemoveRange from the highlight layer. The corresponding IHighlightRange object will be removed 
        /// from all HighlightSegments that belong to this range. All ranges with no more owners will also be removed. 
        /// The visual properties of ranges that have more owners might change.
        /// </summary> 
        /// <param name="highlightRange">The highlight range owner</param>
        /// <returns>true if the range is successfuly removed</returns>
        internal void RemoveRange(IHighlightRange highlightRange)
        { 
            Debug.Assert(highlightRange != null, "null range data");
 
            //if range is 0 length do nothing 
            if (highlightRange.Range.Start.CompareTo(highlightRange.Range.End) == 0)
                return; 

            int startSeg;
            int endSeg;
            GetSpannedSegments(highlightRange.Range.Start, highlightRange.Range.End, out startSeg, out endSeg); 

            //get invalidate start and end point 
            ITextPointer invalidateStart = _segments[startSeg].Segment.Start; 
            ITextPointer invalidateEnd = _segments[endSeg].Segment.End;
            for (int i = startSeg; i <= endSeg; ) 
            {
                HighlightSegment highlightSegment = _segments[i];
                int count = highlightSegment.RemoveOwner(highlightRange);
                if (count == 0) 
                {
                    _segments.Remove(highlightSegment); 
                    endSeg--; 
                }
                else 
                {
                    i++;
                }
            } 

            //TBD:Should do something against fragmentation 
 
            //fire event - do it only for fixed to avoid disposing of the page in flow. Needs to be changed in V2.
            if ((Changed != null) && IsFixedContainer) 
            {
                Changed(this, new AnnotationHighlightChangedEventArgs(invalidateStart, invalidateEnd));
            }
        } 
        // Token: 0x06007C9B RID: 31899 RVA: 0x00230C80 File Offset: 0x0022EE80
        private void ProcessOverlapingSegments(IHighlightRange highlightRange, out ITextPointer invalidateStart, out ITextPointer invalidateEnd)
        {
            ReadOnlyCollection <TextSegment> textSegments = highlightRange.Range.TextSegments;

            invalidateStart = null;
            invalidateEnd   = null;
            int num = 0;
            IEnumerator <TextSegment> enumerator = textSegments.GetEnumerator();
            TextSegment textSegment = enumerator.MoveNext() ? enumerator.Current : TextSegment.Null;

            while (num < this._segments.Count && !textSegment.IsNull)
            {
                AnnotationHighlightLayer.HighlightSegment highlightSegment = this._segments[num];
                if (highlightSegment.Segment.Start.CompareTo(textSegment.Start) <= 0)
                {
                    if (highlightSegment.Segment.End.CompareTo(textSegment.Start) > 0)
                    {
                        IList <AnnotationHighlightLayer.HighlightSegment> list = highlightSegment.Split(textSegment.Start, textSegment.End, highlightRange);
                        if (!list.Contains(highlightSegment))
                        {
                            highlightSegment.ClearOwners();
                        }
                        this._segments.Remove(highlightSegment);
                        this._segments.InsertRange(num, list);
                        num = num + list.Count - 1;
                        if (textSegment.End.CompareTo(highlightSegment.Segment.End) <= 0)
                        {
                            textSegment = (enumerator.MoveNext() ? enumerator.Current : TextSegment.Null);
                        }
                        else
                        {
                            textSegment = new TextSegment(highlightSegment.Segment.End, textSegment.End);
                        }
                        if (invalidateStart == null)
                        {
                            invalidateStart = highlightSegment.Segment.Start;
                        }
                    }
                    else
                    {
                        num++;
                    }
                }
                else
                {
                    if (invalidateStart == null)
                    {
                        invalidateStart = textSegment.Start;
                    }
                    if (textSegment.End.CompareTo(highlightSegment.Segment.Start) > 0)
                    {
                        AnnotationHighlightLayer.HighlightSegment item = new AnnotationHighlightLayer.HighlightSegment(textSegment.Start, highlightSegment.Segment.Start, highlightRange);
                        this._segments.Insert(num++, item);
                        textSegment = new TextSegment(highlightSegment.Segment.Start, textSegment.End);
                    }
                    else
                    {
                        this._segments.Insert(num++, new AnnotationHighlightLayer.HighlightSegment(textSegment.Start, textSegment.End, highlightRange));
                        textSegment = (enumerator.MoveNext() ? enumerator.Current : TextSegment.Null);
                    }
                }
            }
            if (!textSegment.IsNull)
            {
                if (invalidateStart == null)
                {
                    invalidateStart = textSegment.Start;
                }
                this._segments.Insert(num++, new AnnotationHighlightLayer.HighlightSegment(textSegment.Start, textSegment.End, highlightRange));
            }
            while (enumerator.MoveNext())
            {
                List <AnnotationHighlightLayer.HighlightSegment> segments = this._segments;
                int          index        = num++;
                TextSegment  textSegment2 = enumerator.Current;
                ITextPointer start        = textSegment2.Start;
                textSegment2 = enumerator.Current;
                segments.Insert(index, new AnnotationHighlightLayer.HighlightSegment(start, textSegment2.End, highlightRange));
            }
            if (invalidateStart != null)
            {
                if (num == this._segments.Count)
                {
                    num--;
                }
                invalidateEnd = this._segments[num].Segment.End;
            }
        }
            // Token: 0x06008E56 RID: 36438 RVA: 0x0025BACC File Offset: 0x00259CCC
            internal IList <AnnotationHighlightLayer.HighlightSegment> Split(ITextPointer ps1, ITextPointer ps2, IHighlightRange newOwner)
            {
                IList <AnnotationHighlightLayer.HighlightSegment> list = new List <AnnotationHighlightLayer.HighlightSegment>();

                if (ps1.CompareTo(ps2) == 0)
                {
                    if (this._segment.Start.CompareTo(ps1) > 0 || this._segment.End.CompareTo(ps1) < 0)
                    {
                        return(list);
                    }
                    if (this._segment.Start.CompareTo(ps1) < 0)
                    {
                        list.Add(new AnnotationHighlightLayer.HighlightSegment(this._segment.Start, ps1, this._owners));
                    }
                    list.Add(new AnnotationHighlightLayer.HighlightSegment(ps1, ps1, this._owners));
                    if (this._segment.End.CompareTo(ps1) > 0)
                    {
                        list.Add(new AnnotationHighlightLayer.HighlightSegment(ps1, this._segment.End, this._owners));
                    }
                    using (IEnumerator <AnnotationHighlightLayer.HighlightSegment> enumerator = list.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            AnnotationHighlightLayer.HighlightSegment highlightSegment = enumerator.Current;
                            highlightSegment.AddActiveOwners(this._activeOwners);
                        }
                        goto IL_1A1;
                    }
                }
                if (this._segment.Contains(ps1))
                {
                    IList <AnnotationHighlightLayer.HighlightSegment> list2 = this.Split(ps1, LogicalDirection.Forward);
                    for (int i = 0; i < list2.Count; i++)
                    {
                        if (list2[i].Segment.Contains(ps2))
                        {
                            IList <AnnotationHighlightLayer.HighlightSegment> list3 = list2[i].Split(ps2, LogicalDirection.Backward);
                            for (int j = 0; j < list3.Count; j++)
                            {
                                list.Add(list3[j]);
                            }
                            if (!list3.Contains(list2[i]))
                            {
                                list2[i].Discard();
                            }
                        }
                        else
                        {
                            list.Add(list2[i]);
                        }
                    }
                }
                else
                {
                    list = this.Split(ps2, LogicalDirection.Backward);
                }
IL_1A1:
                if (list != null && list.Count > 0 && newOwner != null)
                {
                    if (list.Count == 3)
                    {
                        list[1].AddOwner(newOwner);
                    }
                    else if (list[0].Segment.Start.CompareTo(ps1) == 0 || list[0].Segment.End.CompareTo(ps2) == 0)
                    {
                        list[0].AddOwner(newOwner);
                    }
                    else
                    {
                        list[1].AddOwner(newOwner);
                    }
                }
                return(list);
            }