Skip to content

Commit

Permalink
GMap.NET.WindowsPresentation: added property MouseWheelZoomEnabled
Browse files Browse the repository at this point in the history
  • Loading branch information
radioman committed May 11, 2015
1 parent 5dfb8d7 commit 09d903a
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 52 deletions.
61 changes: 30 additions & 31 deletions GMap.NET.WindowsForms/GMap.NET.WindowsForms/GMapControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,23 +138,23 @@ public MouseWheelZoomType MouseWheelZoomType
}

/// <summary>
/// enable map zoom on mouse wheel
/// </summary>
[Category("GMap.NET")]
[Description("enable map zoom on mouse wheel")]
public bool MouseWheelZoomEnabled
{
get
{
return Core.MouseWheelZoomEnabled;
}
set
{
Core.MouseWheelZoomEnabled = value;
}
}
/// enable map zoom on mouse wheel
/// </summary>
[Category("GMap.NET")]
[Description("enable map zoom on mouse wheel")]
public bool MouseWheelZoomEnabled
{
get
{
return Core.MouseWheelZoomEnabled;
}
set
{
Core.MouseWheelZoomEnabled = value;
}
}

/// <summary>
/// <summary>
/// text on empty tiles
/// </summary>
public string EmptyTileText = "We are sorry, but we don't\nhave imagery at this zoom\nlevel for this region.";
Expand Down Expand Up @@ -245,28 +245,30 @@ public HelperLineOptions HelperLineOption

protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);

if (HelperLineOption == HelperLineOptions.ShowOnModifierKey)
{
renderHelperLine = (e.Modifiers == Keys.Shift || e.Modifiers == Keys.Alt);
if (renderHelperLine)
{
Invalidate();
}
}
base.OnKeyDown(e);
}
}

protected override void OnKeyUp(KeyEventArgs e)
{
base.OnKeyUp(e);

if (HelperLineOption == HelperLineOptions.ShowOnModifierKey)
{
renderHelperLine = (e.Modifiers == Keys.Shift || e.Modifiers == Keys.Alt);
if (!renderHelperLine)
{
Invalidate();
}
}
base.OnKeyUp(e);
}
}
#endif

Expand Down Expand Up @@ -1742,6 +1744,8 @@ private void ClearBackBuffer()
bool isSelected = false;
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);

if (!IsMouseOverMarker)
{
#if !PocketPC
Expand All @@ -1765,8 +1769,6 @@ protected override void OnMouseDown(MouseEventArgs e)
selectionStart = FromLocalToLatLng(e.X, e.Y);
}
}

base.OnMouseDown(e);
}

protected override void OnMouseUp(MouseEventArgs e)
Expand Down Expand Up @@ -1832,6 +1834,8 @@ protected override void OnMouseUp(MouseEventArgs e)
#if !PocketPC
protected override void OnMouseClick(MouseEventArgs e)
{
base.OnMouseClick(e);

if (!Core.IsDragging)
{
for (int i = Overlays.Count - 1; i >= 0; i--)
Expand Down Expand Up @@ -1914,9 +1918,7 @@ protected override void OnMouseClick(MouseEventArgs e)
//if(HelperLineOption == HelperLineOptions.ShowAlways)
//{
// base.Invalidate();
//}

base.OnMouseClick(e);
//}
}
#endif
#if !PocketPC
Expand Down Expand Up @@ -1975,6 +1977,8 @@ GPoint ApplyRotation(int x, int y)

protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);

if (!Core.IsDragging && !Core.mouseDown.IsEmpty)
{
#if PocketPC
Expand Down Expand Up @@ -2219,8 +2223,6 @@ protected override void OnMouseMove(MouseEventArgs e)
}
#endif
}

base.OnMouseMove(e);
}

#if !PocketPC
Expand Down Expand Up @@ -2283,9 +2285,7 @@ protected override void OnMouseWheel(MouseEventArgs e)
{
base.OnMouseWheel(e);

if (MouseWheelZoomEnabled)
{
if (mouseIn && (!IsMouseOverMarker || IgnoreMarkerOnMouseWheel) && !Core.IsDragging)
if (MouseWheelZoomEnabled && mouseIn && (!IsMouseOverMarker || IgnoreMarkerOnMouseWheel) && !Core.IsDragging)
{
if (Core.mouseLastZoom.X != e.X && Core.mouseLastZoom.Y != e.Y)
{
Expand Down Expand Up @@ -2343,7 +2343,6 @@ protected override void OnMouseWheel(MouseEventArgs e)

Core.MouseWheelZooming = false;
}
}
}
#endif
#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,23 @@ public MouseWheelZoomType MouseWheelZoomType
Core.MouseWheelZoomType = value;
}
}

