當前位置: 首頁>>代碼示例>>C#>>正文


C# NotifyCollectionChangedEventArgs.GetAddedRange方法代碼示例

本文整理匯總了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();
				}
			}
		}
開發者ID:XiBeichuan,項目名稱:hydronumerics,代碼行數:69,代碼來源:LineChart.cs

示例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
		}
開發者ID:XiBeichuan,項目名稱:hydronumerics,代碼行數:17,代碼來源:LineChart.cs


注:本文中的System.Collections.Specialized.NotifyCollectionChangedEventArgs.GetAddedRange方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。