Exemple #1
0
        public void Load(IPdfSource source, string password = null)
        {
            this.scrollViewer  = VisualTreeHelperEx.FindChild <ScrollViewer>(this);
            this.imageProvider = new PdfImageProvider(source, this.parent.TotalPages,
                                                      new PageDisplaySettings(this.parent.GetPagesPerRow(), this.parent.ViewType, this.parent.HorizontalMargin, this.parent.Rotation), false, password);

            currentPageIndex = 0;

            if (this.scrollViewer != null)
            {
                this.scrollViewer.Visibility = System.Windows.Visibility.Visible;
            }

            if (this.parent.ZoomType == ZoomType.Fixed)
            {
                this.SetItemsSource();
            }
            else if (this.parent.ZoomType == ZoomType.FitToHeight)
            {
                this.ZoomToHeight();
            }
            else if (this.parent.ZoomType == ZoomType.FitToWidth)
            {
                this.ZoomToWidth();
            }
        }
Exemple #2
0
        public void Load(IPdfSource source, string password = null)
        {
            this.virtualPanel = VisualTreeHelperEx.FindChild <CustomVirtualizingPanel>(this);
            this.scrollViewer = VisualTreeHelperEx.FindChild <ScrollViewer>(this);
            this.virtualPanel.PageRowBounds = this.parent.PageRowBounds.Select(f => f.SizeIncludingOffset).ToArray();
            this.imageProvider = new PdfImageProvider(source, this.parent.TotalPages,
                                                      new PageDisplaySettings(this.parent.GetPagesPerRow(), this.parent.ViewType, this.parent.HorizontalMargin, this.parent.Rotation),
                                                      password: password);

            if (this.parent.ZoomType == ZoomType.Fixed)
            {
                this.CreateNewItemsSource();
            }
            else if (this.parent.ZoomType == ZoomType.FitToHeight)
            {
                this.ZoomToHeight();
            }
            else if (this.parent.ZoomType == ZoomType.FitToWidth)
            {
                this.ZoomToWidth();
            }

            if (this.scrollViewer != null)
            {
                this.scrollViewer.Visibility = System.Windows.Visibility.Visible;
                this.scrollViewer.ScrollToTop();
            }
        }
        private async void OnSelectedMoveChanged(object sender, SelectionChangedEventArgs e)
        {
            ListBox list = (ListBox)sender;

            if (list.SelectedItem == null)
            {
                return;
            }

            await Dispatcher.RunIdleAsync((o) =>
            {
                var scrollViewer = VisualTreeHelperEx.FindChild <ScrollViewer>(list);
                ListBoxItem item = list.ContainerFromItem(list.SelectedItem) as ListBoxItem;
                if (item != null)
                {
                    scrollViewer.ScrollToElement(item);
                }
            });
        }
        void ViewModel_ProgressChanged(object sender, EventArgs e)
        {
            this.Dispatcher.BeginInvoke(new Action(() =>
            {
                var loadingProgress = VisualTreeHelperEx.FindChild <ProgressBar>(this, "LoadingProgress");
                if (loadingProgress == null)
                {
                    return;
                }

                if (_progressBarAnimation != null)
                {
                    _progressBarAnimation.Completed -= ProgressBarAnimation_Completed;
                }

                var duration                     = new Duration(TimeSpan.FromSeconds((this.ViewModel.LoadingProgress - loadingProgress.Value) / 0.5));
                _progressBarAnimation            = new DoubleAnimation(this.ViewModel.LoadingProgress, duration);
                _progressBarAnimation.Completed += ProgressBarAnimation_Completed;
                loadingProgress.BeginAnimation(RangeBase.ValueProperty, _progressBarAnimation);
            }));
        }
Exemple #5
0
        public void Load(string pdfFilename)
        {
            this.scrollViewer  = VisualTreeHelperEx.FindChild <ScrollViewer>(this);
            this.imageProvider = new PdfImageProvider(pdfFilename, this.parent.TotalPages,
                                                      new PageDisplaySettings(this.parent.GetPagesPerRow(), this.parent.ViewType, this.parent.HorizontalMargin, this.parent.Rotation), false);

            currentPageIndex = 0;

            if (this.parent.ZoomType == ZoomType.Fixed)
            {
                this.SetItemsSource();
            }
            else if (this.parent.ZoomType == ZoomType.FitToHeight)
            {
                this.ZoomToHeight();
            }
            else if (this.parent.ZoomType == ZoomType.FitToWidth)
            {
                this.ZoomToWidth();
            }
        }
Exemple #6
0
 private void SinglePageMoonPdfPanel_SizeChanged(object sender, SizeChangedEventArgs e)
 {
     this.scrollViewer = VisualTreeHelperEx.FindChild <ScrollViewer>(this);
 }
Exemple #7
0
 private void ContinuousMoonPdfPanel_SizeChanged(object sender, SizeChangedEventArgs e)
 {
     scrollViewer = VisualTreeHelperEx.FindChild <ScrollViewer>(this);
 }