コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        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);
                }
            }
        }