Hi,
From what I saw, unconnected links are not moved even when in multiple selection. The following code implements that:
private void diagram_SelectionMoving(object sender, ValidationEventArgs e)
{
MoveLineBehavior b = view.CustomBehavior as MoveLineBehavior;
if (b == null)
return;
PointF current = view.ClientToDoc(view.PointToClient(MousePosition));
foreach (DiagramLink link in diagram.Selection.Links)
{
if (link.Origin is DummyNode && link.Destination is DummyNode)
{
for (int i = 0; i < link.ControlPoints.Count; ++i)
{
PointF p = link.ControlPoints[i];
p.X += current.X - startDrag.X;
p.Y += current.Y - startDrag.Y;
link.ControlPoints[i] = p;
}
link.UpdateFromPoints();
}
}
startDrag = current;
}
private void view_MouseDown(object sender, MouseEventArgs e)
{
startDrag = view.ClientToDoc(view.PointToClient(MousePosition));
}
internal PointF startDrag;
Next, using a custom behavior object, you can trick the control to process moving a single selected link as if it's in a multiple selection:
class MoveLineBehavior : LinkShapesBehavior
{
public MoveLineBehavior(DiagramView view) : base(view)
{
}
public override InteractionState StartDraw(PointF point)
{
DiagramLink link = Diagram.GetLinkAt(point, 1);
if (link != null && link.Origin is DummyNode && link.Destination is DummyNode)
return new InteractionState(Diagram.Selection, 8, Action.Modify);
return base.StartDraw(point);
}
}
That code uses the V5 API. I can't remember if version 4.0.3 had support for custom behaviors. If it doesn't, you might have to add some hidden node to the selection, e.g. in the MouseDown event, to implement that. Otherwise you should be able to port the code to V4 by replacing DiagramLink with Arrow, Diagram.Links with FlowChart.Arrows, etc..
I hope that helps,
Stoyan