Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic DiagramNodeAdapter Custom Anchor (Read 3197 times)
Jon Carbone
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 5
Joined: Jan 21st, 2015
DiagramNodeAdapter Custom Anchor
Jan 21st, 2015 at 4:17pm
Print Post  
Hello, I'm attempting to add a custom anchor point for a DiagramNodeAdapter, but it doesn't seem to be working for me.

I'm adding a callback to the DrawAnchorPoint event of the Diagram, and the callback is being called, but the custom anchor (red circle) I'm drawing doesn't show up on the DiagramNodeAdapter nodes. I also have ContainerNodes in the diagram, and the custom anchor draws fine for them.

Here is the code, though there isn't much to it:

diagram.DrawAnchorPoint += new EventHandler<DrawAnchorPointEventArgs>(DrawAnchorPoint);

        void DrawAnchorPoint(object sender, DrawAnchorPointEventArgs e)
        {
            e.Graphics.DrawEllipse(Brushes.Red, new Pen(), new Point(0, 0), 10, 10);
        }

Is there a property or something simple I'm missing to get this to work for DiagramNodeAdapter nodes?

Any help would be greatly appreciated.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: DiagramNodeAdapter Custom Anchor
Reply #1 - Jan 21st, 2015 at 5:22pm
Print Post  
Hi,

It works for me with a Button control in the adapter node. What kind of controls are you using?

Also try setting ShowAnchors = Always. If it shows up then but not with the default Auto value, the problem might be caused by mouse-move event not detected when over the hosted control.

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


I Love MindFusion!

Posts: 5
Joined: Jan 21st, 2015
Re: DiagramNodeAdapter Custom Anchor
Reply #2 - Jan 21st, 2015 at 7:54pm
Print Post  
Thanks for the fast reply!

I'm using a custom WPF UserControl (inheriting from System.Windows.Controls.UserControl).I set ShowAnchors = Always on the Diagram as per your advice.

I tried it with a Button and received the same result. Here is the code I used to accomplish that:

System.Windows.Controls.Button testButton = new System.Windows.Controls.Button();
DiagramNodeAdapter testButtonNode = new DiagramNodeAdapter(testButton);
diagram.Nodes.Add(testButtonNode);

I've attached a screenshot of the Diagram showing my custom node, my DiagramNodeAdapter containing a button, and a (working) ContainerNode.
  

mindfusionScreenshot.PNG ( 7 KB | 73 Downloads )
mindfusionScreenshot.PNG
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: DiagramNodeAdapter Custom Anchor
Reply #3 - Jan 22nd, 2015 at 12:39pm
Print Post  
Your code does not show AnchorPattern being set for the button. Doesn't it work if you set it to same AnchorPattern as ContainerNode's one?
  
Back to top
 
IP Logged
 
Jon Carbone
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 5
Joined: Jan 21st, 2015
Re: DiagramNodeAdapter Custom Anchor
Reply #4 - Apr 28th, 2015 at 6:00pm
Print Post  
This turned out to be developer error regarding the positioning of the anchors. They were large enough values as to result in the anchor points being well out of the bounds of the control.

Thanks for your help!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint