diff --git a/GMap.NET.WindowsForms/GMap.NET.WindowsForms/GMapControl.cs b/GMap.NET.WindowsForms/GMap.NET.WindowsForms/GMapControl.cs index 2b5467d5..07968b8d 100644 --- a/GMap.NET.WindowsForms/GMap.NET.WindowsForms/GMapControl.cs +++ b/GMap.NET.WindowsForms/GMap.NET.WindowsForms/GMapControl.cs @@ -138,23 +138,23 @@ public MouseWheelZoomType MouseWheelZoomType } /// - /// enable map zoom on mouse wheel - /// - [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 + /// + [Category("GMap.NET")] + [Description("enable map zoom on mouse wheel")] + public bool MouseWheelZoomEnabled + { + get + { + return Core.MouseWheelZoomEnabled; + } + set + { + Core.MouseWheelZoomEnabled = value; + } + } - /// + /// /// text on empty tiles /// public string EmptyTileText = "We are sorry, but we don't\nhave imagery at this zoom\nlevel for this region."; @@ -245,6 +245,8 @@ 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); @@ -252,12 +254,13 @@ protected override void OnKeyDown(KeyEventArgs e) { 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); @@ -265,8 +268,7 @@ protected override void OnKeyUp(KeyEventArgs e) { Invalidate(); } - } - base.OnKeyUp(e); + } } #endif @@ -1742,6 +1744,8 @@ private void ClearBackBuffer() bool isSelected = false; protected override void OnMouseDown(MouseEventArgs e) { + base.OnMouseDown(e); + if (!IsMouseOverMarker) { #if !PocketPC @@ -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) @@ -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--) @@ -1914,9 +1918,7 @@ protected override void OnMouseClick(MouseEventArgs e) //if(HelperLineOption == HelperLineOptions.ShowAlways) //{ // base.Invalidate(); - //} - - base.OnMouseClick(e); + //} } #endif #if !PocketPC @@ -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 @@ -2219,8 +2223,6 @@ protected override void OnMouseMove(MouseEventArgs e) } #endif } - - base.OnMouseMove(e); } #if !PocketPC @@ -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) { @@ -2343,7 +2343,6 @@ protected override void OnMouseWheel(MouseEventArgs e) Core.MouseWheelZooming = false; } - } } #endif #endregion diff --git a/GMap.NET.WindowsPresentation/GMap.NET.WindowsPresentation/GMapControl.cs b/GMap.NET.WindowsPresentation/GMap.NET.WindowsPresentation/GMapControl.cs index bad0cb49..3d97d6e2 100644 --- a/GMap.NET.WindowsPresentation/GMap.NET.WindowsPresentation/GMapControl.cs +++ b/GMap.NET.WindowsPresentation/GMap.NET.WindowsPresentation/GMapControl.cs @@ -354,6 +354,23 @@ public MouseWheelZoomType MouseWheelZoomType Core.MouseWheelZoomType = value; } } + + /// + /// enable map zoom on mouse wheel + /// + [Category("GMap.NET")] + [Description("enable map zoom on mouse wheel")] + public bool MouseWheelZoomEnabled + { + get + { + return Core.MouseWheelZoomEnabled; + } + set + { + Core.MouseWheelZoomEnabled = value; + } + } /// /// map dragg button @@ -1499,6 +1516,8 @@ 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)); @@ -1506,12 +1525,13 @@ protected override void OnKeyUp(KeyEventArgs e) { 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); @@ -1519,8 +1539,7 @@ protected override void OnKeyDown(KeyEventArgs e) { InvalidateVisual(); } - } - base.OnKeyDown(e); + } } /// @@ -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); @@ -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); @@ -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; @@ -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 @@ -1795,9 +1815,7 @@ protected override void OnMouseMove(MouseEventArgs e) { InvalidateVisual(true); } - } - - base.OnMouseMove(e); + } } /// @@ -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); @@ -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) @@ -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 @@ -1939,9 +1960,7 @@ protected override void OnStylusMove(StylusEventArgs e) } InvalidateVisual(); } - } - - base.OnStylusMove(e); + } } #endregion