/// <summary> /// Removes the specified project item. /// </summary> /// <param name="item">The item to remove.</param> protected virtual void RemoveProjectItem(ProjectItem item) { if (item == null) { return; } if (Project.Items.Count == 1) { throw new Exception("A project must contain at least one file, therefore, the file could not be removed."); } // Close the editor if any. var e = Editors.GetEditorFormIfExists(item); if (e != null) { e.Save(); e.Close(); Editors.EditorForms.Remove(item.Path); } Project.Items.Remove(item); // If the main item has been removed, set another one as main. if (ReferenceEquals(Project.MainItem, item)) { Project.MainItem = Project.Items[0]; } Project.Save(); }