private void CustomReferenceModeAddEvent(object sender, ElementAddedEventArgs e) { ModelHasReferenceMode link = e.ModelElement as ModelHasReferenceMode; CustomReferenceMode customReferenceMode = link.ReferenceMode as CustomReferenceMode; if (customReferenceMode != null && !customReferenceMode.IsDeleted && link.Model == this.myModel) { int index = myCustomReferenceModesList.BinarySearch(customReferenceMode, NamedElementComparer <CustomReferenceMode> .CurrentCulture); int insertAt = 0; insertAt = (index < 0) ? ~index : index; myCustomReferenceModesList.Insert(insertAt, customReferenceMode); if (myModify != null) { if (myIDidIt) { myIDidIt = false; myModify(this, BranchModificationEventArgs.InsertItems(this, myCustomReferenceModesList.Count - 1, 1)); if (insertAt != index) { myModify(this, BranchModificationEventArgs.MoveItem(this, myCustomReferenceModesList.Count - 1, insertAt)); } } else { myModify(this, BranchModificationEventArgs.InsertItems(this, insertAt - 1, 1)); } } } }
private void CustomReferenceModeRemoveEvent(object sender, ElementDeletedEventArgs e) { ModelHasReferenceMode link = e.ModelElement as ModelHasReferenceMode; CustomReferenceMode customReferenceMode = link.ReferenceMode as CustomReferenceMode; if (customReferenceMode != null && link.Model == this.myModel) { int row = this.FindReferenceMode(customReferenceMode); if (row >= 0) { myCustomReferenceModesList.RemoveAt(row); if (myModify != null) { myModify(this, BranchModificationEventArgs.DeleteItems(this, row, 1)); } } } }