示例#1
0
        //
        // PUBLIC METHODS
        //
        public string GetCatalogPath()
        {
            //
            Dataset parent = this.GetParent();

            if (parent == null)
            {
                string version = string.Empty;
                DiagrammerEnvironment diagrammerEnvironment = DiagrammerEnvironment.Default;
                SchemaModel           schemaModel           = diagrammerEnvironment.SchemaModel;
                switch (schemaModel.WorkspaceType)
                {
                case esriWorkspaceType.esriFileSystemWorkspace:
                case esriWorkspaceType.esriLocalDatabaseWorkspace:
                    break;

                case esriWorkspaceType.esriRemoteDatabaseWorkspace:
                    if (string.IsNullOrEmpty(schemaModel.Version))
                    {
                        break;
                    }
                    version += string.Format("/V={0}", schemaModel.Version);
                    break;
                }
                return(version + this.GetDatasetPath());
            }

            //
            return(parent.GetCatalogPath() + this.GetDatasetPath());
        }
        private void Model_ElementRemoved(object sender, ElementsEventArgs e)
        {
            // Check Relationship
            if (this._geometricNetwork == null)
            {
                return;
            }

            // Get Element
            Element element = e.Value;

            if (element == null)
            {
                return;
            }
            EsriLine <GeometricNetworkControllerMembership> line = element as EsriLine <GeometricNetworkControllerMembership>;

            if (line == null)
            {
                return;
            }

            // Get Rule
            GeometricNetworkControllerMembership controller = line.Parent;

            //
            DiagrammerEnvironment diagrammerEnvironment = DiagrammerEnvironment.Default;
            SchemaModel           schemaModel           = diagrammerEnvironment.SchemaModel;
            ObjectClass           objectClass           = schemaModel.FindParent(controller);

            if (objectClass != null)
            {
                objectClass.ControllerMemberships.Remove(controller);
            }
        }
        private void Model_ElementRemoved(object sender, ElementsEventArgs e)
        {
            // Check Terrain
            if (this._terrain == null)
            {
                return;
            }

            // Get Element
            Element element = e.Value;

            if (element == null)
            {
                return;
            }
            EsriLine <TerrainDataSource> line = element as EsriLine <TerrainDataSource>;

            if (line == null)
            {
                return;
            }

            // Get Rule
            TerrainDataSource terrainDataSource = line.Parent;

            //
            DiagrammerEnvironment diagrammerEnvironment = DiagrammerEnvironment.Default;
            SchemaModel           schemaModel           = diagrammerEnvironment.SchemaModel;
            Terrain terrain = schemaModel.FindParent(terrainDataSource);

            if (terrain != null)
            {
                terrain.TerrainDataSources.Remove(terrainDataSource);
            }
        }
        public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            if (context == null)
            {
                return(null);
            }
            if (context.Instance == null)
            {
                return(null);
            }

            // Get Model
            DiagrammerEnvironment de = DiagrammerEnvironment.Default;

            if (de == null)
            {
                return(null);
            }
            SchemaModel model = de.SchemaModel;

            if (model == null)
            {
                return(null);
            }

            // Get Domains
            List <Domain> domains = model.GetDomains();

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

            //
            foreach (Domain domain in domains)
            {
                list.Add(domain.Name);
            }

            // Sort List and Add (None)
            list.Sort();
            list.Insert(0, Resources.TEXT_NONE_BR);

            // Passes the local integer array.
            StandardValuesCollection svc = new StandardValuesCollection(list);

            return(svc);
        }
        private void Model_ElementInvalid(object sender, ElementEventArgs e)
        {
            // Exit if GeometricNetwork Does not Exist
            if (this._geometricNetwork == null)
            {
                return;
            }

            // Get Element
            Element element = e.Value;

            if (element == null)
            {
                return;
            }
            EsriLine <GeometricNetworkControllerMembership> line = element as EsriLine <GeometricNetworkControllerMembership>;

            if (line == null)
            {
                return;
            }

            // Get Controller
            GeometricNetworkControllerMembership controller = line.Parent;

            // Suspend Rule Events
            controller.Suspend();

            // Get Start and End Elements
            Element elementStart = line.Start.Shape;
            Element elementEnd   = line.End.Shape;

            // Update GeometricNetwork Name Property
            if (elementStart == null)
            {
                controller.GeometricNetworkName = string.Empty;
            }
            else if (elementStart is EsriShape <GeometricNetwork> )
            {
                EsriShape <GeometricNetwork> shape            = (EsriShape <GeometricNetwork>)elementStart;
                GeometricNetwork             geometricNetwork = shape.Parent;
                controller.GeometricNetworkName = geometricNetwork.Name;
            }

            //
            DiagrammerEnvironment diagrammerEnvironment = DiagrammerEnvironment.Default;
            SchemaModel           schemaModel           = diagrammerEnvironment.SchemaModel;
            ObjectClass           objectClass           = schemaModel.FindParent(controller);

            if (objectClass != null)
            {
                objectClass.ControllerMemberships.Remove(controller);
            }

            if (elementEnd == null)
            {
                controller.AncillaryRoleFieldName = string.Empty;
                controller.EnabledFieldName       = string.Empty;
            }
            else if (elementEnd is EsriShape <FeatureClass> )
            {
                EsriShape <FeatureClass> es           = (EsriShape <FeatureClass>)elementEnd;
                FeatureClass             featureClass = es.Parent;
                featureClass.ControllerMemberships.Add(controller);
            }

            // Resume Controller Events
            controller.Resume();
        }
        //
        // PRIVATE METHODS
        //
        private void CreateReport()
        {
            // Exit if Workspace is NULL
            if (this.m_workspaceName == null)
            {
                return;
            }

            //
            DiagrammerEnvironment diagrammerEnvironment = DiagrammerEnvironment.Default;

            diagrammerEnvironment.OnProgressChanged(new ProgressEventArgs("Creating Report"));

            // Get IWorkspace
            IName      name      = (IName)this.m_workspaceName;
            IWorkspace workspace = (IWorkspace)name.Open();

            // Get Temporary File
            string filename = System.IO.Path.Combine(System.IO.Path.GetTempPath(), Guid.NewGuid().ToString("N").ToUpper() + ".xml");

            // Specific XML Settings
            XmlWriterSettings settings = new XmlWriterSettings();

            settings.Encoding            = Encoding.UTF8; //  Encoding.Default;
            settings.Indent              = false;
            settings.NewLineHandling     = NewLineHandling.Entitize;
            settings.OmitXmlDeclaration  = true;
            settings.NewLineOnAttributes = false;

            // Create the XmlWriter object and write some content.
            XmlWriter writer = XmlWriter.Create(filename, settings);

            // <DataReport>
            writer.WriteStartElement("DataReport");

            //
            IEnumDatasetName enumDatasetName1 = workspace.get_DatasetNames(esriDatasetType.esriDTAny);
            IDatasetName     datasetName1     = enumDatasetName1.Next();

            while (datasetName1 != null)
            {
                switch (datasetName1.Type)
                {
                case esriDatasetType.esriDTFeatureDataset:
                    // <DataReport><FeatureDataset>
                    writer.WriteStartElement("FeatureDataset");

                    // <DataReport><FeatureDataset><Name>
                    writer.WriteStartElement("Name");
                    writer.WriteValue(datasetName1.Name);
                    writer.WriteEndElement();

                    IEnumDatasetName enumDatasetName2 = datasetName1.SubsetNames;
                    IDatasetName     datasetName2     = enumDatasetName2.Next();
                    while (datasetName2 != null)
                    {
                        switch (datasetName2.Type)
                        {
                        case esriDatasetType.esriDTFeatureClass:
                            // Display Message
                            string message = string.Format("Adding <{0}>", datasetName2.Name);
                            diagrammerEnvironment.OnProgressChanged(new ProgressEventArgs(message));

                            // Add Dataset
                            this.AddDataset(writer, datasetName2);
                            break;

                        default:
                            break;
                        }
                        datasetName2 = enumDatasetName2.Next();
                    }

                    // <DataReport></FeatureDataset>
                    writer.WriteEndElement();

                    break;

                case esriDatasetType.esriDTFeatureClass:
                case esriDatasetType.esriDTTable:
                    // Display Message
                    string message2 = string.Format("Adding <{0}>", datasetName1.Name);
                    diagrammerEnvironment.OnProgressChanged(new ProgressEventArgs(message2));

                    // Add Dataset
                    this.AddDataset(writer, datasetName1);
                    break;

                default:
                    break;
                }

                datasetName1 = enumDatasetName1.Next();
            }

            // </DataReport>
            writer.WriteEndElement();

            // Close Writer
            writer.Close();

            // Set Source XML
            this.Xml = filename;

            // Fire Invalidate Event so that the Report Tabbed Document can Reload
            this.OnInvalidated(new EventArgs());

            // Clear Messages
            diagrammerEnvironment.OnProgressChanged(new ProgressEventArgs(string.Empty));
        }
