/// <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 distance between point and image rectangle.
        /// </summary>
        /// <param name="point">A point in image viewer space.</param>
        /// <param name="image">An image.</param>
        /// <returns>Distance between point and image rectangle.</returns>
        private float GetDistanceBetweenPointAndImageRect(PointF point, VintasoftImage image)
        {
            AffineMatrix transformMatrix = ImageViewer.GetTransformFromImageToControl(image);
            // get image rectangle
            RectangleF      imageRect      = new RectangleF(0, 0, image.Width, image.Height);
            PointFTransform pointTransform = PointFAffineTransform.FromMatrix(transformMatrix);

            imageRect = PointFAffineTransform.TransformBoundingBox(pointTransform, imageRect);

            PointF imagePoint = PointF.Empty;

            // get X coordinate of point on image
            if (point.X < imageRect.X)
            {
                imagePoint.X = imageRect.X;
            }
            else if (point.X > imageRect.X + imageRect.Width)
            {
                imagePoint.X = imageRect.X + imageRect.Width;
            }
            else
            {
                imagePoint.X = point.X;
            }

            // get Y coordinate of point on image
            if (point.Y < imageRect.Y)
            {
                imagePoint.Y = imageRect.Y;
            }
            else if (point.Y > imageRect.Y + imageRect.Height)
            {
                imagePoint.Y = imageRect.Y + imageRect.Height;
            }
            else
            {
                imagePoint.Y = point.Y;
            }

            // calculate distance
            float dx = (point.X - imagePoint.X);
            float dy = (point.Y - imagePoint.Y);
            float distanceBetweenImageAndPoint = dx * dx + dy * dy;

            return(distanceBetweenImageAndPoint);
        }