private void makeMoleVisable(int mole, PictureBox MoleHill)
{
switch (mole)
{
case 1:
if (p01.Image == pmiss.Image && MoleHill.Image == pHill.Image)
{
molesmissed ++;
}
p01.Image = MoleHill.Image;
break;
case 2:
if (p02.Image == pmiss.Image && MoleHill.Image == pHill.Image)
{
molesmissed++;
}
p02.Image = MoleHill.Image;
break;
** I have 36 of these case statements each one for another for a different picture box; how do I group them all into one case statement so my code can be more efficient**
On the site map, select Service > Cases. Select at least two active case records that you want to merge, and then on the command bar, select Merge Cases. In the Merge Cases dialog box, from the list of cases, select the case the other cases will be merged into, and then select Merge.
You can merge cases from the Cases List View or from the Case Record Home. When you merge cases, you select one case to be the master. You can compare the field values, and select the values that you want to use in the master record. All related lists, feed items, and child records are added to the master.
Go to Lists > Support > Cases. Select a case you want to merge and click either View or Edit. On the case record, click Merge.
It looks like your case is used to select an image, then you always apply the same processing to the image.
How about storing the image in a List or Dictionary, use the mole
value to retrieve the correct image, then process that image?
Something like
Dictionary<int, PictureBox> images;
var image = images[mole];
// do stuff to image
If the images are all numbered sequentially, a List is slightly more efficient. Remember that list indices are 0 based. If you number your images from 1 as seems to be the case from your switch
statement (assumed in the following example), remember to adjust accordingly.
List<PictureBox> images;
int index = mole - 1; // Assumes mole starts with 1, so adjust to 0-based index
var image = images[index];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With