Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Questions about containers (Read 2813 times)
Cornel
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 23
Joined: Dec 17th, 2008
Questions about containers
Jan 12th, 2009 at 7:57am
Print Post  
Hi all,
We are evaluating the software and we need some advice in creating a container shape with the following requirements:
- create custom container shape (or shapenode?) having two custom properties Name and Description;
- the container shape should be a rectangle having the Name displayed over the top edge of the rectangle (so right on the edge, not above or bellow it);
- other custom shapes are placed inside of this container (we created some custom shapes) and it should be also possible to place those shapes over the edges of the container.
Is this possible with FlowChart.NET? How?
Thanks,
Cornel
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Questions about containers
Reply #1 - Jan 12th, 2009 at 11:24am
Print Post  
Hi,

You could use ordinary ShapeNodes. Containment can be implemented using the AttachTo method. The text can be displayed over the edge of the shape in several ways:
- custom drawing, but you might have to reset the clip region first
- define a custom Shape whose text area is above the top of the shape (having Y coordinates < 0)
- display the text in another node, make that node Transparent and Locked, and attach it to the container node.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Cornel
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 23
Joined: Dec 17th, 2008
Re: Questions about containers
Reply #2 - Jan 12th, 2009 at 12:23pm
Print Post  
Hi Stoyan,
Thanks for the quick answer.
Still, I’m not sure how to create what we need (please be patient with me Smiley). In short, on a diagram we have three shape types, named T, A and O. The shapes T and A may only be placed inside (or on the edge of) O. T and A should also be children of O so that when O is moved, resized or deleted its children should also be moved, resized or deleted. For this reason I thought O should be a container node, but when I delete the O shape its children remain on the diagram; also I couldn’t place T or A on the edge of O.
I have a picture with a diagram we need to create. I’ll send it to you by mail. Please give some hints about how to create such diagram with FC.

Thanks in advance,
Cornel
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Questions about containers
Reply #3 - Jan 12th, 2009 at 12:51pm
Print Post  
Hi Cornel,

One of the ways to create the O node:

Code
Select All
private void Form1_Load(object sender, System.EventArgs e)
{
	CreateONode(100, 40, 150, 80, "CA00: PIZZERIA");
}

ShapeNode CreateONode(float x, float y, float w, float h, string text)
{
	ShapeNode o = diagram.Factory.CreateShapeNode(x, y, w, h, Shape.FromId("o"));
	o.Brush = new SolidBrush(Color.White);
	o.Pen = new Pen(Color.LightGray, 1);

	ShapeNode label = diagram.Factory.CreateShapeNode(x, y - 5, w, 10);
	label.AttachTo(o, AttachToNode.TopCenter);
	label.Text = text;
	label.TextFormat.LineAlignment = StringAlignment.Center;
	label.Transparent = true;
	label.Locked = true;

	return o;
}
 

  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Questions about containers
Reply #4 - Jan 12th, 2009 at 1:03pm
Print Post  
Creating a T node and attaching it to the O:

Code
Select All
private void Form1_Load(object sender, System.EventArgs e)
{
	Shape tdef = new Shape(
		Shapes.Ellipse.Outline,
		Shapes.Decision.Outline,
		null,
		FillMode.Winding, "T");

	ShapeNode o = CreateONode(100, 40, 150, 80, "CA00: PIZZERIA");
	CreateTNode(85, 55, 30, 30, "T01", "completion").AttachTo(o, AttachToNode.TopLeft);
}

ShapeNode CreateTNode(float x, float y, float w, float h, string name, string labelText)
{
	ShapeNode t = diagram.Factory.CreateShapeNode(x, y, w, h, Shape.FromId("T"));
	t.Brush = new SolidBrush(Color.White);
	t.Pen = new Pen(Color.Red, 0.5f);
	t.Text = name;
	t.Font = new Font("Arial", 15f);

	ShapeNode label = diagram.Factory.CreateShapeNode(x, y + h, w, 10);
	label.AttachTo(t, AttachToNode.TopCenter);
	label.Text = labelText;
	label.TextFormat.LineAlignment = StringAlignment.Center;
	label.Transparent = true;
	label.Locked = true;

	return t;
}
 



Now if you move the O node, T follows it.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Questions about containers
Reply #5 - Jan 12th, 2009 at 1:09pm
Print Post  
Actually you don't need a separate O definition, so in CreateONode replace Shape.FromId("o") with Shapes.Rectangle.

"A" nodes can be created in a similar manner, or you could use TableNodes that contain just one cell.

After calling node.AttachTo(o, ...), set o.SubordinateGroup.AutoDeleteItems = true, and deleting the O node will also delete its child nodes.

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