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

How disable copy shapes

Hi,
How to disable shape copying (by holding Ctrl key and mouse button up)?
I tried to override method Clone(), but spotted an stange issue: with every mouse click this shape becamed more transparent.



5 Replies

AD Administrator Syncfusion Team March 5, 2008 08:55 PM UTC

Hi Radmir,

If your intention is to prevent the Copy paste functionality while pressing control key and drag the node then you need to prevent the movement of nodes when pressing control key. You need to handle KeyDown and KeyUp event of the diagram control.

The attached sample demonstrates this behavior completely.

http://websamples.syncfusion.com/samples/Diagram.Windows/CloningNodes/main.htm

Please refer to it and let us know if you have any questions.

Please let me know if you have any questions.

Regards,
Nagaraj



RT Radmir Tagirov April 18, 2008 05:57 AM UTC

Hi,
I have a new problem. If I press Ctrl key, and then I try move a shape, all works correctly. But, if I start move a shape before I shall press Ctrl key this code doesn't work correctly.



AD Administrator Syncfusion Team June 2, 2008 11:14 AM UTC

Hi ,

Sorry for the delay in getting back to you.

Please refer to the modified sample. In this sample when you drag the node, the node can be moved and when you press control key while dragging the node, it will stop the moving and prevent the copy-paste action.

Sample: http://www.syncfusion.com/Product/uploads/Copy_PasteNodes_b2e1d64f.zip

Video: http://www.syncfusion.com/Product/uploads/Video_72146_121757f5.zip

Please let me know if you this helps.

Regards,
Nagaraj



SA Stephen Allen January 17, 2009 10:18 PM UTC

Neither of these solutions work very well, they require you to override the KeyDown and KeyUp events and don't work well when the user presses Ctrl after he starts dragging.

The best fix would be for Syncfustion to add an option on the Diagram that enables or disables this Ctrl+Drag copy feature.

As a work-around that is better than the ones proposed above, try the following:


public class YourClass
{
private Diagram _diagram;

public YourClass()
{
this._diagram = new Diagram();

// Substitute our own SelectTool that modifies the MoveTool so that
// we never make copies of nodes when Ctrl+Dragging
Tool selectTool = (Tool)_diagram.Controller.GetTool("SelectTool");
_diagram.Controller.UnRegisterTool(selectTool);
CustomSelectTool customSelectTool = new CustomSelectTool(_diagram.Controller);
_diagram.Controller.RegisterTool(customSelectTool);
if (_diagram.Controller.ActiveTool is SelectTool)
{
_diagram.Controller.ActivateTool(customSelectTool);
}
}

public class CustomSelectTool : SelectTool
{
public CustomSelectTool(DiagramController controller)
: base(controller)
{
}

public CustomSelectTool(DiagramController controller, SelectMode selectMode)
: base(controller, selectMode)
{
}

protected override Tool PerformMove(MouseEventArgs evtArgs)
{
MoveTool moveTool = (MoveTool) base.PerformMove(evtArgs);
moveTool.DragCopyOffset = float.MaxValue;
return moveTool;
}
}
}






Syncfusion_Ctrl_Drag_Workaround_bfcf307c.zip


AM Ajeet M Syncfusion Team January 19, 2009 06:30 AM UTC

Hi Stephen,

Thanks for your valuable suggestion and workaround for the ctrl+drag copy prevention.

We are already looking into appending a property flag for the use of ctrl+drag to allow copy of shapes as per user demand. We shall keep you updated on this always.

Let me know if you shall need any further clarifications in this regard.

Happy coding!

-Ajeet



Loader.
Live Chat Icon For mobile
Up arrow icon