How to draw horizontal/vertical RadDiagramConnection?

2 posts, 0 answers
  1. YB
    YB avatar
    3 posts
    Member since:
    Jan 2014

    Posted 21 Aug 2014 Link to this post

    I want to draw a horizontal/vertical RadDiagramConnection when key Shift is pressed. How to achieve this?
  2. Milena
    Admin
    Milena avatar
    204 posts

    Posted 22 Aug 2014 Link to this post

    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.
     
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top