public void HandleDrop(WinForms::IDataObject dragData) { if (!this.IsValidDropTarget(dragData)) return; IEnumerable<TreeNode> draggedNodes = TreeView.GetTreeNodesFromDragData(dragData); if (draggedNodes == null) return; List<SelectionSetWrapper> selSets = new List<SelectionSetWrapper>(); foreach (TreeNode tn in draggedNodes) { if (tn.Parent == null) continue; SelectionSetWrapper selSet = TreeMode.GetMaxNode(tn.Parent) as SelectionSetWrapper; if (selSet != null && !selSets.Contains(selSet)) selSets.Add(selSet); } IEnumerable<IMaxNode> draggedMaxNodes = TreeMode.GetMaxNodes(draggedNodes); foreach (SelectionSetWrapper selSet in selSets) { IEnumerable<IMaxNode> newNodes = selSet.ChildNodes.Except(draggedMaxNodes); ModifySelectionSetCommand cmd = new ModifySelectionSetCommand(selSet, newNodes); cmd.Execute(); } }
public override void HandleDrop(WinForms::IDataObject dragData) { if (!this.IsValidDropTarget(dragData)) return; IEnumerable<TreeNode> draggedNodes = TreeView.GetTreeNodesFromDragData(dragData); if (draggedNodes == null) return; IEnumerable<IMaxNode> draggedMaxNodes = TreeMode.GetMaxNodes(draggedNodes); SelectionSetWrapper targetSelSet = (SelectionSetWrapper)this.MaxNode; IEnumerable<IMaxNode> combinedNodes = targetSelSet.ChildNodes.Union(draggedMaxNodes); ModifySelectionSetCommand cmd = new ModifySelectionSetCommand(targetSelSet, combinedNodes); cmd.Execute(); if (!ControlHelpers.ShiftPressed) { IEnumerable<SelectionSetWrapper> selSets = draggedNodes.Select(tn => TreeMode.GetMaxNode(tn.Parent)) .OfType<SelectionSetWrapper>() .Where(n => !n.Equals(targetSelSet)) .Distinct(); foreach (SelectionSetWrapper selSet in selSets) { IEnumerable<IMaxNode> newNodes = selSet.ChildNodes.Except(draggedMaxNodes); ModifySelectionSetCommand moveCmd = new ModifySelectionSetCommand(selSet, newNodes); moveCmd.Execute(); } } }