Page 1 of 2

Set annotation location

Posted: Wed Jan 22, 2020 4:45 pm
by missionRoom
I want to add annotations centered on a mouse click, as opposed to the default positioning (annotations top left at the mouse click position). I've tried setting the location of the annotation data, then calling AddAndBuildAnnotation, but the position is changed to match the default. I can change the annotation location after the annotation has been added, but there is a visible jump to the new location.
Is there any way of setting the location before the annotation is added, and not have it revert to the default?

Thanks for any help with this,

Re: Set annotation location

Posted: Thu Jan 23, 2020 8:54 am
by Alex
Hello,

For solving your task you need to specify that annotation builder must center rectangular annotation during annotation building. This can be done using the RectangularObjectBuilder.ObjectBuildingStyle property:
https://www.vintasoft.com/docs/vsimagin ... tyle.html

Here is a code sample:

Code: Select all

...
// create the rectangle annotation data
RectangleAnnotationData rectData = new RectangleAnnotationData();
// create the rectangle annotation view
RectangleAnnotationView rectView = new RectangleAnnotationView(rectData);

// get the annotation builder
RectangularAnnotationBuilder builder = (RectangularAnnotationBuilder)rectView.Builder;
// specify that annotation builder must center rectangular annotation during annotation building
builder.ObjectBuildingStyle = Vintasoft.Imaging.UI.VisualTools.UserInteraction.RectangularObjectBuildingStyle.CenterObject;
// specify the default size for annotation
builder.DefaultSize = new SizeF(150, 100);

...
// add annotation to the annotation viewer and start annotation building
AnnotationViewer1.AddAndBuildAnnotation(rectView);
...
Best regards, Alexander

Re: Set annotation location

Posted: Thu Jan 23, 2020 2:40 pm
by missionRoom
Thanks for the quick response.
That looks like exactly what I want, I need to upgrade to V9 to use this feature by the looks of it. I've downloaded the dlls, and added them to my project, but I'm now getting the attached error when it intialises the annotation viewer, do you know what might be causing this

Exception
The type initializer for 'Vintasoft.Imaging.VintasoftImage' threw an exception.

Stack Trace
at Vintasoft.Imaging.ImageRendering.ImageRenderingRequirements.婻()
at 肓..ctor(揌 A_0, 娑 A_1)
at Vintasoft.Imaging.UI.ImageViewer.娑()
at Vintasoft.Imaging.UI.ImageViewer.嬚()
at Vintasoft.Imaging.UI.ImageViewer..ctor()
at Vintasoft.Imaging.Annotation.UI.AnnotationViewer..ctor()
at SimpleMarkup.AnnotationForm.InitializeComponent() in C:\Users\Jon\Documents\Projects\C#\SimpleMarkup\SimpleMarkup\Forms\AnnotationForm.Designer.cs:line 49
at SimpleMarkup.AnnotationForm..ctor() in C:\Users\Jon\Documents\Projects\C#\SimpleMarkup\SimpleMarkup\Forms\AnnotationForm.cs:line 78
at SimpleMarkup.DataManager.LoadApplication() in C:\Users\Jon\Documents\Projects\C#\SimpleMarkup\SimpleMarkup\Data\DataManager.cs:line 638

Re: Set annotation location

Posted: Thu Jan 23, 2020 3:41 pm
by Alex
I think you have the licensing exception. Please check the inner exception for generated exception and let me know results.

Best regards, Alexander

Re: Set annotation location

Posted: Thu Jan 23, 2020 3:46 pm
by missionRoom
The inner exception is - "Not correct license."
So it looks like you're right. I'm using the same licensing info as for the previous version, is that correct? Or do we need a new one? We should have a valid license for the components.

Thanks,

Re: Set annotation location

Posted: Thu Jan 23, 2020 4:09 pm
by missionRoom
I've just looked through my old emails, and have the V9 update. I've updated the license info in my application and it's all working again now.

Thanks for all the help,

Re: Set annotation location

Posted: Mon Jan 27, 2020 3:44 pm
by missionRoom
I've finally got this all setup, had to renew the PDF license I was using.
But setting the ObjectBuildingStyle to RectangularObjectBuildingStyle.CenterObject, seems to still cause the jumping I was trying to avoid (the annotation is initially placed not centered, then jumps to the center). Is this the expected behavior? Is there any way of avoiding the jump?

Re: Set annotation location

Posted: Fri Jan 31, 2020 8:28 am
by Alex
Hello,
But setting the ObjectBuildingStyle to RectangularObjectBuildingStyle.CenterObject, seems to still cause the jumping I was trying to avoid (the annotation is initially placed not centered, then jumps to the center). Is this the expected behavior? Is there any way of avoiding the jump?
For understanding your problem we need to reproduce the problem on our side. Please send us (to support@vintasoft.com) a small application, which demonstrates the problem. We will analyze your code and will suggest the best solution for your task.

Best regards, Alexander

Re: Set annotation location

Posted: Thu Feb 06, 2020 9:44 am
by Alex
Hello,
I've finally got this all setup, had to renew the PDF license I was using.
But setting the ObjectBuildingStyle to RectangularObjectBuildingStyle.CenterObject, seems to still cause the jumping I was trying to avoid (the annotation is initially placed not centered, then jumps to the center). Is this the expected behavior? Is there any way of avoiding the jump?
Have you solved the problem?

Best regards, Alexander

Re: Set annotation location

Posted: Thu Feb 06, 2020 2:20 pm
by missionRoom
I haven't solved it, but have worked out what is causing it. I'm setting the CanMove, CanRotate and CanResize values to false in the FocusedAnnotationViewChanged, as I want the user to just position the annotation and not be able to move it at all.

Code: Select all

private void annotationViewer_FocusedAnnotationViewChanged(object sender, AnnotationViewChangedEventArgs e)
{
    if (e.NewValue != null)
    {
        // Disallow interation controllers
        e.NewValue.CanMove = false;
        e.NewValue.CanRotate = false;
        e.NewValue.CanResize = false;
    }
}