Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using System.Collections.Specialized;
|
---|
6 | using Microsoft.Research.DynamicDataDisplay.Charts;
|
---|
7 |
|
---|
8 | namespace Microsoft.Research.DynamicDataDisplay.Common.Auxiliary
|
---|
9 | {
|
---|
10 | public static class NotifyCollectionChangedEventArgsExtensions
|
---|
11 | {
|
---|
12 | public static int GetLastAddedIndex(this NotifyCollectionChangedEventArgs args)
|
---|
13 | {
|
---|
14 | if (args.NewItems == null)
|
---|
15 | throw new InvalidOperationException("Cannot get last added index when NewItems are null.");
|
---|
16 |
|
---|
17 | int lastIndex = args.NewStartingIndex + args.NewItems.Count;
|
---|
18 |
|
---|
19 | return lastIndex;
|
---|
20 | }
|
---|
21 |
|
---|
22 | public static Range<int> GetAddedRange(this NotifyCollectionChangedEventArgs args)
|
---|
23 | {
|
---|
24 | int lastIndex = GetLastAddedIndex(args);
|
---|
25 |
|
---|
26 | return new Range<int>(args.NewStartingIndex, lastIndex);
|
---|
27 | }
|
---|
28 | }
|
---|
29 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.