Guess the Celebrity

Objective

To develop a windows application for guessing the hidden celebrity image.

Design

JNJ

Design the form as above with 1 label,1 textbox, 14(or more to hide image)buttons, 1 openFileDialog conrol for browsing the images.

Code

using System;
using System.Drawing;
using System.Windows.Forms;
namespace jnj
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void loadbtn_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "pra")
            {
                fillbtns();
                pictureBox1.ImageLocation = null;
                //openFileDialog1.Title = "select an image";//refer prop.'s
                //openFileDialog1.Filter = "Jpeg(*.jpg)|*.jpg|Bitmap(*.bmp)|*.bmp|All files(*.*)|*.*";
                DialogResult result = openFileDialog1.ShowDialog();
                if (result == DialogResult.OK)
                {
                    pictureBox1.ImageLocation = openFileDialog1.FileName;
                }
            }
            else
            {
                MessageBox.Show("incorrect password");
                textBox1.Focus();
            }
            textBox1.Clear();
        }
        void fillbtns()
        {
            btn1.Show();
            btn2.Show();
            btn3.Show();
            btn4.Show();
            btn5.Show();
            btn6.Show();
            btn7.Show();
            btn8.Show();
            btn9.Show();
            btn10.Show();
            btn11.Show();
            btn12.Show();
        }
        private void btn1_Click(object sender, EventArgs e)
        {
            if (pictureBox1.ImageLocation != null)
            {
                Button btn = sender as Button;
                btn.Hide();
            }
            else
            {
                MessageBox.Show("Plz load the image");
            }
        }
        private void exitbtn_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}

Note. The password in this application is: pra


Similar Articles