VintaSoft Imaging .NET SDK and Plug-ins Discussions

Questions, comments and suggestions concerning VintaSoft Imaging .NET SDK.

Board index < VintaSoft Imaging < VintaSoft Imaging .NET SDK and Plug-ins Discussions

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

Refresh/Paint drawings on ImageViewer



Re: Refresh/Paint drawings on ImageViewer

Post by JeromeC »

Hello Alex,

Thanks it's working great now!

Concerning my previous question on the behavior of the mouse events of the AnnotationView, do you have some more insight?
I did some more tests and it seems the FocusedAnnotation of the AnnotationVisualTool is correctly set on the mouseUp event but not on the MouseDown.

Best regards,
Jerome.


Re: Refresh/Paint drawings on ImageViewer

Post by Alex »

I did some more tests and it seems the FocusedAnnotation of the AnnotationVisualTool is correctly set on the mouseUp event but not on the MouseDown. Do you mean an annotation gets focus only when you release mouse button? Please check our Annotation Demo and let me know if you will have any problem.

Best regards, Alexander


Re: Refresh/Paint drawings on ImageViewer

Post by JeromeC »

Hello Alex,

After further more tests, I was able to do what I want.

On the mouseDown event on the AnnotationVisualTool, I set the HoveredAnnotation to the FocusedAnnotation, that way I don't have to wait for the mouse to be released to have my annotationView selected/focused (which was my problem).

Then I was able to do all my operations on the state of the release of the mouse button in the MouseUp event.

I'm all clear on that topic, Thanks.

Best regards,
Jerome.


Re: Refresh/Paint drawings on ImageViewer

Post by JeromeC »

Hello Alex,

I'm working on the point polygon Annotation.
I need to move the polygon around my AnnotationViewer and store it's coordinates each time it moves.
I have undo/redo buttons, it's working well on the rectangle annotation but not on the polygon annotation.

I have the following code for the rectangle annotation which is working fine.
                    IPolygonData selectedPolygonData = null;

                    if (historyDirection.Equals(PolygonHistoryDirection.Back))
                    {
                        selectedPolygonData = (RectangleData)selectedPolygon.GoToPreviousStateAndGet();
                    }
                    else
                    {
                        selectedPolygonData = (RectangleData)selectedPolygon.GoToNextStateAndGet();
                    }
                    // Apply the new state on the focused(selected) annotationViewData
                    AnnotationDataState annotationDataState = new AnnotationDataState(annotationView.Data)
                    {
                        Location = ((RectangleData)selectedPolygonData).Rectangle.Location,
                        Size = ((RectangleData)selectedPolygonData).Rectangle.Size
                    };
                    annotationDataState.Apply(GetSelectedAnnotationView().Data);

Here is my code to create the Polygon Annotation View (I use the same method to create my Rectangle Annotation).
annotationView = AnnotationViewFactory.CreateView(new PolygonAnnotationData());
annotationView.Name = annotationView.Data.Guid.ToString();
View.GetAnnotationViewer().AddAndBuildAnnotation(annotationView);



Here is my code to handle the changes on my polygon annotation.
selectedPolygonData is my class and is containing a property called Points which is a List<PointF>.

For rectangle I store the the Size and Location, for polygon I store all the points.

But I do not have the possibility to get the annotation state as for the rectangle, it doesn't hold the value of the points, only the Location and size.
I need to have and be able to build point polygon from a list of PointF.

I tried the following code without success.
IPolygonData selectedPolygonData = null;

        if (historyDirection.Equals(PolygonHistoryDirection.Back))
        {
            selectedPolygonData = (PolygonPointsData)selectedPolygon.GoToPreviousStateAndGet();
        }
        else
        {
            selectedPolygonData = (PolygonPointsData)selectedPolygon.GoToNextStateAndGet();
        }
        // Apply the new state on the focused(selected) annotationViewData
        var data = ((PolygonAnnotationData) GetSelectedAnnotationView().Data);
        AnnotationPointCollection annoPointCollection = data.Points;
        annoPointCollection.Clear();
        foreach (var point in ((PolygonPointsData)selectedPolygonData).Points)
        {
            annoPointCollection.Add(point);
        }
        

