private void graph_MouseMove(object sender, MouseEventArgs e) { if (dragging) { Point newPos = e.GetPosition(graph); double yDiff = newPos.Y - dragPos.Y; VerticalOffset += yDiff / VerticalScale; Paint(); dragPos = newPos; } }