Mouse position on Image in AnnotationViewer

Questions, comments and suggestions concerning VintaSoft Annotation .NET Plug-in.

Moderator: Alex

Post Reply
minalchaniara
Posts: 9
Joined: Mon Sep 25, 2023 6:20 pm

Mouse position on Image in AnnotationViewer

Post by minalchaniara »

Hi,

I am not able to get coordinates of Image while doing right click on image which is load in AnnotationViewer. It is giving AnnotationViewer coordinates. I am using below code for getting coordinates. Please help me on the same

Code: Select all

private void AnnotationTool_MouseClick(object sender, VisualToolMouseEventArgs e)
{
     AnnotationVisualTool sAnnotationVisualTool = (AnnotationVisualTool)sender;
     //Point mp = sAnnotationVisualTool.ImageViewer.PointToImage(Control.MousePosition);
     if (e.Button == MouseButtons.Right)
     {
         AnnotationViewer.AnnotationInteractionMode = AnnotationInteractionMode.Author;
         try
         {
             Point objPoint = new Point(e.X, e.Y);
             ReferencedImageAnnotationData objReferencedImageAnnotationData = new ReferencedImageAnnotationData();
             objReferencedImageAnnotationData.Image.SetImage(BitmapToVintasoftImage(global::Advantmed.RiskAdjustment.Application.Properties.Resources.AnnotationDot_Green));
             objReferencedImageAnnotationData.CreatedBy = Convert.ToString(NLPDataID);
             objReferencedImageAnnotationData.ModifiedBy = Convert.ToString(PageAnnotation);
             objReferencedImageAnnotationData.Name = "";
             objReferencedImageAnnotationData.Intent = strDiagnosis;
             objReferencedImageAnnotationData.Size = new SizeF((DotWidth / 2), (DotHeight / 2));
             objReferencedImageAnnotationData.Location = AnnotationViewer.PointFromControlToDip(objPoint);
             objReferencedImageAnnotationData.Border = false;
             objReferencedImageAnnotationData.CanMirror = false;
             objReferencedImageAnnotationData.CanResize = false;
             objReferencedImageAnnotationData.CanRotate = false;
             objReferencedImageAnnotationData.CanMove = true;
             if (objReferencedImageAnnotationData != null)
             {
                 AnnotationViewer.AddAndBuildAnnotation(objReferencedImageAnnotationData);
             }
             AnnotationViewer.FinishAnnotationBuilding();
         }
     }
}
Alex
Site Admin
Posts: 2319
Joined: Thu Jul 10, 2008 2:21 pm

Re: Mouse position on Image in AnnotationViewer

Post by Alex »

Hello,

If you want to convert the screen point to the viewer point, you need to use the AnnotationViewer.PointToClient method.
If you want to convert the viewer point to the annotation point, you need to use the AnnotationViewer.PointFromControlToDip method.

Best regards, Alexander
Post Reply