Exemple #1
0
        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
        }
Exemple #2
0
        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();
                }
            }
        }