Inheritance: ITextPatternRange
Beispiel #1
0
        public int CompareEndpoints(TextPatternRangeEndpoint endpoint, ITextPatternRange targetRange, TextPatternRangeEndpoint targetEndpoint)
        {
            TextRangePattern targetRangePattern = targetRange as TextRangePattern;

            if (targetRangePattern == null)
            {
                throw new ArgumentNullException();
            }

            if (targetRangePattern.accessible != accessible)
            {
                throw new ArgumentException();
            }

            int point = (endpoint == TextPatternRangeEndpoint.End
                                ? endOffset : startOffset);
            int targetPoint = (targetEndpoint ==
                               TextPatternRangeEndpoint.End)
                                ? targetRangePattern.endOffset
                                : targetRangePattern.startOffset;

            if (point < targetPoint)
            {
                return(-1);
            }
            if (point > targetPoint)
            {
                return(1);
            }
            return(0);
        }
Beispiel #2
0
        public void MoveEndpointByRange(TextPatternRangeEndpoint endpoint, ITextPatternRange targetRange, TextPatternRangeEndpoint targetEndpoint)
        {
            TextRangePattern target = targetRange as TextRangePattern;

            if (target == null || target.accessible != accessible)
            {
                throw new ArgumentException();
            }

            int offset =
                (targetEndpoint == TextPatternRangeEndpoint.Start
                                        ? target.startOffset
                                        : target.endOffset);

            if (endpoint == TextPatternRangeEndpoint.Start)
            {
                startOffset = offset;
                if (endOffset < startOffset)
                {
                    endOffset = startOffset;
                }
            }
            else
            {
                endOffset = offset;
                if (startOffset > endOffset)
                {
                    startOffset = endOffset;
                }
            }
        }
Beispiel #3
0
		public ITextPatternRange [] GetSelection ()
		{
			int nSelections = text.NSelections;
			TextRangePattern [] range = new TextRangePattern [nSelections];
			for (int i = 0; i < nSelections; i++) {
				int startOffset, endOffset;
				text.GetSelection (i, out startOffset, out endOffset);
				range [i] = new TextRangePattern (accessible, startOffset, endOffset);
			}
			return range;
		}
Beispiel #4
0
        public ITextPatternRange [] GetSelection()
        {
            int nSelections = text.NSelections;

            TextRangePattern [] range = new TextRangePattern [nSelections];
            for (int i = 0; i < nSelections; i++)
            {
                int startOffset, endOffset;
                text.GetSelection(i, out startOffset, out endOffset);
                range [i] = new TextRangePattern(accessible, startOffset, endOffset);
            }
            return(range);
        }
Beispiel #5
0
        public bool Compare(ITextPatternRange range)
        {
            TextRangePattern other = range as TextRangePattern;

            if (other == null)
            {
                return(false);
            }
            if (other.accessible != accessible)
            {
                throw new ArgumentException("Comparing ranges from different elements");
            }
            return(other.startOffset == startOffset &&
                   other.endOffset == endOffset);
        }