Index: Core/Components/src/Core.Components.DotSpatial.Forms/MapControl.cs =================================================================== diff -u -r6899d3c82fbf191da5c363519bae7e5cfaab8b5b -r301c8db68d1fc607101c81bff8c9b14c5fbc2f50 --- Core/Components/src/Core.Components.DotSpatial.Forms/MapControl.cs (.../MapControl.cs) (revision 6899d3c82fbf191da5c363519bae7e5cfaab8b5b) +++ Core/Components/src/Core.Components.DotSpatial.Forms/MapControl.cs (.../MapControl.cs) (revision 301c8db68d1fc607101c81bff8c9b14c5fbc2f50) @@ -86,7 +86,7 @@ IsPanningEnabled = true; - map.ActivateMapFunction(mapFunctionPan); + map.FunctionMode = FunctionMode.Pan; } public void ToggleRectangleZooming() @@ -147,6 +147,8 @@ { IsPanningEnabled = false; IsRectangleZoomingEnabled = false; + + map.FunctionMode = FunctionMode.None; } private void DrawFeatureSets() @@ -167,7 +169,6 @@ { ProjectionModeDefine = ActionMode.Never, Dock = DockStyle.Fill, - FunctionMode = FunctionMode.Pan, ZoomOutFartherThanMaxExtent = true }; @@ -212,9 +213,6 @@ case MouseButtons.Left: map.Cursor = Cursors.SizeNWSE; break; - case MouseButtons.Middle: - map.Cursor = Cursors.Hand; - break; default: map.Cursor = defaultCursor; break; Index: Core/Components/test/Core.Components.DotSpatial.Forms.Test/MapControlTest.cs =================================================================== diff -u -r40b67559fd19ba271c3366042ffeeace8bc3435d -r301c8db68d1fc607101c81bff8c9b14c5fbc2f50 --- Core/Components/test/Core.Components.DotSpatial.Forms.Test/MapControlTest.cs (.../MapControlTest.cs) (revision 40b67559fd19ba271c3366042ffeeace8bc3435d) +++ Core/Components/test/Core.Components.DotSpatial.Forms.Test/MapControlTest.cs (.../MapControlTest.cs) (revision 301c8db68d1fc607101c81bff8c9b14c5fbc2f50) @@ -322,7 +322,7 @@ [Test] [RequiresSTA] - public void SelectionZoom_MiddleMouseDown_HandCursorSet() + public void SelectionZoom_MiddleMouseDown_DefaultCursorSet() { using (var form = new Form()) { @@ -340,7 +340,7 @@ EventHelper.RaiseEvent(mapFunctionSelectionZoom, "MouseDown", new GeoMouseArgs(new MouseEventArgs(MouseButtons.Middle, 1, 2, 3, 4), map)); // Assert - Assert.AreEqual(Cursors.Hand, map.Cursor); + Assert.AreEqual(Cursors.Default, map.Cursor); } } @@ -568,6 +568,31 @@ } } + [Test] + [RequiresSTA] + public void ToggleRectangleZooming_Always_CorrectlySetsMapFunctions() + { + using (var form = new Form()) + { + // Setup + var mapControl = new MapControl(); + form.Controls.Add(mapControl); + form.Show(); + + var map = (Map) new ControlTester("Map").TheObject; + var mapFunctionPan = map.MapFunctions.OfType().First(); + var mapFunctionSelectionZoom = map.MapFunctions.OfType().First(); + + // Call + mapControl.ToggleRectangleZooming(); + + // Assert + Assert.IsTrue(mapFunctionSelectionZoom.Enabled); + Assert.IsFalse(mapFunctionPan.Enabled); + Assert.AreEqual(FunctionMode.None, map.FunctionMode); + } + } + [TestCase(true)] [TestCase(false)] public void TogglePanning_Always_ChangesState(bool isPanning) @@ -595,6 +620,33 @@ } } + [Test] + [RequiresSTA] + public void TogglePanning_Always_CorrectlySetsMapFunctions() + { + using (var form = new Form()) + { + // Setup + var mapControl = new MapControl(); + form.Controls.Add(mapControl); + form.Show(); + + mapControl.ToggleRectangleZooming(); + + var map = (Map)new ControlTester("Map").TheObject; + var mapFunctionPan = map.MapFunctions.OfType().First(); + var mapFunctionSelectionZoom = map.MapFunctions.OfType().First(); + + // Call + mapControl.TogglePanning(); + + // Assert + Assert.IsTrue(mapFunctionPan.Enabled); + Assert.IsFalse(mapFunctionSelectionZoom.Enabled); + Assert.AreEqual(FunctionMode.Pan, map.FunctionMode); + } + } + [TestCase(true)] [TestCase(false)] public void ToggleMouseCoordinatesVisibility_Always_ChangesState(bool isShowingCoordinates)