private static void LoadFromLibrary() { if (GisEditor.LayerListManager.SelectedLayerListItem == null) { return; } StyleLibraryWindow library = new StyleLibraryWindow(); if (library.ShowDialog().GetValueOrDefault()) { FeatureLayer currentFeatureLayer = GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject as FeatureLayer; if (currentFeatureLayer != null) { ZoomLevelHelper.ApplyStyle(library.Result.CompositeStyle, currentFeatureLayer, library.Result.FromZoomLevelIndex, library.Result.ToZoomLevelIndex); } } }
private static void AddStyle(StylePlugin styleProvider) { Style style = null; StyleBuilderArguments arguments = new StyleBuilderArguments(); FeatureLayer currentFeatureLayer = null; if (GisEditor.LayerListManager.SelectedLayerListItem == null) { return; } //add a new style by right-clicking on a layer node if (GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject is FeatureLayer) { currentFeatureLayer = (FeatureLayer)GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject; } //add a new style by right-clicking on a zoomlevel node else if (GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject is ZoomLevel) { ZoomLevel editingZoomLevel = (ZoomLevel)GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject; arguments.FromZoomLevelIndex = GisEditor.ActiveMap.GetSnappedZoomLevelIndex(editingZoomLevel.Scale, false) + 1; arguments.ToZoomLevelIndex = (int)editingZoomLevel.ApplyUntilZoomLevel; currentFeatureLayer = (FeatureLayer)GisEditor.LayerListManager.SelectedLayerListItem.Parent.ConcreteObject; } //replace an existing style else if (GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject is Style) { Style currentStyle = (Style)GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject; currentFeatureLayer = LayerListHelper.FindMapElementInTree <FeatureLayer>(GisEditor.LayerListManager.SelectedLayerListItem); } arguments.AvailableStyleCategories = LayerListHelper.GetStyleCategoriesByFeatureLayer(currentFeatureLayer); arguments.FeatureLayer = currentFeatureLayer; arguments.FillRequiredColumnNames(); arguments.AppliedCallback = args => { if (args.CompositeStyle != null) { ZoomLevelHelper.ApplyStyle(args.CompositeStyle, currentFeatureLayer, args.FromZoomLevelIndex, args.ToZoomLevelIndex); } }; style = styleProvider.GetDefaultStyle(); style.Name = styleProvider.Name; var componentStyle = new CompositeStyle(style) { Name = currentFeatureLayer.Name }; arguments.StyleToEdit = componentStyle; //var styleResults = GisEditor.StyleManager.EditStyle(arguments); if (currentFeatureLayer != null) { var featureLayerPlugin = GisEditor.LayerManager.GetLayerPlugins(currentFeatureLayer.GetType()).FirstOrDefault() as FeatureLayerPlugin; if (featureLayerPlugin != null) { var styleBuilder = GisEditor.StyleManager.GetStyleBuiderUI(); if (styleBuilder != null) { styleBuilder.StyleBuilderArguments = arguments; if (styleBuilder.ShowDialog().GetValueOrDefault()) { arguments.AppliedCallback(styleBuilder.StyleBuilderResult); } } } } }