There are 3 routes you can go down here
1. Adjust the position as your render by using graphics.Transform(), but then the mouseover code etc would fail OR
2. Actually locate the port as you wish by overding the Shape.LocatePort function OR
3. Overriding the way the port offset is calculatedin Port.CalculateOffset
I include the code for the overriden methods
//Locate a port based on the orientation(side) of the parent and the percentagepublic virtual void LocatePort(Port port)
{
RectangleF shapeRect = TransformRectangle; PointF start = new PointF();
float ratio = port.Percent / 100;switch (port.Orientation)
{
case PortOrientation.Top: start = new PointF(shapeRect.X +(shapeRect.Width * ratio),shapeRect.Y-1);
break;case PortOrientation.Bottom:
start =
new PointF(shapeRect.X +(shapeRect.Width * ratio),shapeRect.Y+shapeRect.Height+1); break;
case PortOrientation.Left: start = new PointF(shapeRect.X-1,shapeRect.Y +(shapeRect.Height * ratio));
break;case PortOrientation.Right:
start =
new PointF(shapeRect.X + shapeRect.Width +1,shapeRect.Y +(shapeRect.Height * ratio)); break;
default: break;
}
port.Validate = false;
port.Location = Intercept(start);
port.Validate = true;
}
protected internal PointF CalculateOffset()
{
float width = Rectangle.Width;
float height = Rectangle.Height; float halfwidth = width / 2;
float halfheight = height / 2; if (Alignment == PortAlignment.Center || Parent ==null) return new PointF(- halfwidth, - halfheight);
//Return outset or inset values if (Alignment == PortAlignment.Outset)
{
if (mOrientation == PortOrientation.Top) return new PointF(- halfwidth,-height);
if (mOrientation == PortOrientation.Bottom) return new PointF(- halfwidth,0); if (mOrientation == PortOrientation.Left) return new PointF(-width,-halfheight); return new PointF(0,-halfheight);
}
else
{
if (mOrientation == PortOrientation.Top) return new PointF(- halfwidth,0);
if (mOrientation == PortOrientation.Bottom) return new PointF(- halfwidth,-height); if (mOrientation == PortOrientation.Left) return new PointF(0,-halfheight); return new PointF(-width,-halfheight);
}
}