private void OnCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { if (!IsAddOrDelete(e.Action)) { return; } if (e.NewItems != null) { foreach (AnnotationBase newAnnotation in e.NewItems) { newAnnotation.Style.FillColor = Color.Transparent; _rectCache.Add(new AnnotationEx(Chart, newAnnotation, Helpers.GetRect(Chart, newAnnotation))); } } if (e.OldItems != null) { HideContentEditor(); foreach (AnnotationBase oldAnnotation in e.OldItems) { var anno = _rectCache.First(a => a.annotation == oldAnnotation); if (anno != null) { _rectCache.Remove(anno); } } } }
private void UpdateRectCache(AnnotationBase annoToUpdate) { var anno = _rectCache.First(a => a.annotation == annoToUpdate); anno.BoundingRectangle = Helpers.GetRect(Chart, anno.annotation); }