Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Coloring control points of link. (Read 1206 times)
NIkolayev_Egor
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 9
Joined: Jan 22nd, 2019
Coloring control points of link.
Sep 9th, 2019 at 2:18pm
Print Post  
How fill with color control point of link if this link is connected to node at this control point?
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Coloring control points of link.
Reply #1 - Sep 10th, 2019 at 5:29am
Print Post  
The only way i can see with public APIs is using custom drawing -

Code
Select All
// in InitializeLink or LinkCreated handler
link.HandlesStyle = HandlesStyle.Custom;

// handler of Diagram.DrawAdjustmentHandles event
void OnDrawAdjustmentHandles(object sender, DrawItemEventArgs e)
{
    var link = e.Item as DiagramLink;
    if (link != null)
    {
        // draw standard handles
        link.HandlesStyle = HandlesStyle.SquareHandles;
        link.DrawHandles(e.Graphics, diagram.ActiveItemHandlesStyle);
        link.HandlesStyle = HandlesStyle.Custom;

        // paint over end points
        var hsize = diagram.AdjustmentHandlesSize;
        var rsize = new Size(hsize, hsize);

        var firstPoint = new Rect(link.TransformDiagramToItem(link.StartPoint), rsize);
        firstPoint.Offset(-hsize / 2, -hsize / 2);
        e.Graphics.DrawRectangle(
            link.Origin != null ? Brushes.Green : Brushes.Red,
            diagram.ActiveItemHandlesStyle.HandlePen,
            firstPoint);

        var lastPoint = new Rect(link.TransformDiagramToItem(link.EndPoint), rsize);
        lastPoint.Offset(-hsize / 2, -hsize / 2);
        e.Graphics.DrawRectangle(
            link.Destination != null ? Brushes.Green : Brushes.Red,
            diagram.ActiveItemHandlesStyle.HandlePen,
            lastPoint);
    }
}
 



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


I Love MindFusion!

Posts: 9
Joined: Jan 22nd, 2019
Re: Coloring control points of link.
Reply #2 - Sep 10th, 2019 at 11:52am
Print Post  
Great! All working! Many thanks and best regards!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint