MapWinGIS:AxMap SelectBoxDrag

This is a back-up of the WIKI.
Not all links might work
We're working on a new wiki.

Main Page | Recent changes | View source | Page history | Log in / create account |

Printable version | Disclaimers | Privacy policy

SelectBoxDrag

This event is fired while the user is dragging a selection box in the map control. The map property SendSelectBoxDrag must be set to True for this event to be fired.
See also SendSelectBoxDrag


VB.NET Usage

Event SelectBoxDrag(Sender As Object, e As AxMapWinGIS._DMapEvents_SelectBoxDragEvent)

            Parameters

Sender

The sender of the event.
e.bottom The bottom boundary of the selection box in pixel coordinates.
e.left The left boundary of the selection box in pixel coordinates.
e.right The right boundary of the selection box in pixel coordinates.
e.top The top boundary of the selection box in pixel coordinates.

Sample Code

    Private Sub Map1_SelectBoxDrag(ByVal sender As Object, ByVal e As AxMapWinGIS._DMapEvents_SelectBoxDragEvent) Handles Map1.SelectBoxDrag
        Dim sf As MapWinGIS.Shapefile
        Dim myExtents As New MapWinGIS.Extents()
        Dim selectedShapes() As Integer
        Dim i As Integer, hndl As Integer
        Dim pxMin As Double, pxMax As Double, pyMin As Double, pyMax As Double, pzMin As Double, pzMax As Double
        Dim col As System.Drawing.Color
        'Check if the map is in selection mode
        If Map1.CursorMode = MapWinGIS.tkCursorMode.cmSelection Then
            'Get the handle of the layer at position 0
            hndl = Map1.get_LayerHandle(0)
            'Get the shapefile in the specified layer
            sf = Map1.get_GetObject(hndl)
            'Convert the boundaries of the selection box from pixel units to projected map coordinates
            Map1.PixelToProj(e.left, e.bottom, pxMin, pyMin)
            Map1.PixelToProj(e.right, e.top, pxMax, pyMax)
            'Set the extents object to be used to find shapes that have been selected in the shapefile
            myExtents.SetBounds(pxMin, pyMin, 0, pxMax, pyMax, 0)
            'Check if there are any shapes with in the shapefile that intersect with the selection box
            If sf.SelectShapes(myExtents, 0, MapWinGIS.SelectMode.INTERSECTION, selectedShapes) Then
                'Get the System.Drawing.Color which is being used as the fill color for the shapes in the layer
                col = Map1.get_ShapeLayerFillColor(hndl)
                'Set all shapes in the shapefile back to their original color
                Map1.set_ShapeLayerFillColor(hndl, System.Convert.ToUInt32(RGB(col.R, col.G, col.B)))
                'For each of the selected shapes in the shapefile, color them differently than their original fill color
                For i = 0 To UBound(selectedShapes)
                    Map1.set_ShapeFillColor(hndl, selectedShapes(i), System.Convert.ToUInt32(RGB(100, 100, 0)))
                Next
            End If
        End If
    End Sub
  

VB 6 Usage

Event SelectBoxDrag(Left As Long, Right As Long, Bottom As Long, Top As Long)
            Parameters

Left

The left boundary of the selection box in pixel coordinates.
Right The right boundary of the selection box in pixel coordinates.
Bottom The bottom boundary of the selection box in pixel coordinates.
Top The top boundary of the selection box in pixel coordinates.

Sample Code

    Private Sub Map1_SelectBoxDrag(ByVal Left As Long, ByVal Right As Long, ByVal Bottom As Long, ByVal Top As Long)
        Dim sf As MapWinGIS.Shapefile
        Dim myExtents As New MapWinGIS.extents
        Dim selectedShapes As Variant
        Dim i As Long, hndl As Long
        Dim pxMin As Double, pxMax As Double, pyMin As Double, pyMax As Double, pzMin As Double, pzMax As Double
        'Check if the map is in selection mode
        If Map1.CursorMode = MapWinGIS.tkCursorMode.cmSelection Then
            'Get the handle of the layer at position 0
            hndl = Map1.LayerHandle(0)
            'Get the shapefile in the specified layer
            Set sf = Map1.GetObject(hndl)
            'Convert the boundaries of the selection box from pixel units to projected map coordinates
            Map1.PixelToProj Left, Bottom, pxMin, pyMin
            Map1.PixelToProj Right, Top, pxMax, pyMax
            'Set the extents object to be used to find shapes that have been selected in the shapefile
            myExtents.SetBounds pxMin, pyMin, 0, pxMax, pyMax, 0
            'Check if there are any shapes with in the shapefile that intersect with the selection box
            If sf.SelectShapes(myExtents, 0, INTERSECTION, selectedShapes) Then
                'Set all shapes in the shapefile back to their original color
                Map1.ShapeLayerFillColor(hndl) = Map1.ShapeLayerFillColor(hndl)
                'For each of the selected shapes in the shapefile, color them differently than their original fill color
                For i = 0 To UBound(selectedShapes)
                    Map1.ShapeFillColor(hndl, selectedShapes(i)) = vbYellow
                Next
            End If
        End If
    End Sub

Retrieved from "http://mapwindow.org/wiki/index.php/MapWinGIS:AxMap_SelectBoxDrag"

This page has been accessed 2,188 times. This page was last modified on 9 November 2005, at 18:38.