//
        // PUBLIC METHODS
        //
        public override void OpenModel()
        {
            // Exit if invalid
            if (this._terrain == null)
            {
                return;
            }

            // Suspend Model
            if (ModelSettings.Default.EnableUndoRedo)
            {
                this.UndoList.Suspend();
            }
            this.Suspend();
            this.SuspendEvents = true;

            // Add GeometricNetwork Shape
            EsriShape <Terrain> shapeTerrain = new EsriShape <Terrain>(this._terrain);

            this.Shapes.Add(this.Shapes.CreateKey(), shapeTerrain);

            // Get Parent FeatureDataset
            Dataset parent = this._terrain.GetParent();

            if (parent != null)
            {
                FeatureDataset featureDataset = parent as FeatureDataset;
                if (featureDataset != null)
                {
                    // Add FeatureDataset Shape
                    EsriShape <FeatureDataset> shapeFeatureDataset = new EsriShape <FeatureDataset>(featureDataset);
                    this.Shapes.Add(this.Shapes.CreateKey(), shapeFeatureDataset);

                    // Add all Child FeatureClasses
                    foreach (Dataset dataset in featureDataset.GetChildren())
                    {
                        if (dataset.GetType() == typeof(FeatureClass))
                        {
                            // Add FetaureClass Shape
                            FeatureClass             featureClass      = (FeatureClass)dataset;
                            EsriShape <FeatureClass> shapeFeatureClass = new EsriShape <FeatureClass>(featureClass);
                            this.Shapes.Add(this.Shapes.CreateKey(), shapeFeatureClass);

                            // Add Link
                            Arrow arrow = new Arrow();
                            arrow.BorderColor    = ModelSettings.Default.DisabledLined;
                            arrow.DrawBackground = false;
                            Line line = new Line(shapeFeatureClass, shapeFeatureDataset);
                            line.BorderColor     = ModelSettings.Default.DisabledLined;
                            line.End.AllowMove   = false;
                            line.Start.Marker    = arrow;
                            line.Start.AllowMove = false;
                            this.Lines.Add(this.Lines.CreateKey(), line);

                            foreach (TerrainDataSource terrainDataSource in this._terrain.TerrainDataSources)
                            {
                                if (terrainDataSource.FeatureClassName == dataset.Name)
                                {
                                    EsriLine <TerrainDataSource> line2 = new EsriLine <TerrainDataSource>(terrainDataSource, shapeTerrain, shapeFeatureClass);
                                    this.Lines.Add(this.Lines.CreateKey(), line2);
                                    break;
                                }
                            }
                        }
                    }
                }
            }

            // Perform Layout
            this.ExecuteLayout(typeof(HierarchicalLayout), true);

            // Resume and Refresh Model
            this.SuspendEvents = false;
            this.Resume();
            if (ModelSettings.Default.EnableUndoRedo)
            {
                this.UndoList.Resume();
            }
            this.Refresh();
        }
