Hi,
I have been working with the TrackInteractiveOverlay and I am counting the number of vertices that the user draws by using the VertexAdded event. I just added the ability to remove the last vertex with a right mouse click. I followed the sample Custom Track Polygon and it works great. Now I need to subtract from my vertex count whenever a vertex is removed and to do that I need to raise a VertexRemoved event in CustomTrackInteractiveOverlay. Do you have any sample code I can follow that will show me how to do this?
Thanks,
Eileen
Adding an Event to CustomTrackInteractiveOverlay
Hi Eillen,
Why not raise a vertex removed event in your mouse right click event function or directly subtract the couting there?
Sorry maybe I ignore some points about your requirement, please let me know if I missed anything.
Regards,
Don
Hi Don,
I would like to raise the vertex removed event in the mouse right click event function, however since TrackInteractiveOverlay does not have a VertexRemoved event I am not sure how to create the event in my CustomTrackInteractiveOverlay that inherits from TrackInteractiveOverlay. I am also not sure how to link it with the main program. I am a hardware engineer with a lot of experience in embedded programing and while I am getting the hang of working with Visual Studio and vb.net, this is a little over my head. I have to say that the Think Geo Samples have helped me a lot and I have been able to get a great deal done in a short period of time because of them. Do you have any examples that show how to create and use an event?
Regards,
Eileen
Hi Eileen,
Sorry I’m not very good at the grammar of vb.net, so I write it in C# and convert it to vb.net. Please confirm it can work in your project.
Public Class CustomTrackInteractiveOverlay
Inherits TrackInteractiveOverlay
Public Event VertexRemoved As EventHandler(Of VertexAddedTrackInteractiveOverlayEventArgs)
Protected Overridable Sub OnVertexRemoved(e As VertexAddedTrackInteractiveOverlayEventArgs)
Dim handler As EventHandler(Of VertexAddedTrackInteractiveOverlayEventArgs) = VertexRemoved
RaiseEvent handler(Me, e)
End Sub
Private Function YourFunction() As Feature
OnVertexRemoved(New VertexAddedTrackInteractiveOverlayEventArgs(New Vertex(xInWorld, yInWorld), currentFeature))
End Function
End Class
Regards,
Don
Hi Don,
I tried using your example and got some errors. I think I fixed the problem with the Sub OnVertexRemoved, but I still have a problem when the main form adds the handler. I converted the CustomTrackPolygon sample to VB.net and added the event code and the handlers. Please see the attached zip file for the project. What am I doing wrong? Also, is the way I coded OnVertexRemoved correct?
Thanks.
Eileen
CustomTrackPolygonVB(1).zip (38.4 KB)
Hi Eileen,
Sorry the code is translated by some online engine, so it have some problem.
You forget to set TrackMode.
I did some small changes in your sample and it looks works well now.
Please download it and have a look at that.
Regards,
Don
CustomTrackPolygonVB.zip (31.7 KB)
Thanks for putting me on the right path, Don. I got it working now in my application.
Regards,
Eileen
Eileen,
You’re welcome, any question please let us know.
Regards,
Don