MapSuiteGisEditor/GisEditorInfrastructure/Plugins/Layers/FeatureLayerPlugin.cs
/// <summary>
/// This method gets a hierarchy object to build the layer list tree.
/// </summary>
/// <param name="layer">The layer list item to build the layer list tree.</param>
/// <returns></returns>
This method gets a hierarchy object to build the layer list tree.
This method gets a hierarchy object to build the layer list tree .
protected override LayerListItem GetLayerListItemCore(Layer layer)
        {
            LayerListItem featureLayerListItem = base.GetLayerListItemCore(layer);
            featureLayerListItem.Load = () =>
            {
                FeatureLayer featureLayer = layer as FeatureLayer;
                List<LayerListItem> styleLayerListItems = LayerListHelper.CollectCompositeStyleLayerListItem(featureLayer);
                if (styleLayerListItems != null)
                {
                    if (styleLayerListItems.Count == 0)
                    {
                        SimpleShapeType simpleShapeType = SimpleShapeType.Unknown;
                        featureLayer.SafeProcess(() =>
                        {
                            simpleShapeType = GetFeatureSimpleShapeType(featureLayer);
                        });
                        var noStyleEntity = new LayerListItem
                        {
                            Name = GisEditor.LanguageManager.GetStringResource("DelimitedTextFeatureLayerPluginDoubleClick"),
                            CheckBoxVisibility = Visibility.Collapsed,
                            DoubleClicked = () =>
                            {
                                Styles.Style shpStyle = null;
                                switch (simpleShapeType)
                                {
                                    case SimpleShapeType.Unknown:
                                    default:
                                        break;
                                    case SimpleShapeType.Point:
                                        shpStyle = new PointStyle();
                                        break;
                                    case SimpleShapeType.Line:
                                        shpStyle = new LineStyle();
                                        break;
                                    case SimpleShapeType.Area:
                                        shpStyle = new AreaStyle();
                                        break;
                                }
                                LayerListHelper.AddStyle();
                            },
                            Parent = featureLayerListItem,
                            ConcreteObject = layer,
                        };
                        switch (simpleShapeType)
                        {
                            case SimpleShapeType.Point:
                                noStyleEntity.ContextMenuItems.Add(LayerListMenuItemHelper.GetAddStyleMenuItem(AddStyleTypes.AddPointStyle | AddStyleTypes.AddTextStyle, featureLayer));
                                break;
                            case SimpleShapeType.Line:
                                noStyleEntity.ContextMenuItems.Add(LayerListMenuItemHelper.GetAddStyleMenuItem(AddStyleTypes.AddLineStyle | AddStyleTypes.AddTextStyle, featureLayer));
                                break;
                            case SimpleShapeType.Area:
                                noStyleEntity.ContextMenuItems.Add(LayerListMenuItemHelper.GetAddStyleMenuItem(AddStyleTypes.AddAreaStyle | AddStyleTypes.AddLineStyle, featureLayer));
                                break;
                        }
                        featureLayerListItem.Children.Add(noStyleEntity);
                    }
                }
                foreach (var styleLayerListItem in styleLayerListItems)
                {
                    styleLayerListItem.Parent = featureLayerListItem;
                    styleLayerListItem.IsExpanded = true;
                    Styles.Style tempStyle = styleLayerListItem.ConcreteObject as Styles.Style;
                    if (tempStyle.Filters.Count > 0)
                    {
                        if (featureLayer.IsOpen && featureLayer.HasBoundingBox)
                        {
                            RectangleShape bbox = featureLayer.GetBoundingBox();
                            Collection<Feature> allDataFeatures = featureLayer.FeatureSource.GetFeaturesForDrawing(bbox, GisEditor.ActiveMap.Width,
    GisEditor.ActiveMap.Height, new Collection<string>());
                            if (allDataFeatures.Count == 0)
                                styleLayerListItem.FontStyle = FontStyles.Italic;
                        }
                    }
                    featureLayerListItem.Children.Add(styleLayerListItem);
                }
            };
            featureLayerListItem.PropertyChanged -= LayerListItemPropertyChanged;
            featureLayerListItem.PropertyChanged += LayerListItemPropertyChanged;
            return featureLayerListItem;
        }
