private void FilterUpdate() { // Suspend if (ModelSettings.Default.EnableUndoRedo) { this.UndoList.Suspend(); } this.Suspend(); this.SuspendEvents = true; foreach (Element element in this.Lines.Values) { if (element is EsriLine <TopologyRule> ) { EsriLine <TopologyRule> line = (EsriLine <TopologyRule>)element; TopologyRule topologyRule = line.Parent; line.Visible = this._topologyRuleType == esriTopologyRuleType.esriTRTAny || this._topologyRuleType == topologyRule.TopologyRuleType; } } // Resume and Refresh Model this.SuspendEvents = false; this.Resume(); if (ModelSettings.Default.EnableUndoRedo) { this.UndoList.Resume(); } this.Refresh(); }
private void Model_ElementRemoved(object sender, ElementsEventArgs e) { // Check Topology if (this._topology == null) { return; } // Get Element Element element = e.Value; if (element == null) { return; } EsriLine <TopologyRule> line = element as EsriLine <TopologyRule>; if (line == null) { return; } // Get Rule TopologyRule rule = line.Parent; // Remove rule from relationship this._topology.TopologyRules.Remove(rule); }
// // PRIVATE METHODS // private void Model_ElementInserted(object sender, ElementsEventArgs e) { // Check Topology if (this._topology == null) { return; } // Get Element Element element = e.Value; if (element == null) { return; } EsriLine <TopologyRule> line = element as EsriLine <TopologyRule>; if (line == null) { return; } // Get Rule TopologyRule rule = line.Parent; // Add Rule this._topology.TopologyRules.Add(rule); }
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (context == null) { return(null); } if (context.Instance == null) { return(null); } if (value.GetType() == typeof(string)) { string text = Convert.ToString(value); // "" or "(None)" if (text == string.Empty || text == Resources.TEXT_NONE_BR) { if (context.PropertyDescriptor.ComponentType == typeof(TopologyRule)) { TopologyRule topologyRule = (TopologyRule)context.Instance; switch (context.PropertyDescriptor.Name) { case "OriginSubtype": return(topologyRule.AllOriginSubtypes ? 0 : -1); case "DestinationSubtype": return(topologyRule.AllDestinationSubtypes ? 0 : -1); default: return(-1); } } return(-1); } // "(Class)" if (text == Resources.TEXT_CLASS_BR) { return(0); } // Subtype Name ObjectClass objectClass = this.GetObjectClass(context); if (objectClass == null) { return(-1); } Subtype subtype = objectClass.FindSubtype(text); if (subtype == null) { return(-1); } return(subtype.SubtypeCode); } return(base.ConvertFrom(context, culture, value)); }
public TopologyRule(TopologyRule prototype) : base(prototype) { this._name = prototype.Name; this._guid = prototype.Guid; this._topologyRuleType = prototype.TopologyRuleType; this._originClassId = prototype.OriginClassId; this._originSubtype = prototype.OriginSubtype; this._destinationClassId = prototype.DestinationClassId; this._destinationSubtype = prototype.DestinationSubtype; this._triggerErrorEvents = prototype.TriggerErrorEvents; this._allOriginSubtypes = prototype.AllOriginSubtypes; this._allDestinationSubtypes = prototype.AllDestinationSubtypes; }
// // CONSTRUCTOR // public Topology(IXPathNavigable path) : base(path) { // Get Navigator XPathNavigator navigator = path.CreateNavigator(); // <Extent></Extent> XPathNavigator navigatorExtent = navigator.SelectSingleNode(Xml.EXTENT); if (navigatorExtent != null) { this._extent = new Extent(navigatorExtent); } else { this._extent = new Extent(); } // <SpatialReference></SpatialReference> XPathNavigator navigatorSpatialReference = navigator.SelectSingleNode(Xml.SPATIALREFERENCE); if (navigatorSpatialReference != null) { this._spatialReference = new SpatialReference(navigatorSpatialReference); } else { this._spatialReference = new SpatialReference(); } // <ClusterTolerance></ClusterTolerance> XPathNavigator navigatorClusterTolerance = navigator.SelectSingleNode(Xml.CLUSTERTOLERANCE); if (navigatorClusterTolerance != null) { this._clusterTolerance = navigatorClusterTolerance.ValueAsDouble; } // <ZClusterTolerance></ZClusterTolerance> XPathNavigator navigatorZClusterTolerance = navigator.SelectSingleNode(Xml.ZCLUSTERTOLERANCE); if (navigatorZClusterTolerance != null) { this._zClusterTolerance = navigatorZClusterTolerance.ValueAsDouble; } // <MaxGeneratedErrorCount></MaxGeneratedErrorCount> XPathNavigator navigatorMaxGeneratedErrorCount = navigator.SelectSingleNode(Xml.MAXGENERATEDERRORCOUNT); if (navigatorMaxGeneratedErrorCount != null) { this._maxGeneratedErrorCount = navigatorMaxGeneratedErrorCount.ValueAsInt; } // <TopologyRules><TopologyRule></TopologyRule></TopologyRules> this._topologyRules = new List <TopologyRule>(); XPathNodeIterator interatorTopologyRule = navigator.Select(string.Format("{0}/{1}", Xml.TOPOLOGYRULES, Xml.TOPOLOGYRULE)); while (interatorTopologyRule.MoveNext()) { // Get <TopologyRule> XPathNavigator navigatorTopologyRule = interatorTopologyRule.Current; // Add Topology Rule TopologyRule topologyRule = new TopologyRule(navigatorTopologyRule); this._topologyRules.Add(topologyRule); } }
// // CONSTRUCTOR // public Topology(IXPathNavigable path) : base(path) { // Get Navigator XPathNavigator navigator = path.CreateNavigator(); // <Extent></Extent> XPathNavigator navigatorExtent = navigator.SelectSingleNode(Xml.EXTENT); if (navigatorExtent != null) { this._extent = new Extent(navigatorExtent); } else { this._extent = new Extent(); } // <SpatialReference></SpatialReference> XPathNavigator navigatorSpatialReference = navigator.SelectSingleNode(Xml.SPATIALREFERENCE); if (navigatorSpatialReference != null) { this._spatialReference = new SpatialReference(navigatorSpatialReference); } else { this._spatialReference = new SpatialReference(); } // <ClusterTolerance></ClusterTolerance> XPathNavigator navigatorClusterTolerance = navigator.SelectSingleNode(Xml.CLUSTERTOLERANCE); if (navigatorClusterTolerance != null) { this._clusterTolerance = navigatorClusterTolerance.ValueAsDouble; } // <ZClusterTolerance></ZClusterTolerance> XPathNavigator navigatorZClusterTolerance = navigator.SelectSingleNode(Xml.ZCLUSTERTOLERANCE); if (navigatorZClusterTolerance != null) { this._zClusterTolerance = navigatorZClusterTolerance.ValueAsDouble; } // <MaxGeneratedErrorCount></MaxGeneratedErrorCount> XPathNavigator navigatorMaxGeneratedErrorCount = navigator.SelectSingleNode(Xml.MAXGENERATEDERRORCOUNT); if (navigatorMaxGeneratedErrorCount != null) { this._maxGeneratedErrorCount = navigatorMaxGeneratedErrorCount.ValueAsInt; } // <TopologyRules><TopologyRule></TopologyRule></TopologyRules> this._topologyRules = new List<TopologyRule>(); XPathNodeIterator interatorTopologyRule = navigator.Select(string.Format("{0}/{1}", Xml.TOPOLOGYRULES, Xml.TOPOLOGYRULE)); while (interatorTopologyRule.MoveNext()) { // Get <TopologyRule> XPathNavigator navigatorTopologyRule = interatorTopologyRule.Current; // Add Topology Rule TopologyRule topologyRule = new TopologyRule(navigatorTopologyRule); this._topologyRules.Add(topologyRule); } }
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); }
private ObjectClass GetObjectClass(ITypeDescriptorContext context) { DiagrammerEnvironment de = DiagrammerEnvironment.Default; SchemaModel model = de.SchemaModel; ObjectClass objectClass = null; if (context.PropertyDescriptor.ComponentType == typeof(EdgeConnectivityRule)) { EdgeConnectivityRule edgeConnectivityRule = (EdgeConnectivityRule)context.Instance; switch (context.PropertyDescriptor.Name) { case "FromEdgeSubtypeCode": objectClass = model.FindObjectClass(edgeConnectivityRule.FromClassID); break; case "ToEdgeSubtypeCode": objectClass = model.FindObjectClass(edgeConnectivityRule.ToClassID); break; case "DefaultJunctionSubtypeCode": objectClass = model.FindObjectClass(edgeConnectivityRule.DefaultJunctionID); break; } } else if (context.PropertyDescriptor.ComponentType == typeof(JunctionSubtype)) { JunctionSubtype junctionSubtype = (JunctionSubtype)context.Instance; switch (context.PropertyDescriptor.Name) { case "SubtypeCode": objectClass = model.FindObjectClass(junctionSubtype.ClassID); break; } } else if (context.PropertyDescriptor.ComponentType == typeof(RelationshipRule)) { RelationshipRule relationshipRule = (RelationshipRule)context.Instance; switch (context.PropertyDescriptor.Name) { case "OriginSubtype": objectClass = model.FindObjectClass(relationshipRule.OriginClass); break; case "DestinationSubtype": objectClass = model.FindObjectClass(relationshipRule.DestinationClass); break; } } else if (context.PropertyDescriptor.ComponentType == typeof(JunctionConnectivityRule)) { JunctionConnectivityRule junctionConnectivityRule = (JunctionConnectivityRule)context.Instance; switch (context.PropertyDescriptor.Name) { case "EdgeSubtypeCode": objectClass = model.FindObjectClass(junctionConnectivityRule.EdgeClassID); break; case "SubtypeCode": objectClass = model.FindObjectClass(junctionConnectivityRule.JunctionClassID); break; } } else if (context.PropertyDescriptor.ComponentType == typeof(TopologyRule)) { TopologyRule topologyRule = (TopologyRule)context.Instance; switch (context.PropertyDescriptor.Name) { case "OriginSubtype": objectClass = model.FindObjectClass(topologyRule.OriginClassId); break; case "DestinationSubtype": objectClass = model.FindObjectClass(topologyRule.DestinationClassId); break; } } return(objectClass); }
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 Model_ElementInvalid(object sender, ElementEventArgs e) { // Exit if Topology Does not Exist if (this._topology == null) { return; } // Get Element Element element = e.Value; if (element == null) { return; } EsriLine <TopologyRule> line = element as EsriLine <TopologyRule>; if (line == null) { return; } // Get TopologyRule TopologyRule rule = line.Parent; // Suspend Rule Events rule.Suspend(); // Get Start and End Elements Element elementStart = line.Start.Shape; Element elementEnd = line.End.Shape; // Update Start Class/Subtype if (elementStart == null) { rule.AllOriginSubtypes = false; rule.OriginClassId = -1; rule.OriginSubtype = -1; } else if (elementStart is EsriShape <FeatureClass> ) { EsriShape <FeatureClass> shape = (EsriShape <FeatureClass>)elementStart; ObjectClass objectClass = shape.Parent; rule.AllOriginSubtypes = true; rule.OriginClassId = objectClass.DSID; rule.OriginSubtype = 0; } else if (elementStart is EsriShape <Subtype> ) { EsriShape <Subtype> shape = (EsriShape <Subtype>)elementStart; Subtype subtype = shape.Parent; ObjectClass objectClass = subtype.GetParent(); rule.AllOriginSubtypes = false; if (objectClass == null) { rule.OriginClassId = -1; rule.OriginSubtype = -1; } else { rule.OriginClassId = objectClass.DSID; rule.OriginSubtype = subtype.SubtypeCode; } } // Update End Class/Subtype if (elementEnd == null) { rule.AllDestinationSubtypes = false; rule.DestinationClassId = -1; rule.DestinationSubtype = -1; } else if (elementEnd is EsriShape <FeatureClass> ) { EsriShape <FeatureClass> shape = (EsriShape <FeatureClass>)elementEnd; ObjectClass objectClass = shape.Parent; rule.AllDestinationSubtypes = true; rule.DestinationClassId = objectClass.DSID; rule.DestinationSubtype = 0; } else if (elementEnd is EsriShape <Subtype> ) { EsriShape <Subtype> shape = (EsriShape <Subtype>)elementEnd; Subtype subtype = shape.Parent; ObjectClass objectClass = subtype.GetParent(); rule.AllDestinationSubtypes = false; if (objectClass == null) { rule.DestinationClassId = -1; rule.DestinationSubtype = -1; } else { rule.DestinationClassId = objectClass.DSID; rule.DestinationSubtype = subtype.SubtypeCode; } } // Resume Rule Events rule.Resume(); }
public TopologyRule(TopologyRule prototype) : base(prototype) { this._name = prototype.Name; this._guid = prototype.Guid; this._topologyRuleType = prototype.TopologyRuleType; this._originClassId = prototype.OriginClassId; this._originSubtype = prototype.OriginSubtype; this._destinationClassId = prototype.DestinationClassId; this._destinationSubtype = prototype.DestinationSubtype; this._triggerErrorEvents = prototype.TriggerErrorEvents; this._allOriginSubtypes = prototype.AllOriginSubtypes; this._allDestinationSubtypes = prototype.AllDestinationSubtypes; }