public ThumbnailsControl(PDFViewWPF viewer)
 {
     InitializeComponent();
     _viewer = viewer;
     InitializeViewer();
     Refresh();
 }
示例#2
0
 void Viewer_OnAction(PDFViewWPF viewer, PDFViewWPF.ActionEventArgs e)
 {
     if (_actionSources.GetActionSource(viewer) is ActionSource actionSource)
     {
         actionSource.EntryPoint = actionSource.Form.PreviewControl.GetPdfViewer()?.GetActualEntryPoint();
     }
 }
示例#3
0
        public MainViewModel()
        {
            // Initilizes PDFNet
            PDFNet.Initialize();

            // Make sure to Terminate any processes
            Application.Current.SessionEnding += Current_SessionEnding;

            // Init all Commands
            CMDOpenDocument   = new Relaycommand(OpenDocument);
            CMDNextPage       = new Relaycommand(NextPage);
            CMDPreviousPage   = new Relaycommand(PreviousPage);
            CMDAnottateText   = new Relaycommand(AddTextSample);
            CMDFreeTextSample = new Relaycommand(AddFreeTextSample);
            CMDSelectText     = new Relaycommand(SelectText);
            CMDExit           = new Relaycommand(ExitApp);
            CMDZoomIn         = new Relaycommand(ZoomIn);
            CMDZoomOut        = new Relaycommand(ZoomOut);
            CMDUndo           = new Relaycommand(Undo);
            CMDRedo           = new Relaycommand(Redo);

            // Checks the scale factor to determine the right resolution
            PresentationSource source      = PresentationSource.FromVisual(Application.Current.MainWindow);
            double             scaleFactor = 1;

            if (source != null)
            {
                scaleFactor = 1 / source.CompositionTarget.TransformFromDevice.M11;
            }

            // Set working doc to Viewer
            PDFViewer = new PDFViewWPF();
            PDFViewer.PixelsPerUnitWidth = scaleFactor;

            // PDF Viewer Events subscription
            PDFViewer.MouseLeftButtonDown += PDFView_MouseLeftButtonDown;

            // Enable access to the Tools available
            _toolManager = new ToolManager(PDFViewer);
            _toolManager.AnnotationAdded   += _toolManager_AnnotationAdded;
            _toolManager.AnnotationRemoved += _toolManager_AnnotationRemoved;
        }
 public ActionSource GetActionSource(PDFViewWPF viewer)
 {
     return(this.FirstOrDefault(obj => obj.Viewer.Equals(viewer)));
 }
        public MainViewModel()
        {
            // Initilizes PDFNet
            PDFNet.Initialize();

            // Make sure to Terminate any processes
            Application.Current.SessionEnding += Current_SessionEnding;

            // Init all Commands
            CMDOpenDocument = new Relaycommand(OpenDocument);
            CMDNextPage     = new Relaycommand(NextPage);
            CMDPreviousPage = new Relaycommand(PreviousPage);

            // Annotations
            CMDAnottateText        = new Relaycommand(AddTextSample);
            CMDFreeTextCreate      = new Relaycommand(AddFreeTextSample);
            CMDSelectText          = new Relaycommand(SelectText);
            CMDSquareCreate        = new Relaycommand(AddSquareAnnotation);
            CMDArrowCreate         = new Relaycommand(AddArrowAnnotation);
            CMDOvalCreate          = new Relaycommand(AddOvalAnnotation);
            CMDSquigglyCreate      = new Relaycommand(AddSquigglyAnnotation);
            CMDUnderlineCreate     = new Relaycommand(AddUnderlineAnnotation);
            CMDStrikeoutCreate     = new Relaycommand(AddStrikeoutAnnotation);
            CMDTextHighlightCreate = new Relaycommand(AddHighlightAnnotation);
            CMDInkCreate           = new Relaycommand(AddInkAnnotation);

            CMDExit    = new Relaycommand(ExitApp);
            CMDZoomIn  = new Relaycommand(ZoomIn);
            CMDZoomOut = new Relaycommand(ZoomOut);
            CMDUndo    = new Relaycommand(Undo);
            CMDRedo    = new Relaycommand(Redo);

            // Checks the scale factor to determine the right resolution
            PresentationSource source      = PresentationSource.FromVisual(Application.Current.MainWindow);
            double             scaleFactor = 1;

            if (source != null)
            {
                scaleFactor = 1 / source.CompositionTarget.TransformFromDevice.M11;
            }

            // Set working doc to Viewer
            PDFViewer = new PDFViewWPF();
            PDFViewer.PixelsPerUnitWidth = scaleFactor;
            PDFViewer.SetPagePresentationMode(PDFViewWPF.PagePresentationMode.e_single_continuous);
            PDFViewer.AllowDrop = true;

            // PDF Viewer Events subscription
            PDFViewer.MouseLeftButtonDown += PDFView_MouseLeftButtonDown;
            PDFViewer.Drop += PDFViewer_Drop;

            // Enable access to the Tools available
            _toolManager = new ToolManager(PDFViewer);
            _toolManager.AnnotationAdded   += _toolManager_AnnotationAdded;
            _toolManager.AnnotationRemoved += _toolManager_AnnotationRemoved;

            // Load PDF file
            PDFDoc doc = new PDFDoc("./Resources/GettingStarted.pdf");

            doc.InitSecurityHandler();
            _undoManager = doc.GetUndoManager();
            PDFViewer.SetDoc(doc);
        }
 public ActionSource(MainForm form, PDFViewWPF viewer)
 {
     Form   = form;
     Viewer = viewer;
 }
示例#7
0
 private void CheckCanExcute(PDFViewWPF view)
 {
 }
 void Viewer_CurrentPageNumberChanged(PDFViewWPF viewer, int currentPage, int totalPages)
 {
     _isSelectionChangeProgrammatic = true;
     UpdateSelectedIndex();
     _isSelectionChangeProgrammatic = false;
 }