Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Derive from ContainerNode and display child nodes (Read 3256 times)
rajesh_patil74
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 220
Joined: Sep 3rd, 2009
Derive from ContainerNode and display child nodes
Mar 31st, 2010 at 10:25am
Print Post  
Hi Stoyo

I have a derived class from ContainerNode. This new class also contains some FixDecoration property for which I am provinding grid object based on some another property "FixDecorationType".

The above construction allows me to show "Pool" & "Lane" with vertical line which is at fixed location.

Now, whenever I add child items, in this container item, I need a region where items are always displayed.
For eq. If I add lane object in my Pool, the lane object should always be placed in grid with column = 2.
How to achive this ? what implementation i need to do in my derived class.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Derive from ContainerNode and display child no
Reply #1 - Mar 31st, 2010 at 11:01am
Print Post  
Hi Rajesh,

Try overriding the container's OnDropOver method, and after calling the base implementation move the dropped node to the second column if you detect is not entirely inside the column bounds.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
rajesh_patil74
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 220
Joined: Sep 3rd, 2009
Re: Derive from ContainerNode and display child no
Reply #2 - Mar 31st, 2010 at 12:50pm
Print Post  
Hi Stoyo

Can you help me in displaysing the Grid properly when i set fixdecorationtype = "Pool2".

In the attached example it doesn't work. Also, the child item which is added in the main item, I am not able to position in grid column 2.

https://cid-2b9bf77533900b84.skydrive.live.com/self.aspx/.Public/Tutorial31.zip

FixDecorationType = "Pool1" works as expected. The only difference is that, in case of Pool2 , child item gets added.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Derive from ContainerNode and display child no
Reply #3 - Mar 31st, 2010 at 6:23pm
Print Post  
Hi Rajesh,

You can't set an UIElement as a child of two elements, so the second line throws an exception:

this.Diagram.Nodes.Add(container);
grid.Children.Add(container);

Comment it out and that will work.

The KeepInsideParent property won't keep the child node only inside the grid's second column - you can fix that by handling NodeModifying or NodeModified. We can also add a property that defines the container's area where child items are constrained by KeepInsideParent.

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


I love YaBB 1G - SP1!

Posts: 220
Joined: Sep 3rd, 2009
Re: Derive from ContainerNode and display child no
Reply #4 - Apr 1st, 2010 at 6:18am
Print Post  
Hi Stoyo

Any idea on how to get cells left and top position within a grid.

As of now, I am setting the container nodes bounds as follow -
Code
Select All
void IControlerContainerNode_SizeChanged(object sender, SizeChangedEventArgs e)
{
double gridHeight = FixDecorationsContainer.ActualHeight;
double gridWidth = FixDecorationsContainer.ActualWidth;
double left = ((IControlerContainerNode)sender).Bounds.Left;
double top = ((IControlerContainerNode)sender).Bounds.Top;

int Rows = FixDecorationsContainer.RowDefinitions.Count;
int columns = FixDecorationsContainer.ColumnDefinitions.Count;

if (Rows > 0)
{
double cellHeight = FixDecorationsContainer.RowDefinitions[0].ActualHeight;
}

double prevWidth = FixDecorationsContainer.ColumnDefinitions[0].ActualWidth;
double cellWidth = FixDecorationsContainer.ColumnDefinitions[1].ActualWidth;
this.Children[0].Bounds = new Rect(left+prevWidth, top, cellWidth, gridHeight);
}
 



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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Derive from ContainerNode and display child no
Reply #5 - Apr 1st, 2010 at 11:31am
Print Post  
Hi Rajesh,

If the grid contains columns or rows of varying width / height, you can find the cell position by iterating over the column and row definitions in their respective lists and sum their actual widths / heights. Break the loop once it reaches the cell's column / row position. If all rows and columns will have the same size, just multiple the cell's index by their width / height.

If there is some UIElement aligned to the top-left of the cell, you could also use the UIElement.TransformToVisual method to find the UIElement's position within the grid.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint