private void UpdateClassesPanel() { string controlName; PictureBox pictureBox; bool flag; string iconName; Image img; Image ResizeImage; controlName = ""; pictureBox = new PictureBox(); //ok lets hide the classes that are already chosen for (int i = 0; i < ClassNames.Count; i++) { controlName = "PanelClassPictureBox[" + i + "]"; pictureBox = (PictureBox)this.panelClasses.Controls[controlName]; if (ClassNames[i] == ChosenClasses[0] || ClassNames[i] == ChosenClasses[1] || ClassNames[i] == ChosenClasses[2]) { pictureBox.Visible = false; } else { pictureBox.Visible = true; //Lets disable the classes that can't be chosen because of alignment issues. flag = true; for (int j = 0; j < 3; j++) { if (ChosenClasses[j] != "") { if (HasAlignmentMatch(ClassNames[i], ChosenClasses[j]) == false) { flag = false; break; } } } if (HasValidAlignment(ClassNames[i]) == false) { flag = false; } if (flag == false) { pictureBox.Image = UtilityClass.ConvertImageToGrayscale(pictureBox.Image); pictureBox.Enabled = false; } else { if (pictureBox.Enabled == false) { pictureBox.Enabled = true; iconName = DataManagerClass.DataManager.ClassDataCollection.Classes[ClassNames[i]].IconName; try { img = Image.FromFile(Application.StartupPath + "\\Graphics\\Classes\\" + iconName + ".png"); } catch { img = Image.FromFile(Application.StartupPath + "\\Graphics\\NoImage.png"); } ResizeImage = (Image) new Bitmap(img, new Size(60, 60)); img = ResizeImage; pictureBox.Image = img; } } } } }