/// <summary>
        /// Create the VM. We generate a first page hero slide.
        /// </summary>
        /// <param name="file">The PDF File to generate. If null, we will make this VM as invalid</param>
        public FirstSlideHeroViewModel(PDFFile file, Lazy <FullTalkAsStripViewModel> fullVM)
        {
            // If we are actually connected to a file, then
            // - setup the hero slide
            // - a button to show all slides
            _heroPageUC   = null;
            HaveHeroSlide = false;
            if (file != null)
            {
                // Hero slide. Tricky because we can't display until
                // a fetch has been done on the PDF data.
                var pdf = new PDFPageViewModel(file.GetPageStreamAndCacheInfo(0));
                _heroPageUC = pdf.LoadSize()
                              .Select(_ => pdf)
                              .ToProperty(this, m => m.HeroPageUC, scheduler: RxApp.MainThreadScheduler);

                HaveHeroSlide = true;

                // Allow a full view
                OpenFullView = ReactiveCommand.Create();
                OpenFullView
                .Subscribe(_ => fullVM.Value.LoadPage(0));
            }
        }
Beispiel #2
0
        /// <summary>
        /// Create n pages, as requested, and prepare them for the UI.
        /// </summary>
        /// <param name="n"></param>
        /// <param name="file"></param>
        /// <returns></returns>
        private async Task <PDFPageViewModel[]> CreateNPages(int n, int start_index, PDFFile file)
        {
            if (n <= 0)
            {
                return(new PDFPageViewModel[0]);
            }

            // Create and initialize pages
            var newPages        = Enumerable.Range(start_index, n).Select(i => new PDFPageViewModel(file.GetPageStreamAndCacheInfo(i))).ToArray();
            var sequenceOfPages = newPages.Select(p => p.LoadSize());

            foreach (var seq in sequenceOfPages)
            {
                var r = await seq.ToArray();
            }

            return(newPages);
        }
        /// <summary>
        /// Create the new slides and load them up.
        /// </summary>
        /// <param name="n"></param>
        /// <param name="pdfFile"></param>
        /// <param name="fullVM"></param>
        /// <returns></returns>
        private async Task <SlideThumbViewModel[]> CreateNewThumbs(int n, PDFFile pdfFile, Lazy <FullTalkAsStripViewModel> fullVM)
        {
            var newSlides = Enumerable.Range(SlideThumbnails.Count, n - SlideThumbnails.Count).Select(i => new SlideThumbViewModel(pdfFile.GetPageStreamAndCacheInfo(i), fullVM, i)).ToArray();

            foreach (var sld in newSlides)
            {
                await sld.LoadSize();
            }
            return(newSlides);
        }