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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Custom Tool

Thread ID:

Created:

Updated:

Platform:

Replies:

103008 Mar 22,2012 02:49 PM UTC Mar 27,2012 12:34 PM UTC WinForms 1
loading
Tags: Diagram
Christian Rattat
Asked On March 22, 2012 02:49 PM UTC

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;
}
}



Amsath Ali M [Syncfusion]
Replied On 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



CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;