private void pictureBox1_Click(object sender, EventArgs e) { if (_grainsSelection == true) { var mouseEvent = (MouseEventArgs)e; double imageX = mouseEvent.X; double imageY = mouseEvent.Y; double imageWidth = pictureBox1.Width; double imageHeight = pictureBox1.Height; var map = _currentSimullation.GetBitmap(); double mapWidth = map.Width; double mapHeight = map.Height; int x = (int)(imageX / imageWidth * mapWidth); int y = (int)(imageY / imageHeight * mapHeight); _currentSimullation.AddOrRemoveGrainsToSelectLis(x, y); var map1 = _currentSimullation.GetBitmapGrainsSelection(true); Render(map1); //_visFlag = !_visFlag; } }