Example #1
0
        /// <summary>
        /// this will delete item 
        /// </summary>
        /// <param name="item"></param>
        public void DeleteItem(EditorItem item)
        {
            // mark item as deleted
            //item.IsDeleted = true;
            // detach it from parent
            if (item.Parent == null)
            {
                throw new Exception("Item for removal has no parent");
            }
            else
            {
                // find exact child and remember index of it
                int parentIndex = 0;
                foreach(EditorItem child in item.Parent.Children)
                {
                    if (child == item)
                    {
                        break;
                    }
                    parentIndex++;
                }
                item.Parent.Children.Remove(item);
                item.StopMoving(true);
                item.IsSelected = false;
                if (EditorItemDeleted != null && item.NotifyDeletion)
                {
                    EditorItemDeleted(item);
                }

                ActionManager.Instance.EditorItemDeleted(item, parentIndex);

                // perform docking on parent to rearrange items
                item.Parent.DockAll();
            }
        }