Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Any watermark text for an empty diagram! (Read 1494 times)
MikeHeal
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 20
Joined: Feb 5th, 2020
Any watermark text for an empty diagram!
Jun 1st, 2021 at 11:19pm
Print Post  
I am using MindFusion for layouting in wpf. Do we have any way to show watermark text when the diagram is empty. Roll Eyes
I would like to display something like "Please add, connect items to make diagram" in the middle when we open a fresh diagram pane.

Thanks a lot MindFusion.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Any watermark text for an empty diagram!
Reply #1 - Jun 2nd, 2021 at 6:26am
Print Post  
Hi,

You could show it using a textblock overlayed on top of the diagram -

Code
Select All
<Grid>

    <ScrollViewer>
        <diag:Diagram ... />
    </ScrollViewer>

    <TextBlock
        x:Name="watermark"
        Text="Please add, connect items to make diagram"
        FontSize="24"
        Foreground="Red"
        Opacity="0.6"
        VerticalAlignment="Center"
        HorizontalAlignment="Center"
        IsHitTestVisible="false" />

</Grid> 



and bind visibility to diagram's Items.Count using a value converter, or just set it to hidden from NodeCreated event handler -

Code
Select All
void OnNodeCreated(object sender, NodeEventArgs e)
{
    watermark.Visibility = Visibility.Collapsed;
} 



Alternatively draw it from DrawForeground event handler -
Code
Select All
diagram.DrawForeground += (sender, args) =>
{
    if (diagram.Items.Count == 0)
    {
        diagram.DrawStyledText(
            args.Graphics,
            "<color=#FF0000>Please add, connect items to make diagram</color>",
            new TextAttributes(new Font("Arial", 24))
            {
                TextAlignment = TextAlignment.Center
            },
            diagram.Viewport);
    }
};
diagram.InvalidateForeground();

void OnNodeCreated(object sender, NodeEventArgs e)
{
    diagram.InvalidateForeground();
} 



Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
MikeHeal
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 20
Joined: Feb 5th, 2020
Re: Any watermark text for an empty diagram!
Reply #2 - Jun 2nd, 2021 at 3:43pm
Print Post  
That helped. Thanks a lot. Smiley
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint