/// <summary> /// Adds one or more <paramref name="results"/> in the location /// specified by <paramref name="row"/> and <paramref name="dropLocation"/> /// of this tree. /// </summary> /// <param name="row">the target row</param> /// <param name="dropLocation">the relative drop location</param> /// <param name="results">the dropped results</param> public void AddResults(Row row, RowDropLocation dropLocation, IResultNode[] results) { if (!IsWorkpad || row == null || results == null || results.Length == 0) { return; } int childIndex; // Determine child index (where to Add or Insert) if (dropLocation == RowDropLocation.AboveRow || dropLocation == RowDropLocation.BelowRow) { childIndex = row.ChildIndex; if (dropLocation == RowDropLocation.BelowRow) { childIndex++; } row = row.ParentRow; } else { childIndex = row.NumChildren; } IResultNode rowResult = row.Item as IResultNode; if (rowResult != null) { // Copy/Move drop results to their new location foreach (IResultNode r in results) { IResultNode result = r; // Copy from old location if (result.Parent != null) { result = result.DeepCopy(); } // Add/Insert at new location if (childIndex >= rowResult.Children.Count) { rowResult.AddChild(result); } else { rowResult.InsertChild(childIndex, result); } childIndex++; } } row.UpdateChildren(false, true); }
protected override DragDropEffects RowDropEffect(Row row, RowDropLocation dropLocation, IDataObject data) { if (!IsWorkpad) { return(base.RowDropEffect(row, dropLocation, data)); } VirtualTree tree = GetTree(data); if (tree == null) { return(DragDropEffects.None); } return((tree == this) ? DragDropEffects.Move : DragDropEffects.Copy); }
protected override void OnRowDrop(Row row, RowDropLocation dropLocation, IDataObject data, DragDropEffects dropEffect) { base.OnRowDrop(row, dropLocation, data, dropEffect); if (IsWorkpad) { Row[] rows = GetRows(data); if (rows == null) { return; } // Delete rows from original location if dropped on the same tree List <IResultNode> results = new List <IResultNode>(); foreach (Row r in rows.GetUniqueRowsInGuiOrder()) { IResultNode result = (IResultNode)r.Item; if (r.Tree == this) { result.Parent.RemoveChild(result); SelectedRows.SuspendChangeNotification(); r.ParentRow.UpdateChildren(false, true); SelectedRows.ResumeChangeNotification(); } results.Add(result); } // Adds the results in the given location AddResults(row, dropLocation, results.ToArray()); } }