Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Automatic link split (Read 1838 times)
baba
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 16
Joined: Jan 20th, 2010
Automatic link split
Mar 17th, 2010 at 3:04pm
Print Post  
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

  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Automatic link split
Reply #1 - Mar 17th, 2010 at 3:10pm
Print Post  
Hi,

Register here to get version 1.3, and let me know if still have the problem with it:
http://clientsarea.eu/

The linked code is for our WPF control by the way.

Stoyan
  
Back to top
 
IP Logged
 
baba
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 16
Joined: Jan 20th, 2010
Re: Automatic link split
Reply #2 - Mar 18th, 2010 at 2:07pm
Print Post  
Hi stoyo,
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Automatic link split
Reply #3 - Mar 18th, 2010 at 3:21pm
Print Post  
Hi 8)
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint