Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Moving/selecting custom shapes created by CreatePathDelegate (Read 1387 times)
Arash
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 1
Joined: Dec 6th, 2013
Moving/selecting custom shapes created by CreatePathDelegate
Dec 6th, 2013 at 12:33am
Print Post  
Hi,

I have created Node on diagram using standard Shapes and they work fine.
When I create a custom shape using delegate CreatePathDelegate it cannot be selected. Should I change Handler or something for these custom shapes?

As you can see in the picture the yellow shape is create by Shapes.Save and works fine.
However the blue shape is create by CreatePathDelegate and behaviors differently. Although the share the same method to be created as a Node and have the same properties configuration.

Here is my method to create shape:
public virtual GraphicsPath CreateNodePath(RectangleF nodeBounds)
{
PointF[] shapePoints = new PointF[5];
shapePoints[0] = new PointF(nodeBounds.Left, nodeBounds.Top);
shapePoints[1] = new PointF(nodeBounds.Right, nodeBounds.Top);
shapePoints[2] = new PointF(nodeBounds.Right, nodeBounds.Bottom);
shapePoints[3] = new PointF(nodeBounds.Left, nodeBounds.Top + nodeBounds.Height);
shapePoints[4] = shapePoints[0];

var g = new GraphicsPath();
// g.AddRectangle(nodeBounds);
g.AddLines(shapePoints);
g.CloseAllFigures();
return g;
}

As you can see I have tried g.AddRectangle(nodeBounds); and still no luck!

Arash
  

Image.PNG (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Moving/selecting custom shapes created by CreatePathDelegate
Reply #1 - Dec 6th, 2013 at 7:06am
Print Post  
Hi,

The path returned by that delegate is rendered by nodes' DrawLocal method and path coordinates should be specified in the node's local coordinate system, starting from [0,0]. This should work:

Code
Select All
public virtual GraphicsPath CreateNodePath(RectangleF nodeBounds)
{
    PointF[] shapePoints = new PointF[5];
    shapePoints[0] = new PointF(0, 0);
    shapePoints[1] = new PointF(nodeBounds.Width, 0);
    shapePoints[2] = new PointF(nodeBounds.Width, nodeBounds.Height);
    shapePoints[3] = new PointF(0, nodeBounds.Height);
    shapePoints[4] = shapePoints[0];

    var g = new GraphicsPath();
    // g.AddRectangle(nodeBounds);
    g.AddLines(shapePoints);
    g.CloseAllFigures();
    return g;
} 



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