Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How to get the click Event? (Read 4036 times)
moelski
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 50
Joined: Feb 28th, 2011
How to get the click Event?
Mar 18th, 2011 at 11:29am
Print Post  
Hi !

In your demo application you add Tablenodes like this:
Code
Select All
private void OnCreateEntityBtn(object sender, EventArgs e)
{
AddEntityForm form = new AddEntityForm();

if (form.ShowDialog(this) != DialogResult.OK)
return;

float rh = _diagram.TableRowHeight;
float th = _diagram.TableCaptionHeight;
float totalh = th + 4 * rh;
TableNode t = _diagram.Factory.CreateTableNode(5, 5, 30 + 2 * rh, totalh);

t.Caption = form.EntityName;
t.Tag = form.EntityDescription;

// Create the help button
RectangleF rc = t.Bounds;
ShapeNode btn = _diagram.Factory.CreateShapeNode(rc.Left + 1.4f,
rc.Bottom - rh, rh, rh);
btn.Transparent = true;
btn.Image = _generalImageList.Images[2];
btn.ImageAlign = ImageAlign.Center;
btn.AttachTo(t, AttachToNode.BottomLeft);
btn.Locked = true;
btn.Tag = 1;
....... 



How can I use this buttons? Must I assign the click event directly to the button or is there any other mechanism?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to get the click Event?
Reply #1 - Mar 18th, 2011 at 12:21pm
Print Post  
Hi,

If you don't need to display a lot of cells, we now recommend using CompositeNode for such scenarios. You could add a ButtonComponent to the node and attach a Click handler directly to the button. For an example, see the sample EmployeeNode class from the demo.

If you prefer using groups, you will have to handle the NodeClicked event, and then check e.Node and e.Node.MasterGroup to find out what 'button' has been clicked.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
moelski
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 50
Joined: Feb 28th, 2011
Re: How to get the click Event?
Reply #2 - Mar 18th, 2011 at 1:44pm
Print Post  
Hi Stoyan,

thx for that information.

Quote:
we now recommend using CompositeNode for such scenario

That looks much better than the Tablenodes  Smiley

But is there a way to have AnchorPoints, too?
We use it this way with tablenodes:


And could you tell me how to change the behaviour of drawing connections?
If draw a connection from an out to an in Anchor the line doesnīt use the direct way. It always uses angles like in the picture.
Could you tell me how to have only a direkt line during the drawing of the connection?

The red arrows show the line during connection drawing.
The black arrow is what I need during connection drawing ...
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to get the click Event?
Reply #3 - Mar 18th, 2011 at 2:05pm
Print Post  
Hi Dominik,

Quote:
But is there a way to have AnchorPoints, too?


You can set CompositeNode.AnchorPattern. However if you need to display a dynamic number of rows with anchor points on them, you'd be better off using TableNodes. Tables have the RowAnchorPattern property which is replicated for every row.

Quote:
The black arrow is what I need during connection drawing ...


Set the diagram's LinkStyle to Polyline and perhaps disable RouteLinks.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
moelski
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 50
Joined: Feb 28th, 2011
Re: How to get the click Event?
Reply #4 - Mar 18th, 2011 at 7:02pm
Print Post  
Hi !

I tried the compositeNode and it seems much more flexible.

I also get some Anchors in the node. But I canīt connect the anchors.

Can you tell me whatīs wrong here?
Code
Select All
	  static public CompositeNode EntityCompCreate(Diagram diagram, ImageList images, string EntityName)
	  {
		CompositeNode node = new CompositeNode(diagram);
		node.Bounds = new RectangleF(10, 10, 60, 40);
		node.Brush = new LinearGradientBrush(Color.RoyalBlue, Color.LightSkyBlue, 45);

		StackPanel panel = new StackPanel();
		panel.Orientation = MindFusion.Diagramming.Components.Orientation.Horizontal;
		panel.Spacing = 1;

		node.Components.Add(panel);

		AnchorPoint ptin = new AnchorPoint(30, 46, true, false, Color.Red, 0);
		ptin.MarkStyle = MarkStyle.Circle;
		AnchorPoint ptout = new AnchorPoint(60, 46, false, true, Color.Red, 3);
		ptout.MarkStyle = MarkStyle.Circle;

		node.AnchorPattern = new AnchorPattern();
		node.AnchorPattern.Points.Add(ptin);
		node.AnchorPattern.Points.Add(ptout);

		diagram.Nodes.Add(node);

		return node;
	  } 

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to get the click Event?
Reply #5 - Mar 21st, 2011 at 9:10am
Print Post  
Hi,

How can't you connect the anchors, from code or interactively? I was able to draw links between two nodes without problems. I had to modify your code to show the node though. By default CompositeNodes do not draw any background and you must set the Background property of a component to see anything, e.g. a BorderComponent:

Code
Select All
CompositeNode node = new CompositeNode(diagram);
node.Bounds = new RectangleF(10, 10, 60, 40);

BorderComponent bc = new BorderComponent();
bc.Background = new LinearGradientBrush(Color.RoyalBlue, Color.LightSkyBlue, 45);
node.Components.Add(bc);

StackPanel panel = new StackPanel();
panel.Orientation = MindFusion.Diagramming.Components.Orientation.Horizontal;
panel.Spacing = 1;
node.Components.Add(panel); 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
moelski
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 50
Joined: Feb 28th, 2011
Re: How to get the click Event?
Reply #6 - Mar 21st, 2011 at 6:03pm
Print Post  
Hi !

I tried it interactively ...

I canīt grap the Anchor with the mouse. If I press the left mouse button I only can move the node.

I have done a small video ...
I think that makes things clear Smiley

http://www.logview.info/Temp/Anchor.wmv

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to get the click Event?
Reply #7 - Mar 21st, 2011 at 6:37pm
Print Post  
You should move the points closer to the border in such case 8) Actually it depends on the nodes' HandlesStyle what will happen when you start to draw, and the one you are using reserves most of its inner area for moving. You could change HandlesStyle, or adapt the custom behavior class from this post to allow drawing links from the anchor points with any style:
http://mindfusion.eu/Forum/YaBB.pl?board=diaglite_disc;action=display;num=128273...

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