private void TreeView1OnDragDrop(object sender, DragEventArgs e)
{
var nodeToDropIn = this.treeView.GetNodeAt(this.treeView.PointToClient(new Point(e.X, e.Y)));
if (nodeToDropIn == null)
{
return;
}
var hostname = "";
object roleName = e.Data.GetData(typeof(string));
if (roleName == null)
{
return;
}
if (nodeToDropIn.Level == 1)
{
hostname = nodeToDropIn.Text;
}
if (nodeToDropIn.Level == 2)
{
nodeToDropIn = nodeToDropIn.Parent;
hostname = nodeToDropIn.Text;
}
if ((hostname != string.Empty) && (roleName.ToString() != string.Empty))
{
nodeToDropIn.Nodes.Add(roleName.ToString());
this.controller.AddRoleToHost(hostname, roleName.ToString());
}
OnChanged(EventArgs.Empty);
}