My function to create the polygon annotation view from my point list:
This doesn't work either.
        private AnnotationView CreatePolygonPointsAnnotationView(List<PointF> pointsList, string toolTip, string name)
        {
            PolygonAnnotationData polyPointsAnnotationData = new PolygonAnnotationData
            {
                CanResize = true,
                ToolTip = toolTip,
                CanRotate = false,
                FillBrush = new AnnotationSolidBrush(Color.Transparent),
                Border = true,
                Outline = { Brush = new AnnotationSolidBrush(Color.Blue), Width = 1 }
            };
            foreach (var point in pointsList)
            {
                polyPointsAnnotationData.Points.Add(point);
            }
            return new PolygonAnnotationView(polyPointsAnnotationData) { Name = name };
        }
Is there a special class to build the polygon point based annotation that I missed? Or just doing it wrong?

Best wishes,
Jerome.


Re: Refresh/Paint drawings on ImageViewer

Post by JeromeC »

I would also like to know how to stop the drawing of an point polygon when I use the following code:
View.GetAnnotationViewer().AddAndBuildAnnotation(annotationView)
I can stop it by double right clicking my annotationViewer, it finishes the annotation with the current position of the mouse, I would like to stop it by pressing enter for example, or a single right click.

Best wishes,
Jerome.


Re: Refresh/Paint drawings on ImageViewer

Post by Alex »

Hello Jerome,
I need to move the polygon around my AnnotationViewer and store it's coordinates each time it moves.
I have undo/redo buttons, it's working well on the rectangle annotation but not on the polygon annotation.
SDK has the Vintasoft.Imaging.Annotation.UI.Undo.AnnotationViewCollectionUndoMonitor and Vintasoft.Imaging.Annotation.UI.Undo.AnnotationViewUndoMonitor classes which allow to add undo/redo functionality to your application. Why dont you use these classes? Annotation Demo shows how to use these classes for managing changes in annotations.

Also Annotation Demo allows to monitor all changes in annotations:
  • Run Annotation Demo
  • Select "View => Show Events Log" and you will see all changes in annotations
I would also like to know how to stop the drawing of an point polygon You can finish the annotation building using the AnnotationVisualTool.FinishAnnotationBuilding method:
https://www.vintasoft.com/docs/vsimaging ... lding.html

You can cancel the annotation building using the AnnotationVisualTool.CancelAnnotationBuilding method:
https://www.vintasoft.com/docs/vsimaging ... lding.html

Best regards, Alexander


Re: Refresh/Paint drawings on ImageViewer

Post by JeromeC »

Hello Alex,
Hello Jerome,
SDK has the Vintasoft.Imaging.Annotation.UI.Undo.AnnotationViewCollectionUndoMonitor and Vintasoft.Imaging.Annotation.UI.Undo.AnnotationViewUndoMonitor classes which allow to add undo/redo functionality to your application. Why dont you use these classes? Annotation Demo shows how to use these classes for managing changes in annotations.
I didn't see these classes and didn't pay attention to that functionality in the annotation demo, I will look into it but I won't be able to use it in my project.

My annotation can be updated dynamicaly with information (List of pointf) coming from another program and/or network, so I need to be able to update all the points from the annotation with a list of points, as my second program and information coming from network don't use the Vintasoft SDK.
You can finish the annotation building using the AnnotationVisualTool.FinishAnnotationBuilding method:
https://www.vintasoft.com/docs/vsimaging ... lding.html

You can cancel the annotation building using the AnnotationVisualTool.CancelAnnotationBuilding method:
https://www.vintasoft.com/docs/vsimaging ... lding.html
Ok I'll use that function.

Best wishes,
Jerome.


Page 2 from 2: 1 2