protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if (_readOnly) { return; } int x = e.X; int y = e.Y; int nh = 1; float yOffset = 0; float xOffset = this.AutoScrollPosition.X; SizeF size = mathExp.ExpSize; if (size.Height > 0) { while (y > (nh * (size.Height + 8))) { yOffset += (size.Height + 8); xOffset -= this.ClientSize.Width; nh++; } y -= (int)yOffset; x -= (int)xOffset; } HitTestResult hit = mathExp.HightLight(new PointF(x, y)); if (hit != null) { Graphics g = this.CreateGraphics(); System.Drawing.Drawing2D.GraphicsState gt0 = g.Save(); if (_lastOffsetSaved) { g.TranslateTransform(_lastOffsetX, _lastOffsetY); } if (hit.Replaced != null) { g.DrawRectangle(Pens.White, hit.Replaced.Bounds); } g.Restore(gt0); g.TranslateTransform(xOffset, yOffset); _lastOffsetX = xOffset; _lastOffsetY = yOffset; _lastOffsetSaved = true; if (hit.Current != null) { _highlighted = hit.Current; g.DrawRectangle(pen, hit.Current.Bounds); } g.Restore(gt0); } }