本文整理汇总了C#中IVsTextView.SetTopLine方法的典型用法代码示例。如果您正苦于以下问题:C# IVsTextView.SetTopLine方法的具体用法?C# IVsTextView.SetTopLine怎么用?C# IVsTextView.SetTopLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IVsTextView
的用法示例。
在下文中一共展示了IVsTextView.SetTopLine方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ScrollToEnd
/// <include file='doc\LanguageService.uex' path='docs/doc[@for="LanguageService.ScrollToEnd2"]/*' />
public void ScrollToEnd(IVsTextView view) {
IVsTextLines buffer;
NativeMethods.ThrowOnFailure(view.GetBuffer(out buffer));
int lines;
NativeMethods.ThrowOnFailure(buffer.GetLineCount(out lines));
int lineHeight;
NativeMethods.ThrowOnFailure(view.GetLineHeight(out lineHeight));
Microsoft.VisualStudio.NativeMethods.RECT bounds = new Microsoft.VisualStudio.NativeMethods.RECT();
NativeMethods.GetClientRect(view.GetWindowHandle(), ref bounds);
int visibleLines = ((bounds.bottom - bounds.top) / lineHeight) - 1;
int top = Math.Max(0, lines - visibleLines + 4);
NativeMethods.ThrowOnFailure(view.SetTopLine(top));
}
示例2: FocusLine
internal static void FocusLine(IVsTextView viewAdapter, int line, int col) {
ErrorHandler.ThrowOnFailure(viewAdapter.SetCaretPos(line, col));
// Make sure that the text is visible.
int topline = line - 10;
if(topline < 0)
topline = 0;
viewAdapter.SetTopLine(topline);
viewAdapter.CenterLines(line, 1);
}
示例3: ScrollToEnd
internal void ScrollToEnd(IVsTextView view)
{
IVsTextLines buffer;
NativeMethods.ThrowOnFailure(view.GetBuffer(out buffer));
int lines;
NativeMethods.ThrowOnFailure(buffer.GetLineCount(out lines));
int lineHeight;
NativeMethods.ThrowOnFailure(view.GetLineHeight(out lineHeight));
NativeMethods.RECT bounds = new NativeMethods.RECT();
NativeMethods.GetClientRect(view.GetWindowHandle(), ref bounds);
int visibleLines = ((bounds.bottom - bounds.top) / lineHeight) - 1;
// The line number needed to be passed to SetTopLine is ZERO based, so need to subtract ONE from number of total lines
int top = Math.Max(0, lines - visibleLines - 1);
Debug.Assert(lines > top, "Cannot set top line to be greater than total number of lines");
#if XMLTRACE
Trace.WriteLine("ScrollToEnd: lines=" + lines + ", visibleLines=" + visibleLines + ", top=" + top);
#endif
NativeMethods.ThrowOnFailure(view.SetTopLine(top));
}
示例4: ScrollToEnd
/// <include file='doc\LanguageService.uex' path='docs/doc[@for="LanguageService.ScrollToEnd2"]/*' />
public void ScrollToEnd(IVsTextView view)
{
IVsTextLines buffer;
NativeMethods.ThrowOnFailure(view.GetBuffer(out buffer));
int lines;
NativeMethods.ThrowOnFailure(buffer.GetLineCount(out lines));
int lineHeight;
NativeMethods.ThrowOnFailure(view.GetLineHeight(out lineHeight));
Microsoft.VisualStudio.NativeMethods.RECT bounds = new Microsoft.VisualStudio.NativeMethods.RECT();
NativeMethods.GetClientRect(view.GetWindowHandle(), ref bounds);
int visibleLines = ((bounds.bottom - bounds.top) / lineHeight) - 1;
// If the view hasn't been shown yet, the bounds will be empty, yielding -1 for visibleLinse.
if (visibleLines < 0) {
visibleLines = 0;
}
// The line number needed to be passed to SetTopLine is ZERO based, so need to subtract ONE from number of total lines
int top = Math.Max(0, lines - visibleLines - 1);
Debug.Assert(lines > top, "Cannot set top line to be greater than total number of lines");
NativeMethods.ThrowOnFailure(view.SetTopLine(top));
}