This is a migrated thread and some comments may be shown as answers.

How to draw horizontal/vertical RadDiagramConnection?

1 Answer 20 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
YB
Top achievements
Rank 1
YB asked on 22 Aug 2014, 12:45 AM
I want to draw a horizontal/vertical RadDiagramConnection when key Shift is pressed. How to achieve this?

1 Answer, 1 is accepted

Sort by
0
Milena
Telerik team
answered on 22 Aug 2014, 08:39 AM
Hi YB,

You can achieve such behavior by adding new diagram tool for creating connections on Shift pressed. To do this you should inherit ToolBase class of the RadDiagram and override the mouse/key events in the default tool.

A similar implementation you can see in our SDK example – CustomTools. There is implemented a ShapeTool for creating diagram shapes on the same user interactions. So, you can change a bit the ShapeTool:
1) You need startPoint (updated on MouseDown) and endpoint (updated on MouseMove) instead of rectangleTransformed;

2) On MouseUp you will create RadDiagramConnection instead of RadDiagramShape:

public bool MouseUp(PointerArgs e)
{
    if (this.IsActive)
    {
        this.Graph.AddConnection(new RadDiagramConnection()
        {
            StartPoint = startPoint,
            EndPoint = endPoint,
             ...
 
        }, isUndoable: true);
 
        this.ToolService.ActivatePrimaryTool();
    }
 
    return false;
}

Please give this approach a try and let us know if further assistance is needed. 

Regards,
Milena
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
Diagram
Asked by
YB
Top achievements
Rank 1
Answers by
Milena
Telerik team
Share this question
or