This starts drag-and-drop when Shift is down:
private void diagViewL_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button != MouseButtons.Left)
return;
if ((Control.ModifierKeys & Keys.Shift) == 0)
return;
DiagramNode node = diagL.GetNodeAt(diagViewL.ClientToDoc(e.Location));
if (diagL.Interaction != null)
diagL.Interaction.Cancel(diagL);
if (diagL.Selection.Nodes.Count > 1)
{
Diagram diagTemp = new Diagram();
SelectionCopy copy = diagL.CopySelection(diagL, false, false);
diagTemp.PasteSelection(diagTemp, copy, null, 0, 0);
DoDragDrop(diagTemp.SaveToString(), DragDropEffects.Copy);
}
else if (node != null && node is ShapeNode)
{
DoDragDrop(node as ShapeNode, DragDropEffects.Copy);
}
}
private void diagViewR_DragOver(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent("System.String"))
{
e.Effect = DragDropEffects.Copy;
}
else if (e.Data.GetDataPresent("MindFusion.Diagramming.ShapeNode"))
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
private void diagViewR_DragDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent("System.String"))
{
string s = e.Data.GetData("System.String") as string;
Diagram diagTemp = new Diagram();
diagTemp.LoadFromString(s);
SelectionCopy copy = diagTemp.CopySelection(diagTemp, false, false);
PointF pt = diagViewR.ClientToDoc(Control.MousePosition);
diagR.PasteSelection(diagR, copy, null, 0, 0);
}
else if (e.Data.GetDataPresent("MindFusion.Diagramming.ShapeNode"))
{
if (e.Effect == DragDropEffects.Copy)
{
ShapeNode node = e.Data.GetData("MindFusion.Diagramming.ShapeNode") as ShapeNode;
Point p = diagViewR.PointToClient(new Point(e.X, e.Y));
PointF pt = diagViewR.ClientToDoc(new Point(p.X, p.Y));
diagR.Nodes.Add(new ShapeNode(node));
MessageBox.Show(diagL.Nodes.Count.ToString());
}
}
}
I don't know why our developer added the diagL.Selection.Nodes.Count == 1 case at all; the CopySelection method should work just fine with a single selected node.
I hope that helps,
Stoyan