Exemplo n.º 1
0
		private void treeViewReorderHandler_DropNodeValidating(object sender, DropNodeValidatingEventArgs e)
		{
			var nodeRow = e.SourceNode.Tag as IEditableNode;
            if (nodeRow != null)
            {
                var targetWrapper = e.TargetNode.Tag as ThemeNodeWrapper;
                if (targetWrapper == null) return;
                var target = targetWrapper.Node;

                var newParent = e.Position == NodePosition.Inside ? target as ContainerNode : target.Parent;
                if (newParent != null)
                {
                    int newIndex;
                    if (e.Position == NodePosition.Inside)
                        newIndex = newParent.Nodes.Count;
                    else if (e.Position == NodePosition.Before)
                        newIndex = e.TargetNode.Index;
                    else
                        newIndex = e.TargetNode.Index + 1;

                    if (nodeRow.CanMoveTo(newParent, e.SourceNode.Index, newIndex))
                        return;
                }
            }
			e.Effect = DragDropEffects.None;
		}
Exemplo n.º 2
0
 protected virtual void OnDropNodeValidating(DragEventArgs e, TreeNode sourceNode, TreeNode targetNode, NodePosition position)
 {
     if (DropNodeValidating != null)
     {
         var args = new DropNodeValidatingEventArgs(e.Data, e.KeyState, e.X, e.Y, e.AllowedEffect, e.Effect, sourceNode, targetNode, position);
         DropNodeValidating(this, args);
         e.Effect = args.Effect;
     }
 }