Question

In MSDN the definition for Top property as follows :

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

The definitions is a bit unclear to me. When I checked the value returned by the Top property of the TextView in the visual studio editor its negative .

How to Interpret the "Top" value ? Is there is a reference point from where the "TOP" property value is calculated for each line ?

Was it helpful?

Solution

ITextViewLine.Top is the position relative to ITextView.ViewportTop. The documentation for the latter hints when it can be negative:

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.

Basically, you should consider that there's an abstract coordinate system that all lines are a part of. Scrolling in the editor is simply moving your viewport within that coordinate system. Some operations (like inserting a new line at the beginning of the file), rather than "moving" all the lines, simply inserts another line at the top with a negative top, and the viewport moves up to that.

OTHER TIPS

Gets the position of the top edge of the text line where the text has been rendered.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top