/// <summary> /// Sets the new rectangle of an object in pixels. /// </summary> /// <param name="rect">The new rectangle of an object in pixels.</param> protected override void SetRect(Rectangle rect) { VintasoftImage image = _imageViewer.Image; if (image != null) { // get transform from control to the device independent pixels (DIP) AffineMatrix matrix = _imageViewer.GetTransformFromControlToDip(); // convert location to the DIP PointF locationInDip = PointFAffineTransform.TransformPoint(matrix, rect.Location); if (HideContentOnTransform) { // if comment control content is visible if (!_isCommentControlContentHidden) { // hide comment control content UpdateCommentControlContentVisibility(false); _isCommentControlContentHidden = true; } } // update comment bounding box CommentControl.Comment.BoundingBox = new RectangleF(locationInDip, rect.Size); } }
/// <summary> /// Returns center point of image viewer in coordinate space of specified image. /// </summary> /// <param name="image">An image.</param> /// <returns> /// Center point of image viewer in coordinate space of specified image. /// </returns> private PointF GetCenterPoint(VintasoftImage image) { // get old visible point PointF centerPoint = new PointF(ImageViewer.ClientSize.Width / 2.0f, ImageViewer.ClientSize.Height / 2.0f); // get transform from image space to viewer space AffineMatrix pointTransfrom = ImageViewer.GetTransformFromControlToImage(image); // transform the point return(PointFAffineTransform.TransformPoint(pointTransfrom, centerPoint)); }