Programlama ve Elektronik

Programlama ve Elektronik (http://www.proelo.com/)
-   Örnek Kodlar (http://www.proelo.com/ornek-kodlar-87/)
-   -   Adam Asmaca (http://www.proelo.com/ornek-kodlar-87/adam-asmaca-705/)

McDroPp 17. May 2008 03:39 AM

Adam Asmaca
 
Adam Asmaca
--------------------------------------------------------------------------------
Visual C#.net geliştirilmiş adam asmaca oyunu..

//Adam asmaca için resim kullanmak istiyorsanız.ResimPicturebox 'a resim ekleyiniz.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace adam_asmaca
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button30_Click(object sender EventArgs e)
{
foreach (Control i in this.Controls) //form üzerindeki bütün kontrolleri tarar....
{
if (i.GetType().Name == "Button") //form üzerindeki buton kontrollerini ayıklama işlemi yapar...
((Button)i).Enabled = true; //bulunan tüm butonların enabled özelliklerini false yapar....
}
button30.Enabled = false;
Random r = new Random();
int sayi = r.Next(39);
comboBox1.SelectedIndex = sayi;
textBox1.Text = comboBox1.Text;
}
private void YAZ(object sender EventArgs e)
{
label9.Text = (sender as ButtonBase ).Text ;
}
private void label1_Click(object sender EventArgs e)
{
if (string.Compare(label9.Text textBox1.Text.Substring(0 1) true) == 0)
{
label1.Text = label9.Text.ToString();
label1.Enabled = false;
won();
}
else
AS();
}
private void label2_Click(object sender EventArgs e)
{
if (string.Compare(label9.Text textBox1.Text.Substring(1 1) true) == 0)
{
label2.Text = label9.Text.ToString();
label2.Enabled = false;
won();
}
else
AS();
}
private void label3_Click(object sender EventArgs e)
{
if (string.Compare(label9.Text textBox1.Text.Substring(2 1) true) == 0)
{
label3.Text = label9.Text.ToString();
label3.Enabled = false;
won();
}
else
AS();
}
private void label4_Click(object sender EventArgs e)
{
if (string.Compare(label9.Text textBox1.Text.Substring(3 1) true) == 0)
{
label4.Text = label9.Text.ToString();
label4.Enabled = false;
won();
}
else
AS();
}
private void label5_Click(object sender EventArgs e)
{
if (string.Compare(label9.Text textBox1.Text.Substring(4 1) true) == 0)
{
label5.Text = label9.Text.ToString();
label5.Enabled = false;
won();
}
else
AS();
}
private void label6_Click(object sender EventArgs e)
{
if (string.Compare(label9.Text textBox1.Text.Substring(5 1) true) == 0)
{
label6.Text = label9.Text.ToString();
label6.Enabled = false;
won();
}
else
AS();
}
private void label7_Click(object sender EventArgs e)
{
if (string.Compare(label9.Text textBox1.Text.Substring(6 1) true) == 0)
{
label7.Text = label9.Text.ToString();
label7.Enabled = false;
won();
}
else
AS();
}
private void label8_Click(object sender EventArgs e)
{
if (string.Compare(label9.Text textBox1.Text.Substring(7 1) true) == 0)
{
label8.Text = label9.Text.ToString();
label8.Enabled = false;
won();
}
else
AS();
}
void AS()
{
if (pictureBox1 .Visible ==false)
{pictureBox1.Visible = true;}
else if(pictureBox2 .Visible ==false )
{pictureBox2 .Visible =true ;}
else if (pictureBox3.Visible == false)
{ pictureBox3.Visible = true; }
else if (pictureBox4.Visible == false)
{ pictureBox4.Visible = true; }
else if (pictureBox5.Visible == false)
{ pictureBox5.Visible = true; }
else if (pictureBox6.Visible == false)
{ pictureBox6.Visible = true; }
else if (pictureBox7.Visible == false)
{ pictureBox7.Visible = true; }
else if (pictureBox8.Visible == false)
{ pictureBox8.Visible = true;}
else if (pictureBox9.Visible == false)
{ pictureBox9.Visible = true; }
else if (pictureBox10.Visible == false)
{ pictureBox10.Visible = true;
kayıp();
}
}
void kayıp()
{
if(pictureBox10 .Visible ==true)
MessageBox.Show("TEBRİKLER OYUNU KAYBETTİNİZ.......BULMANIZ GEREKEN KELİME " + textBox1.Text + " 'olması gerekirdi...");
foreach (Control h in this.Controls) //form üzerindeki bütün kontrolleri tarar....
{
if (h.GetType().Name == "Label") //form üzerindeki buton kontrollerini ayıklama işlemi yapar...
((Label)h).Enabled = true; //bulunan tüm butonların enabled özelliklerini false yapar....
}
foreach (Control k in this.Controls) //form üzerindeki bütün kontrolleri tarar....
{
if (k.GetType().Name == "PictureBox") //form üzerindeki buton kontrollerini ayıklama işlemi yapar...
((PictureBox)k).Visible = false; //bulunan tüm butonların enabled özelliklerini false yapar....
}
foreach (Control i in this.Controls) //form üzerindeki bütün kontrolleri tarar....
{
if (i.GetType().Name == "Button") //form üzerindeki buton kontrollerini ayıklama işlemi yapar...
((Button)i).Enabled = false; //bulunan tüm butonların enabled özelliklerini false yapar....
}
foreach (Control m in this.Controls) //form üzerindeki bütün kontrolleri tarar....
{
if (m.GetType().Name == "Label") //form üzerindeki buton kontrollerini ayıklama işlemi yapar...
((Label)m).Text = " "; //bulunan tüm butonların enabled özelliklerini false yapar....
}
button30.Enabled = true;
}
void won()
{
if (label1.Enabled == false & label2.Enabled == false & label3.Enabled == false & label4.Enabled == false
& label5.Enabled == false & label6.Enabled == false & label7.Enabled == false & label8.Enabled == false)
{
MessageBox.Show("TEBRİKLER KAZANDINIZ....");
kayıp();
}
}


Bütün Zaman Ayarları WEZ +3.5 olarak düzenlenmiştir. şu Anki Saat: 12:11 AM .