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) + 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.FindMapElementInLayerList <FeatureLayer>(GisEditor.LayerListManager.SelectedLayerListItem); } arguments.AvailableStyleCategories = StylePluginHelper.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 (!styleResults.Canceled) { ZoomLevelHelper.ApplyStyle(styleResults.CompositeStyle, currentFeatureLayer, styleResults.FromZoomLevelIndex, styleResults.ToZoomLevelIndex); } }
internal static void AddStyle(Styles.Style style, FeatureLayer layer) { var styleProvider = GisEditor.StyleManager.GetStylePluginByStyle(style); if (styleProvider == null) { return; } Styles.Style csvStyle = styleProvider.GetDefaultStyle(); StyleBuilderArguments arguments = new StyleBuilderArguments(); arguments.AvailableUIElements = StyleBuilderUIElements.ZoomLevelPicker | StyleBuilderUIElements.StyleList; arguments.FeatureLayer = layer; var featureLayerPlugin = GisEditor.LayerManager.GetLayerPlugins(layer.GetType()).FirstOrDefault() as FeatureLayerPlugin; if (featureLayerPlugin != null) { switch (featureLayerPlugin.GetFeatureSimpleShapeType(layer)) { case SimpleShapeType.Point: arguments.AvailableStyleCategories = StyleCategories.Point | StyleCategories.Label | StyleCategories.Composite; break; case SimpleShapeType.Line: arguments.AvailableStyleCategories = StyleCategories.Line | StyleCategories.Label | StyleCategories.Composite; break; case SimpleShapeType.Area: arguments.AvailableStyleCategories = StyleCategories.Area | StyleCategories.Label | StyleCategories.Composite; break; } } arguments.AppliedCallback = args => { if (args.CompositeStyle != null) { ZoomLevelHelper.ApplyStyle(args.CompositeStyle, layer, args.FromZoomLevelIndex, args.ToZoomLevelIndex); } }; arguments.StyleToEdit = new CompositeStyle(new Styles.Style[] { csvStyle }) { Name = styleProvider.Name }; arguments.FillRequiredColumnNames(); var resultStyle = GisEditor.StyleManager.EditStyle(arguments); if (!resultStyle.Canceled) { ZoomLevelHelper.ApplyStyle(resultStyle.CompositeStyle, layer, resultStyle.FromZoomLevelIndex, resultStyle.ToZoomLevelIndex); } }
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); } } }
public void AddQuickFilterStyle(string columnName, string columnValue) { var styleProvider = GisEditor.StyleManager.GetActiveStylePlugins <FilterStylePlugin>().FirstOrDefault(); var styleArguments = new StyleBuilderArguments(); styleArguments.FeatureLayer = ViewModel.SelectedEntity.OwnerFeatureLayer; var featureLayerPlugin = GisEditor.LayerManager.GetLayerPlugins(styleArguments.FeatureLayer.GetType()).FirstOrDefault() as FeatureLayerPlugin; if (featureLayerPlugin != null) { styleArguments.AvailableStyleCategories = StylePluginHelper.GetStyleCategoriesByFeatureLayer(styleArguments.FeatureLayer); styleArguments.FromZoomLevelIndex = 1; styleArguments.ToZoomLevelIndex = GisEditor.ActiveMap.ZoomLevelSet.CustomZoomLevels.Count(z => z.GetType() == typeof(ZoomLevel)); styleArguments.FillRequiredColumnNames(); styleArguments.AppliedCallback = styleResults => { if (styleResults.CompositeStyle != null) { ZoomLevelHelper.AddStyleToZoomLevels(styleResults.CompositeStyle, styleResults.FromZoomLevelIndex, styleResults.ToZoomLevelIndex, styleArguments.FeatureLayer.ZoomLevelSet.CustomZoomLevels); TileOverlay tileOverlay = GisEditor.ActiveMap.GetOverlaysContaining(styleArguments.FeatureLayer).FirstOrDefault(); if (tileOverlay != null) { tileOverlay.Invalidate(); } GisEditor.UIManager.BeginRefreshPlugins(new RefreshArgs(GisEditor.LayerListManager.SelectedLayerListItem, RefreshArgsDescription.ApplyStyleDescription)); } }; var defaultFilterStyle = styleProvider.GetDefaultStyle() as FilterStyle; defaultFilterStyle.Name = string.Format(filterStyleNameFormat, columnName, columnValue); FilterCondition filterCondition = new FilterCondition(); filterCondition.ColumnName = columnName; filterCondition.Name = defaultFilterStyle.Name; bool isNumericColumn = false; styleArguments.FeatureLayer.SafeProcess(() => { Collection <FeatureSourceColumn> columns = styleArguments.FeatureLayer.FeatureSource.GetColumns(); var resultColumn = columns.FirstOrDefault(c => c.ColumnName.Equals(columnName, StringComparison.InvariantCultureIgnoreCase)); if (resultColumn != null) { isNumericColumn = resultColumn.TypeName.Equals("DOUBLE", StringComparison.InvariantCultureIgnoreCase) || resultColumn.TypeName.Equals("INTEGER", StringComparison.InvariantCultureIgnoreCase) || resultColumn.TypeName.Equals("FLOAT", StringComparison.InvariantCultureIgnoreCase); } }); //filterCondition.Expression = string.Format(isNumericColumn ? numericEqualConditionFormat : textContainsConditionFormat, columnValue.ToLowerInvariant()); filterCondition.RegexOptions = System.Text.RegularExpressions.RegexOptions.IgnoreCase; filterCondition.Expression = string.Format(isNumericColumn ? numericEqualConditionFormat : textContainsConditionFormat, columnValue); defaultFilterStyle.Conditions.Add(filterCondition); var componentStyle = new CompositeStyle(defaultFilterStyle) { Name = styleArguments.FeatureLayer.Name }; styleArguments.StyleToEdit = componentStyle; var styleBuilder = GisEditor.StyleManager.GetStyleBuiderUI(styleArguments); if (styleBuilder.ShowDialog().GetValueOrDefault()) { styleArguments.AppliedCallback(styleBuilder.StyleBuilderResult); } } }