Hello,
my company bought DiagramLite about a month ago after a brief evaluation period.
We've received version 1.2 in spite of the fact we actually tested version 1.3, anyway...
I'm trying to implement a sort of automatic link split into segments and so I've been searching for some post about the subject.
Somehow I got into this:
http://mindfusion.eu/_samples/MyBehavior2.cs.
I've tried to use the code but there are a couple of new method which are not declared in v. 1.2: GetLinkAt() and Save/RestoreLocationState().
I've modified the code as follows:
protected override void OnMouseUp(MouseButtonEventArgs e)
{
if (Diagram.Interaction != null && (Diagram.Interaction.CurrentItem is DiagramLink) && dragSegment != DragLinkSegment.None)
{
var link = (DiagramLink)Diagram.Interaction.CurrentItem;
//___***var state = link.SaveLocationState();
var state = link.SaveState();
base.OnMouseUp(e);
//___***link.RestoreLocationState(state);
link.RestoreState(state);
return;
}
base.OnMouseUp(e);
}
and like this:
public override InteractionState StartDraw(Point point)
{
dragSegment = DragLinkSegment.None;
int segment = 0;
var item = Diagram.GetItemAt(point); // GetLinkAt(point, 5, true, ref segment);
if (item != null)
{
if (item is DiagramLink)
{
DiagramLink link = (DiagramLink)item;
segment = link.GetNearestSegment(point);
var points = link.ControlPoints;
if (segment == 0)
{
Point p1 = points[0];
p1.X += 10;
points.Insert(1, p1);
points.Insert(1, p1);
segment = 2;
link.UpdateFromPoints(true);
}
else if (segment == points.Count - 2)
{
Point p1 = points[points.Count - 1];
p1.X -= 10;
points.Insert(points.Count - 1, p1);
points.Insert(points.Count - 2, p1);
link.UpdateFromPoints(true);
}
dragSegment = points[segment].Y == points[segment + 1].Y ?
DragLinkSegment.Horizontal : DragLinkSegment.Vertical;
startPoint = points[segment];
return new InteractionState(link, Action.Modify, segment, link.ControlPoints[segment]);
}
}
Anyway... what I need is to allow the users to automatically create control points when they try to drag a link from a point that belongs to it.
This requirement is solved quite well by the above code. Anyhow, if I try and move a node which is connected to a link which has been jus splitted into segments, I notice that I cannot move the node properly (e.g.: I can move it up and down just for a little delta). This problem disappears as soon as I add a new Node.
Bottom line: can you provide me with some lines of code to properly implement the above requirement in version 1.2 and to avoid the "limited node repositioning after link splitting" problem?
Cheers,
baba