我在下面的代码中将图像添加到网格中。我需要能够说,如果molePopUp 显示在网格上,则将整数加一,这样我就可以记录正确按下图像的所有时间。有什么帮助吗?
// Change Image from "Hut" to Mole \\
private void ChangeImage()
{
Image molePopup = MoleImage();
int numCol = Convert.ToInt32(NumberOfColumns);
//Random Number - Col
Random randomColumns = new Random();
int ranCol = randomColumns.Next(1, numCol);
//Random Number - Row
Random randomRow = new Random();
int ranRow = randomRow.Next(1, NumberofRows);
string Moleimage = TUtils.GetIniFileString(Moleini, "ImagePath", "PictureFile", Root + "mole2.png");
//Populate Grid with Mole at Random Times \\
Grid.SetRow(molePopup, ranRow);
Grid.SetColumn(molePopup, ranCol);
grid_Main.Children.Add(molePopup);
}