protected override LayerListItem GetLayerListItemCore ( Layer layer ) { LayerListItem featureLayerListItem = base . GetLayerListItemCore ( layer ) ; featureLayerListItem . Load = ( ) => { FeatureLayer featureLayer = layer as FeatureLayer ; List < LayerListItem > styleLayerListItems = LayerListHelper . CollectCompositeStyleLayerListItem ( featureLayer ) ; if ( styleLayerListItems != null ) { if ( styleLayerListItems . Count == 0 ) { SimpleShapeType simpleShapeType = SimpleShapeType . Unknown ; featureLayer . SafeProcess ( ( ) => { simpleShapeType = GetFeatureSimpleShapeType ( featureLayer ) ; } ) ; var noStyleEntity = new LayerListItem { Name = GisEditor . LanguageManager . GetStringResource ( " " ) , CheckBoxVisibility = Visibility . Collapsed , DoubleClicked = ( ) => { Styles . Style shpStyle = null ; switch ( simpleShapeType ) { case SimpleShapeType . Unknown : default : break ; case SimpleShapeType . Point : shpStyle = new PointStyle ( ) ; break ; case SimpleShapeType . Line : shpStyle = new LineStyle ( ) ; break ; case SimpleShapeType . Area : shpStyle = new AreaStyle ( ) ; break ; } LayerListHelper . AddStyle ( ) ; } , Parent = featureLayerListItem , ConcreteObject = layer , } ; switch ( simpleShapeType ) { case SimpleShapeType . Point : noStyleEntity . ContextMenuItems . Add ( LayerListMenuItemHelper . GetAddStyleMenuItem ( AddStyleTypes . AddPointStyle | AddStyleTypes . AddTextStyle , featureLayer ) ) ; break ; case SimpleShapeType . Line : noStyleEntity . ContextMenuItems . Add ( LayerListMenuItemHelper . GetAddStyleMenuItem ( AddStyleTypes . AddLineStyle | AddStyleTypes . AddTextStyle , featureLayer ) ) ; break ; case SimpleShapeType . Area : noStyleEntity . ContextMenuItems . Add ( LayerListMenuItemHelper . GetAddStyleMenuItem ( AddStyleTypes . AddAreaStyle | AddStyleTypes . AddLineStyle , featureLayer ) ) ; break ; } featureLayerListItem . Children . Add ( noStyleEntity ) ; } } foreach ( var styleLayerListItem in styleLayerListItems ) { styleLayerListItem . Parent = featureLayerListItem ; styleLayerListItem . IsExpanded = true ; Styles . Style tempStyle = styleLayerListItem . ConcreteObject as Styles . Style ; if ( tempStyle . Filters . Count > 0 ) { if ( featureLayer . IsOpen && featureLayer . HasBoundingBox ) { RectangleShape bbox = featureLayer . GetBoundingBox ( ) ; Collection < Feature > allDataFeatures = featureLayer . FeatureSource . GetFeaturesForDrawing ( bbox , GisEditor . ActiveMap . Width , GisEditor . ActiveMap . Height , new Collection < string > ( ) ) ; if ( allDataFeatures . Count == 0 ) styleLayerListItem . FontStyle = FontStyles . Italic ; } } featureLayerListItem . Children . Add ( styleLayerListItem ) ; } } ; featureLayerListItem . PropertyChanged -= LayerListItemPropertyChanged ; featureLayerListItem . PropertyChanged += LayerListItemPropertyChanged ; return featureLayerListItem ; }
This method gets a hierarchy object to build the layer list tree.
This method gets a hierarchy object to build the layer list tree .
None
layer
Layer
The layer list item to build the layer list tree.
The layer list item to build the layer list tree .