示例#1
0
		/// <summary>Performs a scroll to top action.</summary>
		/// <remarks>
		/// Performs a scroll to top action.
		/// Scrolls to the top of the document.
		/// </remarks>
		/// <param name="widget">The text view.</param>
		/// <param name="buffer">The text buffer.</param>
		/// <returns>True if the event was handled.</returns>
		/// <hide></hide>
		protected internal virtual bool scrollTop(android.widget.TextView widget, android.text.Spannable
			 buffer)
		{
			android.text.Layout layout = widget.getLayout();
			if (getTopLine(widget) >= 0)
			{
				android.text.method.Touch.scrollTo(widget, layout, widget.getScrollX(), layout.getLineTop
					(0));
				return true;
			}
			return false;
		}
示例#2
0
		/// <summary>Performs a scroll up action.</summary>
		/// <remarks>
		/// Performs a scroll up action.
		/// Scrolls up by the specified number of lines.
		/// </remarks>
		/// <param name="widget">The text view.</param>
		/// <param name="buffer">The text buffer.</param>
		/// <param name="amount">The number of lines to scroll by.  Must be at least 1.</param>
		/// <returns>True if the event was handled.</returns>
		/// <hide></hide>
		protected internal virtual bool scrollUp(android.widget.TextView widget, android.text.Spannable
			 buffer, int amount)
		{
			android.text.Layout layout = widget.getLayout();
			int top_1 = widget.getScrollY();
			int topLine = layout.getLineForVertical(top_1);
			if (layout.getLineTop(topLine) == top_1)
			{
				// If the top line is partially visible, bring it all the way
				// into view; otherwise, bring the previous line into view.
				topLine -= 1;
			}
			if (topLine >= 0)
			{
				topLine = System.Math.Max(topLine - amount + 1, 0);
				android.text.method.Touch.scrollTo(widget, layout, widget.getScrollX(), layout.getLineTop
					(topLine));
				return true;
			}
			return false;
		}
示例#3
0
		/// <summary>Performs a scroll to bottom action.</summary>
		/// <remarks>
		/// Performs a scroll to bottom action.
		/// Scrolls to the bottom of the document.
		/// </remarks>
		/// <param name="widget">The text view.</param>
		/// <param name="buffer">The text buffer.</param>
		/// <returns>True if the event was handled.</returns>
		/// <hide></hide>
		protected internal virtual bool scrollBottom(android.widget.TextView widget, android.text.Spannable
			 buffer)
		{
			android.text.Layout layout = widget.getLayout();
			int lineCount = layout.getLineCount();
			if (getBottomLine(widget) <= lineCount - 1)
			{
				android.text.method.Touch.scrollTo(widget, layout, widget.getScrollX(), layout.getLineTop
					(lineCount) - getInnerHeight(widget));
				return true;
			}
			return false;
		}
        private void scroll()
        {
            Layout layout = deviceMessagesTextView.Layout;

            if (layout != null)
            {
                int y = layout.getLineTop(deviceMessagesTextView.LineCount) - deviceMessagesTextView.Height;
                if (y > 0)
                {
                    deviceMessagesTextView.scrollTo(0, y);
                    deviceMessagesTextView.invalidate();
                }
            }
        }
示例#5
0
		/// <summary>Performs a scroll page up action.</summary>
		/// <remarks>
		/// Performs a scroll page up action.
		/// Scrolls up by one page.
		/// </remarks>
		/// <param name="widget">The text view.</param>
		/// <param name="buffer">The text buffer.</param>
		/// <returns>True if the event was handled.</returns>
		/// <hide></hide>
		protected internal virtual bool scrollPageUp(android.widget.TextView widget, android.text.Spannable
			 buffer)
		{
			android.text.Layout layout = widget.getLayout();
			int top_1 = widget.getScrollY() - getInnerHeight(widget);
			int topLine = layout.getLineForVertical(top_1);
			if (topLine >= 0)
			{
				android.text.method.Touch.scrollTo(widget, layout, widget.getScrollX(), layout.getLineTop
					(topLine));
				return true;
			}
			return false;
		}
示例#6
0
		/// <summary>Performs a scroll page up action.</summary>
		/// <remarks>
		/// Performs a scroll page up action.
		/// Scrolls down by one page.
		/// </remarks>
		/// <param name="widget">The text view.</param>
		/// <param name="buffer">The text buffer.</param>
		/// <returns>True if the event was handled.</returns>
		/// <hide></hide>
		protected internal virtual bool scrollPageDown(android.widget.TextView widget, android.text.Spannable
			 buffer)
		{
			android.text.Layout layout = widget.getLayout();
			int innerHeight = getInnerHeight(widget);
			int bottom_1 = widget.getScrollY() + innerHeight + innerHeight;
			int bottomLine = layout.getLineForVertical(bottom_1);
			if (bottomLine <= layout.getLineCount() - 1)
			{
				android.text.method.Touch.scrollTo(widget, layout, widget.getScrollX(), layout.getLineTop
					(bottomLine + 1) - innerHeight);
				return true;
			}
			return false;
		}
示例#7
0
		/// <summary>Performs a scroll down action.</summary>
		/// <remarks>
		/// Performs a scroll down action.
		/// Scrolls down by the specified number of lines.
		/// </remarks>
		/// <param name="widget">The text view.</param>
		/// <param name="buffer">The text buffer.</param>
		/// <param name="amount">The number of lines to scroll by.  Must be at least 1.</param>
		/// <returns>True if the event was handled.</returns>
		/// <hide></hide>
		protected internal virtual bool scrollDown(android.widget.TextView widget, android.text.Spannable
			 buffer, int amount)
		{
			android.text.Layout layout = widget.getLayout();
			int innerHeight = getInnerHeight(widget);
			int bottom_1 = widget.getScrollY() + innerHeight;
			int bottomLine = layout.getLineForVertical(bottom_1);
			if (layout.getLineTop(bottomLine + 1) < bottom_1 + 1)
			{
				// Less than a pixel of this line is out of view,
				// so we must have tried to make it entirely in view
				// and now want the next line to be in view instead.
				bottomLine += 1;
			}
			int limit = layout.getLineCount() - 1;
			if (bottomLine <= limit)
			{
				bottomLine = System.Math.Min(bottomLine + amount - 1, limit);
				android.text.method.Touch.scrollTo(widget, layout, widget.getScrollX(), layout.getLineTop
					(bottomLine + 1) - innerHeight);
				return true;
			}
			return false;
		}
 private static int getCurrentLineTop(android.text.Spannable buffer, android.text.Layout
                                      layout)
 {
     return(layout.getLineTop(layout.getLineForOffset(android.text.Selection.getSelectionEnd
                                                          (buffer))));
 }