protected virtual bool OnBeforeRemoveItemEvent(EntityObject item) { BeforeRemoveItemEventHandler ae = this.BeforeRemoveItem; if (ae != null) { EntityCollectionEventArgs e = new EntityCollectionEventArgs(item); ae(this, e); return(e.Cancel); } return(false); }
private void Entities_RemoveItem(EntityCollection sender, EntityCollectionEventArgs e) { if (this.readOnly) return; if (e.Item.Type == EntityType.Hatch) { Hatch hatch = (Hatch)e.Item; foreach (HatchBoundaryPath path in hatch.BoundaryPaths) { this.Hatch_BoundaryPathRemoved(hatch, new ObservableCollectionEventArgs<HatchBoundaryPath>(path)); } hatch.HatchBoundaryPathAdded -= this.Hatch_BoundaryPathAdded; hatch.HatchBoundaryPathRemoved -= this.Hatch_BoundaryPathRemoved; } this.OnEntityRemovedEvent(e.Item); e.Item.Owner = null; }
private void Entities_BeforeRemoveItem(EntityCollection sender, EntityCollectionEventArgs e) { // only items owned by the actual block can be removed e.Cancel = !ReferenceEquals(e.Item.Owner, this) || this.readOnly; }
private void Entities_BeforeAddItem(EntityCollection sender, EntityCollectionEventArgs e) { // null items, entities already owned by another Block, attribute definitions and attributes are not allowed in the entities list. if (e.Item == null) e.Cancel = true; else if (this.entities.Contains(e.Item)) e.Cancel = true; else if (this.readOnly) e.Cancel = true; else if (e.Item is AttributeDefinition) e.Cancel = true; else if (e.Item.Owner != null) { // if the block does not belong to a document, all entities which owner is not null will be rejected if(this.Record.Owner == null) e.Cancel = true; // if the block belongs to a document, the entity will be added to the block only if both, the block and the entity document, are the same // this is handled by the BlocksRecordCollection } else e.Cancel = false; }
private void Entities_AddItem(EntityCollection sender, EntityCollectionEventArgs e) { if (this.readOnly) return; // if the entity is a hatch we will also add the boundary entities to the block if (e.Item.Type == EntityType.Hatch) { Hatch hatch = (Hatch) e.Item; foreach (HatchBoundaryPath path in hatch.BoundaryPaths) { this.Hatch_BoundaryPathAdded(hatch, new ObservableCollectionEventArgs<HatchBoundaryPath>(path)); } hatch.HatchBoundaryPathAdded += this.Hatch_BoundaryPathAdded; hatch.HatchBoundaryPathRemoved += this.Hatch_BoundaryPathRemoved; } this.OnEntityAddedEvent(e.Item); e.Item.Owner = this; }
private void Entities_RemoveItem(EntityCollection sender, EntityCollectionEventArgs e) { this.OnEntityRemovedEvent(e.Item); }
private void Entities_AddItem(EntityCollection sender, EntityCollectionEventArgs e) { this.OnEntityAddedEvent(e.Item); }
private void Entities_BeforeRemoveItem(EntityCollection sender, EntityCollectionEventArgs e) { }
private void Entities_BeforeAddItem(EntityCollection sender, EntityCollectionEventArgs e) { // null or duplicate items are not allowed in the entities list. if (e.Item == null) e.Cancel = true; else if (this.entities.Contains(e.Item)) e.Cancel = true; else e.Cancel = false; }
private void Entities_RemoveItem(EntityCollection sender, EntityCollectionEventArgs e) { e.Item.RemoveReactor(this); this.OnEntityRemovedEvent(e.Item); }
private void Entities_AddItem(EntityCollection sender, EntityCollectionEventArgs e) { e.Item.AddReactor(this); this.OnEntityAddedEvent(e.Item); }
private void Entities_RemoveItem(EntityCollection sender, EntityCollectionEventArgs e) { if (this.readOnly) return; this.OnEntityRemovedEvent(e.Item); e.Item.Owner = null; }
private void Entities_AddItem(EntityCollection sender, EntityCollectionEventArgs e) { if (this.readOnly) return; this.OnEntityAddedEvent(e.Item); e.Item.Owner = this; }