Пример #1
0
        public void Cleanup()
        {
            GC.SuppressFinalize(this);

            _pdfControl?.Dispose();
            _pdfControl = null;
        }
Пример #2
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();
            }
        }
Пример #3
0
        public void BoundViewSize(string path, ContextObject context)
        {
            _pdfControl = new PdfViewerControl();

            var desiredSize = _pdfControl.GetDesiredControlSizeByFirstPage(path);

            context.SetPreferredSizeFit(desiredSize, 0.8);
        }
Пример #4
0
        public void Prepare(string path, ContextObject context)
        {
            _context = context;
            _path    = path;

            var desiredSize = PdfViewerControl.GetDesiredControlSizeByFirstPage(path);

            context.SetPreferredSizeFit(desiredSize, 0.8);
        }
Пример #5
0
        public void Prepare(string path, ContextObject context)
        {
            _context = context;
            _path    = path;

            var desiredSize = PdfViewerControl.GetDesiredControlSizeByFirstPage(path);

            context.SetPreferredSizeFit(desiredSize, 0.6);

            context.PreferredSize = new Size(context.PreferredSize.Width, context.PreferredSize.Height + 32);
        }
Пример #6
0
        public void Cleanup()
        {
            GC.SuppressFinalize(this);

            if (_pdfControl != null)
            {
                _pdfControl.CurrentPageChanged -= UpdateVindowCaption;
            }
            _pdfControl?.Dispose();
            _pdfControl = null;

            _context = null;
        }