public ITextRangeProvider[] GetVisibleRanges()
        {
            int start_line = -1, end_line = -1;

            Document.GetVisibleLineIndexes(TextBoxBase.Bounds, out start_line, out end_line);

            ITextRangeProvider range = DocumentRange.Clone();

            range.MoveEndpointByUnit(TextPatternRangeEndpoint.Start, TextUnit.Line, start_line);
            range.MoveEndpointByUnit(TextPatternRangeEndpoint.End, TextUnit.Line, end_line - start_line);

            return(new ITextRangeProvider[] { range });
        }
Exemple #2
0
        private ITextRangeProvider GetTextRange(int start, int end)
        {
            ITextRangeProvider textRange = textProvider.DocumentRange;

            if (start >= 0 && end > 0)
            {
                textRange.MoveEndpointByUnit(TextPatternRangeEndpoint.Start,
                                             TextUnit.Character, start);
                textRange.MoveEndpointByRange(TextPatternRangeEndpoint.End,
                                              textRange, TextPatternRangeEndpoint.Start);
                textRange.MoveEndpointByUnit(TextPatternRangeEndpoint.End,
                                             TextUnit.Character, end - start);
            }
            return(textRange);
        }
Exemple #3
0
        public void TextPatternTest()
        {
            T textBoxBase;
            IRawElementProviderSimple provider;

            GetProviderAndControl(out provider, out textBoxBase);

            ITextProvider textProvider
                = provider.GetPatternProvider(TextPatternIdentifiers.Pattern.Id)
                  as ITextProvider;

            Assert.IsNotNull(textProvider, "Not returning TextPatternIdentifiers.");
            Assert.IsTrue(textProvider is ITextProvider, "Not returning TextPatternIdentifiers.");

            textBoxBase.Text      = "abc123";
            textBoxBase.Multiline = true;

            ITextRangeProvider range = textProvider.RangeFromPoint(new Point(0, 0));

            Assert.IsNotNull(range);

            // should always return a degenerate range
            Assert.AreEqual(String.Empty, range.GetText(-1));

            // TODO: Actually check the value, instead of just
            // making sure it doesn't crash
            range.MoveEndpointByUnit(TextPatternRangeEndpoint.End, TextUnit.Character, 1);

            // TODO: Actually check the value, instead of just
            // making sure it doesn't crash
            ITextRangeProvider[] ranges = textProvider.GetVisibleRanges();
            Assert.AreEqual(1, ranges.Length);
        }
 public int MoveEndpointByUnit(TextPatternRangeEndpoint endpoint, TextUnit unit, int count)
 {
     return(provider.MoveEndpointByUnit(endpoint, unit, count));
 }