Ejemplo n.º 1
0
        public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            if (context == null)
            {
                return(null);
            }
            if (context.Instance == null)
            {
                return(null);
            }

            // FeatureClass::ShapeFieldName, AreaFieldName, LengthFieldName, ShapeFieldName
            // GeometricNetworkControllerMembership::EnabledFieldName, AncillaryRoleFieldName
            // IndexField::Name
            // ObjectClass::OIDFieldName, GlobalIDFieldName, RasterFieldName, SubtypeFieldName, OIDFieldName, GlobalIDFieldName
            // RelationshipClass::OriginPrimary, OriginForeign, DestinationPrimary, DestinationForeign
            // SubtypeField::FieldName
            // NetWeightAssociation::FieldName
            // TerrainDataSource::HeightField, TagValueField

            // Create List
            List <string> list = new List <string>();

            DiagrammerEnvironment diagrammerEnvironment = DiagrammerEnvironment.Default;
            SchemaModel           schemaModel           = diagrammerEnvironment.SchemaModel;

            if (context.PropertyDescriptor.ComponentType == typeof(IndexField))
            {
                IndexField  indexField  = (IndexField)context.Instance;
                ObjectClass objectClass = (ObjectClass)indexField.Table;
                foreach (Field field in objectClass.GetFields())
                {
                    list.Add(field.Name);
                }
            }
            else if (context.PropertyDescriptor.ComponentType == typeof(GeometricNetworkControllerMembership))
            {
                GeometricNetworkControllerMembership geometricNetworkControllerMembership = (GeometricNetworkControllerMembership)context.Instance;
                ObjectClass objectClass = schemaModel.FindParent(geometricNetworkControllerMembership);
                foreach (Field field in objectClass.GetFields())
                {
                    list.Add(field.Name);
                }
            }
            else if (context.PropertyDescriptor.ComponentType == typeof(SubtypeField))
            {
                SubtypeField subtypeField = (SubtypeField)context.Instance;
                Subtype      subtype      = (Subtype)subtypeField.Table;
                ObjectClass  objectClass  = subtype.GetParent();
                foreach (Field field in objectClass.GetFields())
                {
                    list.Add(field.Name);
                }
            }
            else if (context.PropertyDescriptor.ComponentType == typeof(ObjectClass))
            {
                ObjectClass objectClass = (ObjectClass)context.Instance;
                foreach (Field field in objectClass.GetFields())
                {
                    list.Add(field.Name);
                }
            }
            else if (context.PropertyDescriptor.ComponentType == typeof(RelationshipClass))
            {
                RelationshipClass relationshipClass = (RelationshipClass)context.Instance;
                if (relationshipClass.IsAttributed)
                {
                    switch (context.PropertyDescriptor.Name)
                    {
                    case "OIDFieldName":
                    case "GlobalIDFieldName":
                    case "RasterFieldName":
                    case "SubtypeFieldName":
                        foreach (Field field in relationshipClass.GetFields())
                        {
                            list.Add(field.Name);
                        }
                        break;

                    case "OriginPrimary":
                        ObjectClass objectClass1 = schemaModel.FindObjectClass(relationshipClass.OriginClassName);
                        foreach (Field field in objectClass1.GetFields())
                        {
                            list.Add(field.Name);
                        }
                        break;

                    case "OriginForeign":
                    case "DestinationForeign":
                        foreach (Field field in relationshipClass.GetFields())
                        {
                            list.Add(field.Name);
                        }
                        break;

                    case "DestinationPrimary":
                        ObjectClass objectClass2 = schemaModel.FindObjectClass(relationshipClass.DestinationClassName);
                        foreach (Field field in objectClass2.GetFields())
                        {
                            list.Add(field.Name);
                        }
                        break;
                    }
                }
                else
                {
                    switch (context.PropertyDescriptor.Name)
                    {
                    case "OIDFieldName":
                    case "GlobalIDFieldName":
                    case "RasterFieldName":
                    case "SubtypeFieldName":
                        foreach (Field field in relationshipClass.GetFields())
                        {
                            list.Add(field.Name);
                        }
                        break;

                    case "OriginPrimary":
                        ObjectClass objectClass1 = schemaModel.FindObjectClass(relationshipClass.OriginClassName);
                        foreach (Field field in objectClass1.GetFields())
                        {
                            list.Add(field.Name);
                        }
                        break;

                    case "OriginForeign":
                        ObjectClass objectClass2 = schemaModel.FindObjectClass(relationshipClass.DestinationClassName);
                        foreach (Field field in objectClass2.GetFields())
                        {
                            list.Add(field.Name);
                        }
                        break;

                    case "DestinationPrimary":
                    case "DestinationForeign":
                        break;
                    }
                }
            }
            else if (
                context.PropertyDescriptor.ComponentType == typeof(FeatureClass) ||
                context.PropertyDescriptor.ComponentType == typeof(RasterCatalog))
            {
                FeatureClass featureClass = (FeatureClass)context.Instance;
                foreach (Field field in featureClass.GetFields())
                {
                    list.Add(field.Name);
                }
            }
            else if (context.PropertyDescriptor.ComponentType == typeof(NetWeightAssociation))
            {
                NetWeightAssociation netWeightAssociation = (NetWeightAssociation)context.Instance;
                if (netWeightAssociation != null)
                {
                    if (!string.IsNullOrEmpty(netWeightAssociation.TableName))
                    {
                        ObjectClass objectClass = schemaModel.FindObjectClass(netWeightAssociation.TableName);
                        if (objectClass != null)
                        {
                            foreach (Field field in objectClass.GetFields())
                            {
                                list.Add(field.Name);
                            }
                        }
                    }
                }
            }
            else if (context.PropertyDescriptor.ComponentType == typeof(TerrainDataSource))
            {
                TerrainDataSource terrainDataSource = (TerrainDataSource)context.Instance;
                if (terrainDataSource != null)
                {
                    if (!string.IsNullOrEmpty(terrainDataSource.FeatureClassName))
                    {
                        ObjectClass objectClass = schemaModel.FindObjectClass(terrainDataSource.FeatureClassName);
                        if (objectClass != null)
                        {
                            foreach (Field field in objectClass.GetFields())
                            {
                                list.Add(field.Name);
                            }
                        }
                    }
                }
            }

            // Sort field name list and insert "None" item
            list.Sort();
            list.Insert(0, Resources.TEXT_NONE_BR);

            // Return sort field name list
            StandardValuesCollection svc = new StandardValuesCollection(list);

            return(svc);
        }