Index: Core/Components/src/Core.Components.DotSpatial.Forms/MapControl.cs
===================================================================
diff -u -rf067677f60f03c2f9c270e4d45d363e0c8d9c1eb -r26af58f85567c97bc68cc744a25334c2bd0b0fca
--- Core/Components/src/Core.Components.DotSpatial.Forms/MapControl.cs (.../MapControl.cs) (revision f067677f60f03c2f9c270e4d45d363e0c8d9c1eb)
+++ Core/Components/src/Core.Components.DotSpatial.Forms/MapControl.cs (.../MapControl.cs) (revision 26af58f85567c97bc68cc744a25334c2bd0b0fca)
@@ -43,7 +43,7 @@
///
/// This class describes a map view with configured projection and function mode.
///
- public sealed class MapControl : Control, IMapControl
+ public class MapControl : Control, IMapControl
{
private readonly ILog log = LogManager.GetLogger(typeof(MapControl));
private readonly Cursor defaultCursor = Cursors.Default;
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj
===================================================================
diff -u -rb519fc798c63691f04bb8008b562a94ed9232d51 -r26af58f85567c97bc68cc744a25334c2bd0b0fca
--- Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision b519fc798c63691f04bb8008b562a94ed9232d51)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision 26af58f85567c97bc68cc744a25334c2bd0b0fca)
@@ -146,6 +146,9 @@
+
+ Component
+
Fisheye: Tag 26af58f85567c97bc68cc744a25334c2bd0b0fca refers to a dead (removed) revision in file `Ringtoets/Common/src/Ringtoets.Common.Forms/Views/PipingFailureMechanismResultView.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/RingtoetsMapControl.cs
===================================================================
diff -u
--- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/RingtoetsMapControl.cs (revision 0)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/RingtoetsMapControl.cs (revision 26af58f85567c97bc68cc744a25334c2bd0b0fca)
@@ -0,0 +1,90 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using Core.Common.Base;
+using Core.Components.DotSpatial.Forms;
+using Core.Components.Gis.Data;
+using Ringtoets.Common.Data.AssessmentSection;
+
+namespace Ringtoets.Common.Forms.Views
+{
+ ///
+ /// This class describes a map view with background.
+ ///
+ public class RingtoetsMapControl : MapControl
+ {
+ private readonly Observer backgroundMapDataObserver;
+
+ private BackgroundData backgroundData;
+
+ ///
+ /// Creates a new instance of .
+ ///
+ public RingtoetsMapControl()
+ {
+ backgroundMapDataObserver = new Observer(UpdateBackgroundMapData);
+ }
+
+ ///
+ /// Gets ans sets the .
+ ///
+ public BackgroundData BackgroundData
+ {
+ get
+ {
+ return backgroundData;
+ }
+ set
+ {
+ backgroundData = value;
+ backgroundMapDataObserver.Observable = backgroundData;
+
+ BackgroundMapData = backgroundData == null
+ ? null
+ : RingtoetsBackgroundMapDataFactory.CreateImageBasedBackgroundMapData(backgroundData);
+ }
+ }
+
+ protected override void Dispose(bool disposing)
+ {
+ backgroundMapDataObserver.Dispose();
+
+ base.Dispose(disposing);
+ }
+
+ private void UpdateBackgroundMapData()
+ {
+ if (backgroundData.BackgroundMapDataType == BackgroundMapDataType.Wmts && BackgroundMapData is WmtsMapData)
+ {
+ RingtoetsBackgroundMapDataFactory.UpdateBackgroundMapData((WmtsMapData) BackgroundMapData, backgroundData);
+ BackgroundMapData.NotifyObservers();
+ }
+ else if(backgroundData.BackgroundMapDataType == BackgroundMapDataType.WellKnown && BackgroundMapData is WellKnownTileSourceMapData)
+ {
+// RingtoetsBackgroundMapDataFactory.UpdateBackgroundMapData(BackgroundMapData, backgroundData);
+ }
+ else
+ {
+ BackgroundMapData = RingtoetsBackgroundMapDataFactory.CreateImageBasedBackgroundMapData(backgroundData);
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/BackgroundDataTestDataGeneratorTest.cs
===================================================================
diff -u -rf9db544ad22552799aaaedc2a154abd8765f7099 -r26af58f85567c97bc68cc744a25334c2bd0b0fca
--- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/BackgroundDataTestDataGeneratorTest.cs (.../BackgroundDataTestDataGeneratorTest.cs) (revision f9db544ad22552799aaaedc2a154abd8765f7099)
+++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/BackgroundDataTestDataGeneratorTest.cs (.../BackgroundDataTestDataGeneratorTest.cs) (revision 26af58f85567c97bc68cc744a25334c2bd0b0fca)
@@ -75,11 +75,12 @@
// Assert
Assert.AreEqual(BackgroundMapDataType.WellKnown, backgroundData.BackgroundMapDataType);
- Assert.IsNull(backgroundData.Name);
- Assert.IsFalse(backgroundData.IsConfigured);
+ Assert.AreEqual("BingAerial", backgroundData.Name);
+ Assert.IsTrue(backgroundData.IsConfigured);
Assert.IsTrue(backgroundData.IsVisible);
Assert.AreEqual(0, backgroundData.Transparency.Value);
- CollectionAssert.IsEmpty(backgroundData.Parameters);
+ Assert.AreEqual(1, backgroundData.Parameters.Count);
+ Assert.AreEqual("1", backgroundData.Parameters[BackgroundDataIdentifiers.WellKnownTileSource]);
}
}
}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/BackgroundDataTestDataGenerator.cs
===================================================================
diff -u -rf9db544ad22552799aaaedc2a154abd8765f7099 -r26af58f85567c97bc68cc744a25334c2bd0b0fca
--- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/BackgroundDataTestDataGenerator.cs (.../BackgroundDataTestDataGenerator.cs) (revision f9db544ad22552799aaaedc2a154abd8765f7099)
+++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/BackgroundDataTestDataGenerator.cs (.../BackgroundDataTestDataGenerator.cs) (revision 26af58f85567c97bc68cc744a25334c2bd0b0fca)
@@ -61,9 +61,18 @@
/// The created .
public static BackgroundData GetWellKnownBackgroundMapData()
{
+ const WellKnownTileSource wellKnownTileSource = WellKnownTileSource.BingAerial;
+
return new BackgroundData
{
- BackgroundMapDataType = BackgroundMapDataType.WellKnown
+ BackgroundMapDataType = BackgroundMapDataType.WellKnown,
+ IsConfigured = true,
+ IsVisible = true,
+ Name = wellKnownTileSource.ToString(),
+ Parameters =
+ {
+ { BackgroundDataIdentifiers.WellKnownTileSource, ((int) wellKnownTileSource).ToString() }
+ }
};
}
}
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj
===================================================================
diff -u -rb519fc798c63691f04bb8008b562a94ed9232d51 -r26af58f85567c97bc68cc744a25334c2bd0b0fca
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision b519fc798c63691f04bb8008b562a94ed9232d51)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision 26af58f85567c97bc68cc744a25334c2bd0b0fca)
@@ -119,6 +119,7 @@
+
@@ -146,10 +147,18 @@
{f49bd8b2-332a-4c91-a196-8cce0a2c7d98}
Core.Common.Utils
+
+ {26214BD0-DAFB-4CFC-8EB2-80C5D53C859E}
+ Core.Common.Gui.TestUtil
+
{d749ee4c-ce50-4c17-bf01-9a953028c126}
Core.Common.TestUtil
+
+ {e02482c7-f12b-42f0-bb2b-c7ec17503a72}
+ Core.Components.BruTile
+
{5A91174A-FB95-4C9D-9CA5-81C0B8D4361A}
Core.Components.DotSpatial.Forms
@@ -166,6 +175,10 @@
{318BA582-88C9-4816-A54A-A7E431461DE3}
Core.Components.Gis
+
+ {1081336C-D919-4249-AB33-9AF15F4D19EC}
+ Core.Components.BruTile.TestUtil
+
{9b6f3987-eaf7-4733-80c1-3dcab44d87ae}
Core.Components.DotSpatial.TestUtil
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/RingtoetsMapControlTest.cs
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/RingtoetsMapControlTest.cs (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/RingtoetsMapControlTest.cs (revision 26af58f85567c97bc68cc744a25334c2bd0b0fca)
@@ -0,0 +1,193 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Collections.Generic;
+using Core.Common.Base;
+using Core.Common.Base.Data;
+using Core.Common.Gui.TestUtil.Settings;
+using Core.Components.BruTile.TestUtil;
+using Core.Components.DotSpatial.Forms;
+using Core.Components.Gis.Data;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.Common.Forms.Views;
+
+namespace Ringtoets.Common.Forms.Test.Views
+{
+ [TestFixture]
+ public class RingtoetsMapControlTest
+ {
+ [Test]
+ public void Constructor_ExpectedValues()
+ {
+ // Call
+ var control = new RingtoetsMapControl();
+
+ // Assert
+ Assert.IsInstanceOf(control);
+ Assert.IsNull(control.BackgroundData);
+ }
+
+ [Test]
+ public void BackgroundData_NotNull_BackgroundMapDataSet()
+ {
+ // Setup
+ var mapData = WmtsMapData.CreateDefaultPdokMapData();
+ BackgroundData backgroundData = BackgroundDataTestDataGenerator.GetWmtsBackgroundMapData(mapData);
+
+ var control = new RingtoetsMapControl();
+
+ using (new UseCustomSettingsHelper(new TestSettingsHelper()))
+ using (new UseCustomTileSourceFactoryConfig(mapData))
+ {
+ // Call
+ control.BackgroundData = backgroundData;
+
+ // Assert
+ Assert.AreSame(backgroundData, control.BackgroundData);
+ Assert.IsNotNull(control.BackgroundMapData);
+ Assert.IsTrue(control.BackgroundMapData is WmtsMapData);
+ }
+ }
+
+ [Test]
+ public void GivenBackgroundData_WhenSetToNull_ThenBackgroundMapDataSetToNull()
+ {
+ // Given
+ var mapData = WmtsMapData.CreateDefaultPdokMapData();
+ BackgroundData backgroundData = BackgroundDataTestDataGenerator.GetWmtsBackgroundMapData(mapData);
+
+ using (new UseCustomSettingsHelper(new TestSettingsHelper()))
+ using (new UseCustomTileSourceFactoryConfig(mapData))
+ {
+ var control = new RingtoetsMapControl
+ {
+ BackgroundData = backgroundData
+ };
+
+ // Precondition
+ Assert.IsNotNull(control.BackgroundMapData);
+
+ // When
+ control.BackgroundData = null;
+
+ // Then
+ Assert.IsNull(control.BackgroundMapData);
+ }
+ }
+
+ [Test]
+ [TestCaseSource(nameof(BackgroundTypes))]
+ public void GivenBackgroundData_WhenBackgroundDataChangedToOtherTypeAndNotified_ThenNewInstanceSetOnBackgroundMapData(
+ BackgroundData originalBackgroundData,
+ BackgroundData newBackgroundData)
+ {
+ // Given
+ var mocks = new MockRepository();
+ var observer = mocks.StrictMock();
+ mocks.ReplayAll();
+
+ using (new UseCustomSettingsHelper(new TestSettingsHelper()))
+ using (new UseCustomTileSourceFactoryConfig(WmtsMapData.CreateDefaultPdokMapData()))
+ {
+ var control = new RingtoetsMapControl
+ {
+ BackgroundData = originalBackgroundData
+ };
+
+ control.BackgroundMapData.Attach(observer);
+
+ ImageBasedMapData oldMapData = control.BackgroundMapData;
+
+ // When
+ originalBackgroundData.Name = newBackgroundData.Name;
+ originalBackgroundData.IsVisible = newBackgroundData.IsVisible;
+ originalBackgroundData.IsConfigured = newBackgroundData.IsConfigured;
+ originalBackgroundData.Transparency = newBackgroundData.Transparency;
+ originalBackgroundData.BackgroundMapDataType = newBackgroundData.BackgroundMapDataType;
+ originalBackgroundData.Parameters.Clear();
+
+ foreach (KeyValuePair parameter in newBackgroundData.Parameters)
+ {
+ originalBackgroundData.Parameters.Add(parameter);
+ }
+ originalBackgroundData.NotifyObservers();
+
+ // Then
+ Assert.IsNotNull(control.BackgroundMapData);
+ Assert.AreNotEqual(oldMapData, control.BackgroundMapData);
+ Assert.AreNotEqual(oldMapData.GetType(), control.BackgroundMapData.GetType());
+ mocks.VerifyAll(); // Expect no observers notified
+ }
+ }
+
+ [Test]
+ public void GivenBackgroundData_WhenBackgroundDataChangedButSameTypeAndNotified_ThenBackgroundMapDataUpdatedAndNotified()
+ {
+ // Given
+ var mocks = new MockRepository();
+ var observer = mocks.StrictMock();
+ observer.Expect(o => o.UpdateObserver());
+ mocks.ReplayAll();
+
+ WmtsMapData mapData = WmtsMapData.CreateDefaultPdokMapData();
+ BackgroundData backgroundData = BackgroundDataTestDataGenerator.GetWmtsBackgroundMapData(mapData);
+
+ using (new UseCustomSettingsHelper(new TestSettingsHelper()))
+ using (new UseCustomTileSourceFactoryConfig(mapData))
+ {
+ var control = new RingtoetsMapControl
+ {
+ BackgroundData = backgroundData
+ };
+
+ control.BackgroundMapData.Attach(observer);
+
+ ImageBasedMapData oldBackgroundMapData = control.BackgroundMapData;
+
+ // When
+ backgroundData.Transparency = (RoundedDouble) 0.3;
+ backgroundData.NotifyObservers();
+
+ // Then
+ Assert.AreSame(oldBackgroundMapData, control.BackgroundMapData);
+ mocks.VerifyAll();
+ }
+ }
+
+ private static IEnumerable BackgroundTypes
+ {
+ get
+ {
+ yield return new TestCaseData(BackgroundDataTestDataGenerator.GetWellKnownBackgroundMapData(),
+ BackgroundDataTestDataGenerator.GetWmtsBackgroundMapData(WmtsMapData.CreateDefaultPdokMapData()))
+ .SetName("WellKnownToWmts");
+
+ yield return new TestCaseData(BackgroundDataTestDataGenerator.GetWmtsBackgroundMapData(WmtsMapData.CreateDefaultPdokMapData()),
+ BackgroundDataTestDataGenerator.GetWellKnownBackgroundMapData())
+ .SetName("WmtsToWellKnown");
+ }
+ }
+ }
+}
\ No newline at end of file