protected override void OnElementInserted(Element element) { // Call base method base.OnElementInserted(element); // Fix: Force newly added table to have a Maximum size of 1000x1000. Model resets size to 320x320. if (!this.SuspendEvents) { if (element is EsriTable) { EsriTable table = (EsriTable)element; if (table.MaximumSize.Width != 1000f || table.MaximumSize.Height != 100000f) { table.MaximumSize = new SizeF(1000f, 100000f); } // Select newly added element if (!table.Selected) { // Clear Model Selection this.SelectElements(false); table.Selected = true; } } } // Add dependant objects. For example, annotation featureclass require domains. if (!this.SuspendEvents) { if (element.GetType() == typeof(FeatureClass)) { FeatureClass featureClass = (FeatureClass)element; List<Domain> domains = Factory.RequiredDomains(featureClass); float y = 0; foreach (Domain domain in domains) { // Check if domain already added if (this.FindDomain(domain.Name) != null) { continue; } // Add domain with vertical offset y += featureClass.Height; domain.Location = new PointF( featureClass.Location.X, featureClass.Location.Y + y); this.Shapes.Add(this.Shapes.CreateKey(), domain); } } } // Reset Navigator this.Navigate.Reset(); }
//Methods public virtual void Add(string key, Element value ) { if (! mModifiable) throw new CollectionNotModifiableException("This collection is not modifiable."); if (value == null) throw new ArgumentNullException("value","Element parameter cannot be null reference."); if (key == null) throw new ArgumentNullException("key","Key may not be null."); if (key == "") throw new ArgumentException("Key may not be null string.","key"); if (! mBaseType.IsInstanceOfType(value) && ! value.GetType().IsSubclassOf(mBaseType)) throw new ArgumentException("Items added to this collection must be of or inherit from type '" + mBaseType.ToString()); //Key can be reset by removing and then readding to collection value.SetKey(key); Dictionary.Add(key, value ); //Zordering now done outside the collection //Since multiple collections can contain the same reference eg layer OnInsert(key,value); }