示例#7
0
        public override void Errors(List <Error> list, EsriTable table)
        {
            // Write Base Errors
            base.Errors(list, table);

            // Get Topology
            Topology topology = (Topology)table;

            // Check for duplicate rules
            bool duplicate = false;

            foreach (TopologyRule topologyRule in topology.TopologyRules)
            {
                if (topologyRule == this)
                {
                    continue;
                }
                if (this._allOriginSubtypes == topologyRule.AllOriginSubtypes &&
                    this._originClassId == topologyRule.OriginClassId &&
                    this._originSubtype == topologyRule.OriginSubtype &&
                    this._allDestinationSubtypes == topologyRule.AllDestinationSubtypes &&
                    this._destinationClassId == topologyRule.DestinationClassId &&
                    this._destinationSubtype == topologyRule.DestinationSubtype &&
                    this._topologyRuleType == topologyRule.TopologyRuleType)
                {
                    duplicate = true;
                    break;
                }
            }
            if (duplicate)
            {
                string message = string.Format("Duplicate topology rules found");
                list.Add(new ErrorObject(this, table, message, ErrorType.Error));
            }

            // Duplicate Guids
            bool duplicateGuid = false;

            foreach (TopologyRule topologyRule in topology.TopologyRules)
            {
                if (topologyRule == this)
                {
                    continue;
                }
                if (this._guid == topologyRule.Guid)
                {
                    duplicateGuid = true;
                    break;
                }
            }
            if (duplicateGuid)
            {
                string message = string.Format("Topology Rule Guid [{0}] is not unique", this._guid);
                list.Add(new ErrorObject(this, table, message, ErrorType.Error));
            }

            // Check if rule conflict with rules using "All Subtypes" - Origin
            if (this._allOriginSubtypes)
            {
                bool originSubtypeConflict = false;
                foreach (TopologyRule topologyRule in topology.TopologyRules)
                {
                    if (topologyRule == this)
                    {
                        continue;
                    }
                    if (topologyRule.AllOriginSubtypes == false &&
                        this._originClassId == topologyRule.OriginClassId &&
                        this._allDestinationSubtypes == topologyRule.AllDestinationSubtypes &&
                        this._destinationClassId == topologyRule.DestinationClassId &&
                        this._destinationSubtype == topologyRule.DestinationSubtype &&
                        this._topologyRuleType == topologyRule.TopologyRuleType)
                    {
                        originSubtypeConflict = true;
                        break;
                    }
                }
                if (originSubtypeConflict)
                {
                    string message = string.Format("The Topology Rule [{0}] with an Origin 'AllSubtypes' setting conflicts another rule", this._guid);
                    list.Add(new ErrorObject(this, table, message, ErrorType.Error));
                }
            }

            // Check if rule conflict with rules using "All Subtypes" - Destination
            if (this._allDestinationSubtypes)
            {
                bool destinationSubtypeConflict = false;
                foreach (TopologyRule topologyRule in topology.TopologyRules)
                {
                    if (topologyRule == this)
                    {
                        continue;
                    }
                    if (topologyRule.AllDestinationSubtypes == false &&
                        this._destinationClassId == topologyRule.DestinationClassId &&
                        this._allOriginSubtypes == topologyRule.AllOriginSubtypes &&
                        this._originClassId == topologyRule.OriginClassId &&
                        this._originSubtype == topologyRule.OriginSubtype &&
                        this._topologyRuleType == topologyRule.TopologyRuleType)
                    {
                        destinationSubtypeConflict = true;
                        break;
                    }
                }
                if (destinationSubtypeConflict)
                {
                    string message = string.Format("The Topology Rule [{0}] with an Destination 'AllSubtypes' setting conflicts another rule", this._guid);
                    list.Add(new ErrorObject(this, table, message, ErrorType.Error));
                }
            }

            // Valid rules for Origin/Destination Shape Types
            DiagrammerEnvironment diagrammerEnvironment = DiagrammerEnvironment.Default;
            SchemaModel           schemaModel           = diagrammerEnvironment.SchemaModel;

            // Get Origin and Destination FeatureClasses
            ObjectClass objectClassOrig = schemaModel.FindObjectClass(this._originClassId);
            ObjectClass objectClassDest = schemaModel.FindObjectClass(this._destinationClassId);

            // Check if Origin and Destination ObjectClasses Exist
            if (objectClassOrig == null)
            {
                list.Add(new ErrorObject(this, table, "Origin FeatureClass Does Not Exist", ErrorType.Error));
            }
            if (objectClassDest == null)
            {
                list.Add(new ErrorObject(this, table, "Destination FeatureClass Does Not Exist", ErrorType.Error));
            }

            // Check if Origin and Destination Subypes Exist
            EsriTable tableOrig = schemaModel.FindObjectClassOrSubtype(this._originClassId, this._originSubtype);
            EsriTable tableDest = schemaModel.FindObjectClassOrSubtype(this._destinationClassId, this._destinationSubtype);

            if (tableOrig == null)
            {
                list.Add(new ErrorObject(this, table, "Origin FeatureClass and/or Subtype Does Not Exist", ErrorType.Error));
            }
            if (tableDest == null)
            {
                list.Add(new ErrorObject(this, table, "Destination FeatureClass and/or Subtype Does Not Exist", ErrorType.Error));
            }

            // Get Origin and Destination FeatureClasses
            FeatureClass featureClassOrig = objectClassOrig as FeatureClass;
            FeatureClass featureClassDest = objectClassDest as FeatureClass;

            // These rules MUST have the same origin and destination class/subtype
            if (featureClassOrig != null && featureClassDest != null && tableOrig != null && tableDest != null)
            {
                switch (this._topologyRuleType)
                {
                case esriTopologyRuleType.esriTRTLineNoOverlap:
                case esriTopologyRuleType.esriTRTLineNoIntersection:
                case esriTopologyRuleType.esriTRTLineNoDangles:
                case esriTopologyRuleType.esriTRTLineNoPseudos:
                case esriTopologyRuleType.esriTRTLineNoSelfOverlap:
                case esriTopologyRuleType.esriTRTLineNoSelfIntersect:
                case esriTopologyRuleType.esriTRTLineNoIntersectOrInteriorTouch:
                case esriTopologyRuleType.esriTRTLineNoMultipart:
                case esriTopologyRuleType.esriTRTAreaNoGaps:
                case esriTopologyRuleType.esriTRTAreaNoOverlap:
                    if (this._originClassId != this._destinationClassId ||
                        this._originSubtype != this._destinationSubtype)
                    {
                        list.Add(new ErrorObject(this, table, "This rule must have the same origin and destination FeatureClass and Subtype", ErrorType.Error));
                    }
                    break;

                default:
                    break;
                }
            }

            // Examine Rule Based on Origin and Destination GeometryType
            bool ok = false;

            if (featureClassOrig != null && featureClassDest != null)
            {
                switch (featureClassOrig.ShapeType)
                {
                case esriGeometryType.esriGeometryPoint:
                    switch (featureClassDest.ShapeType)
                    {
                    case esriGeometryType.esriGeometryPoint:
                        // POINT > POINT
                        switch (this._topologyRuleType)
                        {
                        default:
                            ok = false;
                            break;
                        }
                        break;

                    case esriGeometryType.esriGeometryPolyline:
                        // POINT > POLYLINE
                        switch (this._topologyRuleType)
                        {
                        case esriTopologyRuleType.esriTRTPointCoveredByLine:
                        case esriTopologyRuleType.esriTRTPointCoveredByLineEndpoint:
                            ok = true;
                            break;

                        default:
                            ok = false;
                            break;
                        }
                        break;

                    case esriGeometryType.esriGeometryPolygon:
                        // POINT > POLYGON
                        switch (this._topologyRuleType)
                        {
                        case esriTopologyRuleType.esriTRTPointCoveredByAreaBoundary:
                        case esriTopologyRuleType.esriTRTPointProperlyInsideArea:
                            ok = true;
                            break;

                        default:
                            ok = false;
                            break;
                        }
                        break;
                    }
                    break;

                case esriGeometryType.esriGeometryPolyline:
                    switch (featureClassDest.ShapeType)
                    {
                    case esriGeometryType.esriGeometryPoint:
                        // POLYLINE > POINT
                        switch (this._topologyRuleType)
                        {
                        case esriTopologyRuleType.esriTRTLineEndpointCoveredByPoint:
                            ok = true;
                            break;

                        default:
                            ok = false;
                            break;
                        }
                        break;

                    case esriGeometryType.esriGeometryPolyline:
                        // POLYLINE > POLYLINE
                        switch (this._topologyRuleType)
                        {
                        case esriTopologyRuleType.esriTRTLineNoOverlap:
                        case esriTopologyRuleType.esriTRTLineNoIntersection:
                        case esriTopologyRuleType.esriTRTLineNoDangles:
                        case esriTopologyRuleType.esriTRTLineNoPseudos:
                        case esriTopologyRuleType.esriTRTLineCoveredByLineClass:
                        case esriTopologyRuleType.esriTRTLineNoOverlapLine:
                        case esriTopologyRuleType.esriTRTLineNoSelfOverlap:
                        case esriTopologyRuleType.esriTRTLineNoSelfIntersect:
                        case esriTopologyRuleType.esriTRTLineNoIntersectOrInteriorTouch:
                        case esriTopologyRuleType.esriTRTLineNoMultipart:
                            ok = true;
                            break;

                        default:
                            ok = false;
                            break;
                        }
                        break;

                    case esriGeometryType.esriGeometryPolygon:
                        // POLYLINE > POLYGON
                        switch (this._topologyRuleType)
                        {
                        case esriTopologyRuleType.esriTRTLineCoveredByAreaBoundary:
                            ok = true;
                            break;

                        default:
                            ok = false;
                            break;
                        }
                        break;
                    }
                    break;

                case esriGeometryType.esriGeometryPolygon:
                    switch (featureClassDest.ShapeType)
                    {
                    case esriGeometryType.esriGeometryPoint:
                        // POLYGON > POINT
                        switch (this._topologyRuleType)
                        {
                        case esriTopologyRuleType.esriTRTAreaContainPoint:
                            ok = true;
                            break;

                        default:
                            ok = false;
                            break;
                        }
                        break;

                    case esriGeometryType.esriGeometryPolyline:
                        // POLYGON > POLYLINE
                        switch (this._topologyRuleType)
                        {
                        case esriTopologyRuleType.esriTRTAreaBoundaryCoveredByLine:
                            ok = true;
                            break;

                        default:
                            ok = false;
                            break;
                        }
                        break;

                    case esriGeometryType.esriGeometryPolygon:
                        // POLYGON > POLYGON
                        switch (this._topologyRuleType)
                        {
                        case esriTopologyRuleType.esriTRTAreaNoGaps:
                        case esriTopologyRuleType.esriTRTAreaNoOverlap:
                        case esriTopologyRuleType.esriTRTAreaCoveredByAreaClass:
                        case esriTopologyRuleType.esriTRTAreaAreaCoverEachOther:
                        case esriTopologyRuleType.esriTRTAreaCoveredByArea:
                        case esriTopologyRuleType.esriTRTAreaNoOverlapArea:
                        case esriTopologyRuleType.esriTRTAreaBoundaryCoveredByAreaBoundary:
                            ok = true;
                            break;

                        default:
                            ok = false;
                            break;
                        }
                        break;
                    }
                    break;
                }
            }
            if (!ok)
            {
                list.Add(new ErrorObject(this, table, "This rule cannot be added between these FeatureClass geometric types", ErrorType.Error));
            }
        }
        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);
        }
        public override void Errors(List <Error> list)
        {
            // Field Name Null or Empty
            if (string.IsNullOrEmpty(this._fieldName))
            {
                list.Add(new ErrorTableRow(this, "Subtype Field names cannot be empty", ErrorType.Error));
            }

            // Get DiagrammerEnvironment Singleton
            DiagrammerEnvironment diagrammerEnvironment = DiagrammerEnvironment.Default;
            SchemaModel           schemaModel           = diagrammerEnvironment.SchemaModel;

            // Get Subtype
            Subtype subtype = (Subtype)this.Table;

            // Get ObjectClass
            ObjectClass objectClass = subtype.GetParent();

            if (objectClass == null)
            {
                // This error is handled by the Subtype class
                return;
            }

            // Get Field
            Field field = objectClass.FindField(this._fieldName);

            if (field == null)
            {
                // Field is missing in parent ObjectClass
                string message = string.Format("The subtype field [{0}] does not exist in the parent objectclass", this._fieldName);
                list.Add(new ErrorTableRow(this, message, ErrorType.Error));
                return;
            }

            // Warning if parent default value and domain are identical
            if (this._defaultValue == field.DefaultValue &&
                this._domainName == field.Domain)
            {
                string message = string.Format("The default values and domain for the subtype field [{0}] are identical to those in the parent objectclass", this._fieldName);
                list.Add(new ErrorTableRow(this, message, ErrorType.Warning));
            }

            // Field can only be small int, long in, single, double, text, date, guid
            switch (field.FieldType)
            {
            case esriFieldType.esriFieldTypeDate:
            case esriFieldType.esriFieldTypeDouble:
            case esriFieldType.esriFieldTypeGUID:
            case esriFieldType.esriFieldTypeInteger:
            case esriFieldType.esriFieldTypeSingle:
            case esriFieldType.esriFieldTypeSmallInteger:
            case esriFieldType.esriFieldTypeString:
                // OK
                break;

            case esriFieldType.esriFieldTypeRaster:
            case esriFieldType.esriFieldTypeBlob:
            case esriFieldType.esriFieldTypeGeometry:
            case esriFieldType.esriFieldTypeOID:
            case esriFieldType.esriFieldTypeGlobalID:
            case esriFieldType.esriFieldTypeXML:
                string message = string.Format("The subtype field [{0}] must use a field of type Date, Double, Guid, Integer, Single, SmallInteger or String", this._fieldName);
                list.Add(new ErrorTableRow(this, message, ErrorType.Error));
                break;
            }

            // Find Domain
            if (!string.IsNullOrEmpty(this._domainName))
            {
                // Get Domain
                Domain domain = schemaModel.FindDomain(this._domainName);

                if (domain == null)
                {
                    // Domain does not exit
                    string message = string.Format("The domain [{0}] for field [{1}] does not exist", this._domainName, field.Name);
                    list.Add(new ErrorTableRow(this, message, ErrorType.Error));
                }
                else
                {
                    // Compare domain and field types
                    if (field.FieldType != domain.FieldType)
                    {
                        string message = string.Format("The field [{0}] and assigned domain [{1}] do not have matching field types.", field.Name, this._domainName);
                        list.Add(new ErrorTableRow(this, message, ErrorType.Error));
                    }

                    // Check Default Value (
                    if (!string.IsNullOrEmpty(this._defaultValue))
                    {
                        string message = null;
                        if (!domain.IsValid(this._defaultValue, out message))
                        {
                            list.Add(new ErrorTableRow(this, message, ErrorType.Warning));
                        }
                    }

                    // Check if a domain value is too long for the text field
                    if (field.FieldType == esriFieldType.esriFieldTypeString &&
                        domain.FieldType == esriFieldType.esriFieldTypeString &&
                        domain.GetType() == typeof(DomainCodedValue))
                    {
                        DomainCodedValue domain2 = (DomainCodedValue)domain;
                        foreach (DomainCodedValueRow x in domain2.CodedValues)
                        {
                            if (string.IsNullOrEmpty(x.Code))
                            {
                                continue;
                            }
                            if (x.Code.Length > field.Length)
                            {
                                string message = string.Format("The domain [{0}] has a value [{1}] that is too long for the field [{2}]", this._domainName, x, this._fieldName);
                                list.Add(new ErrorTableRow(this, message, ErrorType.Error));
                            }
                        }
                    }
                }
            }

            // Check validity of default value against field type
            if (!string.IsNullOrEmpty(this._defaultValue))
            {
                string message;
                if (!GeodatabaseUtility.IsValidateValue(field.FieldType, this._defaultValue, out message))
                {
                    string message2 = string.Format("Default value [{0}] {1}", this._defaultValue, message);
                    list.Add(new ErrorTableRow(this, message2, ErrorType.Error));
                }
            }

            //
            if (!string.IsNullOrEmpty(this._defaultValue))
            {
                if (!string.IsNullOrEmpty(this._domainName))
                {
                    if (!string.IsNullOrEmpty(field.Domain))
                    {
                        if (this._domainName != field.Domain)
                        {
                            Domain domain2 = schemaModel.FindDomain(field.Domain);
                            string message = null;
                            if (!domain2.IsValid(this._defaultValue, out message))
                            {
                                string message2 = string.Format("NIM013605: Field [{0}] - {1}", this._fieldName, message);
                                list.Add(new ErrorTableRow(this, message2, ErrorType.Error));
                            }
                        }
                    }
                }
            }
        }
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            if (context == null)
            {
                return(null);
            }
            if (context.Instance == null)
            {
                return(null);
            }

            if (value.GetType() == typeof(string))
            {
                string text = Convert.ToString(value);

                if (context.PropertyDescriptor.ComponentType == typeof(RelationshipClass))
                {
                    switch (context.PropertyDescriptor.Name)
                    {
                    case "OriginClassName":
                    case "DestinationClassName":
                        if (text == string.Empty ||
                            text == Resources.TEXT_NONE_BR)
                        {
                            return(string.Empty);
                        }
                        return(text);
                    }
                }
                else if (context.PropertyDescriptor.ComponentType == typeof(EdgeConnectivityRule))
                {
                    switch (context.PropertyDescriptor.Name)
                    {
                    case "DefaultJunctionID":
                    case "FromClassID":
                    case "ToClassID":
                        if (text == string.Empty ||
                            text == Resources.TEXT_NONE_BR)
                        {
                            return(-1);
                        }
                        DiagrammerEnvironment de          = DiagrammerEnvironment.Default;
                        SchemaModel           model       = de.SchemaModel;
                        ObjectClass           objectClass = model.FindObjectClass(text);
                        if (objectClass == null)
                        {
                            return(-1);
                        }
                        return(objectClass.DSID);
                    }
                }
                else if (context.PropertyDescriptor.ComponentType == typeof(JunctionSubtype))
                {
                    switch (context.PropertyDescriptor.Name)
                    {
                    case "ClassID":
                        if (text == string.Empty ||
                            text == Resources.TEXT_NONE_BR)
                        {
                            return(-1);
                        }
                        DiagrammerEnvironment de          = DiagrammerEnvironment.Default;
                        SchemaModel           model       = de.SchemaModel;
                        ObjectClass           objectClass = model.FindObjectClass(text);
                        if (objectClass == null)
                        {
                            return(-1);
                        }
                        return(objectClass.DSID);
                    }
                }
                else if (context.PropertyDescriptor.ComponentType == typeof(RelationshipRule))
                {
                    switch (context.PropertyDescriptor.Name)
                    {
                    case "OriginClass":
                    case "DestinationClass":
                        if (text == string.Empty ||
                            text == Resources.TEXT_NONE_BR)
                        {
                            return(-1);
                        }
                        DiagrammerEnvironment de          = DiagrammerEnvironment.Default;
                        SchemaModel           model       = de.SchemaModel;
                        ObjectClass           objectClass = model.FindObjectClass(text);
                        if (objectClass == null)
                        {
                            return(-1);
                        }
                        return(objectClass.DSID);
                    }
                }
                else if (context.PropertyDescriptor.ComponentType == typeof(JunctionConnectivityRule))
                {
                    switch (context.PropertyDescriptor.Name)
                    {
                    case "EdgeClassID":
                    case "JunctionClassID":
                        if (text == string.Empty ||
                            text == Resources.TEXT_NONE_BR)
                        {
                            return(-1);
                        }
                        DiagrammerEnvironment de          = DiagrammerEnvironment.Default;
                        SchemaModel           model       = de.SchemaModel;
                        ObjectClass           objectClass = model.FindObjectClass(text);
                        if (objectClass == null)
                        {
                            return(-1);
                        }
                        return(objectClass.DSID);
                    }
                }
                else if (context.PropertyDescriptor.ComponentType == typeof(TopologyRule))
                {
                    switch (context.PropertyDescriptor.Name)
                    {
                    case "OriginClassId":
                    case "DestinationClassId":
                        if (text == string.Empty ||
                            text == Resources.TEXT_NONE_BR)
                        {
                            return(-1);
                        }
                        DiagrammerEnvironment de          = DiagrammerEnvironment.Default;
                        SchemaModel           model       = de.SchemaModel;
                        ObjectClass           objectClass = model.FindObjectClass(text);
                        if (objectClass == null)
                        {
                            return(-1);
                        }
                        return(objectClass.DSID);
                    }
                }
                else if (context.PropertyDescriptor.ComponentType == typeof(NetWeightAssociation))
                {
                    switch (context.PropertyDescriptor.Name)
                    {
                    case "TableName":
                        if (text == string.Empty ||
                            text == Resources.TEXT_NONE_BR)
                        {
                            return(string.Empty);
                        }
                        return(text);
                    }
                }
                else if (context.PropertyDescriptor.ComponentType == typeof(TerrainDataSource))
                {
                    switch (context.PropertyDescriptor.Name)
                    {
                    case "FeatureClassName":
                        if (text == string.Empty ||
                            text == Resources.TEXT_NONE_BR)
                        {
                            return(string.Empty);
                        }
                        return(text);
                    }
                }
            }

            return(base.ConvertFrom(context, culture, value));
        }
        private ObjectClass GetObjectClass(ITypeDescriptorContext context)
        {
            DiagrammerEnvironment de          = DiagrammerEnvironment.Default;
            SchemaModel           model       = de.SchemaModel;
            ObjectClass           objectClass = null;

            if (context.PropertyDescriptor.ComponentType == typeof(EdgeConnectivityRule))
            {
                EdgeConnectivityRule edgeConnectivityRule = (EdgeConnectivityRule)context.Instance;
                switch (context.PropertyDescriptor.Name)
                {
                case "FromEdgeSubtypeCode":
                    objectClass = model.FindObjectClass(edgeConnectivityRule.FromClassID);
                    break;

                case "ToEdgeSubtypeCode":
                    objectClass = model.FindObjectClass(edgeConnectivityRule.ToClassID);
                    break;

                case "DefaultJunctionSubtypeCode":
                    objectClass = model.FindObjectClass(edgeConnectivityRule.DefaultJunctionID);
                    break;
                }
            }
            else if (context.PropertyDescriptor.ComponentType == typeof(JunctionSubtype))
            {
                JunctionSubtype junctionSubtype = (JunctionSubtype)context.Instance;
                switch (context.PropertyDescriptor.Name)
                {
                case "SubtypeCode":
                    objectClass = model.FindObjectClass(junctionSubtype.ClassID);
                    break;
                }
            }
            else if (context.PropertyDescriptor.ComponentType == typeof(RelationshipRule))
            {
                RelationshipRule relationshipRule = (RelationshipRule)context.Instance;
                switch (context.PropertyDescriptor.Name)
                {
                case "OriginSubtype":
                    objectClass = model.FindObjectClass(relationshipRule.OriginClass);
                    break;

                case "DestinationSubtype":
                    objectClass = model.FindObjectClass(relationshipRule.DestinationClass);
                    break;
                }
            }
            else if (context.PropertyDescriptor.ComponentType == typeof(JunctionConnectivityRule))
            {
                JunctionConnectivityRule junctionConnectivityRule = (JunctionConnectivityRule)context.Instance;
                switch (context.PropertyDescriptor.Name)
                {
                case "EdgeSubtypeCode":
                    objectClass = model.FindObjectClass(junctionConnectivityRule.EdgeClassID);
                    break;

                case "SubtypeCode":
                    objectClass = model.FindObjectClass(junctionConnectivityRule.JunctionClassID);
                    break;
                }
            }
            else if (context.PropertyDescriptor.ComponentType == typeof(TopologyRule))
            {
                TopologyRule topologyRule = (TopologyRule)context.Instance;
                switch (context.PropertyDescriptor.Name)
                {
                case "OriginSubtype":
                    objectClass = model.FindObjectClass(topologyRule.OriginClassId);
                    break;

                case "DestinationSubtype":
                    objectClass = model.FindObjectClass(topologyRule.DestinationClassId);
                    break;
                }
            }
            return(objectClass);
        }
        private void RefreshErrorList()
        {
            // Clear Rows and Columns
            this.listViewErrorList.Clear();

            // Clear Groups
            this.listViewErrorList.Groups.Clear();

            // Begin Update
            this.listViewErrorList.BeginUpdate();

            // Create Groups
            ListViewGroup listViewGroupError   = null;
            ListViewGroup listViewGroupWarning = null;

            // Add Groups
            if (this.buttonItemErrors.Checked)
            {
                listViewGroupError = new ListViewGroup(Resources.TEXT_ERRORS, HorizontalAlignment.Left);
                this.listViewErrorList.Groups.Add(listViewGroupError);
            }
            if (this.buttonItemWarnings.Checked)
            {
                listViewGroupWarning = new ListViewGroup(Resources.TEXT_WARNINGS, HorizontalAlignment.Left);
                this.listViewErrorList.Groups.Add(listViewGroupWarning);
            }

            // Counters
            int errors   = 0;
            int warnings = 0;
            int counter  = 0;

            // Add Columns
            ColumnHeader columnDescription = this.listViewErrorList.Columns.Add(Resources.TEXT_DESCRIPTION);

            // Get DiagramEnvironment Singleton
            DiagrammerEnvironment diagrammerEnvironment = DiagrammerEnvironment.Default;

            // Add Errors
            foreach (Error error in this.m_errors)
            {
                // Exit if Error Type is not selected. But increment counter.
                switch (error.ErrorType)
                {
                case ErrorType.Error:
                    errors++;
                    if (!this.buttonItemErrors.Checked)
                    {
                        continue;
                    }
                    break;

                case ErrorType.Warning:
                    warnings++;
                    if (!this.buttonItemWarnings.Checked)
                    {
                        continue;
                    }
                    break;

                default:
                    continue;
                }

                // Increment Counter
                counter++;

                // Display Error Loading Message
                string message = string.Format("Loading Error {0} of {1}", counter.ToString(), this.m_errors.Count.ToString());
                diagrammerEnvironment.OnProgressChanged(new ProgressEventArgs(message));

                // Create  New ListViewItem
                ListViewItemError listViewItemError = new ListViewItemError();

                // Store Error
                listViewItemError.Error = error;

                // Set Item Text
                listViewItemError.Text = error.Description;

                // Set Item Tooltip
                listViewItemError.ToolTipText = error.Description;

                // Set ListViewItem Group
                switch (error.ErrorType)
                {
                case ErrorType.Error:
                    listViewItemError.Group    = listViewGroupError;
                    listViewItemError.ImageKey = ErrorListDiagram.ERRORS_ITEM;
                    break;

                case ErrorType.Warning:
                    listViewItemError.Group    = listViewGroupWarning;
                    listViewItemError.ImageKey = ErrorListDiagram.WARNINGS_ITEM;
                    break;
                }

                // Add to ListView
                this.listViewErrorList.Items.Add(listViewItemError);
            }

            // Update Error Count in Toolbar Button
            this.buttonItemErrors.Text   = string.Format(Resources.TEXT_ERRORS_, errors.ToString());
            this.buttonItemWarnings.Text = string.Format(Resources.TEXT_WARNINGS_, warnings.ToString());

            // Adjust column widths to size of longest entry
            foreach (ColumnHeader column in this.listViewErrorList.Columns)
            {
                column.Width = -2;
            }

            // End Update
            this.listViewErrorList.EndUpdate();

            // Clear Messages
            diagrammerEnvironment.OnProgressChanged(new ProgressEventArgs(string.Empty));
        }
        private void CollectionForm_Closing(object sender, CancelEventArgs e)
        {
            // Get Collection Form
            CollectionForm collectionForm = (CollectionForm)sender;

            // Get edited collection object
            object editValue = collectionForm.EditValue;

            // Check if collection edits have been OK'ed or Canceled
            DialogResult dialogResult = collectionForm.DialogResult;

            switch (dialogResult)
            {
            case DialogResult.OK:
                // Get Schema Model
                DiagrammerEnvironment d           = DiagrammerEnvironment.Default;
                SchemaModel           schemaModel = d.SchemaModel;

                // Suspect Model Draws
                schemaModel.Suspend();

                // Get TableItems Collection
                TableItems tableItems = (TableItems)editValue;

                // Store items in new List
                List <TableItem> list = new List <TableItem>();
                foreach (TableItem tableItem in tableItems)
                {
                    list.Add(tableItem);
                }

                // Clear TableItems Collection
                tableItems.Clear();

                // Re-add all items.
                foreach (TableItem tableItem in list)
                {
                    // If the Table property is not set then use TableItems::Add to append the item.
                    // This will ensure that Table, GradientColor, Indent properties are correctly set.
                    // This will also reset the height of the TableItems collection.
                    if (tableItem.Indent == 0f)
                    {
                        tableItems.Add(tableItem);
                    }
                    else
                    {
                        ((IList)tableItems).Add(tableItem);
                    }
                }

                // Refresh Model
                schemaModel.Resume();
                schemaModel.Refresh();

                break;

            case DialogResult.Cancel:
            default:
                // Collection edits are canceled. No need to refresh.
                break;
            }
        }
