/// <summary> /// Copy items from source collection to target collection. /// </summary> /// <param name="collection">Target collection.</param> /// <param name="newItems">Source collection.</param> protected override void _CopyItems(IList collection, IList newItems) { // Get filter for collection. int index = Collections.IndexOf(collection); MultiCollectionFilter filter = _multiCollectionFilters[index]; collection.Clear(); foreach (object item in newItems) { Debug.Assert(!collection.Contains(item)); // Add item, if item can be add. if (filter(item)) { collection.Add(item); // If item not selected - select in child context. if (!collection.Contains(item)) { int dataGridIndex = Collections.IndexOf(collection); DataGridList[dataGridIndex].SelectInChildContext(item); } } } }
/// <summary> /// Add items to collection. /// </summary> /// <param name="collection">Collection, from to items will added.</param> /// <param name="addedItems">Items to add.</param> /// <param name="newStartingIndex">New starting index.</param> protected override void _AddItems(IList collection, IList addedItems, int newStartingIndex) { // Get filter for collection. int collectionIndex = Collections.IndexOf(collection); MultiCollectionFilter filter = _multiCollectionFilters[collectionIndex]; int index = newStartingIndex; foreach (object addItem in addedItems) { Debug.Assert(!collection.Contains(addItem)); if (!collection.Contains(addItem)) { if (filter(addItem)) { if (collection.Count >= index) { collection.Insert(index++, addItem); } else { collection.Add(addItem); } } } } }
/// <summary> /// Register grid collection /// </summary> /// <param name="grid">Grid to register</param> /// <param name="multiCollectionFilter">Collection filter.</param> public void RegisterCollection(IList collection, MultiCollectionFilter multiCollectionFilter) { _multiCollectionFilters.Add(multiCollectionFilter); _RegisterCollection(collection); }
/// <summary> /// Register grid collection. /// </summary> /// <param name="grid">Grid to register.</param> /// <param name="multiCollectionFilter">Collection filter.</param> public void RegisterCollection(DataGridControlEx grid, MultiCollectionFilter multiCollectionFilter) { _multiCollectionFilters.Add(multiCollectionFilter); _RegisterCollection(grid); }
/// <summary> /// Constuctor. /// </summary> /// <param name="canSelect">Delegate for checking newly added items.</param> public MultiCollectionBindingEx(MultiCollectionFilter canSelect) { Debug.Assert(canSelect != null); _canSelect = canSelect; }