Exemple #1
0
        /// <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);
        }
Exemple #2
0
        /// <summary>
        /// Moves the <paramref name="rows"/> to the top of the tree.
        /// </summary>
        /// <param name="rows">the rows to be moved</param>
        public void MoveToTop(Row[] rows)
        {
            if (rows == null)
            {
                throw new ArgumentNullException("rows");
            }
            if (IsWorkpad && RootRow != null && RootRow.NumChildren > 0)
            {
                IResultNode root  = RootItem as IResultNode;
                int         index = 0;

                foreach (Row row in UniqueSelectedRowsInGuiOrder)
                {
                    IResultNode resultNode = (IResultNode)row.Item;
                    resultNode.Parent.RemoveChild(resultNode);
                    root.InsertChild(index++, resultNode);
                }

                SelectedRows.SuspendChangeNotification();
                RootRow.UpdateChildren(false, true);
                SelectedRows.ResumeChangeNotification();
            }
        }