Thanks guys, this was very helpful!
For us poor VB programmers out there, here is the code that I used to get this working, following what is above, and also in the Track Zoom In Without Shift example:
First, I created the following class
[code] #Region " Map Pan Mode Code "
Public Enum MapMoveMode
TrackZoomIn
Pan
'SelectJob
'SelectAsset
'AddAsset
'EditAsset
End Enum
Namespace TrackZoomInWithoutShiftKey
Class ModeInteractiveOverlay
Inherits ExtentInteractiveOverlay
Private _mode As MapMoveMode
Public Sub New()
'Sets default mode to TrackZoomIn.
MyBase.PanMode = MapPanMode.Disabled
MyBase.LeftClickDragMode = MapLeftClickDragMode.ZoomInWithKey
MyBase.LeftClickDragKey = Keys.None
_mode = MapMoveMode.TrackZoomIn
End Sub
Public Property MapMode() As MapMoveMode
Get
Return _mode
End Get
Set(value As MapMoveMode)
_mode = value
Select Case _mode
Case MapMoveMode.TrackZoomIn
If True Then
UpdateMode(KernPanMode.Off, KernZoomMode.[On], KernTrackMode.Off, KernEditMode.Off, Cursors.Cross)
Exit Select
End If
Case MapMoveMode.Pan
If True Then
UpdateMode(KernPanMode.[On], KernZoomMode.Off, KernTrackMode.Off, KernEditMode.Off, Cursors.SizeAll)
Exit Select
End If
'Case MapMoveMode.SelectJob, MapMoveMode.SelectAsset
' If True Then
' UpdateMode(KernPanMode.Off, KernZoomMode.Off, KernTrackMode.Off, KernEditMode.Off, Cursors.Hand)
' Exit Select
' End If
'Case MapMoveMode.AddAsset
' If True Then
' UpdateMode(KernPanMode.Off, KernZoomMode.Off, KernTrackMode.[On], KernEditMode.Off, Cursors.Arrow)
' Exit Select
' End If
'Case MapMoveMode.EditAsset
' If True Then
' UpdateMode(KernPanMode.Off, KernZoomMode.Off, KernTrackMode.Off, KernEditMode.[On], Cursors.Arrow)
' Exit Select
' End If
End Select
End Set
End Property
Private Sub UpdateMode(panMode__1 As KernPanMode, zoomMode As KernZoomMode, trackMode__2 As KernTrackMode, editMode As KernEditMode, cursor As Windows.Forms.Cursor)
PanMode = If(panMode__1 = KernPanMode.[On], MapPanMode.StandardPanning, MapPanMode.Disabled)
LeftClickDragKey = If(zoomMode = KernZoomMode.[On], Keys.None, Keys.Shift)
LeftClickDragMode = If(zoomMode = KernZoomMode.[On], MapLeftClickDragMode.[Default], MapLeftClickDragMode.Disabled)
DoubleLeftClickMode = If(zoomMode = KernZoomMode.[On], MapDoubleLeftClickMode.[Default], MapDoubleLeftClickMode.Disabled)
'If trackMode__2 = KernTrackMode.Off Then
' _gisMap.TrackOverlay.TrackMode = TrackMode.None
'End If
'If editMode = KernEditMode.Off Then
' EndEdit()
'End If
'_gisMap.Cursor = cursor
End Sub
Protected Overrides Function MouseDownCore(interactionArguments As InteractionArguments) As InteractiveResult
Dim result As InteractiveResult = Nothing
result = MyBase.MouseDownCore(interactionArguments)
MyBase.PanAndTrackZoomState.IsLeftClickDragKeyPressed = True
Return result
End Function
End Class
End Namespace
Namespace Kern.Client.Windows.Controls.MapOverlays
Public Class ModeInteractiveOverlay
Inherits ExtentInteractiveOverlay
Private _mode As MapPanMode
Private ReadOnly _gisMap As DesktopEdition.WinformsMap
Public Sub New(gisMap As WinformsMap)
_gisMap = gisMap
LeftClickDragMode = MapLeftClickDragMode.[Default]
DoubleLeftClickMode = MapDoubleLeftClickMode.[Default]
End Sub
Public Property MapMode() As MapMoveMode
Get
Return _mode
End Get
Set(value As MapMoveMode)
_mode = value
Select Case _mode
Case MapMoveMode.TrackZoomIn
If True Then
UpdateMode(KernPanMode.Off, KernZoomMode.[On], KernTrackMode.Off, KernEditMode.Off, Cursors.Cross)
Exit Select
End If
Case MapMoveMode.Pan
If True Then
UpdateMode(KernPanMode.[On], KernZoomMode.Off, KernTrackMode.Off, KernEditMode.Off, Cursors.SizeAll)
Exit Select
End If
'Case MapMoveMode.SelectJob, MapMoveMode.SelectAsset
' If True Then
' UpdateMode(KernPanMode.Off, KernZoomMode.Off, KernTrackMode.Off, KernEditMode.Off, Cursors.Hand)
' Exit Select
' End If
'Case MapMoveMode.AddAsset
' If True Then
' UpdateMode(KernPanMode.Off, KernZoomMode.Off, KernTrackMode.[On], KernEditMode.Off, Cursors.Default)
' Exit Select
' End If
'Case MapMoveMode.EditAsset
' If True Then
' UpdateMode(KernPanMode.Off, KernZoomMode.Off, KernTrackMode.Off, KernEditMode.[On], Cursors.Default)
' Exit Select
' End If
End Select
End Set
End Property
Private Sub UpdateMode(panMode__1 As KernPanMode, zoomMode As KernZoomMode, trackMode__2 As KernTrackMode, editMode As KernEditMode, cursor As System.Windows.Forms.Cursor)
PanMode = If(panMode__1 = KernPanMode.[On], MapPanMode.StandardPanning, MapPanMode.Disabled)
LeftClickDragKey = If(zoomMode = KernZoomMode.[On], Keys.None, Keys.Shift)
LeftClickDragMode = If(zoomMode = KernZoomMode.[On], MapLeftClickDragMode.[Default], MapLeftClickDragMode.Disabled)
DoubleLeftClickMode = If(zoomMode = KernZoomMode.[On], MapDoubleLeftClickMode.[Default], MapDoubleLeftClickMode.Disabled)
If trackMode__2 = KernTrackMode.Off Then
_gisMap.TrackOverlay.TrackMode = TrackMode.None
End If
If editMode = KernEditMode.Off Then
EndEdit()
End If
_gisMap.Cursor = cursor
End Sub
Private Sub EndEdit()
If _gisMap.EditOverlay.EditShapesLayer.InternalFeatures.Count > 0 Then
Dim feature As Feature = _gisMap.EditOverlay.EditShapesLayer.InternalFeatures(0)
_gisMap.EditOverlay.EditShapesLayer.InternalFeatures.Clear()
_gisMap.EditOverlay.CalculateAllControlPoints()
_gisMap.EditOverlay.EditShapesLayer.InternalFeatures.Add(feature)
_gisMap.Refresh(New Overlay() {_gisMap.EditOverlay})
End If
End Sub
End Class
Enum KernPanMode
Off
[On]
End Enum
Enum KernZoomMode
Off
[On]
End Enum
Enum KernTrackMode
Off
[On]
End Enum
Enum KernEditMode
Off
[On]
End Enum
End Namespace
#End Region
Then, in the form with the map, a private instance of it
[code]
Private _modeInterOver As TrackZoomInWithoutShiftKey.ModeInteractiveOverlay
Linking the object to the map instance:
[code]
Me._modeInterOver = New TrackZoomInWithoutShiftKey.ModeInteractiveOverlay
Me._modeInterOver.MapMode = MapMoveMode.Pan
Me.StormMap.ExtentOverlay = Me._modeInterOver
Finally, changing the modes based on what the user wants:
[code]
Me._modeInterOver.MapMode = MapMoveMode.Pan
Me._modeInterOver.MapMode = MapMoveMode.TrackZoomIn
Hope this helps