/// <summary> /// Removes the specified slide. /// </summary> public void Remove(ISlide removingSlide) { P.Presentation presentation = this.presentationPart.Presentation; // Get the list of slide identifiers in the presentation P.SlideIdList slideIdList = presentation.SlideIdList; // Get the slide identifier of the specified slide P.SlideId slideId = (P.SlideId)slideIdList.ChildElements[removingSlide.Number - 1]; // Gets the relationship identifier of the slide string slideRelId = slideId.RelationshipId; // Remove the slide from the slide list slideIdList.RemoveChild(slideId); // Remove references to the slide from all custom shows if (presentation.CustomShowList != null) { // Iterate through the list of custom shows foreach (var customShow in presentation.CustomShowList.Elements <P.CustomShow>()) { if (customShow.SlideList == null) { continue; } // declares a link list of slide list entries var slideListEntries = new LinkedList <P.SlideListEntry>(); foreach (P.SlideListEntry slideListEntry in customShow.SlideList.Elements()) { // finds the slide reference to remove from the custom show if (slideListEntry.Id != null && slideListEntry.Id == slideRelId) { slideListEntries.AddLast(slideListEntry); } } // Removes all references to the slide from the custom show foreach (P.SlideListEntry slideListEntry in slideListEntries) { customShow.SlideList.RemoveChild(slideListEntry); } } } // Gets the slide part for the specified slide SlidePart slidePart = this.presentationPart.GetPartById(slideRelId) as SlidePart; this.presentationPart.DeletePart(slidePart); this.presentationPart.Presentation.Save(); this.slides.Reset(); }