private void UpdateRectCache(AnnotationBase annoToUpdate) { var anno = _rectCache.First(a => a.annotation == annoToUpdate); anno.BoundingRectangle = Helpers.GetRect(Chart, anno.annotation); }
private void OnMouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { if (e.Button != MouseButtons.Left) { return; } if (AllowMove && SelectedAnnotation != null && _isDragging && _flexChart.PlotRect.Contains(e.Location)) { Cursor.Current = Cursors.SizeAll; _newPoint = e.Location; var diff = new PointF { X = _newPoint.X - _oldPoint.X, Y = _newPoint.Y - _oldPoint.Y }; if (SelectedAnnotation is Line) { var line = SelectedAnnotation as Line; var start = Helpers.AnnoPointToCoords(_flexChart, line, line.Start); var end = Helpers.AnnoPointToCoords(_flexChart, line, line.End); start = start.OffSet(diff); end = end.OffSet(diff); line.Start = Helpers.CoordsToAnnoPoint(_flexChart, line, start); line.End = Helpers.CoordsToAnnoPoint(_flexChart, line, end); } else if (SelectedAnnotation is Polygon) { var polygon = SelectedAnnotation as Polygon; for (int i = 0; i < polygon.Points.Count; i++) { var pt = Helpers.AnnoPointToCoords(_flexChart, polygon, polygon.Points[i]); pt = pt.OffSet(diff); polygon.Points[i] = Helpers.CoordsToAnnoPoint(_flexChart, polygon, pt); } } else { var location = Helpers.AnnoPointToCoords(_flexChart, SelectedAnnotation, SelectedAnnotation.Location); location = location.OffSet(diff); SelectedAnnotation.Location = Helpers.CoordsToAnnoPoint(_flexChart, SelectedAnnotation, location); } _oldPoint = _newPoint; return; } if (this.AllowAdd && this._start != PointF.Empty) { if (_drawing) { this.UpdateAnnotaion(e.Location); } else { SizeF sz = new SizeF { Height = Math.Abs(this._start.Y - (float)e.Location.Y), Width = Math.Abs(this._start.X - (float)e.Location.X) }; Size threshold = SystemInformation.DragSize; if (sz.Width > (float)threshold.Width && sz.Height > (float)threshold.Height) { this.AddAnnotation(this._start); } } } }