protected override StyleUserControl CreateUI(StyleBuilderArguments styleArguments) { if (userControl == null) { StylePluginHelper.FillRequiredValueForStyleArguments(styleArguments); userControl = new FilterStyleUserControl(ConcreteObject as TextFilterStyle, styleArguments); if (Children.Count == 0) { var textStylePlugin = GisEditor.StyleManager.GetDefaultStylePlugin(StyleCategories.Label); if (textStylePlugin != null) { var textStyle = textStylePlugin.GetDefaultStyle() as TextStyle; if (textStyle != null) { textStyle.TextColumnName = styleArguments.ColumnNames.FirstOrDefault(); var styleItem = GisEditor.StyleManager.GetStyleLayerListItem(textStyle); Children.Add(styleItem); UpdateConcreteObject(); } } } } return(userControl); }
private void InitializeAvailablePlugins(FeatureLayer featureLayer) { var shapeType = StylePluginHelper.GetWellKnownType(featureLayer); switch (shapeType) { case SimpleShapeType.Point: InitializeAvailableStyleProviders(StyleCategories.Point); break; case SimpleShapeType.Line: InitializeAvailableStyleProviders(StyleCategories.Line); break; case SimpleShapeType.Area: InitializeAvailableStyleProviders(StyleCategories.Area); break; default: break; } bool isAddingText = ActualObject is TextFilterStyle; if (isAddingText) { InitializeAvailableStyleProviders(StyleCategories.Label, isAddingText); } RemoveIgnoredStylePlugins(); }
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); } }
protected override StyleUserControl CreateUI(StyleBuilderArguments styleArguments) { if (userControl == null) { StylePluginHelper.FillRequiredValueForStyleArguments(styleArguments); userControl = new TextStyleUserControl(ConcreteObject as IconTextStyle, styleArguments); } return(userControl); }
private void ChangeInnerControlsVisibility() { var shapeType = StylePluginHelper.GetWellKnownType(RequiredValues.FeatureLayer); switch (shapeType) { case SimpleShapeType.Point: // Placement Visibility ForceHorizontalLabelForLineVisibility = Visibility.Collapsed; SplineTypeVisibility = Visibility.Collapsed; // Duplication Visiibility LabelPolygonVisibility = Visibility.Collapsed; // Clipping FittingPolygonVisibility = Visibility.Collapsed; FittingFactorVisibility = Visibility.Collapsed; FittingLineInScreenVisibility = Visibility.Collapsed; SegmentRatioVisibility = Visibility.Collapsed; break; case SimpleShapeType.Line: // Placement Visibility BestPlacementVisibility = Visibility.Collapsed; LabelPlacementVisibility = Visibility.Collapsed; // Duplication Visibility LabelPolygonVisibility = Visibility.Collapsed; // Clipping FittingPolygonVisibility = Visibility.Collapsed; FittingFactorVisibility = Visibility.Collapsed; break; case SimpleShapeType.Area: // Placement Visibility ForceHorizontalLabelForLineVisibility = Visibility.Collapsed; SplineTypeVisibility = Visibility.Collapsed; BestPlacementVisibility = Visibility.Collapsed; LabelPlacementVisibility = Visibility.Collapsed; // Clipping FittingLineInScreenVisibility = Visibility.Collapsed; SegmentRatioVisibility = Visibility.Collapsed; break; default: break; } }
protected override StyleUserControl CreateUI(StyleBuilderArguments styleArguments) { if (userControl == null) { StylePluginHelper.FillRequiredValueForStyleArguments(styleArguments); userControl = new FilterStyleUserControl(ConcreteObject as FilterStyle, styleArguments); if (Children.Count == 0) { var pointStylePlugin = GisEditor.StyleManager.GetDefaultStylePlugin(styleArguments.AvailableStyleCategories); if (pointStylePlugin != null) { var style = pointStylePlugin.GetDefaultStyle(); style.Name = pointStylePlugin.Name; var styleItem = GisEditor.StyleManager.GetStyleLayerListItem(style); Children.Add(styleItem); UpdateConcreteObject(); } } } return(userControl); }
public static void EditStyle(LayerListItem selectedLayerListItem) { var componentStyleItem = LayerListHelper.FindItemInLayerList <CompositeStyle>(selectedLayerListItem) as StyleLayerListItem; if (componentStyleItem != null) { var componentStyle = componentStyleItem.ConcreteObject as CompositeStyle; var styleArguments = new StyleBuilderArguments(); styleArguments.FeatureLayer = componentStyleItem.Parent.ConcreteObject as FeatureLayer; var featureLayerPlugin = GisEditor.LayerManager.GetLayerPlugins(styleArguments.FeatureLayer.GetType()).FirstOrDefault() as FeatureLayerPlugin; if (featureLayerPlugin != null) { styleArguments.AvailableStyleCategories = StylePluginHelper.GetStyleCategoriesByFeatureLayer(styleArguments.FeatureLayer); int from = 0; int to = GisEditor.ActiveMap.ZoomLevelSet.CustomZoomLevels.Count; if (!string.IsNullOrEmpty(componentStyleItem.ZoomLevelRange)) { var array = componentStyleItem.ZoomLevelRange.Split(" to ".ToArray(), StringSplitOptions.RemoveEmptyEntries); if (array.Length == 2) { int.TryParse(array[0].Replace("(", "").Trim(), out from); int.TryParse(array[1].Replace(")", "").Trim(), out to); } } styleArguments.FromZoomLevelIndex = from; styleArguments.ToZoomLevelIndex = to; styleArguments.AppliedCallback = new Action <StyleBuilderResult>((styleResults) => { if (!styleResults.Canceled) { var resultStyle = styleResults.CompositeStyle as CompositeStyle; var count = GisEditor.ActiveMap.ZoomLevelSet.GetZoomLevels().Count; for (int i = 0; i < count; i++) { var customStyles = styleArguments.FeatureLayer.ZoomLevelSet.CustomZoomLevels[i].CustomStyles; if (i >= styleResults.FromZoomLevelIndex - 1 && i < styleResults.ToZoomLevelIndex) { if (!customStyles.Contains(componentStyle)) { customStyles.Add(componentStyle); } componentStyle.Styles.Clear(); componentStyle.Name = resultStyle.Name; foreach (var item in resultStyle.Styles) { componentStyle.Styles.Add(item); } } else { customStyles.Remove(componentStyle); } } foreach (var overlay in GisEditor.ActiveMap.GetOverlaysContaining(styleArguments.FeatureLayer)) { if (overlay.MapArguments != null) { overlay.Invalidate(); } } GisEditor.UIManager.BeginRefreshPlugins(new RefreshArgs(styleResults, RefreshArgsDescription.EditStyleDescription)); } }); var styleItems = new Collection <StyleLayerListItem>(); foreach (var style in componentStyle.Styles) { var item = GisEditor.StyleManager.GetStyleLayerListItem(style); if (item != null) { styleItems.Add(item); } } var clonedStyleItems = new Collection <StyleLayerListItem>(); var clonedCompositeStyle = componentStyle.CloneDeep() as CompositeStyle; styleArguments.StyleToEdit = clonedCompositeStyle; foreach (var style in clonedCompositeStyle.Styles) { var item = GisEditor.StyleManager.GetStyleLayerListItem(style); if (item != null) { clonedStyleItems.Add(item); } } object selectedClonedObject = FindSelectedObject(styleItems.ToList(), clonedStyleItems.ToList(), selectedLayerListItem.ConcreteObject); styleArguments.FillRequiredColumnNames(); styleArguments.SelectedConcreteObject = selectedClonedObject; var styleBuilder = GisEditor.StyleManager.GetStyleBuiderUI(styleArguments); if (styleBuilder.ShowDialog().GetValueOrDefault()) { styleArguments.AppliedCallback(styleBuilder.StyleBuilderResult); } } } }
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); } } }