private void IdentityCollection_CollectionChangeRemoved(object sender, IdentityCollectionRemoveEventArgs e) { List <IIdentifier> list = new List <IIdentifier>(e.RemovedItems); IdentityCollectionRemoveEventArgs args = new IdentityCollectionRemoveEventArgs(list); CollectionChangeRemoved?.Invoke(this, args); }
/// <summary> /// Removes given item from collection, if collection contains this item. /// </summary> /// <param name="item">Item to remove from collection.</param> public void RemoveItem(T item) { List <IIdentifier> list = new List <IIdentifier>(); if (Remove(item)) { list.Add(item.Identifier); IdentityCollectionRemoveEventArgs args = new IdentityCollectionRemoveEventArgs(list); CollectionChangeRemoved?.Invoke(this, args); } }
public void RemoveRange(IEnumerable <string> itemIds) { List <string> removed = new List <string>(); foreach (string id in itemIds) { if (Remove(id, false)) { removed.Add(id); } } if (removed.Count > 0) { SelectionCollectionRemoveEventArgs args = new SelectionCollectionRemoveEventArgs(removed); CollectionChangeRemoved?.Invoke(this, args); } }
private bool Remove(string id, bool sendEvent) { if (allItems.Any(x => x.Id.Equals(id))) { allItems.Remove(allItems.First(x => x.Id.Equals(id))); if (sendEvent) { SelectionCollectionRemoveEventArgs args = new SelectionCollectionRemoveEventArgs(new List <string>() { id }); CollectionChangeRemoved?.Invoke(this, args); } return(true); } return(false); }
/// <summary> /// Removes given items from collection, if collection contains these items. /// </summary> /// <param name="items">Items to remove from collection.</param> public void RemoveRange(IEnumerable <T> items) { List <IIdentifier> list = new List <IIdentifier>(); foreach (T target in items) { if (Remove(target)) { list.Add(target.Identifier); } } if (list.Count > 0) { IdentityCollectionRemoveEventArgs args = new IdentityCollectionRemoveEventArgs(list); CollectionChangeRemoved?.Invoke(this, args); } }
public void RemoveRange(IEnumerable <T> targetItems) { List <IIdentifier> removed = new List <IIdentifier>(); foreach (T target in targetItems) { if (Remove(target, false)) { removed.Add(target.Identifier); } } if (removed.Count > 0) { SelectionCollectionRemoveEventArgs args = new SelectionCollectionRemoveEventArgs(removed); CollectionChangeRemoved?.Invoke(this, args); } }
private bool Remove(T targetItem, bool sendEvent) { if (allItems.Any(x => x.Target.Identifier.Id.Equals(targetItem.Identifier.Id))) { allItems.Remove(allItems.First(x => x.Target.Identifier.Id.Equals(targetItem.Identifier.Id))); if (sendEvent) { SelectionCollectionRemoveEventArgs args = new SelectionCollectionRemoveEventArgs(new List <IIdentifier>() { targetItem.Identifier }); CollectionChangeRemoved?.Invoke(this, args); } return(true); } return(false); }
private void Remove(IEnumerable <IIdentifier> targetIdentifiers) { List <IIdentifier> removed = new List <IIdentifier>(); foreach (IIdentifier item in targetIdentifiers) { if (allItems.Any(x => x.Target.Identifier.Id.Equals(item.Id))) { allItems.Remove(allItems.First(x => x.Target.Identifier.Id.Equals(item.Id))); removed.Add(item); } } if (removed.Count > 0) { SelectionCollectionRemoveEventArgs args = new SelectionCollectionRemoveEventArgs(removed); CollectionChangeRemoved?.Invoke(this, args); } }