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 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); }