// This method creates and initializes the slide at the specified index and returns it.
        // The new slide is cached in the _slides array.
        private Slide GetSlide(int slideIndex, bool loadIfNeeded)
        {
            if (slideIndex < 0 || slideIndex >= SlideSettings.Slides.Count())
            {
                return(null);
            }

            // Look into the cache first
            if (SlideCache.ContainsKey(slideIndex.ToString()))
            {
                return(SlideCache [slideIndex.ToString()]);
            }

            if (!loadIfNeeded)
            {
                return(null);
            }

            // Create the new slide
            Type slideClass = ClassOfSlide(slideIndex);
            var  slide      = (Slide)Activator.CreateInstance(slideClass);

            // Update its parameters
            var slideSettings = SlideSettings.Slides [slideIndex].Slide;

            if (slideSettings != null)
            {
                slide.Fetch(slideSettings);
            }

            SlideCache [slideIndex.ToString()] = slide;

            if (slide == null)
            {
                return(null);
            }

            // Setup the slide
            slide.SetupSlide(this);

            return(slide);
        }