public override void Errors(List <Error> list)
        {
            // Field Name
            if (string.IsNullOrEmpty(this._name))
            {
                list.Add(new ErrorTableRow(this, "Index Field names can not be empty", ErrorType.Error));
            }
            else
            {
                // Get Parent Index
                Index index = (Index)base.Parent;

                // Get Sibling IndexFields
                List <IndexField> indexFields = index.GetIndexFields();

                // Check for duplicate IndexField names
                foreach (IndexField indexField in indexFields)
                {
                    if (indexField == this)
                    {
                        continue;
                    }
                    if (indexField.Name == this._name)
                    {
                        // Duplicate IndexField Name found
                        string message = string.Format(
                            "Index Field name '{0}' is duplicated in Index {1}",
                            this._name,
                            index.Name);
                        list.Add(new ErrorTableRow(this, message, ErrorType.Error));
                        break;
                    }
                }

                // Find Field
                Field field = null;
                if (this.Table is ObjectClass)
                {
                    ObjectClass objectClass = (ObjectClass)this.Table;
                    field = objectClass.FindField(this._name);
                }
                else if (this.Table is RasterBand)
                {
                    RasterBand rasterBand = (RasterBand)this.Table;
                    field = rasterBand.FindField(this._name);
                }

                // Error if Field not found
                if (field == null)
                {
                    // Field cannot be found in parent ObjectClass/RasterBand
                    string message = string.Format("Index Field '{0}' is missing from parent dataset", this._name);
                    list.Add(new ErrorTableRow(this, message, ErrorType.Error));
                }
            }
        }
 public RasterBand(RasterBand prototype) : base(prototype)
 {
     this._oidFieldName   = prototype.OidFieldName;
     this._isInteger      = prototype.IsInteger;
     this._meanCellHeight = prototype.MeanCellHeight;
     this._meanCellWidth  = prototype.MeanCellWidth;
     this._height         = prototype.Height2;
     this._width          = prototype.Width2;
     this._pixelType      = prototype.PixelType;
     this._primaryField   = prototype.PrimaryField;
     this._tableType      = prototype.TableType;
     if (prototype.Extent != null)
     {
         this._extent = prototype.Extent.Clone() as Extent;
     }
     if (prototype.SpatialReference != null)
     {
         this._spatialReference = prototype.SpatialReference.Clone() as SpatialReference;
     }
 }
        public override void WriteXml(XmlWriter writer)
        {
            Field field = null;

            if (this.Table is ObjectClass)
            {
                ObjectClass objectClass = (ObjectClass)this.Table;
                field = objectClass.FindField(this._name);
            }
            else if (this.Table is RasterBand)
            {
                RasterBand rasterBand = (RasterBand)this.Table;
                field = rasterBand.FindField(this._name);
            }
            if (field == null)
            {
                return;
            }
            field.WriteXml(writer);
        }
        //
        // PUBLIC METHODS
        //
        public override void OpenModel(string filename) {
            // Exit if FileName is invalid
            if (string.IsNullOrEmpty(filename)) { return; }

            // Exit if File does not exist
            if (!File.Exists(filename)) { return; }

            // Open XML Workspace
            XPathDocument document = null;
            try {
                document = new XPathDocument(filename, XmlSpace.None);
            }
            catch (XmlException ex) {
                MessageBox.Show(
                    "The XML file failed to load. Please select 'View > Exceptions' to view a detailed explanation.",
                    Resources.TEXT_APPLICATION,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error,
                    MessageBoxDefaultButton.Button1,
                    MessageBoxOptions.DefaultDesktopOnly);

                // Add Exception
                ExceptionDialog.HandleException(ex);
            }
            if (document == null) { return; }

            // Get XPathNavigator (IXPathNavigable::CreateNavigator)
            XPathNavigator navigator = document.CreateNavigator();

            // Get <esri:Workspace>
            if (!navigator.MoveToFirstChild()) {
                MessageBox.Show(
                    "This file is not a valid ESRI xml workspace document",
                    Resources.TEXT_APPLICATION,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error,
                    MessageBoxDefaultButton.Button1,
                    MessageBoxOptions.DefaultDesktopOnly);
                return;
            }

            // Check Node Name
            if (navigator.Name != "esri:Workspace") {
                MessageBox.Show(
                    "This file is not a valid ESRI xml workspace document",
                    Resources.TEXT_APPLICATION,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error,
                    MessageBoxDefaultButton.Button1,
                    MessageBoxOptions.DefaultDesktopOnly);
                return;
            }

            // Create Xml Namespace Manager
            XmlNamespaceManager namespaceManager = new XmlNamespaceManager(navigator.NameTable);
            namespaceManager.AddNamespace(Xml._XSI, Xml.XMLSCHEMAINSTANCE);

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

            // Select Domains
            XPathNodeIterator iteratorDomain = navigator.Select("WorkspaceDefinition/Domains/Domain");

            // Add Domains
            while (iteratorDomain.MoveNext()) {
                XPathNavigator domain = iteratorDomain.Current;
                XPathNavigator type = domain.SelectSingleNode(Xml._XSITYPE, namespaceManager);
                switch (type.Value) {
                    case Xml._RANGEDOMAIN:
                        DomainRange domainRange = new DomainRange(domain);
                        this.Shapes.Add(this.Shapes.CreateKey(), domainRange);
                        break;
                    case Xml._CODEDVALUEDOMAIN:
                        DomainCodedValue domainCodedValue = new DomainCodedValue(domain);
                        this.Shapes.Add(this.Shapes.CreateKey(), domainCodedValue);
                        break;
                }
            }

            // Select Root DataElements
            XPathNodeIterator iteratorDataElement = navigator.Select("WorkspaceDefinition/DatasetDefinitions/DataElement");
            while (iteratorDataElement.MoveNext()) {
                XPathNavigator dataElement = iteratorDataElement.Current;
                XPathNavigator type = dataElement.SelectSingleNode(Xml._XSITYPE, namespaceManager);
                switch (type.Value) {
                    case Xml._DEFEATUREDATASET:
                        // Create FeatureDataset
                        FeatureDataset featureDataset = new FeatureDataset(dataElement);
                        this.Shapes.Add(this.Shapes.CreateKey(), featureDataset);

                        // Loop for Child DataElements
                        XPathNodeIterator iteratorDataElement2 = dataElement.Select("Children/DataElement");
                        while (iteratorDataElement2.MoveNext()) {
                            XPathNavigator dataElement2 = iteratorDataElement2.Current;
                            XPathNavigator type2 = dataElement2.SelectSingleNode(Xml._XSITYPE, namespaceManager);
                            switch (type2.Value) {
                                case Xml._DEFEATURECLASS:
                                    // Create FeatureClass
                                    FeatureClass featureClass2 = new FeatureClass(dataElement2);
                                    this.Shapes.Add(this.Shapes.CreateKey(), featureClass2);

                                    // Create Link to FeatureDataset
                                    Link link1 = new Link(featureDataset, featureClass2);
                                    link1.BorderColor = ModelSettings.Default.EnabledLines;
                                    link1.BorderStyle = DashStyle.Solid;
                                    link1.BorderWidth = 1f;
                                    link1.End.Marker.BorderColor = ModelSettings.Default.EnabledLines;
                                    this.Lines.Add(this.Lines.CreateKey(), link1);

                                    // Add Subtypes
                                    this.AddSubtypes(featureClass2, dataElement2);

                                    break;
                                case Xml._DEGEOMETRICNETWORK:
                                    // Create GeometricNetwork
                                    GeometricNetwork geometricNetwork = new GeometricNetwork(dataElement2);
                                    this.Shapes.Add(this.Shapes.CreateKey(), geometricNetwork);

                                    // Create Link to FeatureDataset
                                    Link link2 = new Link(featureDataset, geometricNetwork);
                                    link2.BorderColor = ModelSettings.Default.EnabledLines;
                                    link2.BorderStyle = DashStyle.Solid;
                                    link2.BorderWidth = 1f;
                                    link2.End.Marker.BorderColor = ModelSettings.Default.EnabledLines;
                                    this.Lines.Add(this.Lines.CreateKey(), link2);

                                    break;
                                case Xml._DERELATIONSHIPCLASS:
                                    // Create Relationship
                                    RelationshipClass relationshipClass = new RelationshipClass(dataElement2);
                                    this.Shapes.Add(this.Shapes.CreateKey(), relationshipClass);

                                    // Create Link to FeatureDataset
                                    Link link3 = new Link(featureDataset, relationshipClass);
                                    link3.BorderColor = ModelSettings.Default.EnabledLines;
                                    link3.BorderStyle = DashStyle.Solid;
                                    link3.BorderWidth = 1f;
                                    link3.End.Marker.BorderColor = ModelSettings.Default.EnabledLines;
                                    this.Lines.Add(this.Lines.CreateKey(), link3);

                                    break;
                                case Xml._DETOPOLOGY:
                                    // Create Topology
                                    Topology topology = new Topology(dataElement2);
                                    this.Shapes.Add(this.Shapes.CreateKey(), topology);

                                    // Create Link to FeatureDataset
                                    Link link4 = new Link(featureDataset, topology);
                                    link4.BorderColor = ModelSettings.Default.EnabledLines;
                                    link4.BorderStyle = DashStyle.Solid;
                                    link4.BorderWidth = 1f;
                                    link4.End.Marker.BorderColor = ModelSettings.Default.EnabledLines;
                                    this.Lines.Add(this.Lines.CreateKey(), link4);

                                    break;
                                case Xml._DENETWORKDATASET:
                                    // Create Network Dataset
                                    Network network = new Network(dataElement2);
                                    this.Shapes.Add(this.Shapes.CreateKey(), network);

                                    // Create Link to FeatureDataset
                                    Link link5 = new Link(featureDataset, network);
                                    link5.BorderColor = ModelSettings.Default.EnabledLines;
                                    link5.BorderStyle = DashStyle.Solid;
                                    link5.BorderWidth = 1f;
                                    link5.End.Marker.BorderColor = ModelSettings.Default.EnabledLines;
                                    this.Lines.Add(this.Lines.CreateKey(), link5);

                                    break;
                                case Xml._DETERRAIN:
                                    // Create Network Dataset
                                    Terrain terrain = new Terrain(dataElement2);
                                    this.Shapes.Add(this.Shapes.CreateKey(), terrain);

                                    // Create Link to FeatureDataset
                                    Link link6 = new Link(featureDataset, terrain);
                                    link6.BorderColor = ModelSettings.Default.EnabledLines;
                                    link6.BorderStyle = DashStyle.Solid;
                                    link6.BorderWidth = 1f;
                                    link6.End.Marker.BorderColor = ModelSettings.Default.EnabledLines;
                                    this.Lines.Add(this.Lines.CreateKey(), link6);

                                    break;
                            }
                        }

                        break;
                    case Xml._DEFEATURECLASS:
                        // Create FeatureClass
                        FeatureClass featureClass = new FeatureClass(dataElement);
                        this.Shapes.Add(this.Shapes.CreateKey(), featureClass);

                        // Add Subtypes
                        this.AddSubtypes(featureClass, dataElement);

                        break;
                    case Xml._DETABLE:
                        // Create Table
                        ObjectClass objectClass = new ObjectClass(dataElement);
                        this.Shapes.Add(this.Shapes.CreateKey(), objectClass);

                        // Add Subtypes
                        this.AddSubtypes(objectClass, dataElement);

                        break;
                    case Xml._DERASTERCATALOG:
                        // Create Table
                        RasterCatalog rasterCatalog = new RasterCatalog(dataElement);
                        this.Shapes.Add(this.Shapes.CreateKey(), rasterCatalog);

                        break;
                    case Xml._DERELATIONSHIPCLASS:
                        // Create Relationship
                        RelationshipClass relationshipClass2 = new RelationshipClass(dataElement);
                        this.Shapes.Add(this.Shapes.CreateKey(), relationshipClass2);

                        break;
                    case Xml._DERASTERDATASET:
                        // Create RasterDataset
                        RasterDataset rasterDataset = new RasterDataset(dataElement);
                        this.Shapes.Add(this.Shapes.CreateKey(), rasterDataset);

                        // Loop for Child DataElements
                        XPathNodeIterator iteratorDataElement3 = dataElement.Select("Children/DataElement");
                        while (iteratorDataElement3.MoveNext()) {
                            XPathNavigator dataElement2 = iteratorDataElement3.Current;
                            XPathNavigator type2 = dataElement2.SelectSingleNode(Xml._XSITYPE, namespaceManager);
                            switch (type2.Value) {
                                case Xml._DERASTERBAND:
                                    // Create FeatureClass
                                    RasterBand rasterBand = new RasterBand(dataElement2);
                                    this.Shapes.Add(this.Shapes.CreateKey(), rasterBand);

                                    // Create Link to FeatureDataset
                                    Link link = new Link(rasterDataset, rasterBand);
                                    link.BorderColor = ModelSettings.Default.EnabledLines;
                                    link.BorderStyle = DashStyle.Solid;
                                    link.BorderWidth = 1f;
                                    link.End.Marker.BorderColor = ModelSettings.Default.EnabledLines;
                                    this.Lines.Add(this.Lines.CreateKey(), link);

                                    break;
                            }
                        }

                        break;
                }
            }

            // <esri:Workspace><WorkspaceDefinition><Metadata><XmlDoc>
            XPathNavigator navigatorMetadata = navigator.SelectSingleNode("WorkspaceDefinition/Metadata/XmlDoc");
            if (navigatorMetadata != null) {
                this._metadata = navigatorMetadata.Value;
            }

            // <WorkspaceType>
            XPathNavigator navigatorWorkspaceType = navigator.SelectSingleNode("WorkspaceDefinition/WorkspaceType");
            if (navigatorWorkspaceType != null) {
                this._workspaceType = (esriWorkspaceType)Enum.Parse(typeof(esriWorkspaceType), navigatorWorkspaceType.Value, true);
            }

            // <Version>
            XPathNavigator navigatorVersion = navigator.SelectSingleNode("WorkspaceDefinition/Version");
            if (navigatorVersion != null) {
                this._version = navigatorVersion.Value;
            }

            // Close XML Document
            document = null;

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

            // Resume and Refresh Model
            if (ModelSettings.Default.EnableUndoRedo) {
                this.UndoList.Resume();
            }
            this.SuspendEvents = false;
            this.Resume();
            this.Refresh();

            // Make Dirty
            this._dirty = true;
        }
        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();
        }
        private TreeNode CreateCatalogNode(TreeNode node, EsriTable table)
        {
            if (table.GetType() == typeof(DomainCodedValue))
            {
                // Get Coded Value Domain
                DomainCodedValue domainCodedValue = (DomainCodedValue)table;

                // Add Coded Value Domain
                TreeNodeTable treeNode = new TreeNodeTable(domainCodedValue);
                treeNode.ImageKey         = Catalog.CODED_VALUE_DOMAIN;
                treeNode.SelectedImageKey = Catalog.CODED_VALUE_DOMAIN;
                treeNode.Text             = domainCodedValue.Name;
                node.Nodes.Add(treeNode);

                return(treeNode);
            }

            if (table.GetType() == typeof(DomainRange))
            {
                // Get Range Domain
                DomainRange domainRange = (DomainRange)table;

                // Add Range Domain
                TreeNodeTable treeNode = new TreeNodeTable(domainRange);
                treeNode.ImageKey         = Catalog.RANGE_DOMAIN;
                treeNode.SelectedImageKey = Catalog.RANGE_DOMAIN;
                treeNode.Text             = domainRange.Name;
                node.Nodes.Add(treeNode);

                return(treeNode);
            }

            if (table.GetType() == typeof(FeatureClass))
            {
                // Get FeatureClass
                FeatureClass featureClass = (FeatureClass)table;

                // Add FeatureClass Node
                string imageKey = null;
                switch (featureClass.FeatureType)
                {
                case ESRI.ArcGIS.Geodatabase.esriFeatureType.esriFTAnnotation:
                    imageKey = Catalog.ANNOTATION_FEATURE_CLASS;
                    break;

                case ESRI.ArcGIS.Geodatabase.esriFeatureType.esriFTDimension:
                    imageKey = Catalog.DIMENSION_FEATURE_CLASS;
                    break;

                case ESRI.ArcGIS.Geodatabase.esriFeatureType.esriFTSimple:
                    switch (featureClass.ShapeType)
                    {
                    case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryMultipoint:
                    case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint:
                        imageKey = Catalog.POINT_FEATURE_CLASS;
                        break;

                    case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon:
                        imageKey = Catalog.POLYGON_FEATURE_CLASS;
                        break;

                    case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline:
                        imageKey = Catalog.POLYLINE_FEATURE_CLASS;
                        break;

                    case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryMultiPatch:
                        imageKey = Catalog.MULTIPATCH_FEATURE_CLASS;
                        break;

                    default:
                        imageKey = Catalog.POINT_FEATURE_CLASS;
                        break;
                    }
                    break;

                default:
                    imageKey = POINT_FEATURE_CLASS;
                    break;
                }
                TreeNodeTable treeNode = new TreeNodeTable(featureClass);
                treeNode.ImageKey         = imageKey;
                treeNode.SelectedImageKey = imageKey;
                treeNode.Text             = featureClass.Name;
                node.Nodes.Add(treeNode);

                return(treeNode);
            }

            if (table.GetType() == typeof(FeatureDataset))
            {
                // Get FeatureDataset
                FeatureDataset featureDataset = (FeatureDataset)table;

                // Add FeatureDataset Node
                TreeNodeTable treeNode = new TreeNodeTable(featureDataset);
                treeNode.ImageKey         = Catalog.FEATURE_DATASET;
                treeNode.SelectedImageKey = Catalog.FEATURE_DATASET;
                treeNode.Text             = featureDataset.Name;
                node.Nodes.Add(treeNode);

                return(treeNode);
            }

            if (table.GetType() == typeof(GeometricNetwork))
            {
                // Get GeometricNetwork
                GeometricNetwork geometricNetwork = (GeometricNetwork)table;

                // Add GeometricNetwork Node
                TreeNodeTable treeNode = new TreeNodeTable(geometricNetwork);
                treeNode.ImageKey         = Catalog.GEOMETRIC_NETWORK;
                treeNode.SelectedImageKey = Catalog.GEOMETRIC_NETWORK;
                treeNode.Text             = geometricNetwork.Name;
                node.Nodes.Add(treeNode);

                return(treeNode);
            }

            if (table.GetType() == typeof(Network))
            {
                // Get Network
                Network network = (Network)table;

                // Add Network TreeNode
                TreeNodeTable treeNode = new TreeNodeTable(network);
                treeNode.ImageKey         = Catalog.NETWORK_DATASET;
                treeNode.SelectedImageKey = Catalog.NETWORK_DATASET;
                treeNode.Text             = network.Name;
                node.Nodes.Add(treeNode);

                return(treeNode);
            }

            if (table.GetType() == typeof(ObjectClass))
            {
                // Get ObjectClass
                ObjectClass objectClass = (ObjectClass)table;

                // Add ObjectClass TreeNode
                TreeNodeTable treeNode = new TreeNodeTable(objectClass);
                treeNode.ImageKey         = Catalog.TABLE;
                treeNode.SelectedImageKey = Catalog.TABLE;
                treeNode.Text             = objectClass.Name;
                node.Nodes.Add(treeNode);

                return(treeNode);
            }

            if (table.GetType() == typeof(RasterBand))
            {
                // Get RasterBand
                RasterBand rasterBand = (RasterBand)table;

                // Add RasterBand TreeNode
                TreeNodeTable treeNode = new TreeNodeTable(rasterBand);
                treeNode.ImageKey         = Catalog.RASTER_BAND;
                treeNode.SelectedImageKey = Catalog.RASTER_BAND;
                treeNode.Text             = rasterBand.Name;
                node.Nodes.Add(treeNode);

                return(treeNode);
            }

            if (table.GetType() == typeof(RasterCatalog))
            {
                // Get RasterCatalog
                RasterCatalog rasterCatalog = (RasterCatalog)table;

                // Add RasterCatalog TreeNode
                TreeNodeTable treeNode = new TreeNodeTable(rasterCatalog);
                treeNode.ImageKey         = Catalog.RASTER_CATALOG;
                treeNode.SelectedImageKey = Catalog.RASTER_CATALOG;
                treeNode.Text             = rasterCatalog.Name;
                node.Nodes.Add(treeNode);

                return(treeNode);
            }

            if (table.GetType() == typeof(RasterDataset))
            {
                // Get RasterDataset
                RasterDataset rasterDataset = (RasterDataset)table;

                // Add RasterDataset TreeNode
                TreeNodeTable treeNode = new TreeNodeTable(rasterDataset);
                treeNode.ImageKey         = Catalog.RASTER_DATASET;
                treeNode.SelectedImageKey = Catalog.RASTER_DATASET;
                treeNode.Text             = rasterDataset.Name;
                node.Nodes.Add(treeNode);

                return(treeNode);
            }

            if (table.GetType() == typeof(RelationshipClass))
            {
                // Get RelationshipClass
                RelationshipClass relationshipClass = (RelationshipClass)table;

                // Add RelationshipClass TreeNode
                TreeNodeTable treeNode = new TreeNodeTable(relationshipClass);
                treeNode.ImageKey         = Catalog.RELATIONSHIP_CLASS;
                treeNode.SelectedImageKey = Catalog.RELATIONSHIP_CLASS;
                treeNode.Text             = relationshipClass.Name;
                node.Nodes.Add(treeNode);

                return(treeNode);
            }

            if (table.GetType() == typeof(Subtype))
            {
                // Get Subtype
                Subtype subtype = (Subtype)table;

                // Add Subtype TreeNode
                TreeNodeTable treeNode = new TreeNodeTable(subtype);
                treeNode.ImageKey         = Catalog.SUBTYPE;
                treeNode.SelectedImageKey = Catalog.SUBTYPE;
                treeNode.Text             = subtype.SubtypeName;
                node.Nodes.Add(treeNode);

                return(treeNode);
            }

            if (table.GetType() == typeof(Terrain))
            {
                // Get Terrain
                Terrain terrain = (Terrain)table;

                // Add Terrain TreeNode
                TreeNodeTable treeNode = new TreeNodeTable(terrain);
                treeNode.ImageKey         = Catalog.TERRAIN;
                treeNode.SelectedImageKey = Catalog.TERRAIN;
                treeNode.Text             = terrain.Name;
                node.Nodes.Add(treeNode);

                return(treeNode);
            }

            if (table.GetType() == typeof(Topology))
            {
                // Get Topology
                Topology topology = (Topology)table;

                // Add Topology TreeNode
                TreeNodeTable treeNode = new TreeNodeTable(topology);
                treeNode.ImageKey         = Catalog.TOPOLOGY;
                treeNode.SelectedImageKey = Catalog.TOPOLOGY;
                treeNode.Text             = topology.Name;
                node.Nodes.Add(treeNode);

                return(treeNode);
            }

            return(null);
        }
 public RasterBand(RasterBand prototype) : base(prototype) {
     this._oidFieldName = prototype.OidFieldName;
     this._isInteger = prototype.IsInteger;
     this._meanCellHeight = prototype.MeanCellHeight;
     this._meanCellWidth = prototype.MeanCellWidth;
     this._height = prototype.Height2;
     this._width = prototype.Width2;
     this._pixelType = prototype.PixelType;
     this._primaryField = prototype.PrimaryField;
     this._tableType = prototype.TableType;
     if (prototype.Extent != null) {
         this._extent = prototype.Extent.Clone() as Extent;
     }
     if (prototype.SpatialReference != null) {
         this._spatialReference = prototype.SpatialReference.Clone() as SpatialReference;
     }
 }