VintaSoft Annotation .NET Plug-in Discussions

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

Board index < VintaSoft Imaging < VintaSoft Annotation .NET Plug-in Discussions

We are migrating to new forums engine, no new registration or posting currently available. TIA for your patience.

Create Annotation on Right Click of C# Window Application



Create Annotation on Right Click of C# Window Application

Post by dixit.patel1 »

Hello,

I have created annotation on MouseClick Event but the annotation in not proper placed in location where mouse is right clicked,
it is not working in all tiff files, it shows wrong position and not showing annotation on document viwer.

I am using below Code Snippet.
private void annotationViewer1_MouseClick(object sender, MouseEventArgs e)
{
    if (e.Button == MouseButtons.Right)
    {
        AnnotationView annotationView = null;
        AnnotationData data = null;
        data = new RectangleAnnotationData();
        data.FillBrush = new AnnotationSolidBrush(Color.Green);

        var xPlace = AnnotationViewer.Images[annotationViewer1.FocusedIndex].Resolution.Horizontal;
        var yPlace = AnnotationViewer.Images[annotationViewer1.FocusedIndex].Resolution.Vertical;

        var xPoint = 96 / xPlace;
        var yPoint = 96 / yPlace;

        var xPosition = Convert.ToDecimal(Convert.ToInt32(e.X) * xPoint);
        var yPosition = Convert.ToDecimal(Convert.ToInt32(e.Y) * yPoint);
        var wSize = Convert.ToDecimal(Convert.ToInt32(10) * xPoint);
        var hSize = Convert.ToDecimal(Convert.ToInt32(10) * yPoint);

        var xLocation = Convert.ToDecimal(xPosition + wSize / 2);
        var yLocation = Convert.ToDecimal(yPosition + hSize / 2);

        data.Location = new Point(Convert.ToInt32(xLocation), Convert.ToInt32(yLocation));
        data.Size = new Size(Convert.ToInt32(wSize), Convert.ToInt32(hSize));

        if (data != null)
        {
            // start the annotation building
            AnnotationViewer.AddAndBuildAnnotation(data);
        }
    }
}


Re: Create Annotation on Right Click of C# Window Application

Post by Alex »

Hello,

Your code has logical mistake.

If you want to convert screen point into viewer point, please use the ImageViewer.PointToClient method.

If you want to convert viewer point into annotation point, please use the ImageViewer.PointFromControlToDip method.

Best regards, Alexander


Page 1 from 1: 1