Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Display DiagramLink Hover image.. (Read 494 times)
tt
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 4
Joined: Jan 30th, 2024
Display DiagramLink Hover image..
Jan 30th, 2024 at 12:57am
Print Post  
Is it possible to display an image when hovering over a link?

When I hover over a link, an icon appears, and I want to do something when I click that icon.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3303
Joined: Oct 19th, 2005
Re: Display DiagramLink Hover image..
Reply #1 - Jan 30th, 2024 at 7:50am
Print Post  
Try hit-testing from MouseMove event -

Code
Select All
diagramView.PreviewMouseMove += OnViewMouseMove;

void OnViewMouseMove(object sender, MouseEventArgs e)
{
    var viewPoint = e.GetPosition(diagramView);
    var diagramPoint = diagramView.ViewToDiagram(viewPoint);
    var link = diagram.GetLinkAt(diagramPoint, 50);
    if (link != null && targetLink != link)
    {
        targetLink = link;
        if (itemUI != null)
            grid.Children.Remove(itemUI);

        var uiPoint = link.EndPoint;
        uiPoint = diagramView.DiagramToView(uiPoint);
        uiPoint = diagramView.TransformToAncestor(grid).Transform(uiPoint);

        itemUI = new Button { Content = "test" };
        itemUI.Click += (ss, ee) => link.Stroke = Brushes.Red;
        itemUI.Margin = new Thickness(uiPoint.X, uiPoint.Y, 0, 0);
        itemUI.HorizontalAlignment = HorizontalAlignment.Left;
        itemUI.VerticalAlignment = VerticalAlignment.Top;

        grid.Children.Add(itemUI);
    }
}

Button itemUI;
DiagramLink targetLink;
 



Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint