Hello everyone,
I'm trying to make a kind of log in system for an application. It's pretty simple. There are 6 picture boxes which display images. Of these 6 picture boxes one of the images is a recognizable to the user. When the user clicks on the 'correct' image the process basically repeats two more times. After the third time the user successfully gets to use the application.
So overall there will be 18 images, 3 will be 'important' and 15 will be stub images. So one of these important images needs to show up once and only once on each form attempt. The images that show up on each form should show up only once as well.
I've got a decent implementation in which I scramble my pictures but can't seem to figure out:
1) How do I make sure one of these important images shows up randomly between picture boxes 0-5, 6-11, and 12-17?
2) When I accomplish this how do I distinguish/identify the recognizable images in my form? I want to use the PictureBox.Tag property but not sure I would give a tag based on these. I was thinking I could use the image name..but that would probably be bad security.
public class randomImage
{
int[] indexArray;
string[] stubImages;
string[] specialImages;
public randomImage()
{
//holds indexes..shuffled in shuffleArray()
indexArray = new int[]{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17};
//Holds the stub images
stubImages = new string[]
{"Image1.jpg","Image2.jpg", "Image3.jpg","Image4.jpg","Image5.jpg", "Image6.jpg","Image7.jpg","Image8.jpg", "Image9.jpg","Image10.jpg","Image11.jpg", "Image12.jpg","Image13.jpg","Image14.jpg",
"Image15.jpg"};
//these are the 'special images'
specialImages = new string[]{"Special1.jpg","Special2.jpg","Special3.jpg"};
shuffleArray();
}
private void shuffleArray()
{
Random rnd = new Random();
//scrambles array
for (int inx = indexArray.Length-1; inx > 0; inx--)
{
int position = rnd.Next(inx+1);
int temp = indexArray[inx];
indexArray[inx] = indexArray[position];
indexArray[position] = temp;
}
}
public string returnImage(int index)
{
return stubImages[indexArray[index]];
}
}
I'd appreciate any suggestions or improvements.