///-------------------------------------------------------------------------------- /// <summary>This method applies diagram deletes.</summary> ///-------------------------------------------------------------------------------- public void ProcessDeleteDiagramPerformed(DiagramEventArgs data) { try { bool isItemMatch = false; if (data != null && data.Diagram != null) { foreach (DiagramViewModel item in Diagrams.ToList <DiagramViewModel>()) { if (item.Diagram.DiagramID == data.Diagram.DiagramID) { // remove item from tabs, if present WorkspaceEventArgs message = new WorkspaceEventArgs(); message.ItemID = item.Diagram.DiagramID; Mediator.NotifyColleagues <WorkspaceEventArgs>(MediatorMessages.Command_CloseItemRequested, message); // delete children for (int i = item.Items.Count - 1; i >= 0; i--) { if (item.Items[i] is DiagramEntityViewModel) { DiagramEntityViewModel child = item.Items[i] as DiagramEntityViewModel; DiagramEntityEventArgs childMessage = new DiagramEntityEventArgs(); childMessage.DiagramEntity = child.DiagramEntity; childMessage.DiagramID = item.Diagram.DiagramID; childMessage.Solution = Solution; childMessage.WorkspaceID = child.WorkspaceID; item.ProcessDeleteDiagramEntityPerformed(childMessage); } } // delete item isItemMatch = true; Diagrams.Remove(item); Solution.DiagramList.Remove(item.Diagram); Items.Remove(item); Solution.ResetModified(true); OnUpdated(this, null); break; } } if (isItemMatch == false) { ShowIssue(DisplayValues.Issue_DeleteItemNotFound); } } } catch (Exception ex) { ShowIssue(ex.Message + ex.StackTrace); } }