problems for adding multiple connection point to one side of shape!

Hi
I'm using vs 2022 .net 6 and syncfusion version 20.4.0.38
I use the code below to create a rectangle and assign multiple connection points to the top left and use the offsetY property to Move Connection points down from the very top left!
But at first, of loading 2 connection points are placed on top of each other. and after a little resize on Height(Not width) using the mouse they become separated!!
I want them to be separated from the beginning
this is my code:

var rectangleF = new RectangleF((float) block.Position.X, (float) block.Position.Y, (float) block.Width,(float)block.Height);

var rect = new Rectangle(rectangleF);


Syncfusion.Windows.Forms.Diagram.Label label = new Syncfusion.Windows.Forms.Diagram.Label();

label.Text = block.TypeName;

rect.Labels.Add(label);

var FirstoffsetY = 20;

foreach (var blockInputVariable in block.InputVariables.BlockInputVariable)

{

var connectionPointIN = new ConnectionPoint();

connectionPointIN.Name = blockInputVariable.FormalParameter;

connectionPointIN.OffsetY = FirstoffsetY;

connectionPointIN.OffsetX = 0;

connectionPointIN.ConnectionPointType = ConnectionPointType.Incoming;

connectionPointIN.VisualType = PortVisualType.SquarePort;

connectionPointIN.Visible = true;

connectionPointIN.Position = Position.MiddleLeft;

rect.Ports.Add(connectionPointIN);

FirstoffsetY += 20;

}

 var rightPointFirstOffSetY = 20;

 foreach (var blockOutputVariable in block.OutPutVariables.BlockOutputVariables)

 {

    var connectionPointOut = new ConnectionPoint();

     connectionPointOut.Name = blockOutputVariable.FormalParameter;

     connectionPointOut.OffsetY = rightPointFirstOffSetY;

      connectionPointOut.OffsetX = 0;

      connectionPointOut.ConnectionPointType = ConnectionPointType.Outgoing;

     connectionPointOut.VisualType = PortVisualType.CirclePort;

      connectionPointOut.Visible = true;

      connectionPointOut.Position = Position.MiddleRight;

      rect.Ports.Add(connectionPointOut);

      rightPointFirstOffSetY += 20;

 }

rect.DrawPorts = true;

diagram.Model.AppendChild(rect);

diagram.UpdateView();


this is when a run the code :
1.JPG


this is when I resize the rectangle height (Not Width)just a little(smaller or bigger)
2.JPG

UPDATE : another problem Found :
when I add connection points to Right side of rectangle ! Same Problem exist and when I resize height of rectangle Right side connection points Goes to Left Side automatically !! Why ??
I'm So Confused !!


thanks!
I'm gonna upload a video !


2 Replies

MO mohammad May 28, 2023 07:18 AM UTC



KR Karkuvel Rajan Shanmugavel Syncfusion Team May 29, 2023 09:31 AM UTC

Hi Mohammad,


We have analyzed the provided code example and found that you have used OffsetX, OffsetY and Position properties to set the location of the Connection Points. If you know the X and Y values then use the OffsetX and OffsetY properties or else if you want to place the connection point in any specific position then use the Position property.


 

var rectangleF = new RectangleF((float) block.Position.X, (float) block.Position.Y, (float) block.Width,(float)block.Height);

var rect = new Rectangle(rectangleF);

 

Syncfusion.Windows.Forms.Diagram.Label label = new Syncfusion.Windows.Forms.Diagram.Label();

label.Text = block.TypeName;

rect.Labels.Add(label);

var FirstoffsetY = 20;

foreach (var blockInputVariable in block.InputVariables.BlockInputVariable)

{

var connectionPointIN = new ConnectionPoint();

connectionPointIN.Name = blockInputVariable.FormalParameter;

connectionPointIN.OffsetY = FirstoffsetY;

connectionPointIN.OffsetX = 0;

connectionPointIN.ConnectionPointType = ConnectionPointType.Incoming;

connectionPointIN.VisualType = PortVisualType.SquarePort;

connectionPointIN.Visible = true;

//connectionPointIN.Position = Position.MiddleLeft;

rect.Ports.Add(connectionPointIN);

FirstoffsetY += 20;

}

 var rightPointFirstOffSetY = 20;

 foreach (var blockOutputVariable in block.OutPutVariables.BlockOutputVariables)

 {

    var connectionPointOut = new ConnectionPoint();

     connectionPointOut.Name = blockOutputVariable.FormalParameter;

     connectionPointOut.OffsetY = rightPointFirstOffSetY;

      connectionPointOut.OffsetX = 0;

      connectionPointOut.ConnectionPointType = ConnectionPointType.Outgoing;

     connectionPointOut.VisualType = PortVisualType.CirclePort;

      connectionPointOut.Visible = true;

        //connectionPointOut.Position = Position.MiddleRight;

      rect.Ports.Add(connectionPointOut);

      rightPointFirstOffSetY += 20;

 }

rect.DrawPorts = true;

diagram.Model.AppendChild(rect);

diagram.UpdateView();

 

 


Regards,

Karkuvel Rajan S


Loader.
Up arrow icon