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

Drag insert

1 Answer 52 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Anders Lind
Top achievements
Rank 1
Anders Lind asked on 03 Nov 2014, 08:28 AM
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

1 Answer, 1 is accepted

Sort by
0
Zarko
Telerik team
answered on 05 Nov 2014, 04:11 PM
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.

 
Tags
Diagram
Asked by
Anders Lind
Top achievements
Rank 1
Answers by
Zarko
Telerik team
Share this question
or