private void drag_area_tracker_OnDragComplete(bool button_left_pressed, bool button_right_pressed, Point mouse_down_point, Point mouse_up_point) { FeatureTrackingManager.Instance.UseFeature(Features.Document_AddAnnotation); int MINIMUM_DRAG_SIZE_TO_CREATE_ANNOTATION = 20; if (Math.Abs(mouse_up_point.X - mouse_down_point.X) < MINIMUM_DRAG_SIZE_TO_CREATE_ANNOTATION || Math.Abs(mouse_up_point.Y - mouse_down_point.Y) < MINIMUM_DRAG_SIZE_TO_CREATE_ANNOTATION) { Logging.Info("Drag area too small to create annotation"); return; } PDFAnnotation pdf_annotation = new PDFAnnotation(pdf_renderer_control_stats.pdf_document.PDFRenderer.DocumentFingerprint, page, PDFAnnotationEditorControl.LastAnnotationColor, ConfigurationManager.Instance.ConfigurationRecord.Account_Nickname); pdf_annotation.Left = Math.Min(mouse_up_point.X, mouse_down_point.X) / ActualWidth; pdf_annotation.Top = Math.Min(mouse_up_point.Y, mouse_down_point.Y) / ActualHeight; pdf_annotation.Width = Math.Abs(mouse_up_point.X - mouse_down_point.X) / ActualWidth; pdf_annotation.Height = Math.Abs(mouse_up_point.Y - mouse_down_point.Y) / ActualHeight; pdf_renderer_control_stats.pdf_document.GetAnnotations().AddUpdatedAnnotation(pdf_annotation); PDFAnnotationItem pdf_annotation_item = new PDFAnnotationItem(this, pdf_annotation, pdf_renderer_control_stats); pdf_annotation_item.ResizeToPage(ActualWidth, ActualHeight); Children.Add(pdf_annotation_item); }
public PDFAnnotationLayer(PDFDocument pdf_document, int page) { WPFDoEvents.AssertThisCodeIsRunningInTheUIThread(); this.pdf_document = pdf_document; this.page = page; InitializeComponent(); // Wizard if (1 == page) { WizardDPs.SetPointOfInterest(this, "PDFReadingAnnotationLayer"); } Background = Brushes.Transparent; Cursor = Cursors.Cross; SizeChanged += PDFAnnotationLayer_SizeChanged; drag_area_tracker = new DragAreaTracker(this); drag_area_tracker.OnDragComplete += drag_area_tracker_OnDragComplete; // Add all the already existing annotations foreach (PDFAnnotation pdf_annotation in pdf_document.GetAnnotations()) { if (pdf_annotation.Page == this.page) { if (!pdf_annotation.Deleted) { Logging.Info("Loading annotation on page {0}", page); PDFAnnotationItem pdf_annotation_item = new PDFAnnotationItem(this, pdf_annotation); pdf_annotation_item.ResizeToPage(ActualWidth, ActualHeight); Children.Add(pdf_annotation_item); } else { Logging.Info("Not loading deleted annotation on page {0}", page); } } } //Unloaded += PDFAnnotationLayer_Unloaded; Dispatcher.ShutdownStarted += Dispatcher_ShutdownStarted; }
public PDFAnnotationLayer(PDFRendererControlStats pdf_renderer_control_stats, int page) { this.pdf_renderer_control_stats = pdf_renderer_control_stats; this.page = page; InitializeComponent(); // Wizard if (1 == page) { WizardDPs.SetPointOfInterest(this, "PDFReadingAnnotationLayer"); } Background = Brushes.Transparent; Cursor = Cursors.Cross; SizeChanged += PDFAnnotationLayer_SizeChanged; drag_area_tracker = new DragAreaTracker(this); drag_area_tracker.OnDragComplete += drag_area_tracker_OnDragComplete; // Add all the already existing annotations foreach (PDFAnnotation pdf_annotation in pdf_renderer_control_stats.pdf_document.GetAnnotations()) { if (pdf_annotation.Page == this.page) { if (!pdf_annotation.Deleted) { Logging.Info("Loading annotation on page {0}", page); PDFAnnotationItem pdf_annotation_item = new PDFAnnotationItem(this, pdf_annotation, pdf_renderer_control_stats); pdf_annotation_item.ResizeToPage(ActualWidth, ActualHeight); Children.Add(pdf_annotation_item); } else { Logging.Info("Not loading deleted annotation on page {0}", page); } } } }
internal void DeletePDFAnnotationItem(PDFAnnotationItem pdf_annotation_item) { Children.Remove(pdf_annotation_item); }