public static void ModifySelectedStyle(Style selectedStyle, Style newStyle, int from, int to) { if (GisEditor.LayerListManager.SelectedLayerListItem != null && GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject is Style) { if (selectedStyle != GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject) { //The following check is for issue-7208 and issue-7213. //When we double click on a RegexItem, we actually mean to edit the RegextItem's parent - the RegexStyle. //But the SelectedEntity matches up with the RegextItem, not the RegextStyle, so we need to have this check. //Anyways, this is quite complicated, jsut reconsider before you modify the following code. if (!IsSubStyleSelected(selectedStyle) && selectedStyle != GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject) { selectedStyle = (Style)GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject; } } FeatureLayer currentLayer = LayerListHelper.FindMapElementInTree <FeatureLayer>(GisEditor.LayerListManager.SelectedLayerListItem); ZoomLevel currentZoomLevel = LayerListHelper.FindMapElementInTree <ZoomLevel>(GisEditor.LayerListManager.SelectedLayerListItem); int originalFrom = GisEditor.ActiveMap.GetSnappedZoomLevelIndex(currentZoomLevel.Scale, false) + 1; int originalTo = (int)currentZoomLevel.ApplyUntilZoomLevel; Style nextSelectedStyle = newStyle.CloneDeep(); ReplaceStyle(currentLayer, selectedStyle, newStyle); if (originalFrom != from || originalTo != to) { for (int i = 0; i < currentLayer.ZoomLevelSet.CustomZoomLevels.Count; i++) { var zoomLevel = currentLayer.ZoomLevelSet.CustomZoomLevels[i]; if (i >= from - 1 && i <= to - 1) { if (!zoomLevel.CustomStyles.Contains(newStyle)) { zoomLevel.CustomStyles.Add(newStyle); } } else { if (zoomLevel.CustomStyles.Contains(newStyle)) { zoomLevel.CustomStyles.Remove(newStyle); } } } } GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject = newStyle; LayerListHelper.InvalidateTileOverlay(); GisEditor.UIManager.InvokeRefreshPlugins(new RefreshArgs(GisEditor.LayerListManager.SelectedLayerListItem, RefreshArgsDescriptions.ModifySelectedStyleDescription)); } }
public static void ModifySelectedStyle(Style selectedStyle, Style newStyle, int from, int to) { if (GisEditor.LayerListManager.SelectedLayerListItem != null && GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject is Style) { if (selectedStyle != GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject) { if (!IsSubStyleSelected(selectedStyle) && selectedStyle != GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject) { selectedStyle = (Style)GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject; } } FeatureLayer currentLayer = LayerListHelper.FindMapElementInLayerList <FeatureLayer>(GisEditor.LayerListManager.SelectedLayerListItem); ZoomLevel currentZoomLevel = LayerListHelper.FindMapElementInLayerList <ZoomLevel>(GisEditor.LayerListManager.SelectedLayerListItem); int originalFrom = GisEditor.ActiveMap.GetSnappedZoomLevelIndex(currentZoomLevel.Scale, false) + 1; int originalTo = (int)currentZoomLevel.ApplyUntilZoomLevel; Style nextSelectedStyle = newStyle.CloneDeep(); ReplaceStyle(currentLayer, selectedStyle, newStyle); if (originalFrom != from || originalTo != to) { for (int i = 0; i < currentLayer.ZoomLevelSet.CustomZoomLevels.Count; i++) { var zoomLevel = currentLayer.ZoomLevelSet.CustomZoomLevels[i]; if (i >= from - 1 && i <= to - 1) { if (!zoomLevel.CustomStyles.Contains(newStyle)) { zoomLevel.CustomStyles.Add(newStyle); } } else { if (zoomLevel.CustomStyles.Contains(newStyle)) { zoomLevel.CustomStyles.Remove(newStyle); } } } } GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject = newStyle; LayerListHelper.RefreshCache(); GisEditor.UIManager.BeginRefreshPlugins(new RefreshArgs(GisEditor.LayerListManager.SelectedLayerListItem, RefreshArgsDescription.ModifySelectedStyleDescription)); } }