Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Clickable image in the TableNode header (Read 1386 times)
Ebeid Soliman ElSayed
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 1
Joined: Nov 9th, 2013
Clickable image in the TableNode header
Nov 9th, 2013 at 3:39pm
Print Post  
Hi,

I'm using MidFusion.Diagramming.TableNode and I want to add small clickable icon right to the header text.

Thanks,
Ebeid
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Clickable image in the TableNode header
Reply #1 - Nov 11th, 2013 at 7:37am
Print Post  
Hi,

One way to do that is via a ShapeNode attached to the table; for an example, see the Entities sample project. If you use attached nodes, you will have to filter them out when enumerating diagram.Nodes to process your main nodes.

Another way to implement that is via custom-drawing. Either derive from TableNode and override its DrawLocal method, or handle custom-draw events raised by the Diagram object:

Code
Select All
Image lockImage = Image.FromFile("ac0001-16.png");

RectangleF TopRight(TableNode table)
{
	var captionbarHeight = table.CaptionHeight;
	return new RectangleF(
		table.Bounds.Width - captionbarHeight, 0,
		captionbarHeight, captionbarHeight);
}

private void diagram_InitializeNode(object sender, NodeEventArgs e)
{
	var table = e.Node as TableNode;
	if (table != null)
		table.CustomDraw = CustomDraw.Additional2;
}

private void diagram_DrawNode(object sender, DrawNodeEventArgs e)
{
	var table = e.Node as TableNode;
	if (table != null)
	{
		var iconRect = TopRight(table);
		Utilities.DrawImage(e.Graphics,
			lockImage, iconRect, ImageAlign.Center);
	}
}

private void diagram_NodeClicked(object sender, NodeEventArgs e)
{
	var table = e.Node as TableNode;
	if (table != null)
	{
		var iconRect = TopRight(table);
		iconRect.Offset(table.Bounds.Location);
		if (iconRect.Contains(e.MousePosition))
			MessageBox.Show("click");
	}
} 



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