Using MapXtreme ADDPOLYGON tool in simple VB.net application

38 views
Skip to first unread message

Nick

unread,
Aug 29, 2023, 11:33:23 AM8/29/23
to MapInfo-L
All,

I have a very simple VB.net MapXtreme application.  

I have one tool, ADD POLYGON, and I want to force the tool to stop drawing after the sixth point.

Therefore, the steps would be:
Step 1: Click on Add Polygon tool (from the toolbar)
Step 2: Single-click with the left mouse button six times
Step 3: On the sixth point, I want the tool to stop accepting clicks, do some work, and finish

The issue I am having is on the sixth point, my code never calls the "ToolAddedFeature()" function which seems to be what MapXtreme natively calls when a double-click occurs on a 3-point polygon, 4-point polygon, or 5-point polygon.

Therefore, because I am NOT able to run the "ToolAddedFeature()", I am left with this grey line (the line the user sees as they are drawing points 1 thru 6)  I tried to show an example of the image attached.

Can anyone help me out?  The goal again is to figure out how to stop the ADD POLYGON tool at the sixth point, and also make sure we clear out the native grey line too.  Here is my sample code below:

======================================
  Private Sub ToolUsed(ByRef map As map, ByVal e As MapInfo.Tools.ToolUsedEventArgs)
Try
       tool.Name = e.ToolName.ToUpper.Trim
       tool.Status = e.ToolStatus
       If tool.Status = MapInfo.Tools.ToolStatus.Start Then
           '--nothing here when you first start using polygon tool
      ElseIf tool.Status = MapInfo.Tools.ToolStatus.InProgress Then
          '--here we would store each single point click
       ElseIf tool.Status = MapInfo.Tools.ToolStatus.End Then

       ElseIf tool.Status = MapInfo.Tools.ToolStatus.Cancel Then
              '--anyway here to call ToolAddedFeature manually?
       Else

       End If


 Private Sub ToolAddedFeature(ByVal sender As Object, ByVal e As MapInfo.Tools.FeatureAddedEventArgs)
        LogMessage("ToolAddedFeature Called for ADD POLYGON tool")
    End Sub


Six-Pt-Dbl-Click-On-6th-Point-and-get-Crop.png
Reply all
Reply to author
Forward
0 new messages