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);
        }