
This.GetRectangleFromTextPositionInternal(insertionPosition, true, out rect) InsertionPosition.GetPositionAtOffset( 0, LogicalDirection.Forward)

InsertionPosition.GetPositionAtOffset( 0, LogicalDirection.Backward) Invariant.Assert(insertionPosition != null) InsertionPosition.GetNextInsertionPosition(LogicalDirection.Forward) LogicalDirection.Backward).GetInsertionPosition(LogicalDirection.Backward) TextPointer insertionPosition = (charIndex, Throw new ArgumentOutOfRangeException( " charIndex") Public Rect GetRectFromCharacterIndex( int charIndex, bool trailingEdge) Returns the bounding rectangle for the character at the specified character index. Note that this is the index of the last, at least partially visible, line, rather than the index of the last fully visible line. Otherwise, it is computed from the Lineheight, VerticalOffset, and ViewportHeight. The last line of text could appear in the viewport in which the index is determined by the LineCount. We see that there are two cases for the last visible line index. It is capable of failing even if LineCount > 0. After changes to text and especially key presses, it will take the value of -1. GetLastVisibleLineIndex is rather undependable. Return ( int) Math.Floor(( double) ((( base.VerticalOffset +īase.ViewportHeight) - 1. ((IScrollInfo) base.RenderScope).ExtentHeight // Last line visible box if (( base.VerticalOffset + base.ViewportHeight) >= extentHeight) GetFirstVisibleLineIndex: Returns the line index for the first line that is currently visible in the text box. I will be using the following format: Member Name In creating this control, I found that a significant amount of the documentation on the TextBox that I would have liked to read was nonexistent.
#Codebox odd even background code#
Although this version is much improved and definitely the one I would advise you to use for your purposes, reading the original and examining its code should make this one easier to understand.
#Codebox odd even background upgrade#
This CodeBox is a major revision and upgrade of the one presented in my CodeBox article. This made it practical only for short documents. The previous version rendered all text up until the currently viewed text.


The Big IdeasĬodeBox is an enhanced version of the WPF textbox, allowing a greater degree of visual customization, while keeping as much of the original textbox functionality as possible. I was looking to make a simple but at least somewhat useful app to show off what the improved CodeBox can do.

It also allows you to take snapshots of the displayed code as image files. The sample application is a simple text editor that supports decoration schemes and text coloring. For instance, we can now have a C# decoration scheme and then add highlighting on top of that. In addition to the decorations of word coloring, highlighting, strikethroughs, and underlining, there is now support for decoration schemes that serve as a base for further decorations. It now features line numbering and more efficient rendering. This article presents an enhanced version of the CodeBox of my previous article.
