c# - "ITextViewLine.Top"属性是什么?

标签 c# visual-studio-2010 editor visual-studio-extensions

在MSDN中,Top属性的定义如下:

Gets the position of the top edge of this line in the text rendering coordinate system.

我对这些定义有点不清楚。当我在 Visual Studio 编辑器中检查 TextView 的 Top 属性返回的值时,其值为负。

如何解释“Top”值?是否存在计算每行“TOP”属性值的引用点?

最佳答案

ITextViewLine.Top 是相对于 ITextView.ViewportTop 的位置。 documentation对于后者当它可以为负时的提示:

The value can be either positive or negative. When the viewport layout is only partially changed, ViewportTop is increased or decreased by the number of pixels up or down that the view has been scrolled. When the viewport layout is completely changed (such that all of the lines of the previous layout are changed), ViewportTop is reset to 0.0.

基本上,您应该考虑到存在一个所有线条都是其一部分的抽象坐标系。在编辑器中滚动只是在该坐标系内移动视口(viewport)。某些操作(例如在文件开头插入新行)不是“移动”所有行,而是简单地在顶部插入另一行且顶部为负数,然后视口(viewport)向上移动到该行。

关于c# - "ITextViewLine.Top"属性是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25076368/

相关文章:

c# - Bot Framework 无法发送 FacebookQuickReply ChannelData - 如何查找原因?

c++ - 除以零后无运行时错误

c# - C#编译器版本和语言版本的区别

html - Brackets 中等效的 Atom Indent Guides 是什么?

user-interface - 如何用 `EditorGUI.HelpBox` 实现 `GUIStyle` 外观?

vim - 在Vim中换行

C# - 为什么 System.IO.File.GetLastAccessTime 在找不到文件时返回预期值?

c# - 通过 WebAPI 正确序列化 LocalTime

visual-studio-2010 - 在 Windows 7 中更改程序文件的默认位置

c# - C#获取单个文件最近创建时间的路径