Index: Core/Components/src/Core.Components.DotSpatial.Forms/MapControl.cs =================================================================== diff -u -r301c8db68d1fc607101c81bff8c9b14c5fbc2f50 -r5eea42bf02f794333cacc1aabd88b3e79438d3c4 --- Core/Components/src/Core.Components.DotSpatial.Forms/MapControl.cs (.../MapControl.cs) (revision 301c8db68d1fc607101c81bff8c9b14c5fbc2f50) +++ Core/Components/src/Core.Components.DotSpatial.Forms/MapControl.cs (.../MapControl.cs) (revision 5eea42bf02f794333cacc1aabd88b3e79438d3c4) @@ -214,7 +214,9 @@ map.Cursor = Cursors.SizeNWSE; break; default: - map.Cursor = defaultCursor; + map.Cursor = map.IsBusy + ? Cursors.SizeNWSE + : defaultCursor; break; } } Index: Core/Components/test/Core.Components.DotSpatial.Forms.Test/MapControlTest.cs =================================================================== diff -u -r301c8db68d1fc607101c81bff8c9b14c5fbc2f50 -r5eea42bf02f794333cacc1aabd88b3e79438d3c4 --- Core/Components/test/Core.Components.DotSpatial.Forms.Test/MapControlTest.cs (.../MapControlTest.cs) (revision 301c8db68d1fc607101c81bff8c9b14c5fbc2f50) +++ Core/Components/test/Core.Components.DotSpatial.Forms.Test/MapControlTest.cs (.../MapControlTest.cs) (revision 5eea42bf02f794333cacc1aabd88b3e79438d3c4) @@ -322,7 +322,9 @@ [Test] [RequiresSTA] - public void SelectionZoom_MiddleMouseDown_DefaultCursorSet() + [TestCase(MouseButtons.Right)] + [TestCase(MouseButtons.Middle)] + public void SelectionZoom_OtherThanMouseLeftDownAndMapNotBusy_DefaultCursorSet(MouseButtons mouseButton) { using (var form = new Form()) { @@ -337,16 +339,17 @@ map.Cursor = Cursors.WaitCursor; // Call - EventHelper.RaiseEvent(mapFunctionSelectionZoom, "MouseDown", new GeoMouseArgs(new MouseEventArgs(MouseButtons.Middle, 1, 2, 3, 4), map)); + EventHelper.RaiseEvent(mapFunctionSelectionZoom, "MouseDown", new GeoMouseArgs(new MouseEventArgs(mouseButton, 1, 2, 3, 4), map)); // Assert Assert.AreEqual(Cursors.Default, map.Cursor); } } - [Test] [RequiresSTA] - public void SelectionZoom_RightMouseDown_DefaultCursorSet() + [TestCase(MouseButtons.Right)] + [TestCase(MouseButtons.Middle)] + public void SelectionZoom_OtherThanMouseLeftDownAndMapBusy_SizeNWSECursorSet(MouseButtons mouseButton) { using (var form = new Form()) { @@ -358,13 +361,14 @@ 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(MouseButtons.Right, 1, 2, 3, 4), map)); + EventHelper.RaiseEvent(mapFunctionSelectionZoom, "MouseDown", new GeoMouseArgs(new MouseEventArgs(mouseButton, 1, 2, 3, 4), map)); // Assert - Assert.AreEqual(Cursors.Default, map.Cursor); + Assert.AreEqual(Cursors.SizeNWSE, map.Cursor); } } @@ -541,36 +545,34 @@ } } - [TestCase(true)] - [TestCase(false)] - public void ToggleRectangleZooming_Always_ChangesState(bool isRectangleZooming) + [Test] + [RequiresSTA] + public void ToggleRectangleZooming_Always_CorrectlySetsMapFunctions() { - // Setup - using (var map = new MapControl()) + using (var form = new Form()) { - if (isRectangleZooming) - { - map.ToggleRectangleZooming(); - } + // Setup + var mapControl = new MapControl(); + form.Controls.Add(mapControl); + form.Show(); - // Precondition - Assert.AreEqual(isRectangleZooming, map.IsRectangleZoomingEnabled, - String.Format("Precondition failed: IsRectangleZoomingEnabled is {0}", map.IsRectangleZoomingEnabled)); - Assert.AreEqual(!isRectangleZooming, map.IsPanningEnabled, - String.Format("Precondition failed: IsPanningEnabled is {0}", map.IsPanningEnabled)); + var map = (Map) new ControlTester("Map").TheObject; + var mapFunctionPan = map.MapFunctions.OfType().First(); + var mapFunctionSelectionZoom = map.MapFunctions.OfType().First(); // Call - map.ToggleRectangleZooming(); + mapControl.ToggleRectangleZooming(); // Assert - Assert.IsTrue(map.IsRectangleZoomingEnabled); - Assert.IsFalse(map.IsPanningEnabled); + Assert.IsTrue(mapFunctionSelectionZoom.Enabled); + Assert.IsFalse(mapFunctionPan.Enabled); + Assert.AreEqual(FunctionMode.None, map.FunctionMode); } } [Test] [RequiresSTA] - public void ToggleRectangleZooming_Always_CorrectlySetsMapFunctions() + public void TogglePanning_Always_CorrectlySetsMapFunctions() { using (var form = new Form()) { @@ -579,71 +581,73 @@ 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.ToggleRectangleZooming(); + mapControl.TogglePanning(); // Assert - Assert.IsTrue(mapFunctionSelectionZoom.Enabled); - Assert.IsFalse(mapFunctionPan.Enabled); - Assert.AreEqual(FunctionMode.None, map.FunctionMode); + Assert.IsTrue(mapFunctionPan.Enabled); + Assert.IsFalse(mapFunctionSelectionZoom.Enabled); + Assert.AreEqual(FunctionMode.Pan, map.FunctionMode); } } [TestCase(true)] [TestCase(false)] - public void TogglePanning_Always_ChangesState(bool isPanning) + public void ToggleRectangleZooming_Always_ChangesState(bool isRectangleZooming) { // Setup using (var map = new MapControl()) { - if (!isPanning) + if (isRectangleZooming) { map.ToggleRectangleZooming(); } // Precondition - Assert.AreEqual(isPanning, map.IsPanningEnabled, - String.Format("Precondition failed: IsPanningEnabled is {0}", map.IsPanningEnabled)); - Assert.AreEqual(!isPanning, map.IsRectangleZoomingEnabled, + Assert.AreEqual(isRectangleZooming, map.IsRectangleZoomingEnabled, String.Format("Precondition failed: IsRectangleZoomingEnabled is {0}", map.IsRectangleZoomingEnabled)); + Assert.AreEqual(!isRectangleZooming, map.IsPanningEnabled, + String.Format("Precondition failed: IsPanningEnabled is {0}", map.IsPanningEnabled)); // Call - map.TogglePanning(); + map.ToggleRectangleZooming(); // Assert - Assert.IsTrue(map.IsPanningEnabled); - Assert.IsFalse(map.IsRectangleZoomingEnabled); + Assert.IsTrue(map.IsRectangleZoomingEnabled); + Assert.IsFalse(map.IsPanningEnabled); } } - [Test] - [RequiresSTA] - public void TogglePanning_Always_CorrectlySetsMapFunctions() + [TestCase(true)] + [TestCase(false)] + public void TogglePanning_Always_ChangesState(bool isPanning) { - using (var form = new Form()) + // Setup + using (var map = new MapControl()) { - // Setup - var mapControl = new MapControl(); - form.Controls.Add(mapControl); - form.Show(); + if (!isPanning) + { + map.ToggleRectangleZooming(); + } - mapControl.ToggleRectangleZooming(); + // Precondition + Assert.AreEqual(isPanning, map.IsPanningEnabled, + String.Format("Precondition failed: IsPanningEnabled is {0}", map.IsPanningEnabled)); + Assert.AreEqual(!isPanning, map.IsRectangleZoomingEnabled, + String.Format("Precondition failed: IsRectangleZoomingEnabled is {0}", map.IsRectangleZoomingEnabled)); - var map = (Map)new ControlTester("Map").TheObject; - var mapFunctionPan = map.MapFunctions.OfType().First(); - var mapFunctionSelectionZoom = map.MapFunctions.OfType().First(); - // Call - mapControl.TogglePanning(); + map.TogglePanning(); // Assert - Assert.IsTrue(mapFunctionPan.Enabled); - Assert.IsFalse(mapFunctionSelectionZoom.Enabled); - Assert.AreEqual(FunctionMode.Pan, map.FunctionMode); + Assert.IsTrue(map.IsPanningEnabled); + Assert.IsFalse(map.IsRectangleZoomingEnabled); } }