本文整理汇总了C#中System.Collections.Specialized.NotifyCollectionChangedEventArgs.GetAddedRange方法的典型用法代码示例。如果您正苦于以下问题:C# NotifyCollectionChangedEventArgs.GetAddedRange方法的具体用法?C# NotifyCollectionChangedEventArgs.GetAddedRange怎么用?C# NotifyCollectionChangedEventArgs.GetAddedRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Specialized.NotifyCollectionChangedEventArgs
的用法示例。
在下文中一共展示了NotifyCollectionChangedEventArgs.GetAddedRange方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCollectionChanged
protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
{
base.OnCollectionChanged(e);
// todo temp
HandleCollectionReset();
return;
if (e.Action == NotifyCollectionChangedAction.Reset)
{
HandleCollectionReset();
}
else if (e.Action == NotifyCollectionChangedAction.Add)
{
if (e.NewItems != null)
{
Range<int> addedRange = e.GetAddedRange();
if (indexRange.IntersectsWith(addedRange))
{
HandleCollectionAdd(e);
}
else if (indexRange.Max == addedRange.Min - 1) // item was added into the end of collection
{
Path lastPath = drawnPaths.Last();
int lastCount = LineChartBase.GetPointsCount(lastPath);
Range<int> requestRange = new Range<int>(addedRange.Min - 1, addedRange.Max);
// have path with non-filled geometry
if (lastCount + addedRange.GetLength() <= pathLength)
{
canvas.Children.Remove(lastPath);
drawnPaths.Remove(lastPath);
pathsPool.Put(lastPath);
Range<int> lastPathRange = PointChartBase.GetIndexRange(lastPath);
int min = requestRange.Min;
if (min % pathLength == 0)
min -= 1;
requestRange = new Range<int>(min, addedRange.Max);
}
var points = DataSource.GetPointData(requestRange);
var indexedPoints = IndexWrapper.Generate(points, requestRange.Min);
// do nothing if there is nothing to draw
if (!points.Any())
return;
int minIndex;
int maxIndex;
CreateAndAddPath(indexedPoints, out minIndex, out maxIndex, transformWhileCreateUI);
this.indexRange = new Range<int>(indexRange.Min, maxIndex);
}
else
{
// todo
// do nothing?
}
}
else
{
HandleCollectionReset();
}
}
}
示例2: HandleCollectionAdd
private void HandleCollectionAdd(NotifyCollectionChangedEventArgs e)
{
Range<int> addedRange = e.GetAddedRange();
var paths = (from path in drawnPaths
let pathRange = PointChartBase.GetIndexRange(path)
where pathRange.IntersectsWith(addedRange)
let bounds = PointChartBase.GetContentBounds(path)
select new { path, bounds }).ToList();
DataRect unitedContentBounds = paths.Aggregate(
DataRect.Empty, (rect, other) => DataRect.Union(rect, other.bounds));
var added = e.NewItems;
// todo finish
}