Des chiffres et des lettres? non seulement des lettres !

Soyez le premier à donner votre avis sur cette source.

Snippet vu 10 931 fois - Téléchargée 29 fois

Contenu du snippet

petit "programme" permettant comme son nom l'indique de former des mots avec des lettres rentrées aléatoirement.
Soyez indulgents c'est un programme de débutant, mais je sollicite les critiques constructives.

Source / Exemple :


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

namespace jeu_de_letres
{
	/// <summary>
	/// Description résumée de Form1.
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.GroupBox groupBox2;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.Label label5;
		private System.Windows.Forms.Label label6;
		private System.Windows.Forms.Label label7;
		private System.Windows.Forms.Label label8;
		private System.Windows.Forms.Label label9;
		private System.Windows.Forms.Label label10;
		private System.Windows.Forms.Label label11;
		private System.Windows.Forms.Label label12;
		private System.Windows.Forms.Label label13;
		private System.Windows.Forms.Label label14;
		private System.Windows.Forms.Label label15;
		private System.Windows.Forms.Label label16;
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.Button button2;
		private System.Windows.Forms.Button button3;
		private System.Windows.Forms.MainMenu mainMenu1;
		private System.Windows.Forms.MenuItem menuItem1;
		private System.Windows.Forms.Label labelTime;
		private System.Windows.Forms.Timer timer1;
		private System.Windows.Forms.MenuItem menuItem2;
		private System.Windows.Forms.MenuItem menuItem3;
		private System.ComponentModel.IContainer components;

		public Form1()
		{
			//
			// Requis pour la prise en charge du Concepteur Windows Forms
			//
			InitializeComponent();

			//
			// TODO : ajoutez le code du constructeur après l'appel à InitializeComponent
			//
		}