示例#14
0
        public override void Errors(List <Error> list)
        {
            // Get Model
            DiagrammerEnvironment diagrammerEnvironment = DiagrammerEnvironment.Default;
            SchemaModel           schemaModel           = diagrammerEnvironment.SchemaModel;

            // Domain Name
            if (string.IsNullOrEmpty(this._name))
            {
                // Domain name cannot be null or empty
                list.Add(new ErrorTable(this, "Domain name cannot be empty", ErrorType.Error));
            }
            else
            {
                // Get Validator
                Validator validator = WorkspaceValidator.Default.Validator;

                // Name must not contain invalid characters. Spaces are valid.
                string message = null;
                string name    = this._name.Replace(" ", string.Empty);
                if (validator.ContainsInvalidCharacters(name, out message))
                {
                    list.Add(new ErrorTable(this, message, ErrorType.Error));
                }

                // Domain name must be less thab 255 characters.
                if (this._name.Length > 255)
                {
                    list.Add(new ErrorTable(this, "Domain name is more than 255 characters long", ErrorType.Error));
                }
            }

            // Owner
            if (!string.IsNullOrEmpty(this._owner))
            {
                // Owner must be less than 255 characters.
                if (this._owner.Length > 255)
                {
                    list.Add(new ErrorTable(this, "Owner name is more than 255 characters long", ErrorType.Error));
                }

                // Owner cannot contain spaces.
                if (this._owner.IndexOf(" ") != -1)
                {
                    list.Add(new ErrorTable(this, "Owner name cannot contain spaces", ErrorType.Error));
                }
            }

            // Description must be less than 255 characters.
            if (!string.IsNullOrEmpty(this._description))
            {
                if (this._description.Length > 255)
                {
                    list.Add(new ErrorTable(this, "Description is more than 255 characters long", ErrorType.Error));
                }
            }

            // Is this domain unused?
            if (!string.IsNullOrEmpty(this._name))
            {
                bool used = false;
                List <ObjectClass> objectClasses = schemaModel.GetObjectClasses();
                foreach (ObjectClass objectClass in objectClasses)
                {
                    List <Field> fields = objectClass.GetFields();
                    foreach (Field field in fields)
                    {
                        if (field.Domain == this._name)
                        {
                            used = true;
                            break;
                        }
                    }
                    List <Subtype> subtypes = objectClass.GetSubtypes();
                    foreach (Subtype subtype in subtypes)
                    {
                        List <SubtypeField> subtypeFields = subtype.GetSubtypeFields();
                        foreach (SubtypeField subtypeField in subtypeFields)
                        {
                            if (subtypeField.DomainName == this._name)
                            {
                                used = true;
                                break;
                            }
                        }
                        if (used)
                        {
                            break;
                        }
                    }
                }
                if (!used)
                {
                    string message = string.Format("Domain [{0}] is not used by any Table or FeatureClass", this._name);
                    list.Add(new ErrorTable(this, message, ErrorType.Warning));
                }
            }
        }
        public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            if (context == null)
            {
                return(null);
            }
            if (context.Instance == null)
            {
                return(null);
            }

            // RelationshipClass:        OriginClassName, DestinationClassName
            // EdgeConnectivityRule:     DefaultJunctionID, FromClassID, ToClassID
            // JunctionSubtype:          ClassID
            // RelationshipRule:         OriginClass, DestinationClass
            // JunctionConnectivityRule: EdgeClassID, JunctionClassID
            // TopologyRule:             OriginClassId, DestinationClassId
            // NetWeightAssociation:     TableName
            // TerrainDataSource:        FeatureClassName

            // Get Model
            DiagrammerEnvironment diagrammerEnvironment = DiagrammerEnvironment.Default;

            if (diagrammerEnvironment == null)
            {
                return(null);
            }
            SchemaModel schemaModel = diagrammerEnvironment.SchemaModel;

            if (schemaModel == null)
            {
                return(null);
            }

            // Get ObjectClasses
            List <ObjectClass> objectClasses = schemaModel.GetObjectClasses();

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

            if (context.PropertyDescriptor.ComponentType == typeof(RelationshipClass))
            {
                switch (context.PropertyDescriptor.Name)
                {
                case "OriginClassName":
                case "DestinationClassName":
                    foreach (ObjectClass objectClass in objectClasses)
                    {
                        if (objectClass.GetType() == typeof(ObjectClass) ||
                            objectClass.GetType() == typeof(FeatureClass) ||
                            objectClass.GetType() == typeof(RasterCatalog))
                        {
                            list.Add(objectClass.Name);
                        }
                    }
                    break;
                }
            }
            else if (context.PropertyDescriptor.ComponentType == typeof(EdgeConnectivityRule))
            {
                switch (context.PropertyDescriptor.Name)
                {
                case "DefaultJunctionID":
                    foreach (ObjectClass objectClass in objectClasses)
                    {
                        FeatureClass featureClass = objectClass as FeatureClass;
                        if (featureClass == null)
                        {
                            continue;
                        }
                        switch (featureClass.FeatureType)                  //  (objectClass.CLSID) {
                        {
                        case esriFeatureType.esriFTSimpleJunction:         // EsriRegistry.CLASS_SIMPLEJUNCTION:
                            list.Add(objectClass.Name);
                            break;
                        }
                    }
                    break;

                case "FromClassID":
                case "ToClassID":
                    foreach (ObjectClass objectClass in objectClasses)
                    {
                        FeatureClass featureClass = objectClass as FeatureClass;
                        if (featureClass == null)
                        {
                            continue;
                        }
                        switch (featureClass.FeatureType)               // (objectClass.CLSID) {
                        {
                        case esriFeatureType.esriFTComplexEdge:         // EsriRegistry.CLASS_COMPLEXEDGE:
                        case esriFeatureType.esriFTSimpleEdge:          // EsriRegistry.CLASS_SIMPLEEDGE:
                            list.Add(objectClass.Name);
                            break;
                        }
                    }
                    break;
                }
            }
            else if (context.PropertyDescriptor.ComponentType == typeof(JunctionSubtype))
            {
                switch (context.PropertyDescriptor.Name)
                {
                case "ClassID":
                    foreach (ObjectClass objectClass in objectClasses)
                    {
                        FeatureClass featureClass = objectClass as FeatureClass;
                        if (featureClass == null)
                        {
                            continue;
                        }
                        switch (featureClass.FeatureType)                  // (objectClass.CLSID) {
                        {
                        case esriFeatureType.esriFTSimpleJunction:         // EsriRegistry.CLASS_SIMPLEJUNCTION:
                            list.Add(objectClass.Name);
                            break;
                        }
                    }
                    break;
                }
            }
            else if (context.PropertyDescriptor.ComponentType == typeof(RelationshipRule))
            {
                switch (context.PropertyDescriptor.Name)
                {
                case "OriginClass":
                case "DestinationClass":
                    foreach (ObjectClass objectClass in objectClasses)
                    {
                        if (objectClass.GetType() == typeof(ObjectClass) ||
                            objectClass.GetType() == typeof(FeatureClass))
                        {
                            list.Add(objectClass.Name);
                        }
                    }
                    break;
                }
            }
            else if (context.PropertyDescriptor.ComponentType == typeof(JunctionConnectivityRule))
            {
                switch (context.PropertyDescriptor.Name)
                {
                case "EdgeClassID":
                    foreach (ObjectClass objectClass in objectClasses)
                    {
                        FeatureClass featureClass = objectClass as FeatureClass;
                        if (featureClass == null)
                        {
                            continue;
                        }
                        switch (featureClass.FeatureType)               // (objectClass.CLSID) {
                        {
                        case esriFeatureType.esriFTComplexEdge:         // EsriRegistry.CLASS_COMPLEXEDGE:
                        case esriFeatureType.esriFTSimpleEdge:          // EsriRegistry.CLASS_SIMPLEEDGE:
                            list.Add(objectClass.Name);
                            break;
                        }
                    }
                    break;

                case "JunctionClassID":
                    foreach (ObjectClass objectClass in objectClasses)
                    {
                        FeatureClass featureClass = objectClass as FeatureClass;
                        if (featureClass == null)
                        {
                            continue;
                        }
                        switch (featureClass.FeatureType)                  // (objectClass.CLSID) {
                        {
                        case esriFeatureType.esriFTSimpleJunction:         // EsriRegistry.CLASS_SIMPLEJUNCTION:
                            list.Add(objectClass.Name);
                            break;
                        }
                    }
                    break;
                }
            }
            else if (context.PropertyDescriptor.ComponentType == typeof(TopologyRule))
            {
                switch (context.PropertyDescriptor.Name)
                {
                case "OriginClassId":
                case "DestinationClassId":
                    foreach (ObjectClass objectClass in objectClasses)
                    {
                        if (objectClass.GetType() == typeof(FeatureClass))
                        {
                            list.Add(objectClass.Name);
                        }
                    }
                    break;
                }
            }
            else if (context.PropertyDescriptor.ComponentType == typeof(NetWeightAssociation))
            {
                switch (context.PropertyDescriptor.Name)
                {
                case "TableName":
                    foreach (ObjectClass objectClass in objectClasses)
                    {
                        FeatureClass featureClass = objectClass as FeatureClass;
                        if (featureClass == null)
                        {
                            continue;
                        }
                        switch (featureClass.FeatureType)                  // (objectClass.CLSID) {
                        {
                        case esriFeatureType.esriFTComplexEdge:            // EsriRegistry.CLASS_COMPLEXEDGE:
                        case esriFeatureType.esriFTSimpleEdge:             // EsriRegistry.CLASS_SIMPLEEDGE:
                        case esriFeatureType.esriFTSimpleJunction:         // EsriRegistry.CLASS_SIMPLEJUNCTION:
                            list.Add(objectClass.Name);
                            break;
                        }
                    }
                    break;
                }
            }
            else if (context.PropertyDescriptor.ComponentType == typeof(TerrainDataSource))
            {
                switch (context.PropertyDescriptor.Name)
                {
                case "FeatureClassName":
                    TerrainDataSource terrainDataSource = (TerrainDataSource)context.Instance;
                    SchemaModel       model             = DiagrammerEnvironment.Default.SchemaModel;
                    if (model == null)
                    {
                        break;
                    }
                    Terrain        terrain        = model.FindParent(terrainDataSource);
                    FeatureDataset featureDataset = terrain.GetParent() as FeatureDataset;
                    if (featureDataset == null)
                    {
                        break;
                    }
                    foreach (Dataset dataset in featureDataset.GetChildren())
                    {
                        if (dataset.DatasetType == esriDatasetType.esriDTFeatureClass)
                        {
                            list.Add(dataset.Name);
                        }
                    }
                    break;
                }
            }

            // Sort List
            list.Sort();
            list.Insert(0, Resources.TEXT_NONE_BR);

            // Return List
            StandardValuesCollection svc = new StandardValuesCollection(list);

            return(svc);
        }
        public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            if (context == null)
            {
                return(null);
            }
            if (context.Instance == null)
            {
                return(null);
            }

            // Get Model
            DiagrammerEnvironment de = DiagrammerEnvironment.Default;

            if (de == null)
            {
                return(null);
            }
            SchemaModel model = de.SchemaModel;

            if (model == null)
            {
                return(null);
            }

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

            // In some cases do not display list of subtypes
            bool skip = false;

            if (context.PropertyDescriptor.ComponentType == typeof(TopologyRule))
            {
                // If "All Subtypes" then do not show dropdown
                TopologyRule topologyRule = (TopologyRule)context.Instance;
                switch (context.PropertyDescriptor.Name)
                {
                case "OriginSubtype":
                    skip = topologyRule.AllOriginSubtypes;
                    break;

                case "DestinationSubtype":
                    skip = topologyRule.AllDestinationSubtypes;
                    break;
                }
            }

            //
            if (!skip)
            {
                ObjectClass objectClass = this.GetObjectClass(context);
                if (objectClass != null)
                {
                    List <Subtype> subtypes = objectClass.GetSubtypes();
                    foreach (Subtype subtype in subtypes)
                    {
                        list.Add(subtype.SubtypeName);
                    }
                    if (subtypes.Count == 0)
                    {
                        list.Add(Resources.TEXT_CLASS_BR);
                    }
                }
            }

            // Sort List
            list.Sort();
            list.Insert(0, Resources.TEXT_NONE_BR);

            // Return List
            StandardValuesCollection svc = new StandardValuesCollection(list);

            return(svc);
        }
