Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Custom draw ContainerNodes (Read 1463 times)
AnthonyBrien
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 11
Joined: Feb 5th, 2008
Custom draw ContainerNodes
Feb 22nd, 2008 at 8:01pm
Print Post  
Hello,

I am trying to use ContainerNodes to create a Statechart diagram. Statecharts are like UML state machines. States can link to any other states. States can also contain sub states, which is why I chose to use ContainerNodes.

However, I'm not sure how I'll be able to represent orthogonal states, which are states that are divided by a dashed line, to subdivide the state into concurrent parts.

I haven't found any way to customize the rendering of a ContainerNode. Any ideas how I could accomplish this? Here's an example of an orthogonal state:


Anthony Brien
Tools Architect, Assassin's Creed
UBISOFT
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Custom draw ContainerNodes
Reply #1 - Feb 23rd, 2008 at 7:29am
Print Post  
Hello,

You can override the ContainerNode.Draw method to accomplish that.

Code
Select All
using System.Drawing;
using System.Drawing.Drawing2D;

using MindFusion.Diagramming;
using MindFusion.Drawing;

using Pen = System.Drawing.Pen;


namespace OrthogonalStates
{
	/// <summary>
	/// Summary description for OrthogonalState.
	/// </summary>
	public class OrthogonalState : ContainerNode
	{
		public OrthogonalState(Diagram diagram) : base(diagram)
		{
		}

		public override void Draw(IGraphics graphics, RenderOptions options)
		{
			float dividerLineY = Bounds.Bottom - Bounds.Height / 3;
			base.Draw(graphics, options);

			Pen pen = new Pen(Color.Black, 0);
			pen.DashStyle = DashStyle.Dash;
			graphics.DrawLine(pen, Bounds.Left, dividerLineY, Bounds.Right, dividerLineY);
			pen.Dispose();
		}
	}
}

...

private void MainForm_Load(object sender, System.EventArgs e)
{
	Diagram.RegisterItemClass(typeof(OrthogonalState), "OrthogonalState", 1);

	diagramView.Behavior = Behavior.Custom;
	diagramView.CustomNodeType = typeof(OrthogonalState);
}
 



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