public static bool cutPaste(ToDoItem itemToBeCut, ToDoItem parentOfItemToBeCut, ToDoItem pasteParent) { if (!canBeCutPastedHere(itemToBeCut, pasteParent)) { return(false); } parentOfItemToBeCut.deleteChild(itemToBeCut); pasteParent.addChild(itemToBeCut); return(true); }
private void deleteItemToolStripMenuItem_Click(object sender, EventArgs e) { if (MessageBox.Show(String.Format("Are you sure you want to delete '{0}'?", targetTreeNodeUserInteraction.Text), this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { ToDoItem itemToDelete = targetToDoItem; ToDoItem parent = parentOfTargetToDoItem; bool hasExtraPermission = itemToDelete.isEmpty || MessageBox.Show(String.Format("This item has child items that would also be deleted.\nAre you really really sure you want to delete '{0}'?", targetTreeNodeUserInteraction.Text), this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes; if (hasExtraPermission) { parent.deleteChild(itemToDelete); syncViewFromModel(); } } }