示例#17
0
        //
        // PRIVATE METHODS
        //
        private void CreateReport()
        {
            // Exit if Workspace is NULL
            if (this._workspaceDocument == null)
            {
                return;
            }

            //
            DiagrammerEnvironment diagrammerEnvironment = DiagrammerEnvironment.Default;

            diagrammerEnvironment.OnProgressChanged(new ProgressEventArgs("Creating Report"));

            // Get Temporary File
            string filename = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("N").ToUpper() + ".xml");

            // Specific XML Settings
            XmlWriterSettings writerSettings = new XmlWriterSettings();

            writerSettings.Encoding            = Encoding.Default;
            writerSettings.Indent              = false;
            writerSettings.NewLineHandling     = NewLineHandling.Entitize;
            writerSettings.OmitXmlDeclaration  = true;
            writerSettings.NewLineOnAttributes = false;

            // Create the XmlWriter object and write some content.
            this._writer = XmlWriter.Create(filename, writerSettings);

            // <DataReport>
            this._writer.WriteStartElement("XmlReport");

            // Get ESRI Namespace
            XPathDocument  document      = new XPathDocument(this._workspaceDocument, XmlSpace.None);
            XPathNavigator navigator     = document.CreateNavigator();
            bool           ok            = navigator.MoveToFirstChild();
            string         esriNamespace = navigator.LookupNamespace("esri");

            // Open Geodatabase Schema Document
            XmlDocument schemaDocument = new XmlDocument();

            schemaDocument.LoadXml(Resources.FILE_GEODATABASE_EXCHANGE);

            // Add Namespaces to Schema Document
            XPathNavigator navigator2 = schemaDocument.CreateNavigator();
            bool           ok2        = navigator2.MoveToFirstChild();
            XmlWriter      writer     = navigator2.CreateAttributes();

            writer.WriteAttributeString("xmlns", esriNamespace);
            writer.WriteAttributeString("targetNamespace", esriNamespace);
            writer.Close();

            // Load Schema Document
            StringReader  stringReader  = new StringReader(schemaDocument.OuterXml);
            XmlTextReader xmlTextReader = new XmlTextReader(stringReader);

            // Create XML Reader Settings
            XmlReaderSettings readerSettings = new XmlReaderSettings();

            readerSettings.Schemas.Add(null, xmlTextReader);
            readerSettings.Schemas.Compile();
            readerSettings.CheckCharacters         = true;
            readerSettings.IgnoreComments          = true;
            readerSettings.IgnoreWhitespace        = true;
            readerSettings.ValidationType          = ValidationType.Schema;
            readerSettings.XmlResolver             = new XmlUrlResolver();
            readerSettings.ValidationFlags        |= XmlSchemaValidationFlags.ReportValidationWarnings;
            readerSettings.ValidationEventHandler += new ValidationEventHandler(this.ValidationEventHandler);

            // Load Source XML
            XmlTextReader txtreader = new XmlTextReader(this._workspaceDocument);

            // Validate Against XSL
            XmlReader reader = XmlReader.Create(txtreader, readerSettings);

            while (reader.Read())
            {
                ;
            }

            // Close Readers
            xmlTextReader.Close();
            stringReader.Close();
            txtreader.Close();
            reader.Close();

            // </DataReport>
            this._writer.WriteEndElement();

            // Close Writer
            this._writer.Close();

            // Set Source XML
            this.Xml = filename;

            // Fire Invalidate Event so that the Report Tabbed Document can Reload
            this.OnInvalidated(new EventArgs());

            // Clear Messages
            diagrammerEnvironment.OnProgressChanged(new ProgressEventArgs(string.Empty));
        }