We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Custom Tool

Hello,

I spent quite a time on finding out how to create a custom tool and about the concepts of the standard tools for diagrams.

What I want to have is one custom tool that does the following:

- in default mode (i.e. when it's just activated) it should do nothing else then show the normal mouse cursor and perform a click and selection on diagram nodes. It must not offer selecting a range, panning, zooming or whatever, just a simple click
- if I hold ctrl pressed I want to change to the MoveTool as long as the ctrl key is pressed. As soon as the ctrl key is not pressed it should return back to the default mode
- if I hold down the alt key I want the zoom tool for as long as the alt key is pressed
- if I hold the shift key I want the tool to pan the diagram

My approach is this one below. But this does not do what I want. Pan and Zoom works fine, but when I leave the ctrl or alt key, the tool remains active and I do not get back to this tool at all.

Even worse when I do this with MoveTool it first moves the node and when I release the mouse button a copy of the dragged node is created.

How can I get this working?

Regards,
Christian




public class DiagramStandardTool : UITool
{
public DiagramStandardTool(DiagramController controller)
: base(controller, "InteractiveNodeTool")
{
this.SingleActionTool = false;
}

public override Tool ProcessMouseMove(MouseEventArgs e)
{
return this;
}

public override Tool ProcessMouseUp(MouseEventArgs e)
{
return this;
}

public override Tool ProcessMouseDown(MouseEventArgs e)
{
if (!InAction)
{
if (Control.ModifierKeys == Keys.Alt)
{
return PerformZoom(e);
}
if (Control.ModifierKeys == Keys.Control)
{
return PerformPan(e);
}
}
return this;
}

///
/// Activate Zoomtool and process its MouseDown.
///

/// The event args.
/// The tool to resize.
protected virtual Tool PerformZoom(MouseEventArgs evtArgs)
{
ZoomTool tool = new ZoomTool(this.Controller);
tool.ProcessMouseDown(evtArgs);
return tool;
}

///
/// Activate Zoomtool and process its MouseDown.
///

/// The event args.
/// The tool to resize.
protected virtual Tool PerformPan(MouseEventArgs evtArgs)
{
PanTool tool = new PanTool(this.Controller);
tool.ProcessMouseDown(evtArgs);
tool.SingleActionTool = true;
return tool;
}
}



1 Reply

AA Amsath Ali M Syncfusion Team March 27, 2012 12:34 PM UTC

Hi Christian,

Thanks for using Syncfusion products.

Since you have created a separate Direct-Trac incident [92494] for your query, please refer that incident for better follow up. Please let us know if you have any queries.

Regards,
Amsath Ali. M



Loader.
Live Chat Icon For mobile
Up arrow icon