- Welcome, Guest. Please Login or Register
MindFusion  
  We are soon releasing MindFusion.JavaScript pack. Initial version includes chart, diagram, calendar, map, virtual keyboard, gauge and UI components. Here are the beta version and live demo for anyone interested.  
  HomeHelpSearchLoginRegister   
     
     
   
 
Page Index Toggle Pages: 1 Send Topic Print  
Moving diagramlink as a node.
Read 319 times

NIkolayev_Egor   Offline
YaBB Newbies
*
Posts: 2
I Love MindFusion!


   
     
 
Moving diagramlink as a node.
Jan 22nd, 2019 at 7:38am
 
Hello, I want to implement moving diagramlink just like as a node (all control points and segments in one time) - simple selection on one-click and drag-and-drop to needed place.
 
 
 
IP Logged    
 
     

Slavcho   Offline
God Member
*****
Posts: 1718
Gender: male
tech.support


   
     
 
Re: Moving diagramlink as a node.
Reply #1 - Jan 22nd, 2019 at 8:47am
 
Hi,

That's not supported out of the box, but try following -

Code:
diagram.CustomBehavior = new MoveLinkBehavor(diagram);

class MoveLinkBehavor : LinkShapesBehavior
{
    public MoveLinkBehavor(Diagram diagram) : base(diagram)
    {
    }

    protected override InteractionState StartDrawCommon(Point point, MouseButton button)
    {
        var link = Diagram.GetLinkAt(point, 5);
        if (link != null && link.HitTestHandle(point) == null)
        {
            var points = link.ControlPoints.Clone();
            Diagram.Selection.Change(link);
            return new InteractionState(
                new LinkMover(link), NodeAdjustmentHandle.Move,
                MindFusion.Diagramming.Wpf.Action.Modify);
        }
        return base.StartDrawCommon(point, button);
    }
}

class LinkMover : DiagramNode
{
    public LinkMover(DiagramLink link)
        : base(link.Parent)
    {
        this.link = link;
        this.points = link.ControlPoints.Clone();
    }

    protected override void UpdateModify(Point current, InteractionState ist)
    {
        var delta = ist.CurrentPoint - ist.StartPoint;
        link.ControlPoints.Clear();
        link.ControlPoints.AddRange(points);
        for (int i = 0; i < points.Count; i++)
            link.ControlPoints[i] = points[i] + delta;
        link.UpdateFromPoints();
        base.UpdateModify(current, ist);
    }

    DiagramLink link;
    PointCollection points;
} 



Regards,
Slavcho
Mindfusion
 
 
 
IP Logged    
 
     

NIkolayev_Egor   Offline
YaBB Newbies
*
Posts: 2
I Love MindFusion!


   
     
 
Re: Moving diagramlink as a node.
Reply #2 - Jan 24th, 2019 at 11:58am
 
Great! All working! Many thanks!
 
 
 
IP Logged    
 
     
Page Index Toggle Pages: 1 Send Topic Print