Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Group nodes creation (Read 8849 times)
rajesh_patil74
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 220
Joined: Sep 3rd, 2009
Group nodes creation
Jan 8th, 2010 at 10:06am
Print Post  
Hi Stoyo,

I need to create some specific shape nodes ( treated as Grouping nodes like container).

These group nodes are just for showing border or grouping of multiple items. By setting transparnt color I am able to show grouping of specific nodes under one color.

In some cases it is possible that my top node is partially inside the group node and partially outside. With such case I see the border of group node in the node which is placed above it.

Is it possible that the "partial" border of node should not be shown when another node is placed  above it but not completely(partially in and paritally out).

-Regards
Rajesh
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Group nodes creation
Reply #1 - Jan 8th, 2010 at 12:12pm
Print Post  
Hi Rajesh,

You might set the group's Stroke to a semi-transparent color too. If you need that only when there is a child node intersecting the border, you might handle NodeModified and update the color if you detect the group's Y is between the child's Top and Bottom.

It will get more complicated if you need only the top border line to get semi transparent; you might have to define a custom node template that defines individual lines. You might also use a gradient brush that changes the color's alpha value, so that only a part of a line gets semi-transparent.

Stoyan
  
Back to top
 
IP Logged
 
rajesh_patil74
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 220
Joined: Sep 3rd, 2009
Re: Group nodes creation
Reply #2 - Jan 8th, 2010 at 12:52pm
Print Post  
Hi Stoyo

I want to implement something like following


In this image, the node with text "Test6111" displays half bottom part in different color. Expected is the color which is visible in Upper Top part should be displayed.

Similarly, I am not able to click on bottom part of "Test6111" or on nodes "Test211" and "Test111". I need all small nodes should use the yellow color which is outside the group node.

Will you provide me a code snipet for same.

Regards
Rajesh
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Group nodes creation
Reply #3 - Jan 8th, 2010 at 1:11pm
Print Post  
Hi Rajesh,

Try setting the group's ZIndex to 0.

Stoyan
  
Back to top
 
IP Logged
 
rajesh_patil74
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 220
Joined: Sep 3rd, 2009
Re: Group nodes creation
Reply #4 - Jan 8th, 2010 at 1:17pm
Print Post  
Hi Stoyo

Nope, setting ZIndex = 0 doesn't work. Its behavior is same as older one.

For your information, the 3 small nodes are created in load function and the group node is created using the default behaviour and then its color and zindex is changed in on node creation event.

-Rajesh
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Group nodes creation
Reply #5 - Jan 8th, 2010 at 1:30pm
Print Post  
Is the group a ContainerNode?
  
Back to top
 
IP Logged
 
rajesh_patil74
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 220
Joined: Sep 3rd, 2009
Re: Group nodes creation
Reply #6 - Jan 8th, 2010 at 1:48pm
Print Post  
Hi Stoyo

No, its normal node like any other node and created by default diagram behavior with mouse movement.

I checked with container node and when I add my child nodes in container nodes childeren collection I am able to click on the child nodes and the behavior which is expected when border is shown to group node is not visible when node is partially in group and partially out of group.

In my problem, I need same behavior using normal nodes.
In my application all nodes are normal node. The group node user might want to show below all nodes to just visually indicate the group of nodes ( in reality they are not child of any nodes) . Addtion of this group node is depend on user choice and it may be possible that one node needs to be shown shared by more than one container.

With container node, on node creation or resizing i need to find out which node needs to be added in current container. I don't want to do this for performance reason.

------------------------------------------------------------------Update for your infomration :
For container node i think adding childern is not required.

Following code doesn't give me expected behavior



foreach (MyShape shape1 in list)


{


ShapeNode shape = new ShapeNode(this);


shape.Brush = new SolidColorBrush(Color.FromArgb(255, 255, 255, 45));


//shape.Stroke = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));


shape.Text = shape1.Name;


//c.Children.Add(shape);


this.Nodes.Add(shape);


}

[b]

ContainerNode c = new ContainerNode(this);


c.Text = "123";


c.Brush = new SolidColorBrush(Color.FromArgb(10, 128, 0, 145));


//c.Stroke = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));


c.ZIndex = 0;


this.Nodes.Add(c);[/b]

But if I write the bold code before the for loop i get expected behavior. In my case the container needs to be created later on demand by the user.


Regards
Rajesh
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Group nodes creation
Reply #7 - Jan 8th, 2010 at 2:12pm
Print Post  
I've managed to make this work with ShapeNodes by calling Canvas.SetZIndex:

Code
Select All
private void OnNodeCreated(object sender, NodeEventArgs e)
{
	e.Node.ZIndex = 0;
	Canvas.SetZIndex(e.Node, 0);
	e.Node.Brush = Brushes.White;
} 



The ZIndex setter does that internally, but for some reason it needs a second call to hide behind the other nodes...

Stoyan
  
Back to top
 
IP Logged
 
rajesh_patil74
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 220
Joined: Sep 3rd, 2009
Re: Group nodes creation
Reply #8 - Jan 8th, 2010 at 2:31pm
Print Post  
Hi Stoyo

It seems there is some issue with
e.Node.ZIndex = 0;

Because I don't think second call is required. I commented out above statement and with
Canvas.SetZIndex(e.Node,0) it is working as expected.

Will you arrage to fix this issue.

-Regards
Rajesh
  
Back to top
WWW  
IP Logged
 
rajesh_patil74
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 220
Joined: Sep 3rd, 2009
Re: Group nodes creation
Reply #9 - Jan 11th, 2010 at 9:22am
Print Post  
Hi Stoyo

With nodes creation ( either created before or after the group node) setting Z-index using canvas works as expected and I can select the node to re-position.

However, selection of links is not working ( doesn't matter whether the links between the nodes are  created before or after the creation of group node.

Will you provide some insight on same.

Regards
Rajesh
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Group nodes creation
Reply #10 - Jan 11th, 2010 at 9:33am
Print Post  
Hi Rajesh,

Try setting diagram.HitTestPriority = ZOrder.

Stoyan
  
Back to top
 
IP Logged
 
rajesh_patil74
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 220
Joined: Sep 3rd, 2009
Re: Group nodes creation
Reply #11 - Jan 11th, 2010 at 2:24pm
Print Post  
Hi Stoyo

Somehow following code is not working for setting zindex.



int i = 0;


foreach (MyShape shape1 in list)


{


ShapeNode shape = new ShapeNode(this);


shape.Brush = new SolidColorBrush(Color.FromArgb(255, 255, 255, 45));


if (i == 3)


{



shape.Brush = new SolidColorBrush(Color.FromArgb(10, 128, 0, 145));



shape.ZIndex = 0;



Canvas.SetZIndex(shape, 0);



shape.Text = shape1.Name + "Back Node";


}


else


{



//shape.Stroke = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));



//shape.ZIndex = 1;



//Canvas.SetZIndex(shape, 1);



shape.Text = shape1.Name;


}


i = i + 1;


//c.Children.Add(shape);


this.Nodes.Add(shape);


}

I am not handling node creation event. The 4th node I am creating should be treated as group node.


Updates : If i set the Canvas.SetZindex after adding the node to the collection visual representation is correct but i am not able to click on items which are created before the group node. This is not working even after setting the HitTestPriority to ZOrder.

-Rajesh
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Group nodes creation
Reply #12 - Jan 11th, 2010 at 2:46pm
Print Post  
Hi,

Set node.ZIndex too after calling diagram.Nodes.Add. Z order operations do not have any effect before that.

Stoyan
  
Back to top
 
IP Logged
 
rajesh_patil74
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 220
Joined: Sep 3rd, 2009
Re: Group nodes creation
Reply #13 - Jan 11th, 2010 at 3:00pm
Print Post  
Hi,

Thanks. Its working now. But I guess its more logical to set zindex when node is created instead of setting once it gets added in collection.

-Rajesh
  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint