/// <summary> /// Adds a log message about mouse event. /// </summary> /// <param name="annotationView">The annotation view.</param> /// <param name="eventName">The event name.</param> /// <param name="e">The <see cref="ObjectPropertyChangedEventArgs"/> instance containing the event data.</param> private void AddMouseEventLogMessage( AnnotationView annotationView, string eventName, MouseEventArgs e) { // location in viewer space PointF locationInViewerSpace = e.Location; // transformation from annotation space (DIP) to the viewer space PointFTransform toViewerTransform = annotationView.GetPointTransform(AnnotationViewer, AnnotationViewer.Image); PointFTransform inverseTransform = toViewerTransform.GetInverseTransform(); // location in annotation space (DIP) PointF locationInAnnotationSpace = inverseTransform.TransformPoint(locationInViewerSpace); // location in annotation content space PointF locationInAnnotationContentSpace; // matrix from annotation content space to the annotation space (DIP) using (Matrix fromDipToContentSpace = GdiConverter.Convert(annotationView.GetTransformFromContentToImageSpace())) { // DIP space -> annotation content space fromDipToContentSpace.Invert(); PointF[] points = new PointF[] { locationInAnnotationSpace }; fromDipToContentSpace.TransformPoints(points); locationInAnnotationContentSpace = points[0]; } AddLogMessage(string.Format("{0}.{1}: ViewerSpace={2}; ContentSpace={3}", GetAnnotationInfo(annotationView), eventName, locationInViewerSpace, locationInAnnotationContentSpace)); }
/// <summary> /// Returns an annotation selection as <see cref="GraphicsPath"/> in annotation content space. /// </summary> public override GraphicsPath GetSelectionAsGraphicsPath() { GraphicsPath path = new GraphicsPath(); SizeF size = Size; path.AddRectangle(new RectangleF(-size.Width / 2, -size.Height / 2, size.Width, size.Height)); using (Matrix transform = GdiConverter.Convert(GetTransformFromContentToImageSpace())) path.Transform(transform); return(path); }