		/// <summary>
		/// Nettoyage des ressources utilisées.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Code généré par le Concepteur Windows Form
		/// <summary>
		/// Méthode requise pour la prise en charge du concepteur - ne modifiez pas
		/// le contenu de cette méthode avec l'éditeur de code.
		/// </summary>
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this.label8 = new System.Windows.Forms.Label();
			this.label7 = new System.Windows.Forms.Label();
			this.label6 = new System.Windows.Forms.Label();
			this.label5 = new System.Windows.Forms.Label();
			this.label4 = new System.Windows.Forms.Label();
			this.label3 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.label1 = new System.Windows.Forms.Label();
			this.groupBox2 = new System.Windows.Forms.GroupBox();
			this.label13 = new System.Windows.Forms.Label();
			this.label12 = new System.Windows.Forms.Label();
			this.label11 = new System.Windows.Forms.Label();
			this.label10 = new System.Windows.Forms.Label();
			this.label9 = new System.Windows.Forms.Label();
			this.label14 = new System.Windows.Forms.Label();
			this.label15 = new System.Windows.Forms.Label();
			this.label16 = new System.Windows.Forms.Label();
			this.button1 = new System.Windows.Forms.Button();
			this.button2 = new System.Windows.Forms.Button();
			this.button3 = new System.Windows.Forms.Button();
			this.mainMenu1 = new System.Windows.Forms.MainMenu();
			this.menuItem1 = new System.Windows.Forms.MenuItem();
			this.menuItem2 = new System.Windows.Forms.MenuItem();
			this.menuItem3 = new System.Windows.Forms.MenuItem();
			this.labelTime = new System.Windows.Forms.Label();
			this.timer1 = new System.Windows.Forms.Timer(this.components);
			this.groupBox1.SuspendLayout();
			this.groupBox2.SuspendLayout();
			this.SuspendLayout();
			// 
			// groupBox1
			// 
			this.groupBox1.BackColor = System.Drawing.Color.LightSteelBlue;
			this.groupBox1.Controls.Add(this.label8);
			this.groupBox1.Controls.Add(this.label7);
			this.groupBox1.Controls.Add(this.label6);
			this.groupBox1.Controls.Add(this.label5);
			this.groupBox1.Controls.Add(this.label4);
			this.groupBox1.Controls.Add(this.label3);
			this.groupBox1.Controls.Add(this.label2);
			this.groupBox1.Controls.Add(this.label1);
			this.groupBox1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.groupBox1.Location = new System.Drawing.Point(16, 8);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(664, 120);
			this.groupBox1.TabIndex = 0;
			this.groupBox1.TabStop = false;
			// 
			// label8
			// 
			this.label8.BackColor = System.Drawing.Color.LightBlue;
			this.label8.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.label8.Font = new System.Drawing.Font("Microsoft Sans Serif", 48F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label8.Location = new System.Drawing.Point(576, 32);
			this.label8.Name = "label8";
			this.label8.Size = new System.Drawing.Size(72, 72);
			this.label8.TabIndex = 7;
			this.label8.DragEnter += new System.Windows.Forms.DragEventHandler(this.label_DragEnter);
			this.label8.DragDrop += new System.Windows.Forms.DragEventHandler(this.label_DragDrop);
			this.label8.MouseDown += new System.Windows.Forms.MouseEventHandler(this.label_MouseDown);
			// 
			// label7
			// 
			this.label7.BackColor = System.Drawing.Color.LightBlue;
			this.label7.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.label7.Font = new System.Drawing.Font("Microsoft Sans Serif", 48F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label7.Location = new System.Drawing.Point(496, 32);
			this.label7.Name = "label7";
			this.label7.Size = new System.Drawing.Size(72, 72);
			this.label7.TabIndex = 6;
			this.label7.DragEnter += new System.Windows.Forms.DragEventHandler(this.label_DragEnter);
			this.label7.DragDrop += new System.Windows.Forms.DragEventHandler(this.label_DragDrop);
			this.label7.MouseDown += new System.Windows.Forms.MouseEventHandler(this.label_MouseDown);
			// 
			// label6
			// 
			this.label6.BackColor = System.Drawing.Color.LightBlue;
			this.label6.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 48F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label6.Location = new System.Drawing.Point(416, 32);
			this.label6.Name = "label6";
			this.label6.Size = new System.Drawing.Size(72, 72);
			this.label6.TabIndex = 5;
			this.label6.DragEnter += new System.Windows.Forms.DragEventHandler(this.label_DragEnter);
			this.label6.DragDrop += new System.Windows.Forms.DragEventHandler(this.label_DragDrop);
			this.label6.MouseDown += new System.Windows.Forms.MouseEventHandler(this.label_MouseDown);
			// 
			// label5
			// 
			this.label5.BackColor = System.Drawing.Color.LightBlue;
			this.label5.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 48F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label5.Location = new System.Drawing.Point(336, 32);
			this.label5.Name = "label5";
			this.label5.Size = new System.Drawing.Size(72, 72);
			this.label5.TabIndex = 4;
			this.label5.DragEnter += new System.Windows.Forms.DragEventHandler(this.label_DragEnter);
			this.label5.DragDrop += new System.Windows.Forms.DragEventHandler(this.label_DragDrop);
			this.label5.MouseDown += new System.Windows.Forms.MouseEventHandler(this.label_MouseDown);
			// 
			// label4
			// 
			this.label4.BackColor = System.Drawing.Color.LightBlue;
			this.label4.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 48F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label4.Location = new System.Drawing.Point(256, 32);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(72, 72);
			this.label4.TabIndex = 3;
			this.label4.DragEnter += new System.Windows.Forms.DragEventHandler(this.label_DragEnter);
			this.label4.DragDrop += new System.Windows.Forms.DragEventHandler(this.label_DragDrop);
			this.label4.MouseDown += new System.Windows.Forms.MouseEventHandler(this.label_MouseDown);
			// 
			// label3
			// 
			this.label3.BackColor = System.Drawing.Color.LightBlue;
			this.label3.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 48F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label3.Location = new System.Drawing.Point(176, 32);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(72, 72);
			this.label3.TabIndex = 2;
			this.label3.DragEnter += new System.Windows.Forms.DragEventHandler(this.label_DragEnter);
			this.label3.DragDrop += new System.Windows.Forms.DragEventHandler(this.label_DragDrop);
			this.label3.MouseDown += new System.Windows.Forms.MouseEventHandler(this.label_MouseDown);
			// 
			// label2
			// 
			this.label2.BackColor = System.Drawing.Color.LightBlue;
			this.label2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 48F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label2.Location = new System.Drawing.Point(96, 32);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(72, 72);
			this.label2.TabIndex = 1;
			this.label2.DragEnter += new System.Windows.Forms.DragEventHandler(this.label_DragEnter);
			this.label2.DragDrop += new System.Windows.Forms.DragEventHandler(this.label_DragDrop);
			this.label2.MouseDown += new System.Windows.Forms.MouseEventHandler(this.label_MouseDown);
			// 
			// label1
			// 
			this.label1.BackColor = System.Drawing.Color.LightBlue;
			this.label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 48F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label1.Location = new System.Drawing.Point(16, 32);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(72, 72);
			this.label1.TabIndex = 0;
			this.label1.DragEnter += new System.Windows.Forms.DragEventHandler(this.label_DragEnter);
			this.label1.DragDrop += new System.Windows.Forms.DragEventHandler(this.label_DragDrop);
			this.label1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.label_MouseDown);
			// 
			// groupBox2
			// 
			this.groupBox2.BackColor = System.Drawing.Color.LightSteelBlue;
			this.groupBox2.Controls.Add(this.label13);
			this.groupBox2.Controls.Add(this.label12);
			this.groupBox2.Controls.Add(this.label11);
			this.groupBox2.Controls.Add(this.label10);
			this.groupBox2.Controls.Add(this.label9);
			this.groupBox2.Controls.Add(this.label14);
			this.groupBox2.Controls.Add(this.label15);
			this.groupBox2.Controls.Add(this.label16);
			this.groupBox2.Cursor = System.Windows.Forms.Cursors.Default;
			this.groupBox2.Location = new System.Drawing.Point(16, 144);
			this.groupBox2.Name = "groupBox2";
			this.groupBox2.Size = new System.Drawing.Size(664, 120);
			this.groupBox2.TabIndex = 0;
			this.groupBox2.TabStop = false;
			// 
			// label13
			// 
			this.label13.BackColor = System.Drawing.Color.LightBlue;
			this.label13.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.label13.Font = new System.Drawing.Font("Microsoft Sans Serif", 48F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label13.Location = new System.Drawing.Point(336, 24);
			this.label13.Name = "label13";
			this.label13.Size = new System.Drawing.Size(72, 72);
			this.label13.TabIndex = 4;
			this.label13.DragEnter += new System.Windows.Forms.DragEventHandler(this.label_DragEnter);
			this.label13.DragDrop += new System.Windows.Forms.DragEventHandler(this.label_DragDrop);
			this.label13.MouseDown += new System.Windows.Forms.MouseEventHandler(this.label_MouseDown);
			// 
			// label12
			// 
			this.label12.BackColor = System.Drawing.Color.LightBlue;
			this.label12.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.label12.Font = new System.Drawing.Font("Microsoft Sans Serif", 48F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label12.Location = new System.Drawing.Point(256, 24);
			this.label12.Name = "label12";
			this.label12.Size = new System.Drawing.Size(72, 72);
			this.label12.TabIndex = 3;
			this.label12.DragEnter += new System.Windows.Forms.DragEventHandler(this.label_DragEnter);
			this.label12.DragDrop += new System.Windows.Forms.DragEventHandler(this.label_DragDrop);
			this.label12.MouseDown += new System.Windows.Forms.MouseEventHandler(this.label_MouseDown);
			// 
			// label11
			// 
			this.label11.BackColor = System.Drawing.Color.LightBlue;
			this.label11.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.label11.Font = new System.Drawing.Font("Microsoft Sans Serif", 48F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label11.Location = new System.Drawing.Point(176, 24);
			this.label11.Name = "label11";
			this.label11.Size = new System.Drawing.Size(72, 72);
			this.label11.TabIndex = 2;
			this.label11.DragEnter += new System.Windows.Forms.DragEventHandler(this.label_DragEnter);
			this.label11.DragDrop += new System.Windows.Forms.DragEventHandler(this.label_DragDrop);
			this.label11.MouseDown += new System.Windows.Forms.MouseEventHandler(this.label_MouseDown);
			// 
			// label10
			// 
			this.label10.BackColor = System.Drawing.Color.LightBlue;
			this.label10.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.label10.Font = new System.Drawing.Font("Microsoft Sans Serif", 48F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label10.Location = new System.Drawing.Point(96, 24);
			this.label10.Name = "label10";
			this.label10.Size = new System.Drawing.Size(72, 72);
			this.label10.TabIndex = 1;
			this.label10.DragEnter += new System.Windows.Forms.DragEventHandler(this.label_DragEnter);
			this.label10.DragDrop += new System.Windows.Forms.DragEventHandler(this.label_DragDrop);
			this.label10.MouseDown += new System.Windows.Forms.MouseEventHandler(this.label_MouseDown);
			// 
			// label9
			// 
			this.label9.BackColor = System.Drawing.Color.LightBlue;
			this.label9.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.label9.Font = new System.Drawing.Font("Microsoft Sans Serif", 48F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label9.Location = new System.Drawing.Point(16, 24);
			this.label9.Name = "label9";
			this.label9.Size = new System.Drawing.Size(72, 72);
			this.label9.TabIndex = 0;
			this.label9.DragEnter += new System.Windows.Forms.DragEventHandler(this.label_DragEnter);
			this.label9.DragDrop += new System.Windows.Forms.DragEventHandler(this.label_DragDrop);
			this.label9.MouseDown += new System.Windows.Forms.MouseEventHandler(this.label_MouseDown);
			// 
			// label14
			// 
			this.label14.BackColor = System.Drawing.Color.LightBlue;
			this.label14.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.label14.Font = new System.Drawing.Font("Microsoft Sans Serif", 48F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label14.Location = new System.Drawing.Point(416, 24);
			this.label14.Name = "label14";
			this.label14.Size = new System.Drawing.Size(72, 72);
			this.label14.TabIndex = 5;
			this.label14.DragEnter += new System.Windows.Forms.DragEventHandler(this.label_DragEnter);
			this.label14.DragDrop += new System.Windows.Forms.DragEventHandler(this.label_DragDrop);
			this.label14.MouseDown += new System.Windows.Forms.MouseEventHandler(this.label_MouseDown);
			// 
			// label15
			// 
			this.label15.BackColor = System.Drawing.Color.LightBlue;
			this.label15.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.label15.Font = new System.Drawing.Font("Microsoft Sans Serif", 48F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label15.Location = new System.Drawing.Point(496, 24);
			this.label15.Name = "label15";
			this.label15.Size = new System.Drawing.Size(72, 72);
			this.label15.TabIndex = 6;
			this.label15.DragEnter += new System.Windows.Forms.DragEventHandler(this.label_DragEnter);
			this.label15.DragDrop += new System.Windows.Forms.DragEventHandler(this.label_DragDrop);
			this.label15.MouseDown += new System.Windows.Forms.MouseEventHandler(this.label_MouseDown);
			// 
			// label16
			// 
			this.label16.BackColor = System.Drawing.Color.LightBlue;
			this.label16.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.label16.Font = new System.Drawing.Font("Microsoft Sans Serif", 48F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label16.Location = new System.Drawing.Point(576, 24);
			this.label16.Name = "label16";
			this.label16.Size = new System.Drawing.Size(72, 72);
			this.label16.TabIndex = 7;
			this.label16.DragEnter += new System.Windows.Forms.DragEventHandler(this.label_DragEnter);
			this.label16.DragDrop += new System.Windows.Forms.DragEventHandler(this.label_DragDrop);
			this.label16.MouseDown += new System.Windows.Forms.MouseEventHandler(this.label_MouseDown);
			// 
			// button1
			// 
			this.button1.BackColor = System.Drawing.Color.RoyalBlue;
			this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.button1.Location = new System.Drawing.Point(16, 272);
			this.button1.Name = "button1";
			this.button1.Size = new System.Drawing.Size(200, 56);
			this.button1.TabIndex = 1;
			this.button1.Text = "&Consonne";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// button2
			// 
			this.button2.BackColor = System.Drawing.Color.RoyalBlue;
			this.button2.Font = new System.Drawing.Font("Microsoft Sans Serif", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.button2.ForeColor = System.Drawing.Color.Black;
			this.button2.Location = new System.Drawing.Point(480, 272);
			this.button2.Name = "button2";
			this.button2.Size = new System.Drawing.Size(200, 56);
			this.button2.TabIndex = 2;
			this.button2.Text = "&Voyelle";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// button3
			// 
			this.button3.BackColor = System.Drawing.Color.RoyalBlue;
			this.button3.Font = new System.Drawing.Font("Microsoft Sans Serif", 24F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.button3.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(64)), ((System.Byte)(0)), ((System.Byte)(64)));
			this.button3.Location = new System.Drawing.Point(16, 336);
			this.button3.Name = "button3";
			this.button3.Size = new System.Drawing.Size(664, 56);
			this.button3.TabIndex = 3;
			this.button3.Text = "STOP";
			this.button3.Click += new System.EventHandler(this.button3_Click);
			// 
			// mainMenu1
			// 
			this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItem1});
			// 
			// menuItem1
			// 
			this.menuItem1.Index = 0;
			this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItem2,
																					  this.menuItem3});
			this.menuItem1.Text = "&Jeu";
			// 
			// menuItem2
			// 
			this.menuItem2.Index = 0;
			this.menuItem2.Text = "&Nouvelle Partie";
			this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
			// 
			// menuItem3
			// 
			this.menuItem3.Index = 1;
			this.menuItem3.Text = "&Quitter le Jeu";
			this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
			// 
			// labelTime
			// 
			this.labelTime.Location = new System.Drawing.Point(232, 280);
			this.labelTime.Name = "labelTime";
			this.labelTime.Size = new System.Drawing.Size(232, 48);
			this.labelTime.TabIndex = 4;
			// 
			// timer1
			// 
			this.timer1.Interval = 1000;
			this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(10, 22);
			this.BackColor = System.Drawing.Color.CadetBlue;
			this.ClientSize = new System.Drawing.Size(704, 406);
			this.Controls.Add(this.labelTime);
			this.Controls.Add(this.button3);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.button1);
			this.Controls.Add(this.groupBox1);
			this.Controls.Add(this.groupBox2);
			this.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.Menu = this.mainMenu1;
			this.Name = "Form1";
			this.Text = "Jeu To be";
			this.groupBox1.ResumeLayout(false);
			this.groupBox2.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// Point d'entrée principal de l'application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new Form1());
		}
		public int seconde;
		public int stoklettre = 1;
		public string retarr = "";

		private void menuItem3_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void menuItem2_Click(object sender, System.EventArgs e)
		{
			label1.Text =label2.Text=label3.Text=label4.Text=label5.Text=label6.Text
				=label7.Text=label8.Text = label9.Text =label10.Text =label11.Text
				=label12.Text =label13.Text = label14.Text = label15.Text
				= label16.Text = "";
			stoklettre = 1;
			button1.Visible = true;
			button2.Visible = true;
			button3.Enabled = true;
			for (int i = 0; i<8;i++)
			{
				groupBox1.Controls [i].AllowDrop = false;
				groupBox2.Controls [i].AllowDrop = false;
			}
			labelTime.Text = "";
		}

		private void timer1_Tick(object sender, System.EventArgs e)
		{
			seconde = seconde+1;
			labelTime.Text = "TIME  " + seconde + "  S";
		}

		private void button3_Click(object sender, System.EventArgs e)
		{
			timer1.Stop();
			seconde = 0;
			for (int i = 0; i<8;i++)
			{
				groupBox1.Controls [i].AllowDrop = true;
				groupBox2.Controls [i].AllowDrop = true;
			}
			button3.Enabled = false;
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			string [] tcons = new String [] {"B", "C", "D", "F", "G", "H", "J", "K", 
												"L", "M", "N", "P", "Q", "R", "S", "T", "V", "W", "X", "Z",};
			Random hasardcons = new Random();
			int cons = 0;
			switch (stoklettre)
			{
				case 1 :
					cons = hasardcons.Next (0,19);
					label1.Text = tcons [cons];
					break;
				case 2 :
					cons = hasardcons.Next (0,19);
					label2.Text = tcons [cons];
					break;
				case 3 :
					cons = hasardcons.Next (0,19);
					label3.Text = tcons [cons];
					break;
				case 4 :
					cons = hasardcons.Next (0,19);
					label4.Text = tcons [cons];
					break;
				case 5 :
					cons = hasardcons.Next (0,19);
					label5.Text = tcons [cons];
					break;
				case 6 :
					cons = hasardcons.Next (0,19);
					label6.Text = tcons [cons];
					break;
				case 7 :
					cons = hasardcons.Next (0,19);
					label7.Text = tcons [cons];
					break;
				case 8 :
					cons = hasardcons.Next (0,19);
					label8.Text = tcons [cons];
					break;
				default :
					break;
			}
			stoklettre = stoklettre+1;
			if (stoklettre == 9)
			{
				timer1.Start ();
				button2.Hide();
				button1.Hide();
			}

		}

		private void button2_Click(object sender, System.EventArgs e)
		{
			string [] tvoy = new String [] {"A", "E", "I", "O", "U", "Y",};
			Random hasardvoy = new Random();
			int voy = 0;
			switch (stoklettre)
			{
				case 1 :
					voy = hasardvoy.Next (0,5);
					label1.Text = tvoy [voy];
					break;
				case 2 :
					voy = hasardvoy.Next (0,5);
					label2.Text = tvoy [voy];
					break;
				case 3 :
					voy = hasardvoy.Next (0,5);
					label3.Text = tvoy [voy];
					break;
				case 4 :
					voy = hasardvoy.Next (0,5);
					label4.Text = tvoy [voy];
					break;
				case 5 :
					voy = hasardvoy.Next (0,5);
					label5.Text = tvoy [voy];
					break;
				case 6 :
					voy = hasardvoy.Next (0,5);
					label6.Text = tvoy [voy];
					break;
				case 7 :
					voy = hasardvoy.Next (0,5);
					label7.Text = tvoy [voy];
					break;
				case 8 :
					voy = hasardvoy.Next (0,5);
					label8.Text = tvoy [voy];
					break;
                 
				default :
					break;
			}
			stoklettre = stoklettre+1;
			if (stoklettre == 9)
			{
				timer1.Start ();
				button2.Hide();
				button1.Hide();
			}
		
		}
		//
		private void label_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
		{
			if (sender.GetType()==label1.GetType())
			{
				Label labeltest = (Label) sender;
				if (labeltest.Text!="")
				{
					DragDropEffects effet = labeltest.DoDragDrop(labeltest.Text,DragDropEffects.Copy |
						DragDropEffects.Move);
					retarr = Controls.GetEnumerator().ToString();
					if (effet == DragDropEffects.Copy)
					{
						labeltest.Text = "";

					}
				}

			}
		}
        //
		private void label_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
		{
			if (e.Data.GetDataPresent(DataFormats.Text))
				e.Effect = DragDropEffects.Copy;
			else
				e.Effect = DragDropEffects.None;

		}

		

		private void label_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
		{
			Label label1test = (Label) sender;
			if (label1test.Text =="")
			{
				label1test.Text = e.Data.GetData(DataFormats.Text).ToString();
			}
			else
			{
				Controls[Convert.ToInt32(retarr)].Text = e.Data.GetData(DataFormats.Text).ToString();
			}
		}

		
		
		}

		
	}

Conclusion :


si on me suggère des améliorations, je ferai une mise à jour,
bien sur j'ai fait avec huit lettres ce qui est un peu juste, il est possible d'en mettre plus.

A voir également

Ajouter un commentaire Commentaires
Messages postés
4030
Date d'inscription
mardi 13 mai 2003
Statut
Modérateur
Dernière intervention
23 décembre 2008
22
Salut,

Dans ton jeu, la probabilité de piocher un Y est la même que celle de piocher un E... La probabilité de piocher un W est la même que la probabilité de piocher un L
Résultat, ce n'est pas très jouable.
Tu devrais pondérer les occurences de chaque lettre, en faisant comme ceci par exemple pour les voyelles.

string [] tvoy = new String [] {"A", "A", "A", "E", "E", "E", "E", "E", "I", "I", "I", "O", "O", "O", "U", "U", "Y",};

puis voy = hasardvoy.Next (0,16);

Ainsi,
Proba(piocher Y) = 1/17
Proba(piocher E) = 5/17
Messages postés
41
Date d'inscription
mardi 30 septembre 2003
Statut
Membre
Dernière intervention
21 avril 2011

Salut,
ce code est un bon début.Mais Il manque quand même la mise en oeuvre d'un dictionnaire pour contrôler la validité des réponses. Pour cela tu pourrait par exemple utiliser l'interop. avec le correcteur d'othographe de Word.
Messages postés
5487
Date d'inscription
dimanche 4 août 2002
Statut
Membre
Dernière intervention
20 juin 2013
58
Mon commentaire n'avait rien d'aigre-doux...
C'était juste une petite remarque sans grande prétention.
Pas de panique :-)
Messages postés
5
Date d'inscription
mercredi 20 avril 2005
Statut
Membre
Dernière intervention
26 juillet 2005

j'ai vérifié : le drag & drop ainsi que le timer fonctionnent bien chez moi.
Messages postés
5
Date d'inscription
mercredi 20 avril 2005
Statut
Membre
Dernière intervention
26 juillet 2005

merci à MorpionMx pour les conseils, (j'étais un peu découragé par le premier commentaire sur ma source, un peu aigre-doux)
je n'avais pas pensé au zip.
je vais essayer les user controls.
Afficher les 7 commentaires

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.