/// <summary>
/// enable map zoom on mouse wheel
/// </summary>
[Category("GMap.NET")]
[Description("enable map zoom on mouse wheel")]
public bool MouseWheelZoomEnabled
{
get
{
return Core.MouseWheelZoomEnabled;
}
set
{
Core.MouseWheelZoomEnabled = value;
}
}

/// <summary>
/// map dragg button
Expand Down Expand Up @@ -1499,28 +1516,30 @@ public HelperLineOptions HelperLineOption

protected override void OnKeyUp(KeyEventArgs e)
{
base.OnKeyUp(e);

if(HelperLineOption == HelperLineOptions.ShowOnModifierKey)
{
renderHelperLine = !(e.IsUp && (e.Key == Key.LeftShift || e.SystemKey == Key.LeftAlt));
if(!renderHelperLine)
{
InvalidateVisual();
}
}
base.OnKeyUp(e);
}
}

protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);

if(HelperLineOption == HelperLineOptions.ShowOnModifierKey)
{
renderHelperLine = e.IsDown && (e.Key == Key.LeftShift || e.SystemKey == Key.LeftAlt);
if(renderHelperLine)
{
InvalidateVisual();
}
}
base.OnKeyDown(e);
}
}

/// <summary>
Expand All @@ -1537,7 +1556,7 @@ protected override void OnMouseWheel(MouseWheelEventArgs e)
{
base.OnMouseWheel(e);

if((IsMouseDirectlyOver || IgnoreMarkerOnMouseWheel) && !Core.IsDragging)
if(MouseWheelZoomEnabled && (IsMouseDirectlyOver || IgnoreMarkerOnMouseWheel) && !Core.IsDragging)
{
System.Windows.Point p = e.GetPosition(this);

Expand Down Expand Up @@ -1601,14 +1620,14 @@ protected override void OnMouseWheel(MouseWheelEventArgs e)

Core.MouseWheelZooming = false;
}

base.OnMouseWheel(e);
}

bool isSelected = false;

protected override void OnMouseDown(MouseButtonEventArgs e)
{
base.OnMouseDown(e);

if(CanDragMap && e.ChangedButton == DragButton)
{
Point p = e.GetPosition(this);
Expand All @@ -1635,14 +1654,15 @@ protected override void OnMouseDown(MouseButtonEventArgs e)
selectionEnd = PointLatLng.Empty;
selectionStart = FromLocalToLatLng((int)p.X, (int)p.Y);
}
}
base.OnMouseDown(e);
}
}

int onMouseUpTimestamp = 0;

protected override void OnMouseUp(MouseButtonEventArgs e)
{
base.OnMouseUp(e);

if(isSelected)
{
isSelected = false;
Expand Down Expand Up @@ -1694,14 +1714,14 @@ protected override void OnMouseUp(MouseButtonEventArgs e)
InvalidateVisual();
}
}

base.OnMouseUp(e);
}

Cursor cursorBefore = Cursors.Arrow;

protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);

// wpf generates to many events if mouse is over some visual
// and OnMouseUp is fired, wtf, anyway...
// http://greatmaps.codeplex.com/workitem/16013
Expand Down Expand Up @@ -1795,9 +1815,7 @@ protected override void OnMouseMove(MouseEventArgs e)
{
InvalidateVisual(true);
}
}

base.OnMouseMove(e);
}
}

/// <summary>
Expand All @@ -1807,6 +1825,8 @@ protected override void OnMouseMove(MouseEventArgs e)

protected override void OnStylusDown(StylusDownEventArgs e)
{
base.OnStylusDown(e);

if(TouchEnabled && CanDragMap && !e.InAir)
{
Point p = e.GetPosition(this);
Expand All @@ -1822,13 +1842,13 @@ protected override void OnStylusDown(StylusDownEventArgs e)
Core.mouseDown.Y = (int)p.Y;

InvalidateVisual();
}

base.OnStylusDown(e);
}
}

protected override void OnStylusUp(StylusEventArgs e)
{
base.OnStylusUp(e);

if(TouchEnabled)
{
if(isSelected)
Expand Down Expand Up @@ -1862,11 +1882,12 @@ protected override void OnStylusUp(StylusEventArgs e)
InvalidateVisual();
}
}
base.OnStylusUp(e);
}

protected override void OnStylusMove(StylusEventArgs e)
{
base.OnStylusMove(e);

if(TouchEnabled)
{
// wpf generates to many events if mouse is over some visual
Expand Down Expand Up @@ -1939,9 +1960,7 @@ protected override void OnStylusMove(StylusEventArgs e)
}
InvalidateVisual();
}
}

base.OnStylusMove(e);
}
}

#endregion
Expand Down

0 comments on commit 09d903a

Please sign in to comment.