/// <summary> /// Gets called when the parent model element of the current model element is about to change /// </summary> /// <param name="oldParent">The old parent model element</param> /// <param name="newParent">The new parent model element</param> protected override void OnParentChanging(IModelElement newParent, IModelElement oldParent) { IGrafcet oldGrafcet = ModelHelper.CastAs <IGrafcet>(oldParent); IGrafcet newGrafcet = ModelHelper.CastAs <IGrafcet>(newParent); ValueChangedEventArgs e = new ValueChangedEventArgs(oldGrafcet, newGrafcet); this.OnGrafcetChanging(e); this.OnPropertyChanging("Grafcet", e, _grafcetReference); }
/// <summary> /// Adds the given element to the collection /// </summary> /// <param name="item">The item to add</param> public override void Add(IModelElement item) { if ((this._parent.Grafcet == null)) { IGrafcet grafcetCasted = item.As <IGrafcet>(); if ((grafcetCasted != null)) { this._parent.Grafcet = grafcetCasted; return; } } }
/// <summary> /// Gets called when the parent model element of the current model element changes /// </summary> /// <param name="oldParent">The old parent model element</param> /// <param name="newParent">The new parent model element</param> protected override void OnParentChanged(IModelElement newParent, IModelElement oldParent) { IGrafcet oldGrafcet = ModelHelper.CastAs <IGrafcet>(oldParent); IGrafcet newGrafcet = ModelHelper.CastAs <IGrafcet>(newParent); if ((oldGrafcet != null)) { oldGrafcet.Elements.Remove(this); } if ((newGrafcet != null)) { newGrafcet.Elements.Add(this); } ValueChangedEventArgs e = new ValueChangedEventArgs(oldGrafcet, newGrafcet); this.OnGrafcetChanged(e); this.OnPropertyChanged("Grafcet", e, _grafcetReference); base.OnParentChanged(newParent, oldParent); }