Hi,
I have created my diagram based on “Planogram” example. My requirement is when i drag an object
from one group to other it should not be dragged. i have implement custom dragging tool in the following way
public class MyDraggingTool : DraggingTool
{
/// <summary>
/// To check whether the node is a ValidMember or not.
/// </summary>
/// <param name="group">The Group to check.</param>
/// <param name="node">The Node to verify.</param>
/// <returns>The status Boolean.</returns>
public override bool IsValidMember(Group group, Node node)
{
var parent = (group as Part).Data as FPDSymbolDataVM;
if (node != null)
{
//For category other than Text Restricted area should work.
if (parent.Key == "Rack2")
{
DoCancel();
return false;
}
}
return base.IsValidMember(group, node);
}
///Palette dragging
protected override bool MayCopyExternal(DragEventArgs e)
{
// check standard cases
if (!base.MayCopyExternal(e)) return false;
// see if the mouse is over a Group
Part overgroup = this.Diagram.Panel.FindElementAt(this.Diagram.LastMousePointInModel,
Part.FindAncestor, p => true, SearchLayers.Parts);
if (overgroup == null) return false;
var node = overgroup.Data as MyNodeData;
if (node.Key == "Rack4")
{
return false;
}
// maybe look at the e.Data to reject additional cases
return true;
}
protected override bool ConsiderDragOver(Point pt, Part p)
{
var item = p.Data as MyNodeData;
if (item.Key == "Rack4")
{
DoCancel();
}
return base.ConsiderDragOver(pt, p);
}
}
But some times I can drag and drop the node on other groups. and it while releasing the mouse it is creating the copy of that object. How can i avoid these issues?