Hi Dylan,
Thanks for your interest in Syncfusion products.
We are glad to inform you that we have achieved your
requirement by creating a custom tool called “DragDropTool” and activated the
custom tool to drag and drop an element from diagram into treeview control.
Please refer the below code snippet.
Here is the code:
[C#]
public Form1()
{
InitializeComponent();
DragDropTool tool = new DragDropTool(this.diagram1.Controller);
diagram1.Controller.RegisterTool(tool);
this.dragHelper = new
DragHelper();
treeView1.AllowDrop = true;
treeView1.MouseDown += new
MouseEventHandler(treeView1_MouseDown);
treeView1.MouseMove += new
MouseEventHandler(treeView1_MouseMove);
treeView1.MouseUp += new
MouseEventHandler(treeView1_MouseUp);
treeView1.QueryContinueDrag += new
QueryContinueDragEventHandler(treeView1_QueryContinueDrag);
treeView1.GiveFeedback += new
GiveFeedbackEventHandler(treeView1_GiveFeedback);
treeView1.DragDrop += new
DragEventHandler(treeView1_DragDrop);
treeView1.DragEnter += new
DragEventHandler(treeView1_DragEnter);
diagram1.DragEnter += new
DragEventHandler(diagram1_DragEnter);
diagram1.DragDrop += new
DragEventHandler(diagram1_DragDrop);
diagram1.MouseDown += new
MouseEventHandler(diagram1_MouseDown);
diagram1.Model.EventSink.PinPointChanging += new
PinPointChangingEventHandler(EventSink_PinPointChanging);
this.Disposed += new
EventHandler(Form1_Disposed);
}
void diagram1_MouseDown(object
sender, MouseEventArgs e)
{
Node node
= this.diagram1.Controller.GetNodeUnderMouse(e.Location)
as Node;
if (node != null
&& diagram1.Controller.ActiveTool is
DragDropTool)
{
DragDropData data = new DragDropData(node);
data.DragNodeCueEnabled = bDragNodeCueEnabled;
diagram1.DoDragDrop(data, DragDropEffects.Copy);
}
}
void treeView1_DragEnter(object
sender, DragEventArgs e)
{
e.Effect
= DragDropEffects.Copy;
}
void treeView1_DragDrop(object
sender, DragEventArgs e)
{
TreeNode
nodeToDropIn = this.treeView1.GetNodeAt(this.treeView1.PointToClient(new
Point(e.X, e.Y)));
if (nodeToDropIn == null)
{ return; }
if (nodeToDropIn.Level > 0)
{
nodeToDropIn = nodeToDropIn.Parent;
}
object data = e.Data.GetData(typeof(DragDropData));
nodeToDropIn.Nodes.Add(((DragDropData)data).Nodes[0].Name);
e.Effect
= DragDropEffects.None;
}
DragDropTool.cs:
class DragDropTool:ZoomTool
{
internal static string ToolName = "DragDropTool";
public DragDropTool(DiagramController contllr)
: base(contllr)
{
//Ser Arrow as Tool's action cursor
this.ActionCursor = Cursors.Arrow;
this.Name = ToolName;
this.SingleActionTool = false;
}
public override Tool
ProcessMouseDown(MouseEventArgs evtArgs)
{
Tool
toolToReturn = this;
if (this.Controller.Viewer
!= null && this.InAction)
{
this.InAction = false;
}
return toolToReturn;
}
}
Please try the below attached sample and let us know if you
have any queries.
Regards,
Amsath Ali. M
Hi Dylan,
Thanks for your update.
We are able to reproduce the issue reported by you at our
end, and the issue has been suspected to be a defect. Please create a DT
incident for your query so that we can update the patch for this issue.
You can create the DT incident from the following link.
<http://www.syncfusion.com/account/dashboard>
In the interests of maintaining confidentiality, we have a policy of not
sharing patches or otherwise proprietary customer specific information in the
public Forum.
Please let us know if you have any queries.
Regards,
Amsath Ali. M