Beispiel #2
0
        //
        // PROTECTED
        //
        protected override void WriteInnerXml(XmlWriter writer)
        {
            // Write Base Xml
            base.WriteInnerXml(writer);

            // <Extent></Extent>
            if (this._extent != null)
            {
                this._extent.WriteXml(writer);
            }

            // <SpatialReference></SpatialReference>
            if (this._spatialReference != null)
            {
                this._spatialReference.WriteXml(writer);
            }

            // <ClusterTolerance></ClusterTolerance>
            writer.WriteStartElement(Xml.CLUSTERTOLERANCE);
            writer.WriteValue(this._clusterTolerance);
            writer.WriteEndElement();

            // <ZClusterTolerance></ZClusterTolerance>
            writer.WriteStartElement(Xml.ZCLUSTERTOLERANCE);
            writer.WriteValue(this._zClusterTolerance);
            writer.WriteEndElement();

            // <MaxGeneratedErrorCount></MaxGeneratedErrorCount>
            writer.WriteStartElement(Xml.MAXGENERATEDERRORCOUNT);
            writer.WriteValue(this._maxGeneratedErrorCount);
            writer.WriteEndElement();

            // <FeatureClassNames>
            writer.WriteStartElement(Xml.FEATURECLASSNAMES);
            writer.WriteAttributeString(Xml._XSI, Xml._TYPE, null, Xml._NAMES);

            Dataset dataset = this.GetParent();

            if (dataset != null)
            {
                if (dataset.GetType() == typeof(FeatureDataset))
                {
                    FeatureDataset featureDataset = (FeatureDataset)dataset;
                    List <Dataset> datasets       = featureDataset.GetChildren();
                    foreach (Dataset dataset2 in datasets)
                    {
                        if (dataset2.GetType() == typeof(FeatureClass))
                        {
                            FeatureClass featureClass = (FeatureClass)dataset2;
                            List <ControllerMembership> controllers = featureClass.ControllerMemberships;
                            foreach (ControllerMembership controller in controllers)
                            {
                                if (controller is TopologyControllerMembership)
                                {
                                    TopologyControllerMembership topologyControllerMembership = (TopologyControllerMembership)controller;
                                    if (topologyControllerMembership.TopologyName == this.Name)
                                    {
                                        // <Name></Name>
                                        writer.WriteStartElement(Xml.NAME);
                                        writer.WriteValue(featureClass.Name);
                                        writer.WriteEndElement();
                                    }
                                }
                            }
                        }
                    }
                }
            }

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

            // <TopologyRules>
            writer.WriteStartElement(Xml.TOPOLOGYRULES);
            writer.WriteAttributeString(Xml._XSI, Xml._TYPE, null, Xml._ARRAYOFTOPOLOGYRULE);

            // <TopologyRule></TopologyRule>
            foreach (TopologyRule topologyRule in this._topologyRules)
            {
                topologyRule.WriteXml(writer);
            }

            // </TopologyRules>
            writer.WriteEndElement();
        }
        //
        // PUBLIC METHODS
        //
        public override void OpenModel()
        {
            // Exit if invalid
            if (this._geometricNetwork == null)
            {
                return;
            }

            // Suspend Model
            if (ModelSettings.Default.EnableUndoRedo)
            {
                base.UndoList.Suspend();
            }
            base.Suspend();
            base.SuspendEvents = true;

            // Add GeometricNetwork Shape
            EsriShape <GeometricNetwork> shapeGN = new EsriShape <GeometricNetwork>(this._geometricNetwork);

            base.Shapes.Add(base.Shapes.CreateKey(), shapeGN);

            // Get Parent FeatureDataset
            Dataset parent = this._geometricNetwork.GetParent();

            if (parent == null)
            {
                return;
            }
            FeatureDataset featureDataset = parent as FeatureDataset;

            if (featureDataset == null)
            {
                return;
            }

            // Add FeatureDataset Shape
            EsriShape <FeatureDataset> shapeFD = new EsriShape <FeatureDataset>(featureDataset);

            base.Shapes.Add(base.Shapes.CreateKey(), shapeFD);

            // Add all Child FeatureClasses
            foreach (Dataset dataset in featureDataset.GetChildren())
            {
                if (dataset.GetType() == typeof(FeatureClass))
                {
                    // Add FetaureClass Shape
                    FeatureClass             featureClass = (FeatureClass)dataset;
                    EsriShape <FeatureClass> shapeFC      = new EsriShape <FeatureClass>(featureClass);
                    base.Shapes.Add(base.Shapes.CreateKey(), shapeFC);

                    // Add Link
                    Arrow arrow = new Arrow();
                    arrow.BorderColor    = ModelSettings.Default.DisabledLined;
                    arrow.DrawBackground = false;
                    Line line = new Line(shapeFC, shapeFD);
                    line.BorderColor     = ModelSettings.Default.DisabledLined;
                    line.End.AllowMove   = false;
                    line.Start.Marker    = arrow;
                    line.Start.AllowMove = false;
                    base.Lines.Add(base.Lines.CreateKey(), line);

                    foreach (ControllerMembership controllerMembership in featureClass.ControllerMemberships)
                    {
                        if (controllerMembership is GeometricNetworkControllerMembership)
                        {
                            GeometricNetworkControllerMembership geometricNetworkControllerMembership = (GeometricNetworkControllerMembership)controllerMembership;
                            if (geometricNetworkControllerMembership.GeometricNetworkName == this._geometricNetwork.Name)
                            {
                                EsriLine <GeometricNetworkControllerMembership> line2 = new EsriLine <GeometricNetworkControllerMembership>(geometricNetworkControllerMembership, shapeGN, shapeFC);
                                base.Lines.Add(base.Lines.CreateKey(), line2);
                            }
                        }
                    }
                }
            }

            // Perform Layout
            base.ExecuteLayout(typeof(HierarchicalLayout), true);

            // Resume and Refresh Model
            base.SuspendEvents = false;
            base.Resume();
            if (ModelSettings.Default.EnableUndoRedo)
            {
                base.UndoList.Resume();
            }
            base.Refresh();
        }
