Sorry, it seems I'm fighting with simple problems, but I need help.
I tried it with the adornment layer.
But I don't know, which event I should use to add the watermark.
the view.TextAreaLayout gives me only access to the region, where the tex line is written. and it was called on each new line event.
But I want the watermark just shown once like the evaluation watermark.
I tried it with the Event view.SyntaxEditor.Loaded to make sure, the watermark is loaded only once.
But how can I center the watermark in the SyntaxEditor-View?
The IEditorView again gives me only the region, where the text is written, but not the whole window control.
Here is the code snippte of my WatermarkAdornmentManager. For the test case I just use a rectangle as watermark. As sson as it is positioned where I expect, I'll replace it by an image or text.
Could you please help me how to find the correct event and way to position the watermakr in the center of the editor-windowControl?
Perhaps I can even get an example code for the "evaluation" watermark shown in the syntax editor?
public WatermarkAdornmentManager(IEditorView view) : base(view, layerDefinition, true)
{
view.SyntaxEditor.Loaded += new RoutedEventHandler(SyntaxEditor_Loaded);
//view.TextAreaLayout += new EventHandler<TextViewTextAreaLayoutEventArgs>(view_TextAreaLayout);
}
void view_TextAreaLayout(object sender, TextViewTextAreaLayoutEventArgs e)
{
IEditorView editorView = sender as IEditorView;
AddAdornment(editorView);
}
void SyntaxEditor_Loaded(object sender, RoutedEventArgs e)
{
IEditorView editorView = sender as IEditorView;
AddAdornment(editorView);
}
private void AddAdornment(IEditorView activeView)
{
// Create a watermark textbox
SolidColorBrush brush = new SolidColorBrush(Color.FromArgb(0xFF, 0xF0, 0xF0, 0xF0));
// Create the adornment
Rectangle element = new Rectangle();
element.Width = 1000;
element.Height = 20;
element.Fill = brush;
// Add the adornment to the layer
//this.AdornmentLayer.AddAdornment(element, new
// Point(activeView.TextAreaViewportBounds.Width/2,
// activeView.TextAreaViewportBounds.Height/2), null, null);
this.AdornmentLayer.AddAdornment(element,
activeView.VisualElement.RenderTransformOrigin, null, null);
}
Thanks again for your help!