private static void RemoveStyle() { if (GisEditor.LayerListManager.SelectedLayerListItem == null) { return; } var featureLayer = GisEditor.LayerListManager.SelectedLayerListItem.Parent.ConcreteObject as FeatureLayer; if (featureLayer != null) { var style = GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject as Style; foreach (var zoomLevel in featureLayer.ZoomLevelSet.CustomZoomLevels) { if (zoomLevel.CustomStyles.Contains(style)) { zoomLevel.CustomStyles.Remove(style); } } } else { var parent = GisEditor.LayerListManager.SelectedLayerListItem.Parent as StyleLayerListItem; if (parent != null) { parent.Children.Remove(GisEditor.LayerListManager.SelectedLayerListItem); parent.UpdateConcreteObject(); } } LayerListHelper.RefreshCache(); GisEditor.UIManager.BeginRefreshPlugins(new RefreshArgs(GisEditor.LayerListManager.SelectedLayerListItem, RefreshArgsDescription.RemoveStyleDescription)); }
private static void RemoveSubStyle() { if (GisEditor.LayerListManager.SelectedLayerListItem == null) { return; } Style style = GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject as Style; object parentActualObject = GisEditor.LayerListManager.SelectedLayerListItem.Parent.ConcreteObject; if (style != null) { if (parentActualObject is ValueStyle) { var valueStyle = (ValueStyle)parentActualObject; var resultValueItem = valueStyle.ValueItems.Where(valueItem => valueItem.CustomStyles.Contains(style)).FirstOrDefault(); valueStyle.ValueItems.Remove(resultValueItem); } else if (parentActualObject is ClassBreakStyle) { var classBreakStyle = (ClassBreakStyle)parentActualObject; var resultClassBreak = classBreakStyle.ClassBreaks.Where(classBreak => classBreak.CustomStyles.Contains(style)).FirstOrDefault(); classBreakStyle.ClassBreaks.Remove(resultClassBreak); } else if (parentActualObject is RegexStyle) { var regexStyle = (RegexStyle)parentActualObject; var resultRegexItem = regexStyle.RegexItems.Where(regexItem => regexItem.CustomStyles.Contains(style)).FirstOrDefault(); regexStyle.RegexItems.Remove(resultRegexItem); } LayerListHelper.RefreshCache(); GisEditor.UIManager.BeginRefreshPlugins(new RefreshArgs(GisEditor.LayerListManager.SelectedLayerListItem, RefreshArgsDescription.RemoveSubStyleDescription)); } }
private static void RemoveZoomLevel() { if (GisEditor.LayerListManager.SelectedLayerListItem == null) { return; } ZoomLevel selectedZoomLevel = GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject as ZoomLevel; if (selectedZoomLevel != null) { FeatureLayer featureLayer = (FeatureLayer)GisEditor.LayerListManager.SelectedLayerListItem.Parent.ConcreteObject; foreach (var zoomLevel in featureLayer.ZoomLevelSet.CustomZoomLevels) { foreach (var style in selectedZoomLevel.CustomStyles) { if (zoomLevel.CustomStyles.Contains(style)) { zoomLevel.CustomStyles.Remove(style); } } } LayerListHelper.RefreshCache(); GisEditor.UIManager.BeginRefreshPlugins(new RefreshArgs(selectedZoomLevel, RefreshArgsDescription.RemoveZoomLevelDescription)); } }
public static void ResetZoomLevelRange(ZoomLevel selectedZoomLevel, FeatureLayer featureLayer, int from, int to) { for (int i = 0; i < featureLayer.ZoomLevelSet.CustomZoomLevels.Count; i++) { var zoomLevel = featureLayer.ZoomLevelSet.CustomZoomLevels[i]; if (i >= from - 1 && i <= to - 1) { foreach (var style in selectedZoomLevel.CustomStyles) { if (!zoomLevel.CustomStyles.Contains(style)) { zoomLevel.CustomStyles.Add(style); } } } else { foreach (var style in selectedZoomLevel.CustomStyles) { if (zoomLevel.CustomStyles.Contains(style)) { zoomLevel.CustomStyles.Remove(style); } } } } LayerListHelper.RefreshCache(); GisEditor.UIManager.BeginRefreshPlugins(new RefreshArgs(selectedZoomLevel, RefreshArgsDescription.ResetZoomLevelRangeDescription)); }
public static void ApplyStyle(Style newStyle, FeatureLayer currentFeatureLayer, int fromZoomLevel, int toZoomLevel, bool needsRefresh = true) { currentFeatureLayer.ZoomLevelSet .CustomZoomLevels .Where(tmpLevel => tmpLevel.CustomStyles.Contains(newStyle)) .ForEach(tmpLevel => tmpLevel.CustomStyles.Remove(newStyle)); if (GisEditor.LayerListManager.SelectedLayerListItem != null && GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject != null) { FeatureLayer featureLayer = null; ZoomLevel zoomLevel = null; Style currentStyle = null; if ((featureLayer = GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject as FeatureLayer) != null) { AddStyleToZoomLevels(newStyle, fromZoomLevel, toZoomLevel, featureLayer.ZoomLevelSet.CustomZoomLevels); } else if ((zoomLevel = GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject as ZoomLevel) != null) { var customZoomLevels = (GisEditor.LayerListManager.SelectedLayerListItem.Parent.ConcreteObject as FeatureLayer).ZoomLevelSet.CustomZoomLevels; AddStyleToZoomLevels(newStyle, fromZoomLevel, toZoomLevel, customZoomLevels); } else if ((currentStyle = GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject as Style) != null) { featureLayer = GisEditor.LayerListManager.SelectedLayerListItem.Parent.Parent.ConcreteObject as FeatureLayer; ReplaceStyle(featureLayer, currentStyle, newStyle); } if (needsRefresh) { LayerListHelper.RefreshCache(); GisEditor.UIManager.BeginRefreshPlugins(new RefreshArgs(GisEditor.LayerListManager.SelectedLayerListItem, RefreshArgsDescription.ApplyStyleDescription)); } } }
public static MenuItem GetAddStyleWizardMenuItem(ShapeFileFeatureLayer shapeFileFeatureLayer) { var command = new ObservedCommand(() => { if (GisEditorWpfMapExtension.AddStyleToLayerWithStyleWizard(new Layer[] { shapeFileFeatureLayer })) { LayerListHelper.RefreshCache(); GisEditor.UIManager.BeginRefreshPlugins(new RefreshArgs(shapeFileFeatureLayer, RefreshArgsDescription.GetAddStyleWizardMenuItemDescription)); } }, () => true); return(GetMenuItem("Style Wizard", "/GisEditorPluginCore;component/Images/addstyle.png", command)); }
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)); } }