Index: Core/Plugins/src/Core.Plugins.Map/Legend/MapLegendView.cs =================================================================== diff -u -r8f5a8b418455b1aa49479fd271953cad51515999 -rf95ac0d2a1a35e333dc84aee0465ac41dac83f21 --- Core/Plugins/src/Core.Plugins.Map/Legend/MapLegendView.cs (.../MapLegendView.cs) (revision 8f5a8b418455b1aa49479fd271953cad51515999) +++ Core/Plugins/src/Core.Plugins.Map/Legend/MapLegendView.cs (.../MapLegendView.cs) (revision f95ac0d2a1a35e333dc84aee0465ac41dac83f21) @@ -175,74 +175,47 @@ }); } - private StrictContextMenuItem CreateZoomToExtentsItem(FeatureBasedMapData nodeData) + private StrictContextMenuItem CreateZoomToExtentsItem(MapData nodeData, string toolTip, bool isEnabled) { - var hasFeatures = nodeData.Features.Any(); - var enabled = nodeData.IsVisible && hasFeatures; - string toolTip = string.Empty; - - if (enabled) - { - toolTip = MapResources.MapLegendView_CreateZoomToExtentsItem_ZoomToAll_Tooltip; - } - else if (!nodeData.IsVisible) - { - toolTip = MapResources.MapLegendView_CreateZoomToExtentsItem_ZoomToAllDisabled_Tooltip; - } - else if (!hasFeatures) - { - toolTip = MapResources.MapLegendView_CreateZoomToExtentsItem_NoFeatures_ZoomToAllDisabled_Tooltip; - } - return new StrictContextMenuItem($"&{MapResources.Ribbon_ZoomToAll}", - toolTip, + toolTip, MapResources.ZoomToAllIcon, (sender, args) => { MapControl?.ZoomToAllVisibleLayers(nodeData); }) { - Enabled = enabled + Enabled = isEnabled }; } - private StrictContextMenuItem CreateZoomToExtentsItem(MapDataCollection nodeData) + #region MapData + + private static void MapDataOnNodeChecked(FeatureBasedMapData featureBasedMapData, object parentData) { - FeatureBasedMapData[] featureBasedMapDatas = nodeData.GetFeatureBasedMapDataRecursively().ToArray(); - var isVisible = featureBasedMapDatas.Any(md => md.IsVisible); - var hasFeatures = featureBasedMapDatas.Any(mapData => mapData.Features.Any()); + featureBasedMapData.IsVisible = !featureBasedMapData.IsVisible; + featureBasedMapData.NotifyObservers(); + } - var enabled = isVisible && hasFeatures; - + private StrictContextMenuItem CreateZoomToExtentsItem(FeatureBasedMapData nodeData) + { + var hasFeatures = nodeData.Features.Any(); + var enabled = nodeData.IsVisible && hasFeatures; string toolTip = string.Empty; if (enabled) { - toolTip = MapResources.MapLegendView_CreateZoomToExtentsItem_MapDataCollection_ZoomToAll_Tooltip; + toolTip = MapResources.MapLegendView_CreateZoomToExtentsItem_ZoomToAll_Tooltip; } - else if (!isVisible) + else if (!nodeData.IsVisible) { - toolTip = MapResources.MapLegendView_CreateZoomToExtentsItem_MapDataCollection_ZoomToAllDisabled_Tooltip; + toolTip = MapResources.MapLegendView_CreateZoomToExtentsItem_ZoomToAllDisabled_Tooltip; } else if (!hasFeatures) { - toolTip = MapResources.MapLegendView_CreateZoomToExtentsItem_MapDataCollection_NoFeatures_ZoomToAllDisabled_Tooltip; + toolTip = MapResources.MapLegendView_CreateZoomToExtentsItem_NoFeatures_ZoomToAllDisabled_Tooltip; } - return new StrictContextMenuItem($"&{MapResources.Ribbon_ZoomToAll}", - toolTip, - MapResources.ZoomToAllIcon, - (sender, args) => { MapControl?.ZoomToAllVisibleLayers(nodeData); }) - { - Enabled = enabled - }; + return CreateZoomToExtentsItem(nodeData, toolTip, enabled); } - #region MapData - - private static void MapDataOnNodeChecked(FeatureBasedMapData featureBasedMapData, object parentData) - { - featureBasedMapData.IsVisible = !featureBasedMapData.IsVisible; - featureBasedMapData.NotifyObservers(); - } - #endregion #region MapDataCollection @@ -267,6 +240,32 @@ target.NotifyObservers(); } + private StrictContextMenuItem CreateZoomToExtentsItem(MapDataCollection nodeData) + { + FeatureBasedMapData[] featureBasedMapDatas = nodeData.GetFeatureBasedMapDataRecursively().ToArray(); + var isVisible = featureBasedMapDatas.Any(md => md.IsVisible); + var hasFeatures = featureBasedMapDatas.Any(mapData => mapData.Features.Any()); + + var enabled = isVisible && hasFeatures; + + string toolTip = string.Empty; + + if (enabled) + { + toolTip = MapResources.MapLegendView_CreateZoomToExtentsItem_MapDataCollection_ZoomToAll_Tooltip; + } + else if (!isVisible) + { + toolTip = MapResources.MapLegendView_CreateZoomToExtentsItem_MapDataCollection_ZoomToAllDisabled_Tooltip; + } + else if (!hasFeatures) + { + toolTip = MapResources.MapLegendView_CreateZoomToExtentsItem_MapDataCollection_NoFeatures_ZoomToAllDisabled_Tooltip; + } + + return CreateZoomToExtentsItem(nodeData, toolTip, enabled); + } + #endregion } } \ No newline at end of file