private void drawingTimer_Tick(object sender, EventArgs e) { var position = pictureBox1.PointToClient(MousePosition); if ((position.X >= 0 && position.Y >= 0 && position.X < pictureBox1.Width && position.Y < pictureBox1.Height) && (position.X != previousPosition.X || position.Y != previousPosition.Y)) { int row = (int)Math.Round((double)game.Rows / pictureBox1.Height * position.Y); int column = (int)Math.Round((double)game.Columns / pictureBox1.Width * position.X); game.SetCellState(row, column, mouseEvent.Button == MouseButtons.Left ? CellState.Alive : CellState.Dead); DrawField(game); } }