Hello, I'm trying to get a screenshot of the SyntaxEditor's text without highlighting styles, but with lexing color coding still intact. What is the best way to prepare the control? Here is my best guess for an editor in single-line mode, but the screenshot keeps coming out with the highlights still inside:
Public ReadOnly Property Preview As RenderTargetBitmap
Get
Dim r As HighlightingStyleRegistry = editor.HighlightingStyleRegistry
editor.HighlightingStyleRegistry = Nothing
editor.InvalidateVisual()
Dim v As EditorView = editor.ActiveView
Dim bmp As New RenderTargetBitmap(2000, v.VisualElement.ActualHeight, 96, 96, PixelFormats.Pbgra32)
v.VisualElement.Measure(New Size(2000, v.VisualElement.ActualHeight))
v.VisualElement.Arrange(New Rect(0, 0, 2000, v.VisualElement.ActualHeight))
bmp.Render(v.VisualElement)
editor.HighlightingStyleRegistry = r
Return bmp
End Get
End Property