Index: Core/Components/src/Core.Components.DotSpatial.Forms/MapControl.cs =================================================================== diff -u -r5eea42bf02f794333cacc1aabd88b3e79438d3c4 -r229b43aff2a2f984ae50b83ce39fa7928d02bdcd --- Core/Components/src/Core.Components.DotSpatial.Forms/MapControl.cs (.../MapControl.cs) (revision 5eea42bf02f794333cacc1aabd88b3e79438d3c4) +++ Core/Components/src/Core.Components.DotSpatial.Forms/MapControl.cs (.../MapControl.cs) (revision 229b43aff2a2f984ae50b83ce39fa7928d02bdcd) @@ -215,8 +215,8 @@ break; default: map.Cursor = map.IsBusy - ? Cursors.SizeNWSE - : defaultCursor; + ? Cursors.SizeNWSE + : defaultCursor; break; } } Index: Core/Components/src/Core.Components.DotSpatial/MapFunctions/MapFunctionSelectionZoom.cs =================================================================== diff -u -r6899d3c82fbf191da5c363519bae7e5cfaab8b5b -r229b43aff2a2f984ae50b83ce39fa7928d02bdcd --- Core/Components/src/Core.Components.DotSpatial/MapFunctions/MapFunctionSelectionZoom.cs (.../MapFunctionSelectionZoom.cs) (revision 6899d3c82fbf191da5c363519bae7e5cfaab8b5b) +++ Core/Components/src/Core.Components.DotSpatial/MapFunctions/MapFunctionSelectionZoom.cs (.../MapFunctionSelectionZoom.cs) (revision 229b43aff2a2f984ae50b83ce39fa7928d02bdcd) @@ -41,13 +41,14 @@ /// . /// /// - public class MapFunctionSelectionZoom : MapFunction + public class MapFunctionSelectionZoom : MapFunctionZoom { private readonly Pen selectionPen; private Point currentPoint; private Coordinate geoStartPoint; private bool isDragging; private Point startPoint = Point.Empty; + private bool mouseButtonMiddleDown; /// /// Creates a new instance of . @@ -59,7 +60,7 @@ { DashStyle = DashStyle.Dash }; - YieldStyle = YieldStyles.LeftButton | YieldStyles.RightButton; + YieldStyle = YieldStyles.LeftButton | YieldStyles.RightButton | YieldStyles.Scroll; } protected override void OnDraw(MapDrawArgs e) @@ -77,6 +78,10 @@ protected override void OnMouseDown(GeoMouseArgs e) { + if (e.Button == MouseButtons.Middle) + { + mouseButtonMiddleDown = true; + } if (e.Button == MouseButtons.Left) { startPoint = e.Location; @@ -99,11 +104,19 @@ currentPoint = e.Location; Map.Invalidate(new Rectangle(x, y, mx - x, my - y)); } + if (mouseButtonMiddleDown) + { + return; + } base.OnMouseMove(e); } protected override void OnMouseUp(GeoMouseArgs e) { + if (e.Button == MouseButtons.Middle) + { + mouseButtonMiddleDown = false; + } if (!(e.Map.IsZoomedToMaxExtent && e.Button == MouseButtons.Right)) { e.Map.IsZoomedToMaxExtent = false; Index: Core/Components/test/Core.Components.DotSpatial.Forms.Test/MapControlTest.cs =================================================================== diff -u -r5eea42bf02f794333cacc1aabd88b3e79438d3c4 -r229b43aff2a2f984ae50b83ce39fa7928d02bdcd --- Core/Components/test/Core.Components.DotSpatial.Forms.Test/MapControlTest.cs (.../MapControlTest.cs) (revision 5eea42bf02f794333cacc1aabd88b3e79438d3c4) +++ Core/Components/test/Core.Components.DotSpatial.Forms.Test/MapControlTest.cs (.../MapControlTest.cs) (revision 229b43aff2a2f984ae50b83ce39fa7928d02bdcd) @@ -346,32 +346,6 @@ } } - [RequiresSTA] - [TestCase(MouseButtons.Right)] - [TestCase(MouseButtons.Middle)] - public void SelectionZoom_OtherThanMouseLeftDownAndMapBusy_SizeNWSECursorSet(MouseButtons mouseButton) - { - using (var form = new Form()) - { - // Setup - var mapControl = new MapControl(); - form.Controls.Add(mapControl); - form.Show(); - - var map = (Map) new ControlTester("Map").TheObject; - var mapFunctionSelectionZoom = map.MapFunctions.OfType().First(); - - map.IsBusy = true; - map.Cursor = Cursors.WaitCursor; - - // Call - EventHelper.RaiseEvent(mapFunctionSelectionZoom, "MouseDown", new GeoMouseArgs(new MouseEventArgs(mouseButton, 1, 2, 3, 4), map)); - - // Assert - Assert.AreEqual(Cursors.SizeNWSE, map.Cursor); - } - } - [Test] [RequiresSTA] public void SelectionZoom_Activated_DefaultCursorSet() @@ -597,6 +571,32 @@ } } + [RequiresSTA] + [TestCase(MouseButtons.Right)] + [TestCase(MouseButtons.Middle)] + public void SelectionZoom_OtherThanMouseLeftDownAndMapBusy_SizeNWSECursorSet(MouseButtons mouseButton) + { + using (var form = new Form()) + { + // Setup + var mapControl = new MapControl(); + form.Controls.Add(mapControl); + form.Show(); + + var map = (Map) new ControlTester("Map").TheObject; + var mapFunctionSelectionZoom = map.MapFunctions.OfType().First(); + + map.IsBusy = true; + map.Cursor = Cursors.WaitCursor; + + // Call + EventHelper.RaiseEvent(mapFunctionSelectionZoom, "MouseDown", new GeoMouseArgs(new MouseEventArgs(mouseButton, 1, 2, 3, 4), map)); + + // Assert + Assert.AreEqual(Cursors.SizeNWSE, map.Cursor); + } + } + [TestCase(true)] [TestCase(false)] public void ToggleRectangleZooming_Always_ChangesState(bool isRectangleZooming) Index: Core/Components/test/Core.Components.DotSpatial.Test/MapFunctions/MapFunctionSelectionZoomTest.cs =================================================================== diff -u -re29d1599a1157443fcef2f993009ed21886704e7 -r229b43aff2a2f984ae50b83ce39fa7928d02bdcd --- Core/Components/test/Core.Components.DotSpatial.Test/MapFunctions/MapFunctionSelectionZoomTest.cs (.../MapFunctionSelectionZoomTest.cs) (revision e29d1599a1157443fcef2f993009ed21886704e7) +++ Core/Components/test/Core.Components.DotSpatial.Test/MapFunctions/MapFunctionSelectionZoomTest.cs (.../MapFunctionSelectionZoomTest.cs) (revision 229b43aff2a2f984ae50b83ce39fa7928d02bdcd) @@ -49,14 +49,16 @@ public void Constructor_Always_ExpectedValues() { // Setup - var mapMock = mockingRepository.StrictMock(); + var mapMock = mockingRepository.Stub(); mockingRepository.ReplayAll(); // Call MapFunctionSelectionZoom mapFunction = new MapFunctionSelectionZoom(mapMock); // Assert - Assert.IsInstanceOf(mapFunction); + Assert.IsInstanceOf(mapFunction); + var expectedYieldStyle = YieldStyles.LeftButton | YieldStyles.RightButton | YieldStyles.Scroll; + Assert.AreEqual(expectedYieldStyle, mapFunction.YieldStyle); mockingRepository.VerifyAll(); } @@ -90,7 +92,7 @@ int mx = Math.Max(Math.Max(startPointX, 0), endPointX); int my = Math.Max(Math.Max(startPointY, 0), endPointY); var expectedRectangle = new Rectangle(x, y, mx - x, my - y); - + var mapMock = mockingRepository.Stub(); mapMock.Stub(e => e.PixelToProj(Arg.Is.Anything)).Return(null); mapMock.Expect(e => e.Invalidate(Arg.Matches(m => m.Equals(expectedRectangle)))); @@ -241,5 +243,25 @@ // Assert mockingRepository.VerifyAll(); } + + [Test] + public void OnMouseMove_DraggingWithMiddleMouseButtonDown_DoesNotPan() + { + // Setup + var mapMock = mockingRepository.Stub(); + mapMock.MapFrame = mockingRepository.Stub(); + mockingRepository.ReplayAll(); + + var mapFunction = new MapFunctionSelectionZoom(mapMock); + mapFunction.DoMouseDown(new GeoMouseArgs(new MouseEventArgs(MouseButtons.Middle, 1, 10, 10, 0), mapMock)); + + // Call + var view = mapMock.MapFrame.View; + mapFunction.DoMouseMove(new GeoMouseArgs(new MouseEventArgs(MouseButtons.Middle, 1, 20, 20, 0), mapMock)); + + // Assert + Assert.AreEqual(view, mapMock.MapFrame.View); + mockingRepository.VerifyAll(); + } } } \ No newline at end of file