Drag insert

2 posts, 0 answers
  1. Anders Lind
    Anders Lind avatar
    5 posts
    Member since:
    Aug 2014

    Posted 03 Nov 2014 Link to this post

    We are implemting a diagram with geometry shapes. These shapes is meant to be inserted in a work "Shapes" way. Meaning this:

    User select a circle from the ribbon, and the cursor changes to cross.
    Now when the user press and hold left mouse button (MouseLeftButtonDown), the shape is inserted and a resize operation is started.

    My problem is i have some trouble starting the resize operation.

    I have tried in PreviewMouseLeftButtonDown to set handle, and change the ActiveTool to ResizeSENW, and call ResizeIntialise on the Resize service.

    This with no luck. Can you guys point me in the right direction to achieve this.

    Regards

    Anders
  2. Zarko
    Admin
    Zarko avatar
    755 posts

    Posted 05 Nov 2014 Link to this post

    Hello Anders,
    I'd like to point out that we have an SDK demo - Custom tools and one of the tools there ("ShapeTool") does something very similar so you should try it out.
    As for your scenario - this code should help you:
    private void diagram_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
    {
        var position = e.GetPosition(this.diagram);
        var transformedPosition = this.diagram.GetTransformedPoint(position);
        var shape = new RadDiagramShape() { Position = transformedPosition, Width = 60, Height = 40 };
        this.diagram.Items.Add(shape);
        this.diagram.DeselectAll();
        shape.IsSelected = true;
     
        var tooLService = this.diagram.ServiceLocator.GetService<IToolService>();
        tooLService.ActivateTool(ManipulationTool.ToolNameNWSE);
        this.resizeTool = tooLService.FindTool(ManipulationTool.ToolNameNWSE) as ManipulationTool;
        this.resizeTool.MouseDown(new PointerArgs(position, transformedPosition));
    }
     
    private void diagram_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
    {
        var position = e.GetPosition(this.diagram);
        var transformedPosition = this.diagram.GetTransformedPoint(position);
        this.resizeTool.MouseUp(new PointerArgs(position, transformedPosition));
    }
    If you have more questions feel free to ask.

    Regards,
    Zarko
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top