/Main/src/DynamicDataDisplay/Common/Auxiliary/NotifyCollectionChangedEventArgsExtensions.cs
C# | 29 lines | 24 code | 5 blank | 0 comment | 2 complexity | 3b1e528c1162409b281d1dcc2ef386c3 MD5 | raw file
Possible License(s): CC-BY-SA-3.0
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Collections.Specialized;
- using Microsoft.Research.DynamicDataDisplay.Charts;
-
- namespace Microsoft.Research.DynamicDataDisplay.Common.Auxiliary
- {
- public static class NotifyCollectionChangedEventArgsExtensions
- {
- public static int GetLastAddedIndex(this NotifyCollectionChangedEventArgs args)
- {
- if (args.NewItems == null)
- throw new InvalidOperationException("Cannot get last added index when NewItems are null.");
-
- int lastIndex = args.NewStartingIndex + args.NewItems.Count;
-
- return lastIndex;
- }
-
- public static Range<int> GetAddedRange(this NotifyCollectionChangedEventArgs args)
- {
- int lastIndex = GetLastAddedIndex(args);
-
- return new Range<int>(args.NewStartingIndex, lastIndex);
- }
- }
- }