Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/DynamicDataDisplay/Common/Auxiliary/NotifyCollectionChangedEventArgsExtensions.cs @ 13792

Last change on this file since 13792 was 12503, checked in by aballeit, 9 years ago

#2283 added GUI and charts; fixed MCTS

File size: 850 bytes
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Collections.Specialized;
6using Microsoft.Research.DynamicDataDisplay.Charts;
7
8namespace 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.