Rendering SyntaxEditor.ActiveView without highlighting

SyntaxEditor for WPF Forum

Posted 4 years ago by Andrew Levine
Version: 19.1.0684

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
            Dim r As HighlightingStyleRegistry = editor.HighlightingStyleRegistry
            editor.HighlightingStyleRegistry = Nothing
            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))
            editor.HighlightingStyleRegistry = r
            Return bmp
        End Get
    End Property

Comments (2)

Answer - Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA


If the editor.HighlightingStyleRegistry is null (the default), then it will use the AmbientHighlightingStyleRegistry.Instance as the registry.  You might want to have the AmbientHighlightingStyleRegistry.Instance registry be the one with all your normal styles and then when you want a limited set, make a new HighlightingStyleRegistry, register only the lexing classification types and highlighting styles you need on it, and them temporarily set that to the editor.HighlightingStyleRegistry property while you take your screenshot.

Actipro Software Support

Posted 4 years ago by Andrew Levine

Great idea, thanks!

The latest build of this product (v24.1.2) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.