Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How to create a Link other than drag-and-drop (Read 232 times)
Nobu
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 24
Joined: Nov 27th, 2023
How to create a Link other than drag-and-drop
Mar 26th, 2024 at 1:41am
Print Post  
Is it possible to create a Link while clicking on the View as shown in the attached figure?

  

2024-03-26.png ( 6 KB | 20 Downloads )
2024-03-26.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3204
Joined: Oct 19th, 2005
Re: How to create a Link other than drag-and-drop
Reply #1 - Mar 26th, 2024 at 7:52am
Print Post  
You could collect link points from DiagramView's mouse events -

Code
Select All
bool linkFromClicksMode = true;
DiagramLink linkFromClicks = null;

void diagramView_MouseUp(object sender, MouseEventArgs e)
{
    var diagramPoint = diagramView.ClientToDoc(e.Location);
    if (linkFromClicksMode)
    {
        var node = diagram.GetNodeAt(diagramPoint);
        if (linkFromClicks == null)
        {
            linkFromClicks = diagram.Factory.CreateDiagramLink(diagramPoint, diagramPoint);
            if (node != null)
            {
                linkFromClicks.OriginConnection = node.CreateConnectionPoint(
                    linkFromClicks, diagramPoint, false);
                linkFromClicks.StartPoint = node.GetNearestBorderPoint(diagramPoint);
            }
        }
        else
        {
            linkFromClicks.EndPoint = diagramPoint;
            if (node != null)
            {
                linkFromClicks.DestinationConnection = node.CreateConnectionPoint(
                    linkFromClicks, diagramPoint, true);
                linkFromClicks = null;
                linkFromClicksMode = false;
                return;
            }
            linkFromClicks.ControlPoints.Add(diagramPoint);
            linkFromClicks.UpdateFromPoints();
        }
    }
}

void diagramView_MouseMove(object sender, MouseEventArgs e)
{
    if (linkFromClicks != null)
    {
        var diagramPoint = diagramView.ClientToDoc(e.Location);
        linkFromClicks.EndPoint = diagramPoint;
        linkFromClicks.UpdateFromPoints();
    }
} 



Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Nobu
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 24
Joined: Nov 27th, 2023
Re: How to create a Link other than drag-and-drop
Reply #2 - Mar 26th, 2024 at 9:29am
Print Post  
Thank you for your answer.
I will give it a try.

regards,
nodu
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint