Imports System.Windows
Imports System.Windows.Input
Imports ThinkGeo.UI.WinForms

Public Class CustomMapView
  Inherits MapView
  'Private WithEvents moExtentOverlay As ExtentInteractiveOverlay
  Public Sub New()
    MyBase.New
    'FocusableProperty.OverrideMetadata(TypeOf (CustomMapView), New FrameworkPropertyMetadata(False))
    'moExtentOverlay = New ExtentInteractiveOverlay()
    'ExtentOverlay = moExtentOverlay
  End Sub

  Private Sub CustomMapView_MapMouseDown(sender As Object, e As MapMouseDownMapViewEventArgs) Handles Me.MapMouseDown
    Debug.WriteLine("MapMouseDown")
  End Sub

  'Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  '  If e.Button = Windows.Forms.MouseButtons.Middle Then
  '    '***** Call OnKeyDown and simulate a keypress with the 'P' key
  '    Dim oArgs As New KeyEventArgs(Keys.P)
  '    OnKeyDown(oArgs)
  '    '***** Call the base OnMouseDown, but fool it into thinking
  '    '***** the left mouse button is pressed, otherwize the map won't pan
  '    e = New MouseEventArgs(MouseButtons.Left, e.Clicks, e.X, e.Y, e.Delta)
  '  End If



  '  'Dim e As New KeyEventArgs(Keys.P)
  '  'OnKeyUp()
  '  'e = New MouseEventArgs(MouseButtons.Left, e.Clicks, e.X, e.Y, e.Delta)



  '  MyBase.OnMouseDown(e)

  'End Sub
  'Protected Overrides Sub OnKeyDown(e As KeyEventArgs)
  '  If e.KeyCode = Keys.P Then
  '    ExtentOverlay.PanMode = MapPanMode.StandardPanning
  '  End If
  '  MyBase.OnKeyDown(e)
  'End Sub
  'Protected Overrides Sub OnKeyUp(e As KeyEventArgs)

  '  If e.KeyCode = Keys.P Or e.KeyCode = Keys.Add Or e.KeyCode = Keys.Subtract Or e.KeyCode = Keys.Oemplus Or e.KeyCode = Keys.OemMinus Then
  '    '***** Restore the state that existing when the 'p' key was pressed
  '    ExtentOverlay.PanMode = MapPanMode.Disabled
  '  End If
  '  MyBase.OnKeyUp(e)


  'End Sub

  'Private Sub CustomMapView_MapMouseDown(sender As Object, e As Input.MouseButtonEventArgs) Handles Me.MapMouseDown
  '  If e.MiddleButton = Windows.Input.MouseButtonState.Pressed Then ' Windows.Forms.MouseButtons.Middle Then
  '    e = New Windows.Input.MouseButtonEventArgs(e.MouseDevice, e.Timestamp, Windows.Input.MouseButton.Left)
  '    '***** Call OnKeyDown and simulate a keypress with the 'P' key
  '    Dim oArgs As New KeyEventArgs(Keys.P)
  '    OnKeyDown(oArgs)
  '    '***** Call the base OnMouseDown, but fool it into thinking
  '    '***** the left mouse button is pressed, otherwize the map won't pan


  '  End If

  'End Sub

  'Private Sub moExtentOverlay_MapKeyDown(sender As Object, e As MapKeyDownInteractiveOverlayEventArgs) Handles moExtentOverlay.MapKeyDown
  '  If e.InteractionArguments.Key = Input.Key.P Then
  '    ExtentOverlay.PanMode = MapPanMode.StandardPanning
  '  End If

  'End Sub

  'Private Sub CustomMapView_MapMouseUp(sender As Object, e As Input.MouseButtonEventArgs) Handles Me.MapMouseUp
  '  If e.ChangedButton = Windows.Input.MouseButton.Middle AndAlso e.MiddleButton = Windows.Input.MouseButtonState.Released Then ' Windows.Forms.MouseButtons.Middle Then
  '    '***** We were panning with the mouse wheel depressed, so call
  '    '***** OnKeyUp with a 'P' to stop the process and return to the
  '    '***** correct mouse cursor
  '    Dim oArgs As New KeyEventArgs(Keys.P)
  '    OnKeyUp(oArgs)
  '  End If

  'End Sub

End Class
