public void removeSlides(IEnumerable <Slide> slides, Slide primarySelection)
        {
            int slideIndex = slideshow.indexOf(primarySelection);
            List <SlideInfo> removedSlides = new List <SlideInfo>(from slide in slides select new SlideInfo(slide, slideshow.indexOf(slide)));

            if (removedSlides.Count > 0)
            {
                removedSlides.Sort(SlideInfo.Sort);

                doRemoveSlides(removedSlides);

                Slide changeToSlide = null;
                if (primarySelection == lastEditSlide)
                {
                    if (slideIndex < slideshow.Count)
                    {
                        changeToSlide = slideshow.get(slideIndex);
                    }
                    else if (slideIndex - 1 >= 0)
                    {
                        changeToSlide = slideshow.get(slideIndex - 1);
                    }
                }

                bool wasAllowingUndo = allowUndoCreation;
                allowUndoCreation = false;
                if (changeToSlide != null && SlideSelected != null)
                {
                    SlideSelected.Invoke(changeToSlide, IEnumerableUtil <Slide> .EmptyIterator);
                }
                allowUndoCreation = wasAllowingUndo;

                if (allowUndoCreation)
                {
                    undoBuffer.pushAndSkip(new TwoWayDelegateCommand(
                                               new TwoWayDelegateCommand.Funcs()
                    {
                        ExecuteFunc = () =>     //Execute
                        {
                            ThreadManager.invoke(new Action(() =>
                            {
                                allowUndoCreation = false;
                                doRemoveSlides(removedSlides);
                                if (changeToSlide != null && SlideSelected != null)
                                {
                                    SlideSelected.Invoke(changeToSlide, IEnumerableUtil <Slide> .EmptyIterator);
                                }
                                allowUndoCreation = true;
                            }));
                        },
                        UndoFunc = () =>     //Undo
                        {
                            ThreadManager.invoke(new Action(() =>
                            {
                                allowUndoCreation = false;
                                foreach (SlideInfo slide in removedSlides)
                                {
                                    slideshow.insertSlide(slide.Index, slide.Slide);
                                    if (SlideAdded != null)
                                    {
                                        SlideAdded.Invoke(slide.Slide, slide.Index);
                                    }
                                }
                                if (SlideSelected != null)
                                {
                                    SlideSelected.Invoke(primarySelection, secondarySlideSelections(removedSlides, primarySelection));
                                }
                                allowUndoCreation = true;
                            }));
                        },
                        PoppedFrontFunc = () =>
                        {
                            foreach (SlideInfo slideInfo in removedSlides)
                            {
                                cleanupThumbnail(slideInfo);
                            }
                        }
                    }));
                }
            }
        }