Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic WPF Diagram - Custom nodes and layout (Read 3571 times)
Bertrand
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 7
Joined: Jan 24th, 2018
WPF Diagram - Custom nodes and layout
Jan 24th, 2018 at 12:58am
Print Post  
Hi,

We use the WPF diagram. We draw nodes (custom nodes) and links. Two nodes can have multiple links between them.

I added in copy files to implement our custom nodes (BaseElNode). To test, we can add these files to the Mindfusion Demo project. I added a xml file: "Mindfusion sample.xml" which contains our nodes and links. It is the file that we can open in the demo project in order to test the layouts.

With the demo, we try the different layouts of the sample and at the end the diagram is on one line… We have the feeling that no layout works with custom nodes.

Another issue is that the first node has no icon. Can you explain what is wrong on this point?

Maybe we don’t use correctly custom node. For instance, we create 4 anchor points to see the different links separately but maybe there is a layout to do this automatically. As we can have more than 4 links between two nodes.

Best regards,
  

Mindfusion_sample.zip (Attachment deleted)
Themes.zip (Attachment deleted)
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3447
Joined: Oct 19th, 2005
Re: WPF Diagram - Custom nodes and layout
Reply #1 - Jan 24th, 2018 at 10:46am
Print Post  
Hi,

The one line is due to the <IgnoreLayout>True</IgnoreLayout> set on all links. It causes the layout class to split the diagram into a bunch of single-node graphs, arranged as per the MultipleGraphsLayout setting.

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


tech.support

Posts: 3447
Joined: Oct 19th, 2005
Re: WPF Diagram - Custom nodes and layout
Reply #2 - Jan 24th, 2018 at 11:16am
Print Post  
The icon works if you move the style override to a static constructor -

Code
Select All
static BaseElNode()
{
	DefaultStyleKeyProperty.OverrideMetadata(
		typeof(BaseElNode), new FrameworkPropertyMetadata(typeof(BaseElNode)));
} 



instead of instance one -

Code
Select All
public BaseElNode()
{
    if (isFirstCall) {
    DefaultStyleKeyProperty.OverrideMetadata(
        typeof(BaseElNode), new FrameworkPropertyMetadata(typeof(BaseElNode)));
    isFirstCall = false;
    }
} 



My guess is the instance one does not apply the full template on time, but it's ready for next loaded nodes...

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


I Love MindFusion!

Posts: 7
Joined: Jan 24th, 2018
Re: WPF Diagram - Custom nodes and layout
Reply #3 - Jan 25th, 2018 at 9:55am
Print Post  
Hi,

Thank you,

It's clear for me now, but...

If I set <IgnoreLayout>True</IgnoreLayout> on all links, it's because when I apply a layout, the anchor points are loose (all links start from the same point). As we can have more than one link between two nodes, we have a bad rendering.

Do you have an idea to keep the anchor points ?

Thank you for the icon too.

ps: I join the file with <IgnoreLayout>False</IgnoreLayout> on all links.
  

Mindfusion_sample_001.zip (Attachment deleted)
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3447
Joined: Oct 19th, 2005
Re: WPF Diagram - Custom nodes and layout
Reply #4 - Jan 25th, 2018 at 1:28pm
Print Post  
Hi,

Layout classes ignore anchor points by default. You could set Anchoring to Reassign or Keep to use them, but note that the layout classes won't try to change node positions to better match anchor points. You could instead use properties like LinkPadding to pull apart links, or run OrthogonalRouter as a post-processing step. E.g. try following code with and without the routing calls.

Regards,
Slavcho

Code
Select All
var layout = new LayeredLayout();
layout.Orientation = Layout.Orientation.Vertical;
layout.LinkType = LayeredLayoutLinkType.Cascading;
layout.LinkPadding = 10;
layout.Arrange(diagram);

//diagram.LinkRouter = new GridRouter();
//diagram.RouteAllLinks();
new OrthogonalRouter().Arrange(diagram); 

  
Back to top
 
IP Logged
 
Bertrand
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 7
Joined: Jan 24th, 2018
Re: WPF Diagram - Custom nodes and layout
Reply #5 - Jan 26th, 2018 at 9:49am
Print Post  
With those informations, it works well now !

Thank you
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint