Пример #1
0
        private void RulesTreeView_DragDrop(object sender, DragEventArgs e)
        {
            Point targetPoint = RulesTreeView.PointToClient(new Point(e.X, e.Y));

            TreeNode targetNode = RulesTreeView.GetNodeAt(targetPoint);

            TreeNode draggedNode = (TreeNode)e.Data.GetData(typeof(TreeNode));

            if (Tools.IsSubnodeOf(draggedNode, targetNode))
            {
                e.Effect = DragDropEffects.None;
                return;
            }

            RulesTreeView.Nodes.Remove(draggedNode);

            if (targetNode != null)
            {
                targetNode.Nodes.Insert(0, draggedNode);
            }
            else
            {
                RulesTreeView.Nodes.Add(draggedNode);
            }

            RulesTreeView.SelectedNode = draggedNode;
            RestoreSelectedRule();

            e.Effect = DragDropEffects.Move;
        }
Пример #2
0
        private void RulesTreeView_DragOver(object sender, DragEventArgs e)
        {
            Point targetPoint = RulesTreeView.PointToClient(new Point(e.X, e.Y));

            TreeNode targetNode = RulesTreeView.GetNodeAt(targetPoint);

            RulesTreeView.SelectedNode = targetNode;

            TreeNode draggedNode = (TreeNode)e.Data.GetData(typeof(TreeNode));

            if (Tools.IsSubnodeOf(draggedNode, targetNode))
            {
                e.Effect = DragDropEffects.None;
                return;
            }

            e.Effect = DragDropEffects.Move;
        }