Index: Core/Plugins/src/Core.Plugins.Map/Legend/MapLegendView.cs
===================================================================
diff -u -r6e008d39203d261ead7023eeab03f641915eab14 -r8a777581cae3ba0631a7a9306e63a457786a976b
--- Core/Plugins/src/Core.Plugins.Map/Legend/MapLegendView.cs (.../MapLegendView.cs) (revision 6e008d39203d261ead7023eeab03f641915eab14)
+++ Core/Plugins/src/Core.Plugins.Map/Legend/MapLegendView.cs (.../MapLegendView.cs) (revision 8a777581cae3ba0631a7a9306e63a457786a976b)
@@ -177,14 +177,29 @@
private StrictContextMenuItem CreateZoomToExtentsItem(FeatureBasedMapData nodeData)
{
+ var hasFeaters = nodeData.Features.Any();
+ var enabled = nodeData.IsVisible && hasFeaters;
+ string toolTip = string.Empty;
+
+ if (enabled)
+ {
+ toolTip = MapResources.MapLegendView_CreateZoomToExtentsItem_ZoomToAll_Tooltip;
+ }
+ else if (!nodeData.IsVisible)
+ {
+ toolTip = MapResources.MapLegendView_CreateZoomToExtentsItem_ZoomToAllDisabled_Tooltip;
+ }
+ else if (!hasFeaters)
+ {
+ toolTip = MapResources.MapLegendView_CreateZoomToExtentsItem_NoFeatures_ZoomToAllDisabled_Tooltip;
+ }
+
return new StrictContextMenuItem($"&{MapResources.Ribbon_ZoomToAll}",
- nodeData.IsVisible ?
- MapResources.MapLegendView_CreateZoomToExtentsItem_ZoomToAll_Tooltip :
- MapResources.MapLegendView_CreateZoomToExtentsItem_ZoomToAllDisabled_Tooltip,
+ toolTip,
MapResources.ZoomToAllIcon,
(sender, args) => { MapControl?.ZoomToAllVisibleLayers(nodeData); })
{
- Enabled = nodeData.IsVisible
+ Enabled = enabled
};
}
Index: Core/Plugins/src/Core.Plugins.Map/Properties/Resources.Designer.cs
===================================================================
diff -u -r6e008d39203d261ead7023eeab03f641915eab14 -r8a777581cae3ba0631a7a9306e63a457786a976b
--- Core/Plugins/src/Core.Plugins.Map/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 6e008d39203d261ead7023eeab03f641915eab14)
+++ Core/Plugins/src/Core.Plugins.Map/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 8a777581cae3ba0631a7a9306e63a457786a976b)
@@ -293,6 +293,15 @@
}
///
+ /// Looks up a localized string similar to Om het zoomniveau aan te passen moet de kaartlaag elementen bevatten..
+ ///
+ public static string MapLegendView_CreateZoomToExtentsItem_NoFeatures_ZoomToAllDisabled_Tooltip {
+ get {
+ return ResourceManager.GetString("MapLegendView_CreateZoomToExtentsItem_NoFeatures_ZoomToAllDisabled_Tooltip", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Zet het zoomniveau van de kaart dusdanig dat alle zichtbare elementen van deze kaartlaag precies in het beeld past..
///
public static string MapLegendView_CreateZoomToExtentsItem_ZoomToAll_Tooltip {
@@ -302,7 +311,7 @@
}
///
- /// Looks up a localized string similar to Om het zoomniveau aan te passen moet de laag zichtbaar zijn..
+ /// Looks up a localized string similar to Om het zoomniveau aan te passen moet de kaartlaag zichtbaar zijn..
///
public static string MapLegendView_CreateZoomToExtentsItem_ZoomToAllDisabled_Tooltip {
get {
Index: Core/Plugins/src/Core.Plugins.Map/Properties/Resources.resx
===================================================================
diff -u -r6e008d39203d261ead7023eeab03f641915eab14 -r8a777581cae3ba0631a7a9306e63a457786a976b
--- Core/Plugins/src/Core.Plugins.Map/Properties/Resources.resx (.../Resources.resx) (revision 6e008d39203d261ead7023eeab03f641915eab14)
+++ Core/Plugins/src/Core.Plugins.Map/Properties/Resources.resx (.../Resources.resx) (revision 8a777581cae3ba0631a7a9306e63a457786a976b)
@@ -254,12 +254,15 @@
Zet het zoomniveau van de kaart dusdanig dat alle zichtbare elementen van deze kaartlaag precies in het beeld past.
- Om het zoomniveau aan te passen moet de laag zichtbaar zijn.
+ Om het zoomniveau aan te passen moet de kaartlaag zichtbaar zijn.
Om het zoomniveau aan te passen moet er minstens één kaartlaag in deze kaartlagenmap zichtbaar zijn.
Zet het zoomniveau van de kaart dusdanig dat alle zichtbare elementen van deze kaartlagenmap precies in het beeld passen.
+
+ Om het zoomniveau aan te passen moet de kaartlaag elementen bevatten.
+
\ No newline at end of file
Index: Core/Plugins/test/Core.Plugins.Map.Test/Legend/MapLineDataTreeNodeInfoTest.cs
===================================================================
diff -u -rdf867fb9bd84169c6a7f095f8483ccf5778d66c5 -r8a777581cae3ba0631a7a9306e63a457786a976b
--- Core/Plugins/test/Core.Plugins.Map.Test/Legend/MapLineDataTreeNodeInfoTest.cs (.../MapLineDataTreeNodeInfoTest.cs) (revision df867fb9bd84169c6a7f095f8483ccf5778d66c5)
+++ Core/Plugins/test/Core.Plugins.Map.Test/Legend/MapLineDataTreeNodeInfoTest.cs (.../MapLineDataTreeNodeInfoTest.cs) (revision 8a777581cae3ba0631a7a9306e63a457786a976b)
@@ -21,14 +21,17 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using Core.Common.Base;
using Core.Common.Controls.TreeView;
using Core.Common.Gui.ContextMenu;
using Core.Common.Gui.TestUtil.ContextMenu;
using Core.Common.TestUtil;
using Core.Common.Utils.Reflection;
using Core.Components.Gis.Data;
+using Core.Components.Gis.Features;
using Core.Components.Gis.Forms;
+using Core.Components.Gis.Geometries;
using Core.Plugins.Map.Legend;
using Core.Plugins.Map.Properties;
using NUnit.Framework;
@@ -158,7 +161,11 @@
var mapData = new MapLineData("A")
{
- IsVisible = true
+ IsVisible = true,
+ Features = new[]
+ {
+ new MapFeature(Enumerable.Empty())
+ }
};
// Call
@@ -192,21 +199,51 @@
// Assert
TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuZoomToAllIndex,
"&Zoom naar alles",
- "Om het zoomniveau aan te passen moet de laag zichtbaar zijn.",
+ "Om het zoomniveau aan te passen moet de kaartlaag zichtbaar zijn.",
Resources.ZoomToAllIcon,
false);
}
}
[Test]
- public void ContextMenuStrip_MapLegendViewHasMapControlAndClickZoomToAll_DoZoomToAllVisibleLayersForMapData()
+ public void ContextMenuStrip_MapDataWithoutFeatures_ZoomToAllItemDisabled()
{
// Setup
+ var builder = new CustomItemsOnlyContextMenuBuilder();
+ contextMenuBuilderProvider.Expect(p => p.Get(null, null)).IgnoreArguments().Return(builder);
+
+ mocks.ReplayAll();
+
var mapData = new MapLineData("A")
{
IsVisible = true
};
+ // Call
+ using (var contextMenu = info.ContextMenuStrip(mapData, null, null))
+ {
+ // Assert
+ TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuZoomToAllIndex,
+ "&Zoom naar alles",
+ "Om het zoomniveau aan te passen moet de kaartlaag elementen bevatten.",
+ Resources.ZoomToAllIcon,
+ false);
+ }
+ }
+
+ [Test]
+ public void ContextMenuStrip_MapLegendViewHasMapControlAndClickZoomToAll_DoZoomToAllVisibleLayersForMapData()
+ {
+ // Setup
+ var mapData = new MapLineData("A")
+ {
+ IsVisible = true,
+ Features = new[]
+ {
+ new MapFeature(Enumerable.Empty())
+ }
+ };
+
var builder = new CustomItemsOnlyContextMenuBuilder();
contextMenuBuilderProvider.Stub(p => p.Get(null, null)).IgnoreArguments().Return(builder);
Index: Core/Plugins/test/Core.Plugins.Map.Test/Legend/MapPointDataTreeNodeInfoTest.cs
===================================================================
diff -u -rdf867fb9bd84169c6a7f095f8483ccf5778d66c5 -r8a777581cae3ba0631a7a9306e63a457786a976b
--- Core/Plugins/test/Core.Plugins.Map.Test/Legend/MapPointDataTreeNodeInfoTest.cs (.../MapPointDataTreeNodeInfoTest.cs) (revision df867fb9bd84169c6a7f095f8483ccf5778d66c5)
+++ Core/Plugins/test/Core.Plugins.Map.Test/Legend/MapPointDataTreeNodeInfoTest.cs (.../MapPointDataTreeNodeInfoTest.cs) (revision 8a777581cae3ba0631a7a9306e63a457786a976b)
@@ -21,15 +21,17 @@
using System;
using System.Collections.Generic;
-using System.Windows.Forms;
+using System.Linq;
using Core.Common.Base;
using Core.Common.Controls.TreeView;
using Core.Common.Gui.ContextMenu;
using Core.Common.Gui.TestUtil.ContextMenu;
using Core.Common.TestUtil;
using Core.Common.Utils.Reflection;
using Core.Components.Gis.Data;
+using Core.Components.Gis.Features;
using Core.Components.Gis.Forms;
+using Core.Components.Gis.Geometries;
using Core.Plugins.Map.Legend;
using Core.Plugins.Map.Properties;
using NUnit.Framework;
@@ -159,7 +161,11 @@
var mapData = new MapPointData("A")
{
- IsVisible = true
+ IsVisible = true,
+ Features = new []
+ {
+ new MapFeature(Enumerable.Empty())
+ }
};
// Call
@@ -193,21 +199,51 @@
// Assert
TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuZoomToAllIndex,
"&Zoom naar alles",
- "Om het zoomniveau aan te passen moet de laag zichtbaar zijn.",
+ "Om het zoomniveau aan te passen moet de kaartlaag zichtbaar zijn.",
Resources.ZoomToAllIcon,
false);
}
}
[Test]
- public void ContextMenuStrip_MapLegendViewHasMapControlAndClickZoomToAll_DoZoomToAllVisibleLayersForMapData()
+ public void ContextMenuStrip_MapDataWithoutFeatures_ZoomToAllItemDisabled()
{
// Setup
+ var builder = new CustomItemsOnlyContextMenuBuilder();
+ contextMenuBuilderProvider.Expect(p => p.Get(null, null)).IgnoreArguments().Return(builder);
+
+ mocks.ReplayAll();
+
var mapData = new MapPointData("A")
{
IsVisible = true
};
+ // Call
+ using (var contextMenu = info.ContextMenuStrip(mapData, null, null))
+ {
+ // Assert
+ TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuZoomToAllIndex,
+ "&Zoom naar alles",
+ "Om het zoomniveau aan te passen moet de kaartlaag elementen bevatten.",
+ Resources.ZoomToAllIcon,
+ false);
+ }
+ }
+
+ [Test]
+ public void ContextMenuStrip_MapLegendViewHasMapControlAndClickZoomToAll_DoZoomToAllVisibleLayersForMapData()
+ {
+ // Setup
+ var mapData = new MapPointData("A")
+ {
+ IsVisible = true,
+ Features = new[]
+ {
+ new MapFeature(Enumerable.Empty()),
+ }
+ };
+
var builder = new CustomItemsOnlyContextMenuBuilder();
contextMenuBuilderProvider.Stub(p => p.Get(null, null)).IgnoreArguments().Return(builder);
Index: Core/Plugins/test/Core.Plugins.Map.Test/Legend/MapPolygonDataTreeNodeInfoTest.cs
===================================================================
diff -u -rdf867fb9bd84169c6a7f095f8483ccf5778d66c5 -r8a777581cae3ba0631a7a9306e63a457786a976b
--- Core/Plugins/test/Core.Plugins.Map.Test/Legend/MapPolygonDataTreeNodeInfoTest.cs (.../MapPolygonDataTreeNodeInfoTest.cs) (revision df867fb9bd84169c6a7f095f8483ccf5778d66c5)
+++ Core/Plugins/test/Core.Plugins.Map.Test/Legend/MapPolygonDataTreeNodeInfoTest.cs (.../MapPolygonDataTreeNodeInfoTest.cs) (revision 8a777581cae3ba0631a7a9306e63a457786a976b)
@@ -21,6 +21,7 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using System.Windows.Forms;
using Core.Common.Base;
using Core.Common.Controls.TreeView;
@@ -29,7 +30,9 @@
using Core.Common.TestUtil;
using Core.Common.Utils.Reflection;
using Core.Components.Gis.Data;
+using Core.Components.Gis.Features;
using Core.Components.Gis.Forms;
+using Core.Components.Gis.Geometries;
using Core.Plugins.Map.Legend;
using Core.Plugins.Map.Properties;
using NUnit.Framework;
@@ -159,7 +162,11 @@
var mapData = new MapPolygonData("A")
{
- IsVisible = true
+ IsVisible = true,
+ Features = new[]
+ {
+ new MapFeature(Enumerable.Empty())
+ }
};
// Call
@@ -193,21 +200,51 @@
// Assert
TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuZoomToAllIndex,
"&Zoom naar alles",
- "Om het zoomniveau aan te passen moet de laag zichtbaar zijn.",
+ "Om het zoomniveau aan te passen moet de kaartlaag zichtbaar zijn.",
Resources.ZoomToAllIcon,
false);
}
}
[Test]
- public void ContextMenuStrip_MapLegendViewHasMapControlAndClickZoomToAll_DoZoomToAllVisibleLayersForMapData()
+ public void ContextMenuStrip_MapDataWithoutFeatures_ZoomToAllItemDisabled()
{
// Setup
+ var builder = new CustomItemsOnlyContextMenuBuilder();
+ contextMenuBuilderProvider.Expect(p => p.Get(null, null)).IgnoreArguments().Return(builder);
+
+ mocks.ReplayAll();
+
var mapData = new MapPolygonData("A")
{
IsVisible = true
};
+ // Call
+ using (var contextMenu = info.ContextMenuStrip(mapData, null, null))
+ {
+ // Assert
+ TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuZoomToAllIndex,
+ "&Zoom naar alles",
+ "Om het zoomniveau aan te passen moet de kaartlaag elementen bevatten.",
+ Resources.ZoomToAllIcon,
+ false);
+ }
+ }
+
+ [Test]
+ public void ContextMenuStrip_MapLegendViewHasMapControlAndClickZoomToAll_DoZoomToAllVisibleLayersForMapData()
+ {
+ // Setup
+ var mapData = new MapPolygonData("A")
+ {
+ IsVisible = true,
+ Features = new[]
+ {
+ new MapFeature(Enumerable.Empty())
+ }
+ };
+
var builder = new CustomItemsOnlyContextMenuBuilder();
contextMenuBuilderProvider.Stub(p => p.Get(null, null)).IgnoreArguments().Return(builder);