public void SetDefault() { // Exit if already default if (this._default) { return; } // Set Default this._default = true; // Refresh Graphics this.Refresh(); // Get Parent ObjectClass objectClass = this.GetParent(); if (objectClass == null) { return; } // Get Siblings List <Subtype> subtypes = objectClass.GetSubtypes(); // Make Siblings foreach (Subtype subtype in subtypes) { if (subtype == this) { continue; } subtype.Default = false; } }
// // PUBLIC METHODS // public override void OpenModel() { EsriShape <ObjectClass> orig = null; EsriShape <ObjectClass> dest = null; List <EsriShape <Subtype> > originSubtypes = new List <EsriShape <Subtype> >(); List <EsriShape <Subtype> > destinationSubtypes = new List <EsriShape <Subtype> >(); // Exit if invalid if (this._relationshipClass == null) { return; } // Suspend Model if (ModelSettings.Default.EnableUndoRedo) { this.UndoList.Suspend(); } this.Suspend(); this.SuspendEvents = true; // Get Schema Model SchemaModel schemaModel = (SchemaModel)this._relationshipClass.Container; // Get Origin and Destination ObjectClasses ObjectClass objectClassOrig = schemaModel.FindObjectClass(this._relationshipClass.OriginClassName); ObjectClass objectClassDest = schemaModel.FindObjectClass(this._relationshipClass.DestinationClassName); // Add ObjectClasses orig = new EsriShape <ObjectClass>(objectClassOrig); dest = new EsriShape <ObjectClass>(objectClassDest); this.Shapes.Add(this.Shapes.CreateKey(), orig); this.Shapes.Add(this.Shapes.CreateKey(), dest); // Get Subtypes List <Subtype> subtypesOrig = objectClassOrig.GetSubtypes(); List <Subtype> subtypesDest = objectClassDest.GetSubtypes(); // Add Subtypes foreach (Subtype subtype in subtypesOrig) { EsriShape <Subtype> sub = new EsriShape <Subtype>(subtype); this.Shapes.Add(this.Shapes.CreateKey(), sub); Arrow arrow = new Arrow(); arrow.BorderColor = ModelSettings.Default.DisabledLined; arrow.DrawBackground = false; Line line = new Line(orig, sub); line.BorderColor = ModelSettings.Default.DisabledLined; line.End.AllowMove = false; line.End.Marker = arrow; line.Start.AllowMove = false; this.Lines.Add(this.Lines.CreateKey(), line); originSubtypes.Add(sub); } foreach (Subtype subtype in subtypesDest) { EsriShape <Subtype> sub = new EsriShape <Subtype>(subtype); this.Shapes.Add(this.Shapes.CreateKey(), sub); Arrow arrow = new Arrow(); arrow.BorderColor = ModelSettings.Default.DisabledLined; arrow.DrawBackground = false; Line line = new Line(sub, dest); line.BorderColor = ModelSettings.Default.DisabledLined; line.End.AllowMove = false; line.Start.AllowMove = false; line.Start.Marker = arrow; this.Lines.Add(this.Lines.CreateKey(), line); destinationSubtypes.Add(sub); } // Get Rules List <RelationshipRule> rules = this._relationshipClass.RelationshipRules; foreach (RelationshipRule rule in rules) { Shape shapeOrign = null; if (subtypesOrig.Count == 0) { shapeOrign = orig; } else { foreach (EsriShape <Subtype> subtype in originSubtypes) { if (subtype.Parent.SubtypeCode == rule.OriginSubtype) { shapeOrign = subtype; break; } } } Shape shapeDestination = null; if (subtypesDest.Count == 0) { shapeDestination = dest; } else { foreach (EsriShape <Subtype> subtype in destinationSubtypes) { if (subtype.Parent.SubtypeCode == rule.DestinationSubtype) { shapeDestination = subtype; break; } } } if (shapeOrign == null || shapeDestination == null) { continue; } // EsriLine <RelationshipRule> line = new EsriLine <RelationshipRule>(rule, shapeOrign, shapeDestination); this.Lines.Add(this.Lines.CreateKey(), line); } // 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); } // Get Model DiagrammerEnvironment de = DiagrammerEnvironment.Default; if (de == null) { return(null); } SchemaModel model = de.SchemaModel; if (model == null) { return(null); } // Create List List <string> list = new List <string>(); // In some cases do not display list of subtypes bool skip = false; if (context.PropertyDescriptor.ComponentType == typeof(TopologyRule)) { // If "All Subtypes" then do not show dropdown TopologyRule topologyRule = (TopologyRule)context.Instance; switch (context.PropertyDescriptor.Name) { case "OriginSubtype": skip = topologyRule.AllOriginSubtypes; break; case "DestinationSubtype": skip = topologyRule.AllDestinationSubtypes; break; } } // if (!skip) { ObjectClass objectClass = this.GetObjectClass(context); if (objectClass != null) { List <Subtype> subtypes = objectClass.GetSubtypes(); foreach (Subtype subtype in subtypes) { list.Add(subtype.SubtypeName); } if (subtypes.Count == 0) { list.Add(Resources.TEXT_CLASS_BR); } } } // Sort List list.Sort(); list.Insert(0, Resources.TEXT_NONE_BR); // Return List StandardValuesCollection svc = new StandardValuesCollection(list); return(svc); }
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (context == null) { return(null); } if (context.Instance == null) { return(null); } if (destinationType == null) { throw new ArgumentNullException("destinationType"); } if (destinationType == typeof(string)) { if (value.GetType() == typeof(int)) { int id = Convert.ToInt32(value); ObjectClass objectClass = this.GetObjectClass(context); if (objectClass == null) { return(Resources.TEXT_NONE_BR); } List <Subtype> subtypes = objectClass.GetSubtypes(); if (subtypes.Count == 0) { if (id == -1) { return(Resources.TEXT_NONE_BR); } return(Resources.TEXT_CLASS_BR); } if (context.PropertyDescriptor.ComponentType == typeof(TopologyRule)) { TopologyRule topologyRule = (TopologyRule)context.Instance; switch (context.PropertyDescriptor.Name) { case "OriginSubtype": if (topologyRule.OriginSubtype == 0 && topologyRule.AllOriginSubtypes) { return(Resources.TEXT_NONE_BR); } break; case "DestinationSubtype": if (topologyRule.DestinationSubtype == 0 && topologyRule.AllDestinationSubtypes) { return(Resources.TEXT_NONE_BR); } break; } } Subtype subtype = objectClass.FindSubtype(id); if (subtype == null) { return(Resources.TEXT_NONE_BR); } return(subtype.SubtypeName); } } return(base.ConvertTo(context, culture, value, destinationType)); }
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(); }