Index: Core/Components/src/Core.Components.DotSpatial/Converter/FeatureBasedMapDataConverter.cs
===================================================================
diff -u -r9e9976818f1b446948c3bf815cafe2e023f98ac1 -r0dfebb879c18e065254d43b6d1f4b991651d9155
--- Core/Components/src/Core.Components.DotSpatial/Converter/FeatureBasedMapDataConverter.cs (.../FeatureBasedMapDataConverter.cs) (revision 9e9976818f1b446948c3bf815cafe2e023f98ac1)
+++ Core/Components/src/Core.Components.DotSpatial/Converter/FeatureBasedMapDataConverter.cs (.../FeatureBasedMapDataConverter.cs) (revision 0dfebb879c18e065254d43b6d1f4b991651d9155)
@@ -102,6 +102,7 @@
layer.IsVisible = data.IsVisible;
layer.Name = data.Name;
layer.ShowLabels = data.ShowLabels;
+ layer.SelectionEnabled = data.IsSelectable;
((IMapFeatureLayer) layer).LabelLayer = GetLabelLayer(GetAttributeMapping(data), layer.DataSet, data.SelectedMetaDataAttribute);
if (data.Theme != null)
Index: Core/Components/src/Core.Components.Gis/Data/FeatureBasedMapData.cs
===================================================================
diff -u -r9e9976818f1b446948c3bf815cafe2e023f98ac1 -r0dfebb879c18e065254d43b6d1f4b991651d9155
--- Core/Components/src/Core.Components.Gis/Data/FeatureBasedMapData.cs (.../FeatureBasedMapData.cs) (revision 9e9976818f1b446948c3bf815cafe2e023f98ac1)
+++ Core/Components/src/Core.Components.Gis/Data/FeatureBasedMapData.cs (.../FeatureBasedMapData.cs) (revision 0dfebb879c18e065254d43b6d1f4b991651d9155)
@@ -45,6 +45,7 @@
{
features = new MapFeature[0];
ShowLabels = false;
+ IsSelectable = false;
}
///
@@ -71,6 +72,11 @@
/// Gets or sets a value indicating whether the labels of the should be shown.
///
public bool ShowLabels { get; set; }
+
+ ///
+ /// Gets or sets a value indicating whether the layer features can be selected.
+ ///
+ public bool IsSelectable { get; set; }
///
/// Gets or sets the selected attribute of the meta data to show as label.
Index: Core/Components/test/Core.Components.DotSpatial.Test/Converter/FeatureBasedMapDataConverterTest.cs
===================================================================
diff -u -r9e9976818f1b446948c3bf815cafe2e023f98ac1 -r0dfebb879c18e065254d43b6d1f4b991651d9155
--- Core/Components/test/Core.Components.DotSpatial.Test/Converter/FeatureBasedMapDataConverterTest.cs (.../FeatureBasedMapDataConverterTest.cs) (revision 9e9976818f1b446948c3bf815cafe2e023f98ac1)
+++ Core/Components/test/Core.Components.DotSpatial.Test/Converter/FeatureBasedMapDataConverterTest.cs (.../FeatureBasedMapDataConverterTest.cs) (revision 0dfebb879c18e065254d43b6d1f4b991651d9155)
@@ -53,11 +53,11 @@
var mapLayer = new TestFeatureLayer();
// Call
- TestDelegate test = () => testConverter.ConvertLayerFeatures(null, mapLayer);
+ void Call() => testConverter.ConvertLayerFeatures(null, mapLayer);
// Assert
const string expectedMessage = "Null data cannot be converted into feature layer data.";
- TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage);
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, expectedMessage);
}
[Test]
@@ -68,11 +68,11 @@
var mapData = new TestFeatureBasedMapData("test data");
// Call
- TestDelegate test = () => testConverter.ConvertLayerFeatures(mapData, null);
+ void Call() => testConverter.ConvertLayerFeatures(mapData, null);
// Assert
const string expectedMessage = "Null data cannot be used as conversion target.";
- TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage);
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, expectedMessage);
}
[Test]
@@ -83,11 +83,11 @@
var mapLayer = new TestFeatureLayer();
// Call
- TestDelegate test = () => testConverter.ConvertLayerProperties(null, mapLayer);
+ void Call() => testConverter.ConvertLayerProperties(null, mapLayer);
// Assert
const string expectedMessage = "Null data cannot be converted into feature layer data.";
- TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage);
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, expectedMessage);
}
[Test]
@@ -98,11 +98,11 @@
var mapData = new TestFeatureBasedMapData("test data");
// Call
- TestDelegate test = () => testConverter.ConvertLayerProperties(mapData, null);
+ void Call() => testConverter.ConvertLayerProperties(mapData, null);
// Assert
const string expectedMessage = "Null data cannot be used as conversion target.";
- TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage);
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, expectedMessage);
}
[Test]
@@ -502,6 +502,26 @@
[Test]
[TestCase(true)]
[TestCase(false)]
+ public void ConvertLayerProperties_MapData_IsSelectableSetToLayer(bool isSelectable)
+ {
+ // Setup
+ var testConverter = new TestFeatureBasedMapDataConverter();
+ var mapData = new TestFeatureBasedMapData("test data")
+ {
+ IsSelectable = isSelectable
+ };
+ var mapLayer = new TestFeatureLayer();
+
+ // Call
+ testConverter.ConvertLayerProperties(mapData, mapLayer);
+
+ // Assert
+ Assert.AreEqual(isSelectable, mapLayer.SelectionEnabled);
+ }
+
+ [Test]
+ [TestCase(true)]
+ [TestCase(false)]
public void ConvertLayerProperties_MapData_IsVisibleSetToLayer(bool isVisible)
{
// Setup
Index: Core/Components/test/Core.Components.Gis.Test/Data/FeatureBasedMapDataTest.cs
===================================================================
diff -u -r9e9976818f1b446948c3bf815cafe2e023f98ac1 -r0dfebb879c18e065254d43b6d1f4b991651d9155
--- Core/Components/test/Core.Components.Gis.Test/Data/FeatureBasedMapDataTest.cs (.../FeatureBasedMapDataTest.cs) (revision 9e9976818f1b446948c3bf815cafe2e023f98ac1)
+++ Core/Components/test/Core.Components.Gis.Test/Data/FeatureBasedMapDataTest.cs (.../FeatureBasedMapDataTest.cs) (revision 0dfebb879c18e065254d43b6d1f4b991651d9155)
@@ -48,6 +48,7 @@
Assert.AreEqual(name, data.Name);
CollectionAssert.IsEmpty(data.Features);
Assert.IsFalse(data.ShowLabels);
+ Assert.IsFalse(data.IsSelectable);
Assert.IsNull(data.SelectedMetaDataAttribute);
CollectionAssert.IsEmpty(data.MetaData);
}
@@ -59,11 +60,11 @@
public void Constructor_InvalidName_ThrowsArgumentException(string invalidName)
{
// Call
- TestDelegate test = () => new TestFeatureBasedMapData(invalidName);
+ void Call() => new TestFeatureBasedMapData(invalidName);
// Assert
const string expectedMessage = "A name must be set to the map data.";
- TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage);
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, expectedMessage);
}
[Test]
@@ -91,11 +92,11 @@
var data = new TestFeatureBasedMapData("test data");
// Call
- TestDelegate test = () => data.Features = null;
+ void Call() => data.Features = null;
// Assert
const string expectedMessage = "The array of features cannot be null or contain null.";
- TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage);
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, expectedMessage);
}
[Test]
@@ -105,14 +106,14 @@
var data = new TestFeatureBasedMapData("test data");
// Call
- TestDelegate test = () => data.Features = new MapFeature[]
+ void Call() => data.Features = new MapFeature[]
{
null
};
// Assert
const string expectedMessage = "The array of features cannot be null or contain null.";
- TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage);
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, expectedMessage);
}
[Test]
@@ -153,10 +154,10 @@
public void TypedConstructor_ThemeNull_ThrowsArgumentNullException()
{
// Call
- TestDelegate call = () => new TypedTestFeatureBasedMapData("name", null);
+ void Call() => new TypedTestFeatureBasedMapData("name", null);
// Assert
- var exception = Assert.Throws(call);
+ var exception = Assert.Throws(Call);
Assert.AreEqual("theme", exception.ParamName);
}