private void HandleModifiedItemsForFooterOfCollection(NotifyKeyGroupsCollectionChangedEventArgs e) { if (e.Action != NotifyCollectionChangedAction.Add || !_collectionChangedAction.IsAlive) { return; } var lastDataSourceItemIndex = ItemCount - 1; var lastGroupedDataSourceItemIndex = GroupedDataSource.Count - 1; var lastInsertedSectionIndex = int.MinValue; if (e.ModifiedSectionsIndexes.Any()) { lastInsertedSectionIndex = e.ModifiedSectionsIndexes.Max(); } if (lastInsertedSectionIndex == lastGroupedDataSourceItemIndex) { _collectionChangedAction.Execute(lastDataSourceItemIndex); } else { var(section, modifiedIndexes) = e.ModifiedItemsIndexes.FirstOrDefault(x => x.Section == lastGroupedDataSourceItemIndex); if (modifiedIndexes != null && modifiedIndexes.Any()) { var lastInsertedItemIndex = modifiedIndexes.Max(); if (lastInsertedItemIndex == GroupedDataSource[section].Count - 1) { _collectionChangedAction.Execute(lastDataSourceItemIndex); } } } }
private void HandleModifiedItemsForLastItemRequest(NotifyKeyGroupsCollectionChangedEventArgs e) { if (e.Action != NotifyCollectionChangedAction.Add) { return; } var lastModifiedItemsCount = 0; foreach (var newSectionIndex in e.ModifiedSectionsIndexes) { lastModifiedItemsCount += GroupedDataSource[newSectionIndex].Count + 1; } foreach (var(section, modifiedIndexes) in e.ModifiedItemsIndexes) { lastModifiedItemsCount += modifiedIndexes.Count; } if (lastModifiedItemsCount > 0) { if (_lastItemsLoadedAction.IsAlive) { _lastItemsLoadedAction.Execute(lastModifiedItemsCount); } } }
private void OnMessagesAddedToCollection(object sender, NotifyKeyGroupsCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Add || e.Action == NotifyCollectionChangedAction.Reset) { MarkMessagesAsRead(); } }
public void NotifyKeyGroupsCollectionChangedEventArgs_WhenCreated_InitializesProperties( NotifyCollectionChangedAction action, List <int> oldSectionsSizes) { var args = new NotifyKeyGroupsCollectionChangedEventArgs(action, oldSectionsSizes); if (oldSectionsSizes == null) { oldSectionsSizes = new List <int>(); } Assert.Equal(action, args.Action); Assert.Equal(oldSectionsSizes, args.OldSectionsSizes); Assert.Equal(oldSectionsSizes.Count, args.OldSectionsCount); Assert.Empty(args.ModifiedSectionsIndexes); Assert.Empty(args.ModifiedItemsIndexes); }
protected override void NotifyCollectionChanged(NotifyKeyGroupsCollectionChangedEventArgs e) { HandleModifiedItemsForLastItemRequest(e); HandleModifiedItemsForFooterOfCollection(e); }