예제 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ItemForDeletionTreeNode"/> class.
 /// </summary>
 /// <param name="itemForDeletion">The <see cref="ItemForDeletion"/> to use.</param>
 public ItemForDeletionTreeNode(ItemForDeletion itemForDeletion)
     : base(itemForDeletion.Name)
 {
     _itemForDeletion = itemForDeletion;
     _actionType      = itemForDeletion.Type.ToString();
     Tag = itemForDeletion;
 }
예제 #2
0
        /// <summary>
        /// Inserts the specified item at the tree.
        /// Also creates the tree nodes for the path of the item, if needed.
        /// Item is not inserted if is contained in the another item to delete.
        /// For example: actor with its children is removing, children are not shown because ther are automatically removed by their parent.
        /// </summary>
        /// <param name="item">The item to insert.</param>
        /// <returns><c>true</c> if the item has been inserted; otherwise <c>false</c>.</returns>
        private bool InsertItem(ItemForDeletion item)
        {
            itemPath.Clear();
            item.GetPath(itemPath);

            for (int i = itemPath.Count - 1; i >= 0; --i)
            {
                if (ContainsItemsToDelete(itemPath[i].Tag))
                {
                    return(false);
                }
            }

            bool creatingNodes             = false;
            Collection <Node> currentLevel = treeModel.Nodes;
            Node node;

            for (int i = itemPath.Count - 1; i >= 0; --i)
            {
                if (!creatingNodes)
                {
                    node = ContainsItem(currentLevel, itemPath[i]);

                    if (node != null)
                    {
                        currentLevel = node.Nodes;
                    }
                    else
                    {
                        creatingNodes = true;
                    }
                }

                if (creatingNodes)
                {
                    node = new Node(String.IsNullOrEmpty(itemPath[i].Type) ? itemPath[i].Name : String.Format("{0} - {1}", itemPath[i].Type, itemPath[i].Name))
                    {
                        Tag = itemPath[i].Tag
                    };
                    currentLevel.Add(node);
                    currentLevel = node.Nodes;
                }
            }

            currentLevel.Add(new ItemForDeletionTreeNode(item));

            return(true);
        }
예제 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConsistentDeletionForm"/> class.
 /// </summary>
 /// <param name="itemForDeletion">The <see cref="ItemForDeletion"/> to remove from the project.</param>
 public ConsistentDeletionForm(ItemForDeletion itemForDeletion)
     : this(new List <ItemForDeletion>() { itemForDeletion })
 {
 }