Refresh/Paint drawings on ImageViewer

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

Moderator: Alex

JeromeC
Posts: 11
Joined: Wed Apr 22, 2015 4:56 pm

Re: Refresh/Paint drawings on ImageViewer

Post by JeromeC » Tue May 05, 2015 11:13 am

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.

Alex
Site Admin
Posts: 1445
Joined: Thu Jul 10, 2008 2:21 pm

Re: Refresh/Paint drawings on ImageViewer

Post by Alex » Tue May 05, 2015 11:45 am

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

JeromeC
Posts: 11
Joined: Wed Apr 22, 2015 4:56 pm

Re: Refresh/Paint drawings on ImageViewer

Post by JeromeC » Tue May 05, 2015 4:53 pm

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.

JeromeC
Posts: 11
Joined: Wed Apr 22, 2015 4:56 pm

Re: Refresh/Paint drawings on ImageViewer

Post by JeromeC » Mon May 11, 2015 6:19 pm

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.

Code: Select all

                    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).

Code: Select all

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.

Code: Select all


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.

Code: Select all

        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.

JeromeC
Posts: 11
Joined: Wed Apr 22, 2015 4:56 pm

Re: Refresh/Paint drawings on ImageViewer

Post by JeromeC » Mon May 11, 2015 6:22 pm

I would also like to know how to stop the drawing of an point polygon when I use the following code:

Code: Select all

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.

Alex
Site Admin
Posts: 1445
Joined: Thu Jul 10, 2008 2:21 pm

Re: Refresh/Paint drawings on ImageViewer

Post by Alex » Mon May 11, 2015 8:09 pm

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:
http://www.vintasoft.com/docs/vsimaging ... lding.html

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

Best regards, Alexander

JeromeC
Posts: 11
Joined: Wed Apr 22, 2015 4:56 pm

Re: Refresh/Paint drawings on ImageViewer

Post by JeromeC » Tue May 12, 2015 10:17 am

Hello Alex,
Alex wrote: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.
Alex wrote: You can finish the annotation building using the AnnotationVisualTool.FinishAnnotationBuilding method:
http://www.vintasoft.com/docs/vsimaging ... lding.html

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

Best wishes,
Jerome.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest