예제 #1
0
        private void GlucoseOnPropertyChanged(object sender, PropertyChangedEventArgs args)
        {
            var glucose  = (GlucoseItem)sender;
            var oldPoint = glucose.GetDataPoint();

            GlucoseDataPoints.Remove(oldPoint);
            AddGlucoseDatapoint(glucose.GenerateDataPoint());
            RaisePropertyChanged(() => GlucoseDataPoints);
        }
예제 #2
0
        private void GlucoseCollectionChanged(object sender, NotifyCollectionChangedEventArgs args)
        {
            switch (args.Action)
            {
            case NotifyCollectionChangedAction.Add:

                foreach (GlucoseItem glucose in args.NewItems)
                {
                    AddGlucoseDatapoint(glucose.GetDataPoint());
                }
                break;

            case NotifyCollectionChangedAction.Remove:

                foreach (GlucoseItem glucose in args.OldItems)
                {
                    GlucoseDataPoints.Remove(glucose.GetDataPoint());
                }
                break;

            case NotifyCollectionChangedAction.Replace:
                int count = args.OldItems.Count;
                for (int i = 0; i < count; i++)
                {
                    var glucose = args.OldItems[i] as GlucoseItem;
                    if (!GlucoseDataPoints.Contains(glucose.GetDataPoint()))
                    {
                        throw new ValueUnavailableException("Datapoint is missing.");
                    }

                    GlucoseDataPoints.Remove(glucose.GetDataPoint());
                    if (args.NewItems[i] is GlucoseItem newGlucose)
                    {
                        AddGlucoseDatapoint(newGlucose.GetDataPoint());
                    }
                }

                break;

            case NotifyCollectionChangedAction.Move:
                break;

            case NotifyCollectionChangedAction.Reset:
                GlucoseDataPoints.Clear();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }