Ejemplo n.º 1
0
        private void DeleteItem(UndertaleObject obj)
        {
            TreeViewItem container = GetNearestParent <TreeViewItem>(GetTreeViewItemFor(obj));
            object       source    = container.ItemsSource;
            IList        list      = ((source as ICollectionView)?.SourceCollection as IList) ?? (source as IList);
            bool         isLast    = list.IndexOf(obj) == list.Count - 1;

            if (MessageBox.Show("Delete " + obj.ToString() + "?" + (!isLast ? "\n\nNote that the code often references objects by ID, so this operation is likely to break stuff because other items will shift up!" : ""), "Confirmation", MessageBoxButton.YesNo, isLast ? MessageBoxImage.Question : MessageBoxImage.Warning) == MessageBoxResult.Yes)
            {
                list.Remove(obj);
                while (SelectionHistory.Remove(obj))
                {
                    ;
                }
                if (Selected == obj)
                {
                    ChangeSelection(null);
                }
                if (Highlighted == obj)
                {
                    Highlighted = null;
                }
            }
        }