Page Index Toggle Pages: [1] 2 3  Send TopicPrint
Very Hot Topic (More than 25 Replies) Customizing node appearance (Read 20295 times)
Hunter
Full Member
***
Offline



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Customizing node appearance
Dec 29th, 2009 at 8:18am
Print Post  
Hello. I can't find in the help file how can I add shadows to my nodes?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Customizing node appearance
Reply #1 - Dec 29th, 2009 at 11:19am
Print Post  
Hi,

Set their Effect property to a DropShadowEffect instance.

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



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Re: Customizing node appearance
Reply #2 - Dec 29th, 2009 at 12:28pm
Print Post  
Thanks
  
Back to top
 
IP Logged
 
Hunter
Full Member
***
Offline



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Re: Customizing node appearance
Reply #3 - Dec 29th, 2009 at 2:27pm
Print Post  
How to cutomize handles style in following way:
1) When mouse cursor in the any position over node exlude anchor points and corners the node will be moved
2) when mouse position over is the anchor point the link will be creates from this point
3) When mouse position over the corners the node will be resize?
I defined the next event handler:
Code
Select All
	  private void OnDiagramHitTestAdjustmentHandles(object sender, HitTestEventArgs e)
	  {
		if (e.Item == null || e.Item.GetType() != typeof(TPDENode)) return;
		TPDENode node = e.Item as TPDENode;
		if (node.Type == NodeType.SimpleProcess && node.Bounds.Contains(e.MousePosition))
		{
		    bool bOverAnchorPoint = false;
		    foreach (AnchorPoint pnt in node.AnchorPattern.Points)
		    {
			  if (pnt.IsMouseOver)
			  {
				bOverAnchorPoint = true;
				break;
			  }
		    }
		    if (!bOverAnchorPoint) e.HitResult = 8;
		    else if (node.Bounds.TopLeft == e.MousePosition) e.HitResult = 0;
		    else if (node.Bounds.TopRight == e.MousePosition) e.HitResult = 1;
		    else if (node.Bounds.BottomLeft == e.MousePosition) e.HitResult = 2;
		    else if (node.Bounds.BottomRight == e.MousePosition) e.HitResult = 3;
		    else e.HitResult = -1;
		}
	  }
 


But in this case I can only move the node...
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Customizing node appearance
Reply #4 - Dec 29th, 2009 at 4:04pm
Print Post  
Try this:

Code
Select All
bool bOverAnchorPoint = false;
foreach (AnchorPoint pnt in node.AnchorPattern.Points)
{
	var transform = pnt.TransformToVisual(diagram.DocumentPlane);
	if (Utilities.Distance(transform.Transform(new Point(2, 2)), e.MousePosition) < 5)
	{
		bOverAnchorPoint = true;
		break;
	}
}
if (bOverAnchorPoint) e.HitResult = -1;
else if (Utilities.Distance(node.Bounds.TopLeft, e.MousePosition) < 5) e.HitResult = 0;
else if (Utilities.Distance(node.Bounds.TopRight, e.MousePosition) < 5) e.HitResult = 1;
else if (Utilities.Distance(node.Bounds.BottomRight, e.MousePosition) < 5) e.HitResult = 2;
else if (Utilities.Distance(node.Bounds.BottomLeft, e.MousePosition) < 5) e.HitResult = 3;
else e.HitResult = 8; 

  
Back to top
 
IP Logged
 
Hunter
Full Member
***
Offline



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Re: Customizing node appearance
Reply #5 - Dec 29th, 2009 at 4:19pm
Print Post  
Thank you. All works as need!
  
Back to top
 
IP Logged
 
Hunter
Full Member
***
Offline



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Re: Customizing node appearance
Reply #6 - Jan 14th, 2010 at 3:12pm
Print Post  
Can I show anchor points always? Now they are shown only when mouse is over the node or link. I can call node.DrawHandles() in SetMouseCursor override but I need to get DrawingContext and HandlesVisualStyle
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Customizing node appearance
Reply #7 - Jan 14th, 2010 at 3:25pm
Print Post  
Set Diagram.ShowAnchors = Always 8)
  
Back to top
 
IP Logged
 
Hunter
Full Member
***
Offline



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Re: Customizing node appearance
Reply #8 - Jan 14th, 2010 at 3:27pm
Print Post  
Thank you Smiley. The end of working day counted Wink
  
Back to top
 
IP Logged
 
Hunter
Full Member
***
Offline



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Re: Customizing node appearance
Reply #9 - Jan 19th, 2010 at 9:57am
Print Post  
Is there any way to show numbers of anchor points near the points of shape nodes? Is it necessary to override the AnchorPoint class to add this functionality?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Customizing node appearance
Reply #10 - Jan 19th, 2010 at 10:21am
Print Post  
Do you mean displaying the anchor point index in a label near the point?
  
Back to top
 
IP Logged
 
Hunter
Full Member
***
Offline



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Re: Customizing node appearance
Reply #11 - Jan 19th, 2010 at 10:24am
Print Post  
Yes. But I need not only the indexes. For example my node has 5 points at the left side and they are inputs. I need to display their indexes from 1 to 5. And the same node has 3 points at the right side and they are outputs. I need to display their indexes from 1 to 3.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Customizing node appearance
Reply #12 - Jan 19th, 2010 at 10:49am
Print Post  
You will have to set the points MarkStyle to Custom, and handle the DrawAnchorPoint event to render both the point's mark and label.

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



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Re: Customizing node appearance
Reply #13 - Jan 19th, 2010 at 11:55am
Print Post  
But DrawAnchorPointEventArgs contains only AnchorPoint and GraphicContext. How can I take the DiagramNode of this point?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Customizing node appearance
Reply #14 - Jan 19th, 2010 at 12:13pm
Print Post  
It also has a "public DiagramNode Node" property.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 3 
Send TopicPrint