Index: Core/Components/src/Core.Components.DotSpatial.Forms/MapControl.cs =================================================================== diff -u -r47b297452f61fb5201b05797634afed738751903 -r1d7f9c7875b22fe69fd5b1a32b2bc817dd6cf192 --- Core/Components/src/Core.Components.DotSpatial.Forms/MapControl.cs (.../MapControl.cs) (revision 47b297452f61fb5201b05797634afed738751903) +++ Core/Components/src/Core.Components.DotSpatial.Forms/MapControl.cs (.../MapControl.cs) (revision 1d7f9c7875b22fe69fd5b1a32b2bc817dd6cf192) @@ -51,6 +51,7 @@ private readonly RecursiveObserver mapDataCollectionObserver; private readonly Observer backGroundMapDataObserver; private readonly IList drawnMapDataList = new List(); + protected bool Removing; private Map map; private MapFunctionPan mapFunctionPan; @@ -90,7 +91,7 @@ mapDataCollectionObserver.Observable = data; - if (HasMapData) + if (HasMapData && !Removing) { DrawInitialMapData(); } @@ -118,13 +119,21 @@ backgroundLayerStatus = BackgroundLayerStatusFactory.CreateBackgroundLayerStatus(backgroundMapData); } - if (HasMapData) + if (HasMapData && !Removing) { DrawInitialMapData(); } } } + public virtual void RemoveAllData() + { + Removing = true; + Data = null; + BackgroundMapData = null; + Removing = false; + } + protected override void Dispose(bool disposing) { map.Dispose(); Index: Core/Components/src/Core.Components.Gis.Forms/IMapControl.cs =================================================================== diff -u -reada3ba8d4d1b06b3039918f8d0ad9f9789ab374 -r1d7f9c7875b22fe69fd5b1a32b2bc817dd6cf192 --- Core/Components/src/Core.Components.Gis.Forms/IMapControl.cs (.../IMapControl.cs) (revision eada3ba8d4d1b06b3039918f8d0ad9f9789ab374) +++ Core/Components/src/Core.Components.Gis.Forms/IMapControl.cs (.../IMapControl.cs) (revision 1d7f9c7875b22fe69fd5b1a32b2bc817dd6cf192) @@ -55,6 +55,11 @@ ImageBasedMapData BackgroundMapData { get; set; } /// + /// Removes all the data from the map without redrawing any layers. + /// + void RemoveAllData(); + + /// /// Zooms to a level so that all visible layers are in view. /// void ZoomToAllVisibleLayers(); Index: Core/Components/test/Core.Components.DotSpatial.Forms.Test/MapControlTest.cs =================================================================== diff -u -r9c660fc9a1125762276ea0fd66a8befaa33bac28 -r1d7f9c7875b22fe69fd5b1a32b2bc817dd6cf192 --- Core/Components/test/Core.Components.DotSpatial.Forms.Test/MapControlTest.cs (.../MapControlTest.cs) (revision 9c660fc9a1125762276ea0fd66a8befaa33bac28) +++ Core/Components/test/Core.Components.DotSpatial.Forms.Test/MapControlTest.cs (.../MapControlTest.cs) (revision 1d7f9c7875b22fe69fd5b1a32b2bc817dd6cf192) @@ -116,6 +116,49 @@ directoryDisposeHelper.Dispose(); } + [Test] + public void RemoveAllData_Always_SetDataAndBackgroundMapDataNull() + { + // Setup + WmtsMapData backgroundMapData = WmtsMapData.CreateDefaultPdokMapData(); + + using (new UseCustomSettingsHelper(new TestSettingsHelper())) + using (new UseCustomTileSourceFactoryConfig(backgroundMapData)) + using (var map = new MapControl()) + { + map.BackgroundMapData = backgroundMapData; + var mapDataCollection = new MapDataCollection("A"); + mapDataCollection.Add(new MapPointData("points") + { + Features = new[] + { + new MapFeature(new[] + { + new MapGeometry(new[] + { + new[] + { + new Point2D(1.1, 2.2) + } + }) + }) + } + }); + map.Data = mapDataCollection; + + // Precondition + Assert.IsNotNull(map.Data); + Assert.IsNotNull(map.BackgroundMapData); + + // Call + map.RemoveAllData(); + + // Assert + Assert.IsNull(map.Data); + Assert.IsNull(map.BackgroundMapData); + } + } + private static MapDataCollection GetTestData() { var mapDataCollection = new MapDataCollection("Test data"); Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Views/ClosingStructuresFailureMechanismView.cs =================================================================== diff -u -rd71d12fa277ebebb488ccc434cb59bed32c0755b -r1d7f9c7875b22fe69fd5b1a32b2bc817dd6cf192 --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Views/ClosingStructuresFailureMechanismView.cs (.../ClosingStructuresFailureMechanismView.cs) (revision d71d12fa277ebebb488ccc434cb59bed32c0755b) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Views/ClosingStructuresFailureMechanismView.cs (.../ClosingStructuresFailureMechanismView.cs) (revision 1d7f9c7875b22fe69fd5b1a32b2bc817dd6cf192) @@ -132,8 +132,7 @@ calculationGroupObserver.Observable = null; calculationObserver.Observable = null; - Map.Data = null; - mapControl.BackgroundData = null; + mapControl.RemoveAllData(); } else { @@ -148,7 +147,7 @@ SetMapDataFeatures(); - Map.Data = mapDataCollection; + mapControl.Data = mapDataCollection; mapControl.BackgroundData = data.Parent.BackgroundData; } } Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/FailureMechanismView.cs =================================================================== diff -u -rd71d12fa277ebebb488ccc434cb59bed32c0755b -r1d7f9c7875b22fe69fd5b1a32b2bc817dd6cf192 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/FailureMechanismView.cs (.../FailureMechanismView.cs) (revision d71d12fa277ebebb488ccc434cb59bed32c0755b) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/FailureMechanismView.cs (.../FailureMechanismView.cs) (revision 1d7f9c7875b22fe69fd5b1a32b2bc817dd6cf192) @@ -102,8 +102,7 @@ mapDataCollection.Name = defaultMapDataCollectionName; - Map.Data = null; - mapControl.BackgroundData = null; + mapControl.RemoveAllData(); } else { @@ -115,7 +114,7 @@ SetMapDataFeatures(); - Map.Data = mapDataCollection; + mapControl.Data = mapDataCollection; mapControl.BackgroundData = data.Parent.BackgroundData; } } Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/RingtoetsMapControl.cs =================================================================== diff -u -r47b297452f61fb5201b05797634afed738751903 -r1d7f9c7875b22fe69fd5b1a32b2bc817dd6cf192 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/RingtoetsMapControl.cs (.../RingtoetsMapControl.cs) (revision 47b297452f61fb5201b05797634afed738751903) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/RingtoetsMapControl.cs (.../RingtoetsMapControl.cs) (revision 1d7f9c7875b22fe69fd5b1a32b2bc817dd6cf192) @@ -64,6 +64,14 @@ } } + public override void RemoveAllData() + { + Removing = true; + BackgroundData = null; + Data = null; + Removing = false; + } + protected override void Dispose(bool disposing) { backgroundMapDataObserver.Dispose(); Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/RingtoetsMapControlTest.cs =================================================================== diff -u -r47b297452f61fb5201b05797634afed738751903 -r1d7f9c7875b22fe69fd5b1a32b2bc817dd6cf192 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/RingtoetsMapControlTest.cs (.../RingtoetsMapControlTest.cs) (revision 47b297452f61fb5201b05797634afed738751903) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/RingtoetsMapControlTest.cs (.../RingtoetsMapControlTest.cs) (revision 1d7f9c7875b22fe69fd5b1a32b2bc817dd6cf192) @@ -25,12 +25,15 @@ using BruTile.Predefined; using Core.Common.Base; using Core.Common.Base.Data; +using Core.Common.Base.Geometry; using Core.Common.Gui.TestUtil.Settings; using Core.Common.TestUtil; using Core.Components.BruTile.Configurations; using Core.Components.BruTile.TestUtil; using Core.Components.DotSpatial.Forms; using Core.Components.Gis.Data; +using Core.Components.Gis.Features; +using Core.Components.Gis.Geometries; using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; @@ -46,23 +49,6 @@ private DirectoryDisposeHelper directoryDisposeHelper; private TestSettingsHelper testSettingsHelper; - [OneTimeSetUp] - public void OneTimeSetUp() - { - testSettingsHelper = new TestSettingsHelper - { - ApplicationLocalUserSettingsDirectory = TestHelper.GetScratchPadPath(nameof(RingtoetsMapControlTest)) - }; - - directoryDisposeHelper = new DirectoryDisposeHelper(TestHelper.GetScratchPadPath(), nameof(RingtoetsMapControlTest)); - } - - [OneTimeTearDown] - public void OneTimeTearDown() - { - directoryDisposeHelper.Dispose(); - } - private static IEnumerable BackgroundTypes { get @@ -89,6 +75,50 @@ } [Test] + public void RemoveAllData_Always_SetDataAndBackgroundMapDataNull() + { + // Setup + WmtsMapData backgroundMapData = WmtsMapData.CreateDefaultPdokMapData(); + + using (new UseCustomSettingsHelper(new TestSettingsHelper())) + using (new UseCustomTileSourceFactoryConfig(backgroundMapData)) + using (var map = new RingtoetsMapControl()) + { + map.BackgroundMapData = backgroundMapData; + var mapDataCollection = new MapDataCollection("A"); + mapDataCollection.Add(new MapPointData("points") + { + Features = new[] + { + new MapFeature(new[] + { + new MapGeometry(new[] + { + new[] + { + new Point2D(1.1, 2.2) + } + }) + }) + } + }); + map.Data = mapDataCollection; + + // Precondition + Assert.IsNotNull(map.Data); + Assert.IsNotNull(map.BackgroundMapData); + + // Call + map.RemoveAllData(); + + // Assert + Assert.IsNull(map.Data); + Assert.IsNull(map.BackgroundData); + Assert.IsNull(map.BackgroundMapData); + } + } + + [Test] public void BackgroundData_NotNull_BackgroundMapDataSet() { // Setup @@ -301,5 +331,22 @@ mocks.VerifyAll(); } } + + [OneTimeSetUp] + public void OneTimeSetUp() + { + testSettingsHelper = new TestSettingsHelper + { + ApplicationLocalUserSettingsDirectory = TestHelper.GetScratchPadPath(nameof(RingtoetsMapControlTest)) + }; + + directoryDisposeHelper = new DirectoryDisposeHelper(TestHelper.GetScratchPadPath(), nameof(RingtoetsMapControlTest)); + } + + [OneTimeTearDown] + public void OneTimeTearDown() + { + directoryDisposeHelper.Dispose(); + } } } \ No newline at end of file Index: Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/Views/DuneErosionFailureMechanismView.cs =================================================================== diff -u -rd71d12fa277ebebb488ccc434cb59bed32c0755b -r1d7f9c7875b22fe69fd5b1a32b2bc817dd6cf192 --- Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/Views/DuneErosionFailureMechanismView.cs (.../DuneErosionFailureMechanismView.cs) (revision d71d12fa277ebebb488ccc434cb59bed32c0755b) +++ Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/Views/DuneErosionFailureMechanismView.cs (.../DuneErosionFailureMechanismView.cs) (revision 1d7f9c7875b22fe69fd5b1a32b2bc817dd6cf192) @@ -92,8 +92,7 @@ assessmentSectionObserver.Observable = null; duneLocationsObserver.Observable = null; - Map.Data = null; - mapControl.BackgroundData = null; + mapControl.RemoveAllData(); } else { @@ -105,7 +104,7 @@ SetMapDataFeatures(); - Map.Data = mapDataCollection; + mapControl.Data = mapDataCollection; mapControl.BackgroundData = data.Parent.BackgroundData; } } Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsFailureMechanismView.cs =================================================================== diff -u -rd71d12fa277ebebb488ccc434cb59bed32c0755b -r1d7f9c7875b22fe69fd5b1a32b2bc817dd6cf192 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsFailureMechanismView.cs (.../GrassCoverErosionInwardsFailureMechanismView.cs) (revision d71d12fa277ebebb488ccc434cb59bed32c0755b) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsFailureMechanismView.cs (.../GrassCoverErosionInwardsFailureMechanismView.cs) (revision 1d7f9c7875b22fe69fd5b1a32b2bc817dd6cf192) @@ -128,8 +128,7 @@ calculationGroupObserver.Observable = null; calculationObserver.Observable = null; - Map.Data = null; - mapControl.BackgroundData = null; + mapControl.RemoveAllData(); } else { @@ -143,7 +142,7 @@ SetMapDataFeatures(); - Map.Data = mapDataCollection; + mapControl.Data = mapDataCollection; mapControl.BackgroundData = data.Parent.BackgroundData; } } Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Views/GrassCoverErosionOutwardsFailureMechanismView.cs =================================================================== diff -u -rd71d12fa277ebebb488ccc434cb59bed32c0755b -r1d7f9c7875b22fe69fd5b1a32b2bc817dd6cf192 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Views/GrassCoverErosionOutwardsFailureMechanismView.cs (.../GrassCoverErosionOutwardsFailureMechanismView.cs) (revision d71d12fa277ebebb488ccc434cb59bed32c0755b) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Views/GrassCoverErosionOutwardsFailureMechanismView.cs (.../GrassCoverErosionOutwardsFailureMechanismView.cs) (revision 1d7f9c7875b22fe69fd5b1a32b2bc817dd6cf192) @@ -118,8 +118,7 @@ calculationGroupObserver.Observable = null; calculationObserver.Observable = null; - Map.Data = null; - mapControl.BackgroundData = null; + mapControl.RemoveAllData(); } else { @@ -133,7 +132,7 @@ SetMapDataFeatures(); - Map.Data = mapDataCollection; + mapControl.Data = mapDataCollection; mapControl.BackgroundData = data.Parent.BackgroundData; } } Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Views/HeightStructuresFailureMechanismView.cs =================================================================== diff -u -rd71d12fa277ebebb488ccc434cb59bed32c0755b -r1d7f9c7875b22fe69fd5b1a32b2bc817dd6cf192 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Views/HeightStructuresFailureMechanismView.cs (.../HeightStructuresFailureMechanismView.cs) (revision d71d12fa277ebebb488ccc434cb59bed32c0755b) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Views/HeightStructuresFailureMechanismView.cs (.../HeightStructuresFailureMechanismView.cs) (revision 1d7f9c7875b22fe69fd5b1a32b2bc817dd6cf192) @@ -132,8 +132,7 @@ calculationGroupObserver.Observable = null; calculationObserver.Observable = null; - Map.Data = null; - mapControl.BackgroundData = null; + mapControl.RemoveAllData(); } else { @@ -149,7 +148,7 @@ SetMapDataFeatures(); - Map.Data = mapDataCollection; + mapControl.Data = mapDataCollection; mapControl.BackgroundData = data.Parent.BackgroundData; } } Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/AssessmentSectionView.cs =================================================================== diff -u -r28e008eb00299c3c5a6a7c825dee3c4dba2f239a -r1d7f9c7875b22fe69fd5b1a32b2bc817dd6cf192 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/AssessmentSectionView.cs (.../AssessmentSectionView.cs) (revision 28e008eb00299c3c5a6a7c825dee3c4dba2f239a) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/AssessmentSectionView.cs (.../AssessmentSectionView.cs) (revision 1d7f9c7875b22fe69fd5b1a32b2bc817dd6cf192) @@ -84,14 +84,13 @@ if (data == null) { - Map.Data = null; - mapControl.BackgroundData = null; + mapControl.RemoveAllData(); } else { SetMapDataFeatures(); - Map.Data = mapDataCollection; + mapControl.Data = mapDataCollection; mapControl.BackgroundData = data.BackgroundData; } } Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingFailureMechanismView.cs =================================================================== diff -u -rd71d12fa277ebebb488ccc434cb59bed32c0755b -r1d7f9c7875b22fe69fd5b1a32b2bc817dd6cf192 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingFailureMechanismView.cs (.../PipingFailureMechanismView.cs) (revision d71d12fa277ebebb488ccc434cb59bed32c0755b) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingFailureMechanismView.cs (.../PipingFailureMechanismView.cs) (revision 1d7f9c7875b22fe69fd5b1a32b2bc817dd6cf192) @@ -130,8 +130,7 @@ calculationGroupObserver.Observable = null; calculationObserver.Observable = null; - Map.Data = null; - mapControl.BackgroundData = null; + mapControl.RemoveAllData(); } else { @@ -146,7 +145,7 @@ SetMapDataFeatures(); - Map.Data = mapDataCollection; + mapControl.Data = mapDataCollection; mapControl.BackgroundData = data.Parent.BackgroundData; } } Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/Views/StabilityPointStructuresFailureMechanismView.cs =================================================================== diff -u -rd71d12fa277ebebb488ccc434cb59bed32c0755b -r1d7f9c7875b22fe69fd5b1a32b2bc817dd6cf192 --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/Views/StabilityPointStructuresFailureMechanismView.cs (.../StabilityPointStructuresFailureMechanismView.cs) (revision d71d12fa277ebebb488ccc434cb59bed32c0755b) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/Views/StabilityPointStructuresFailureMechanismView.cs (.../StabilityPointStructuresFailureMechanismView.cs) (revision 1d7f9c7875b22fe69fd5b1a32b2bc817dd6cf192) @@ -132,8 +132,7 @@ calculationGroupObserver.Observable = null; calculationObserver.Observable = null; - Map.Data = null; - mapControl.BackgroundData = null; + mapControl.RemoveAllData(); } else { @@ -148,7 +147,7 @@ SetMapDataFeatures(); - Map.Data = mapDataCollection; + mapControl.Data = mapDataCollection; mapControl.BackgroundData = data.Parent.BackgroundData; } } Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Views/StabilityStoneCoverFailureMechanismView.cs =================================================================== diff -u -rd71d12fa277ebebb488ccc434cb59bed32c0755b -r1d7f9c7875b22fe69fd5b1a32b2bc817dd6cf192 --- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Views/StabilityStoneCoverFailureMechanismView.cs (.../StabilityStoneCoverFailureMechanismView.cs) (revision d71d12fa277ebebb488ccc434cb59bed32c0755b) +++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Views/StabilityStoneCoverFailureMechanismView.cs (.../StabilityStoneCoverFailureMechanismView.cs) (revision 1d7f9c7875b22fe69fd5b1a32b2bc817dd6cf192) @@ -126,8 +126,7 @@ calculationGroupObserver.Observable = null; calculationObserver.Observable = null; - Map.Data = null; - mapControl.BackgroundData = null; + mapControl.RemoveAllData(); } else { @@ -141,7 +140,7 @@ SetMapDataFeatures(); - Map.Data = mapDataCollection; + mapControl.Data = mapDataCollection; mapControl.BackgroundData = data.Parent.BackgroundData; } } Index: Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Forms/Views/WaveImpactAsphaltCoverFailureMechanismView.cs =================================================================== diff -u -rd71d12fa277ebebb488ccc434cb59bed32c0755b -r1d7f9c7875b22fe69fd5b1a32b2bc817dd6cf192 --- Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Forms/Views/WaveImpactAsphaltCoverFailureMechanismView.cs (.../WaveImpactAsphaltCoverFailureMechanismView.cs) (revision d71d12fa277ebebb488ccc434cb59bed32c0755b) +++ Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Forms/Views/WaveImpactAsphaltCoverFailureMechanismView.cs (.../WaveImpactAsphaltCoverFailureMechanismView.cs) (revision 1d7f9c7875b22fe69fd5b1a32b2bc817dd6cf192) @@ -126,8 +126,7 @@ calculationGroupObserver.Observable = null; calculationObserver.Observable = null; - Map.Data = null; - mapControl.BackgroundData = null; + mapControl.RemoveAllData(); } else { @@ -141,7 +140,7 @@ SetMapDataFeatures(); - Map.Data = mapDataCollection; + mapControl.Data = mapDataCollection; mapControl.BackgroundData = data.Parent.BackgroundData; } }