Example #1
0
        public void View(string path, ContextObject context)
        {
            _pdfControl           = new PdfViewerControl();
            context.ViewerContent = _pdfControl;

            Exception exception = null;

            _pdfControl.Dispatcher.BeginInvoke(new Action(() =>
            {
                try
                {
                    _pdfControl.LoadPdf(path);

                    context.Title = $"{Path.GetFileName(path)} (1 / {_pdfControl.TotalPages})";
                    _pdfControl.CurrentPageChanged += (sender2, e2) => context.Title =
                        $"{Path.GetFileName(path)} ({_pdfControl.CurrentPage + 1} / {_pdfControl.TotalPages})";
                    context.IsBusy = false;
                }
                catch (Exception e)
                {
                    exception = e;
                }
            }), DispatcherPriority.Loaded).Wait();

            if (exception != null)
            {
                ExceptionDispatchInfo.Capture(exception).Throw();
            }
        }
Example #2
0
        public void View(string path, ContextObject context)
        {
            context.ViewerContent = _pdfControl;

            _pdfControl.Loaded += (sender, e) =>
            {
                _pdfControl.LoadPdf(path);

                context.Title = $"{Path.GetFileName(path)} (1 / {_pdfControl.TotalPages})";
                _pdfControl.CurrentPageChanged += (sender2, e2) => context.Title =
                    $"{Path.GetFileName(path)} ({_pdfControl.CurrentPage + 1} / {_pdfControl.TotalPages})";

                context.IsBusy = false;
            };
        }