在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/