Beispiel #4
0
        //
        // PROTECTED METHDOS
        //
        protected override void WriteInnerXml(XmlWriter writer)
        {
            // Write Base Xml
            base.WriteInnerXml(writer);

            // Get Model
            SchemaModel model = (SchemaModel)base.Container;

            // <Extent></Extent>
            if (this._extent != null)
            {
                this._extent.WriteXml(writer);
            }

            // <SpatialReference></SpatialReference>
            if (this._spatialReference != null)
            {
                this._spatialReference.WriteXml(writer);
            }

            // <NetworkType></NetworkType>
            writer.WriteStartElement(Xml.NETWORKTYPE);
            writer.WriteValue(this._networkType.ToString());
            writer.WriteEndElement();

            // <OrphanJunctionFeatureClassName></OrphanJunctionFeatureClassName>
            writer.WriteStartElement(Xml.ORPHANJUNCTIONFEATURECLASSNAME);
            writer.WriteValue(this._orphanJunctionFeatureClassName);
            writer.WriteEndElement();

            // <FeatureClassNames>
            writer.WriteStartElement(Xml.FEATURECLASSNAMES);
            writer.WriteAttributeString(Xml._XSI, Xml._TYPE, null, Xml._NAMES);

            Dataset dataset = base.GetParent();

            if (dataset.GetType() == typeof(FeatureDataset))
            {
                FeatureDataset featureDataset = (FeatureDataset)dataset;
                List <Dataset> datasets       = featureDataset.GetChildren();
                foreach (Dataset dataset2 in datasets)
                {
                    if (dataset2.GetType() == typeof(FeatureClass))
                    {
                        FeatureClass featureClass = (FeatureClass)dataset2;
                        List <ControllerMembership> controllers = featureClass.ControllerMemberships;
                        foreach (ControllerMembership controller in controllers)
                        {
                            if (controller is GeometricNetworkControllerMembership)
                            {
                                GeometricNetworkControllerMembership geometricNetworkControllerMembership = (GeometricNetworkControllerMembership)controller;
                                if (geometricNetworkControllerMembership.GeometricNetworkName == base.Name)
                                {
                                    // <Name></Name>
                                    writer.WriteStartElement(Xml.NAME);
                                    writer.WriteValue(featureClass.Name);
                                    writer.WriteEndElement();
                                }
                            }
                        }
                    }
                }
            }

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

            // <ConnectivityRules>
            writer.WriteStartElement(Xml.CONNECTIVITYRULES);
            writer.WriteAttributeString(Xml._XSI, Xml._TYPE, null, Xml._ARRAYOFCONNECTIVITYRULE);

            // <ConnectivityRule></ConnectivityRule>
            foreach (ConnectivityRule connectivityRule in this._connectivityRules)
            {
                connectivityRule.WriteXml(writer);
            }

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

            // <NetworkWeights>
            writer.WriteStartElement(Xml.NETWORKWEIGHTS);
            writer.WriteAttributeString(Xml._XSI, Xml._TYPE, null, Xml._ARRAYOFNETWEIGHT);

            // <NetWeight></NetWeight>
            foreach (NetWeight netWeight in this._netWeights)
            {
                netWeight.WriteXml(writer);
            }

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

            // <WeightAssociations>
            writer.WriteStartElement(Xml.WEIGHTASSOCIATIONS);
            writer.WriteAttributeString(Xml._XSI, Xml._TYPE, null, Xml._ARRAYOFNETWEIGHTASSOCIATION);

            // <NetWeightAssociation></NetWeightAssociation>
            foreach (NetWeightAssociation netWeightAssociation in this._netWeightAssociations)
            {
                netWeightAssociation.WriteXml(writer);
            }

            // </WeightAssociations>
            writer.WriteEndElement();
        }
        private void LoadModel()
        {
            // Store Selected EsriTable (if any)
            EsriTable table = null;

            if (this.treeView1.SelectedNode != null)
            {
                TreeNodeTable treeNodeTable = this.treeView1.SelectedNode as TreeNodeTable;
                if (treeNodeTable != null)
                {
                    if (treeNodeTable.Table != null)
                    {
                        table = treeNodeTable.Table;
                    }
                }
            }

            // Clear TreeView
            this.treeView1.Nodes.Clear();

            // Exit if No Model
            if (this._model == null)
            {
                return;
            }

            // Get Datasets
            List <Dataset> datasets = this._model.GetDatasets();

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

            // Start TreeView Update
            this.treeView1.BeginUpdate();
            this.treeView1.Sorted = false;

            // Add Geodatabase Node
            TreeNodeGeodatabase treeNode = new TreeNodeGeodatabase(this._model);

            treeNode.ImageKey         = Catalog.GEODATABASE;
            treeNode.SelectedImageKey = Catalog.GEODATABASE;
            treeNode.Text             = this._model.Title;
            this.treeView1.Nodes.Add(treeNode);

            if (this.buttonItemCatalog.Checked)
            {
                // Sort Datasets
                datasets.Sort();

                // Loop Throught Datasets
                foreach (Dataset dataset in datasets)
                {
                    if (dataset is FeatureDataset)
                    {
                        // Get FeatureDataset
                        FeatureDataset featureDataset = (FeatureDataset)dataset;

                        // Add FeatureDataset Node
                        TreeNode treeNode2 = this.CreateCatalogNode(treeNode, featureDataset);

                        // Get Child Datasets
                        List <Dataset> datasets2 = featureDataset.GetChildren();
                        datasets2.Sort();

                        foreach (Dataset dataset2 in datasets2)
                        {
                            TreeNode treeNode3 = this.CreateCatalogNode(treeNode2, dataset2);

                            // Add Subtypes if ObjectClass
                            if (dataset2 is ObjectClass)
                            {
                                // Get ObjectClass
                                ObjectClass objectClass = (ObjectClass)dataset2;

                                // Get Subtypes
                                List <Subtype> subtypes = objectClass.GetSubtypes();
                                subtypes.Sort();

                                // Add Subtypes Nodes
                                foreach (Subtype subtype in subtypes)
                                {
                                    TreeNode treeNodeSubtype = this.CreateCatalogNode(treeNode3, subtype);
                                }
                            }
                        }
                    }
                }

                // Add Everything Else
                foreach (Dataset dataset in datasets)
                {
                    // Skip FeatureDataset and FeatureDataset Objects
                    if (dataset is FeatureDataset ||
                        dataset is GeometricNetwork ||
                        dataset is Network ||
                        dataset is RasterBand ||
                        dataset is Terrain ||
                        dataset is Topology)
                    {
                        continue;
                    }

                    // Skip Objects that Belong to a FeatureDataset
                    if (dataset is FeatureClass ||
                        dataset is RelationshipClass)
                    {
                        Dataset parent = dataset.GetParent();
                        if (parent != null)
                        {
                            continue;
                        }
                    }

                    // Create Node
                    TreeNode treeNode2 = this.CreateCatalogNode(treeNode, dataset);

                    // Add Subtypes if ObjectClass
                    if (dataset is ObjectClass)
                    {
                        // Get ObjectClass
                        ObjectClass objectClass = (ObjectClass)dataset;

                        // Get Subtypes
                        List <Subtype> subtypes = objectClass.GetSubtypes();
                        subtypes.Sort();

                        // Add Subtypes Nodes
                        foreach (Subtype subtype in subtypes)
                        {
                            TreeNode treeNodeSubtype = this.CreateCatalogNode(treeNode2, subtype);
                        }
                    }

                    // Add Raster Bands
                    if (dataset.GetType() == typeof(RasterDataset))
                    {
                        // Get RasterDataset
                        RasterDataset rasterDataset = (RasterDataset)dataset;

                        // Get RasterBands
                        List <Dataset> rasterBands = rasterDataset.GetChildren();

                        // Add RasterBands
                        foreach (Dataset datasetRasterBand in rasterBands)
                        {
                            if (datasetRasterBand.GetType() == typeof(RasterBand))
                            {
                                RasterBand rasterBand         = (RasterBand)datasetRasterBand;
                                TreeNode   treeNodeRasterBand = this.CreateCatalogNode(treeNode2, rasterBand);
                            }
                        }
                    }
                }

                // Sort Domains
                domains.Sort();

                // Add Domains
                foreach (Domain domain in domains)
                {
                    TreeNode treeNodeDomain = this.CreateCatalogNode(treeNode, domain);
                }

                // Expand Geodatabase Node
                treeNode.Expand();
            }
            else if (this.buttonItemCategorized.Checked)
            {
                // Loop for each Dataset
                foreach (Dataset dataset in datasets)
                {
                    // Get Group Node Name
                    string key = string.Empty;
                    if (dataset.GetType() == typeof(FeatureDataset))
                    {
                        key = Resources.TEXT_FEATURE_DATASET;
                    }
                    else if (dataset.GetType() == typeof(FeatureClass))
                    {
                        key = Resources.TEXT_FEATURE_CLASS;
                    }
                    else if (dataset.GetType() == typeof(GeometricNetwork))
                    {
                        key = Resources.TEXT_GEOMETRIC_NETWORK;
                    }
                    else if (dataset.GetType() == typeof(ObjectClass))
                    {
                        key = Resources.TEXT_TABLE;
                    }
                    else if (dataset.GetType() == typeof(RasterBand))
                    {
                        key = Resources.TEXT_RASTER_BAND;
                    }
                    else if (dataset.GetType() == typeof(RasterCatalog))
                    {
                        key = Resources.TEXT_RASTER_CATALOG;
                    }
                    else if (dataset.GetType() == typeof(RasterDataset))
                    {
                        key = Resources.TEXT_RASTER_DATASET;
                    }
                    else if (dataset.GetType() == typeof(RelationshipClass))
                    {
                        key = Resources.TEXT_RELATIONSHIP;
                    }
                    else if (dataset.GetType() == typeof(Terrain))
                    {
                        key = Resources.TEXT_TERRAIN;
                    }
                    else if (dataset.GetType() == typeof(Topology))
                    {
                        key = Resources.TEXT_TOPOLOGY;
                    }
                    if (string.IsNullOrEmpty(key))
                    {
                        continue;
                    }

                    // Get Group Node (create if it does not exist)
                    TreeNodeGroup treeNodeGroup = null;
                    foreach (TreeNodeGroup group in treeNode.Nodes)
                    {
                        if (group.Type == dataset.GetType())
                        {
                            treeNodeGroup = group;
                            break;
                        }
                    }
                    if (treeNodeGroup == null)
                    {
                        treeNodeGroup                  = new TreeNodeGroup(dataset.GetType());
                        treeNodeGroup.ImageKey         = Catalog.FOLDER_CLOSED;
                        treeNodeGroup.SelectedImageKey = Catalog.FOLDER_CLOSED;
                        treeNodeGroup.Text             = key;
                        treeNode.Nodes.Add(treeNodeGroup);
                    }

                    // Create New Dataset Node
                    TreeNode treeNodeDataset = this.CreateCatalogNode(treeNodeGroup, dataset);
                }

                // Append Subtypes Nodes
                foreach (Dataset dataset in datasets)
                {
                    // Is ObjectClass?
                    if (dataset is ObjectClass)
                    {
                        // Cast to ObjectClass
                        ObjectClass objectClass = (ObjectClass)dataset;

                        // Get Subtypes
                        List <Subtype> subtypes = objectClass.GetSubtypes();
                        if (subtypes.Count == 0)
                        {
                            continue;
                        }

                        // Find Subtype Group Node
                        TreeNodeGroup treeNodeGroup = null;
                        foreach (TreeNodeGroup group in treeNode.Nodes)
                        {
                            if (group.Type == typeof(Subtype))
                            {
                                treeNodeGroup = group;
                                break;
                            }
                        }
                        if (treeNodeGroup == null)
                        {
                            treeNodeGroup                  = new TreeNodeGroup(typeof(Subtype));
                            treeNodeGroup.ImageKey         = Catalog.FOLDER_CLOSED;
                            treeNodeGroup.SelectedImageKey = Catalog.FOLDER_CLOSED;
                            treeNodeGroup.Text             = Resources.TEXT_SUBTYPE;
                            treeNode.Nodes.Add(treeNodeGroup);
                        }

                        // Add Each Subtype
                        foreach (Subtype subtype in subtypes)
                        {
                            TreeNode treeNodeSubtype = this.CreateCatalogNode(treeNodeGroup, subtype);
                        }
                    }
                }

                // Loop for each Domain
                foreach (Domain domain in domains)
                {
                    // Get Group Node Name
                    string key = string.Empty;
                    if (domain.GetType() == typeof(DomainCodedValue))
                    {
                        key = Resources.TEXT_CODED_VALUE;
                    }
                    else if (domain.GetType() == typeof(DomainRange))
                    {
                        key = Resources.TEXT_RANGE_DOMAIN;
                    }
                    if (string.IsNullOrEmpty(key))
                    {
                        continue;
                    }

                    // Get Group Node (create if it does not exist)
                    TreeNodeGroup treeNodeGroup = null;
                    foreach (TreeNodeGroup group in treeNode.Nodes)
                    {
                        if (group.Type == domain.GetType())
                        {
                            treeNodeGroup = group;
                            break;
                        }
                    }
                    if (treeNodeGroup == null)
                    {
                        treeNodeGroup                  = new TreeNodeGroup(domain.GetType());
                        treeNodeGroup.ImageKey         = Catalog.FOLDER_CLOSED;
                        treeNodeGroup.SelectedImageKey = Catalog.FOLDER_CLOSED;
                        treeNodeGroup.Text             = key;
                        treeNode.Nodes.Add(treeNodeGroup);
                    }

                    // Create New Dataset Node
                    TreeNode treeNodeDomain = this.CreateCatalogNode(treeNodeGroup, domain);
                }

                // Expand Geodatabase Node
                treeNode.Expand();

                // Traditional Text Sort
                this.treeView1.Sort();
            }
            else if (this.buttonItemAlphabetical.Checked)
            {
                // Loop for each Dataset
                foreach (Dataset dataset in datasets)
                {
                    // Create New Dataset Node
                    TreeNode treeNodeDataset = this.CreateCatalogNode(treeNode, dataset);

                    if (dataset is ObjectClass)
                    {
                        // Cast to ObjectClass
                        ObjectClass objectClass = (ObjectClass)dataset;

                        // Get and Add Subtypes
                        List <Subtype> subtypes = objectClass.GetSubtypes();
                        foreach (Subtype subtype in subtypes)
                        {
                            TreeNode treeNodeSubtype = this.CreateCatalogNode(treeNode, subtype);
                        }
                    }
                }

                // Loop for each Domain
                foreach (Domain domain in domains)
                {
                    TreeNode treeNodeDomain = this.CreateCatalogNode(treeNode, domain);
                }

                // Expand Geodatabase Node
                treeNode.Expand();

                // Traditional Text Sort
                this.treeView1.Sort();
            }

            // Reselect Previous EsriTable (if any)
            if (table != null)
            {
                if (this.treeView1.Nodes.Count == 1)
                {
                    //TreeNode treeNode = this.treeView1.Nodes[0];
                    TreeNode treeNodeFind = this.FindNode(treeNode, table);
                    if (treeNodeFind != null)
                    {
                        treeNodeFind.EnsureVisible();
                        treeNodeFind.TreeView.SelectedNode = treeNodeFind;
                    }
                }
            }

            // End TreeView Update
            this.treeView1.EndUpdate();
        }
        //
        // PUBLIC METHODS
        //
        public override void OpenModel()
        {
            // Create Origin and Destination Lists
            List <EsriShape <FeatureClass> > listFeatureClassFrom = new List <EsriShape <FeatureClass> >();
            List <EsriShape <FeatureClass> > listFeatureClassTo   = new List <EsriShape <FeatureClass> >();
            List <EsriShape <Subtype> >      listSubtypeFrom      = new List <EsriShape <Subtype> >();
            List <EsriShape <Subtype> >      listSubtypeTo        = new List <EsriShape <Subtype> >();

            // Exit if invalid
            if (this._topology == null)
            {
                return;
            }

            // Suspend Model
            if (ModelSettings.Default.EnableUndoRedo)
            {
                this.UndoList.Suspend();
            }
            this.Suspend();
            this.SuspendEvents = true;

            // Get SchemaModel
            SchemaModel schemaModel = (SchemaModel)this._topology.Container;

            // Get Parent FeatureDataset
            Dataset parent = this._topology.GetParent();

            if (parent == null)
            {
                return;
            }
            FeatureDataset featureDataset = parent as FeatureDataset;

            if (featureDataset == null)
            {
                return;
            }

            // Add From and To FeatureDatasets
            EsriShape <FeatureDataset> featureDataset1 = new EsriShape <FeatureDataset>(featureDataset);
            EsriShape <FeatureDataset> featureDataset2 = new EsriShape <FeatureDataset>(featureDataset);

            this.Shapes.Add(this.Shapes.CreateKey(), featureDataset1);
            this.Shapes.Add(this.Shapes.CreateKey(), featureDataset2);

            // Add all Child FeatureClasses
            foreach (Dataset dataset in featureDataset.GetChildren())
            {
                if (dataset.GetType() != typeof(FeatureClass))
                {
                    continue;
                }

                // Get FeatureClass
                FeatureClass featureClass = (FeatureClass)dataset;

                // Only continue if FeatureClass belongs to the Topology
                bool participate = false;
                foreach (ControllerMembership controller in featureClass.ControllerMemberships)
                {
                    if (controller is TopologyControllerMembership)
                    {
                        TopologyControllerMembership topologyControllerMembership = (TopologyControllerMembership)controller;
                        if (topologyControllerMembership.TopologyName == this._topology.Name)
                        {
                            participate = true;
                            break;
                        }
                    }
                }
                if (!participate)
                {
                    continue;
                }

                // Get Subtypes
                List <Subtype> subtypes = featureClass.GetSubtypes();

                // Add From FetaureClasses and Subtypes
                EsriShape <FeatureClass> featureClass1 = new EsriShape <FeatureClass>(featureClass);
                this.Shapes.Add(this.Shapes.CreateKey(), featureClass1);
                listFeatureClassFrom.Add(featureClass1);

                // Add Line from FeatureDataset to FeatureClass
                Arrow arrow1 = new Arrow();
                arrow1.BorderColor    = ModelSettings.Default.DisabledLined;
                arrow1.DrawBackground = false;
                Line line1 = new Line(featureDataset1, featureClass1);
                line1.End.AllowMove   = false;
                line1.End.Marker      = arrow1;
                line1.Start.AllowMove = false;
                line1.BorderColor     = ModelSettings.Default.DisabledLined;
                this.Lines.Add(this.Lines.CreateKey(), line1);

                // Add Subtypes and Link to FeatureClass
                foreach (Subtype subtype in subtypes)
                {
                    EsriShape <Subtype> sub = new EsriShape <Subtype>(subtype);
                    this.Shapes.Add(this.Shapes.CreateKey(), sub);
                    listSubtypeFrom.Add(sub);
                    Arrow arrow3 = new Arrow();
                    arrow3.BorderColor    = ModelSettings.Default.DisabledLined;
                    arrow3.DrawBackground = false;
                    Line line = new Line(featureClass1, sub);
                    line.End.AllowMove   = false;
                    line.End.Marker      = arrow3;
                    line.Start.AllowMove = false;
                    line.BorderColor     = ModelSettings.Default.DisabledLined;
                    this.Lines.Add(this.Lines.CreateKey(), line);
                }

                // Add To FetaureClasses and Subtypes
                EsriShape <FeatureClass> featureClass2 = new EsriShape <FeatureClass>(featureClass);
                this.Shapes.Add(this.Shapes.CreateKey(), featureClass2);
                listFeatureClassTo.Add(featureClass2);

                // Add Line from FeatureDataset to FeatureClass
                Arrow arrow2 = new Arrow();
                arrow2.BorderColor    = ModelSettings.Default.DisabledLined;
                arrow2.DrawBackground = false;
                Line line2 = new Line(featureClass2, featureDataset2);
                line2.End.AllowMove   = false;
                line2.Start.AllowMove = false;
                line2.Start.Marker    = arrow2;
                line2.BorderColor     = ModelSettings.Default.DisabledLined;
                this.Lines.Add(this.Lines.CreateKey(), line2);

                // Add Subtyes and Link to FeatureClasses
                foreach (Subtype subtype in subtypes)
                {
                    EsriShape <Subtype> sub = new EsriShape <Subtype>(subtype);
                    this.Shapes.Add(this.Shapes.CreateKey(), sub);
                    listSubtypeTo.Add(sub);
                    Arrow arrow4 = new Arrow();
                    arrow4.BorderColor    = ModelSettings.Default.DisabledLined;
                    arrow4.DrawBackground = false;
                    Line line = new Line(sub, featureClass2);
                    line.End.AllowMove   = false;
                    line.Start.Marker    = arrow4;
                    line.Start.AllowMove = false;
                    line.BorderColor     = ModelSettings.Default.DisabledLined;
                    this.Lines.Add(this.Lines.CreateKey(), line);
                }
            }

            // Loop Through All Connectivity Rules
            foreach (TopologyRule topologyRule in this._topology.TopologyRules)
            {
                // Origin Table
                EsriTable origin = null;
                if (topologyRule.AllOriginSubtypes)
                {
                    origin = schemaModel.FindObjectClass(topologyRule.OriginClassId);
                }
                else
                {
                    origin = schemaModel.FindObjectClassOrSubtype(
                        topologyRule.OriginClassId,
                        topologyRule.OriginSubtype);
                }

                // Destination Table
                EsriTable destination = null;
                if (topologyRule.AllDestinationSubtypes)
                {
                    destination = schemaModel.FindObjectClass(topologyRule.DestinationClassId);
                }
                else
                {
                    destination = schemaModel.FindObjectClassOrSubtype(
                        topologyRule.DestinationClassId,
                        topologyRule.DestinationSubtype);
                }

                // Origin and Destination Shapes
                Shape shapeOrigin      = null;
                Shape shapeDestiantion = null;

                // Find Origin Shape in Diagram
                foreach (EsriShape <FeatureClass> f in listFeatureClassFrom)
                {
                    if (f.Parent == origin)
                    {
                        shapeOrigin = f;
                        break;
                    }
                }
                if (shapeOrigin == null)
                {
                    foreach (EsriShape <Subtype> s in listSubtypeFrom)
                    {
                        if (s.Parent == origin)
                        {
                            shapeOrigin = s;
                            break;
                        }
                    }
                }

                // Find Destination Shape in Diagram
                foreach (EsriShape <FeatureClass> f in listFeatureClassTo)
                {
                    if (f.Parent == destination)
                    {
                        shapeDestiantion = f;
                        break;
                    }
                }
                if (shapeDestiantion == null)
                {
                    foreach (EsriShape <Subtype> s in listSubtypeTo)
                    {
                        if (s.Parent == destination)
                        {
                            shapeDestiantion = s;
                            break;
                        }
                    }
                }

                // Skip if Origin and Destination Shapes not found
                if (shapeOrigin == null || shapeDestiantion == null)
                {
                    continue;
                }

                EsriLine <TopologyRule> line2 = new EsriLine <TopologyRule>(topologyRule, shapeOrigin, shapeDestiantion);
                this.Lines.Add(this.Lines.CreateKey(), line2);
            }

            // Perform Layout
            this.ExecuteLayout(typeof(HierarchicalLayout), true);

            // Resume and Refresh Model
            this.SuspendEvents = false;
            this.Resume();
            if (ModelSettings.Default.EnableUndoRedo)
            {
                this.UndoList.Resume();
            }
            this.Refresh();
        }
        //
        // PUBLIC METHODS
        //
        public override void OpenModel()
        {
            List <EsriShape <FeatureClass> > listFeatureClassFrom = new List <EsriShape <FeatureClass> >();
            List <EsriShape <FeatureClass> > listFeatureClassTo   = new List <EsriShape <FeatureClass> >();
            List <EsriShape <Subtype> >      listSubtypeFrom      = new List <EsriShape <Subtype> >();
            List <EsriShape <Subtype> >      listSubtypeTo        = new List <EsriShape <Subtype> >();

            // Exit if invalid
            if (this._geometricNetwork == null)
            {
                return;
            }

            // Suspend Model
            if (ModelSettings.Default.EnableUndoRedo)
            {
                this.UndoList.Suspend();
            }
            this.Suspend();
            this.SuspendEvents = true;

            // Get SchemaModel
            SchemaModel schemaModel = (SchemaModel)this._geometricNetwork.Container;

            // Get Parent FeatureDataset
            Dataset parent = this._geometricNetwork.GetParent();

            if (parent == null)
            {
                return;
            }
            FeatureDataset featureDataset = parent as FeatureDataset;

            if (featureDataset == null)
            {
                return;
            }

            // Add From and To FeatureDatasets
            EsriShape <FeatureDataset> featureDataset1 = new EsriShape <FeatureDataset>(featureDataset);
            EsriShape <FeatureDataset> featureDataset2 = new EsriShape <FeatureDataset>(featureDataset);

            this.Shapes.Add(this.Shapes.CreateKey(), featureDataset1);
            this.Shapes.Add(this.Shapes.CreateKey(), featureDataset2);

            // Add all Child FeatureClasses
            foreach (Dataset dataset in featureDataset.GetChildren())
            {
                if (dataset.GetType() != typeof(FeatureClass))
                {
                    continue;
                }

                // Get FeatureClass
                FeatureClass featureClass = (FeatureClass)dataset;

                // Only allow Simle and Complex Edges
                switch (featureClass.FeatureType)
                {
                case esriFeatureType.esriFTSimpleEdge:
                case esriFeatureType.esriFTComplexEdge:
                case esriFeatureType.esriFTSimpleJunction:
                    break;

                default:
                    continue;
                }

                // Only continue if FeatureClass belongs to the GeometricNetwork
                bool participate = false;
                foreach (ControllerMembership controller in featureClass.ControllerMemberships)
                {
                    if (controller is GeometricNetworkControllerMembership)
                    {
                        GeometricNetworkControllerMembership geometricNetworkControllerMembership = (GeometricNetworkControllerMembership)controller;
                        if (geometricNetworkControllerMembership.GeometricNetworkName == this._geometricNetwork.Name)
                        {
                            participate = true;
                            break;
                        }
                    }
                }
                if (!participate)
                {
                    continue;
                }

                // Get Subtypes
                List <Subtype> subtypes = featureClass.GetSubtypes();

                switch (featureClass.FeatureType)       //  (featureClass.CLSID) {
                {
                case esriFeatureType.esriFTSimpleEdge:  //  EsriRegistry.CLASS_SIMPLEEDGE:
                case esriFeatureType.esriFTComplexEdge: //  EsriRegistry.CLASS_COMPLEXEDGE:
                    // Add From FetaureClasses and Subtypes
                    EsriShape <FeatureClass> featureClass1 = new EsriShape <FeatureClass>(featureClass);
                    this.Shapes.Add(this.Shapes.CreateKey(), featureClass1);
                    listFeatureClassFrom.Add(featureClass1);

                    // Add Line from FeatureDataset to FeatureClass
                    Arrow arrow1 = new Arrow();
                    arrow1.BorderColor    = ModelSettings.Default.DisabledLined;
                    arrow1.DrawBackground = false;
                    Line line1 = new Line(featureDataset1, featureClass1);
                    line1.End.AllowMove   = false;
                    line1.End.Marker      = arrow1;
                    line1.Start.AllowMove = false;
                    line1.BorderColor     = ModelSettings.Default.DisabledLined;
                    this.Lines.Add(this.Lines.CreateKey(), line1);

                    // Add Subtypes and Link to FeatureClass
                    foreach (Subtype subtype in subtypes)
                    {
                        EsriShape <Subtype> sub = new EsriShape <Subtype>(subtype);
                        this.Shapes.Add(this.Shapes.CreateKey(), sub);
                        listSubtypeFrom.Add(sub);
                        Arrow arrow3 = new Arrow();
                        arrow3.BorderColor    = ModelSettings.Default.DisabledLined;
                        arrow3.DrawBackground = false;
                        Line line = new Line(featureClass1, sub);
                        line.End.AllowMove   = false;
                        line.End.Marker      = arrow3;
                        line.Start.AllowMove = false;
                        line.BorderColor     = ModelSettings.Default.DisabledLined;
                        this.Lines.Add(this.Lines.CreateKey(), line);
                    }
                    break;

                case esriFeatureType.esriFTSimpleJunction:     // EsriRegistry.CLASS_SIMPLEJUNCTION:
                    // Add To FetaureClasses and Subtypes
                    EsriShape <FeatureClass> featureClass2 = new EsriShape <FeatureClass>(featureClass);
                    this.Shapes.Add(this.Shapes.CreateKey(), featureClass2);
                    listFeatureClassTo.Add(featureClass2);

                    // Add Line from FeatureDataset to FeatureClass
                    Arrow arrow2 = new Arrow();
                    arrow2.BorderColor    = ModelSettings.Default.DisabledLined;
                    arrow2.DrawBackground = false;
                    Line line2 = new Line(featureClass2, featureDataset2);
                    line2.End.AllowMove   = false;
                    line2.Start.AllowMove = false;
                    line2.Start.Marker    = arrow2;
                    line2.BorderColor     = ModelSettings.Default.DisabledLined;
                    this.Lines.Add(this.Lines.CreateKey(), line2);

                    // Add Subtyes and Link to FeatureClasses
                    foreach (Subtype subtype in subtypes)
                    {
                        EsriShape <Subtype> sub = new EsriShape <Subtype>(subtype);
                        this.Shapes.Add(this.Shapes.CreateKey(), sub);
                        listSubtypeTo.Add(sub);
                        Arrow arrow4 = new Arrow();
                        arrow4.BorderColor    = ModelSettings.Default.DisabledLined;
                        arrow4.DrawBackground = false;
                        Line line = new Line(sub, featureClass2);
                        line.End.AllowMove   = false;
                        line.Start.Marker    = arrow4;
                        line.Start.AllowMove = false;
                        line.BorderColor     = ModelSettings.Default.DisabledLined;
                        this.Lines.Add(this.Lines.CreateKey(), line);
                    }
                    break;
                }
            }

            // Loop Through All Connectivity Rules
            foreach (ConnectivityRule connectivityRule in this._geometricNetwork.ConnectivityRules)
            {
                // Continue only if Edge Connectivity Rule
                if (!(connectivityRule is JunctionConnectivityRule))
                {
                    continue;
                }

                // Get Edge Connectivity Rule
                JunctionConnectivityRule junctionConnectivityRule = (JunctionConnectivityRule)connectivityRule;

                // Origin Table
                EsriTable origin = schemaModel.FindObjectClassOrSubtype(
                    junctionConnectivityRule.EdgeClassID,
                    junctionConnectivityRule.EdgeSubtypeCode);

                // Destination Table
                EsriTable destination = schemaModel.FindObjectClassOrSubtype(
                    junctionConnectivityRule.JunctionClassID,
                    junctionConnectivityRule.SubtypeCode);

                // Origin and Destination Shapes
                Shape shapeOrigin      = null;
                Shape shapeDestiantion = null;

                // Find Origin Shape in Diagram
                foreach (EsriShape <FeatureClass> f in listFeatureClassFrom)
                {
                    if (f.Parent == origin)
                    {
                        shapeOrigin = f;
                        break;
                    }
                }
                if (shapeOrigin == null)
                {
                    foreach (EsriShape <Subtype> s in listSubtypeFrom)
                    {
                        if (s.Parent == origin)
                        {
                            shapeOrigin = s;
                            break;
                        }
                    }
                }

                // Find Destination Shape in Diagram
                foreach (EsriShape <FeatureClass> f in listFeatureClassTo)
                {
                    if (f.Parent == destination)
                    {
                        shapeDestiantion = f;
                        break;
                    }
                }
                if (shapeDestiantion == null)
                {
                    foreach (EsriShape <Subtype> s in listSubtypeTo)
                    {
                        if (s.Parent == destination)
                        {
                            shapeDestiantion = s;
                            break;
                        }
                    }
                }

                // Skip if Origin and Destination Shapes not found
                if (shapeOrigin == null || shapeDestiantion == null)
                {
                    continue;
                }

                EsriLine <JunctionConnectivityRule> line2 = new EsriLine <JunctionConnectivityRule>(junctionConnectivityRule, shapeOrigin, shapeDestiantion);
                this.Lines.Add(this.Lines.CreateKey(), line2);
            }

            // Perform Layout
            this.ExecuteLayout(typeof(HierarchicalLayout), true);

            // Resume and Refresh Model
            this.SuspendEvents = false;
            this.Resume();
            if (ModelSettings.Default.EnableUndoRedo)
            {
                this.UndoList.Resume();
            }
            this.Refresh();
        }
        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);
        }