private void DeleteSelectedItem() { #if CHECKERS if (tvItems.SelectedNode == null) { throw new FireFlyException("No nodes selected"); } #endif if (Extenders.ConfirmDelete(tvItems.SelectedNode.Text)) { try { //var node = (ItemType)tvItems.SelectedNode.Tag; //var res = Course.Manifest.resources[node.IdentifierRef]; var selectedNode = tvItems.SelectedNode; ((IDisposable)selectedNode.Tag).Dispose(); //if (res != null) //{ // Course.Manifest.resources.Resources.Remove(res); //} IContainer c = selectedNode.Parent.Tag as IContainer; Debug.Assert(c != null, "Parent of the selected object is not support Manifest.IContainer"); c.RemoveChild(selectedNode.Tag as IManifestNode); } catch (IOException) { ErrorDialog.ShowError(string.Format("File '{0}' used by another program. Close all programs that can use this file and try again", tvItems.SelectedNode.Text)); } } }
private void miDelete_Click(object sender, EventArgs e) { #if CHECKERS if (IsSelectionEmpty) { throw new InvalidOperationException(); } #endif var b = new StringBuilder(); bool isFirst = true; foreach (var c in _selectionList) { if (!isFirst) { b.Append(", "); } else { isFirst = false; } b.Append(c.Owner.Title); } if (Extenders.ConfirmDelete(b.ToString())) { var list = _selectionList.ToArray(); UnSelectAll(); var mg = new ModificationCollection <HtmlControlModification>(); foreach (var c in list) { FreeResources(c.Owner); HtmlDesignMovableControl owner = c.Owner; owner.NotifyDelete(); mg.Add(HtmlControlModification.GetRemoved(owner)); owner.Parent = null; } if (mg.Count > 0) { HtmlPage.AddUndoOperation(mg.Count == 1 ? (IModification)mg[0] : mg); } else { throw new InvalidOperationException(); } UpdateUndoRedoState(); } }