Public feed #722262

Anonymous

public text v1 · immutable
Raw Edit
·published 2007-10-01 21:36 UTC
rendered paste body
//*********************************************************
// Société: ETML 
// Auteur:  Rowien Bolkensteyn
// Date:    01.10.2007
// But:     Faire un mini jeu, dans lequel un chevalier
//			doit se deplacer le moins de coup possible et
//			être bloqué.
//**********************************************************
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace WindowsApplication1
{
	/// <summary>
	/// Description résumée de Form1.
	/// </summary>
	public class FrmMain : System.Windows.Forms.Form
	{
        public const int INTNBLIGNES = 10;					// Nombre de lignes pour le jeu
        public const int INTCOLONNES = 10;					// Nombre de colonnes pour le jeu
        public const int TAILLECASE = 50;					// Défini la taille de la case
        Button[,] tbl_Tableau = new Button[INTNBLIGNES, INTCOLONNES];
		private System.Windows.Forms.Button btnInitialisation;
        private Button btnQuitter;
        private Panel panel1;
        private IContainer components;

        void CreerBouton()
        {
            int intTop = 0;
            for (int i = 0; i < INTNBLIGNES; i++)
            {
                int intLeft = 0;
                for (int j = 0;j<INTCOLONNES; j++)
                {
                    if (j % 10 == 0 && j != 0)
                    {
                        intTop += 50;
                    }
                    tbl_Tableau[i, j] = new Button();
                    //this.tbl_Tableau[i, j].Location = new System.Drawing.Point(16, 200);
                    //this.tbl_Tableau[i, j].Size = new System.Drawing.Size(100, 24);
                    //this.tbl_Tableau[i, j].TabIndex = 12;
                    tbl_Tableau[i,j].Width = TAILLECASE;
                    tbl_Tableau[i,j].Height = TAILLECASE;
                    tbl_Tableau[i, j].Left = intLeft;
                    tbl_Tableau[i, j].Top = intTop;
                    tbl_Tableau[i, j].Tag = 1;
                    panel1.Controls.Add(tbl_Tableau[i, j]);

                    intLeft += 50;
                }
                intTop += 50;
            }
        }
        /*************************************************
         * Modification a effectuer :
         * - Initilisation du compteur de coup
         * */
        void InitialiserJeu()
        {
            for (int i = 0; i < INTNBLIGNES; i++)
            {
                for (int j = 0; j < INTCOLONNES; j++)
                {
                    tbl_Tableau[i, j].Text = null;
                }
            }
        }

        public FrmMain()
		{
			//
			// 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.btnInitialisation = new System.Windows.Forms.Button();
            this.btnQuitter = new System.Windows.Forms.Button();
            this.panel1 = new System.Windows.Forms.Panel();
            this.SuspendLayout();
            // 
            // btnInitialisation
            // 
            this.btnInitialisation.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.btnInitialisation.Location = new System.Drawing.Point(24, 529);
            this.btnInitialisation.Name = "btnInitialisation";
            this.btnInitialisation.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.btnInitialisation.Size = new System.Drawing.Size(472, 24);
            this.btnInitialisation.TabIndex = 0;
            this.btnInitialisation.Text = "Initialisation";
            this.btnInitialisation.Click += new System.EventHandler(this.btnInitialisation_Click);
            this.tbl_Tableau[0, 0].Click += new EventHandler(this.btnTab_Click);
            // 
            // btnQuitter
            // 
            this.btnQuitter.Location = new System.Drawing.Point(24, 564);
            this.btnQuitter.Name = "btnQuitter";
            this.btnQuitter.Size = new System.Drawing.Size(472, 24);
            this.btnQuitter.TabIndex = 1;
            this.btnQuitter.Text = "Quitter";
            this.btnQuitter.UseVisualStyleBackColor = true;
            // 
            // panel1
            // 
            this.panel1.Location = new System.Drawing.Point(10, 10);
            this.panel1.Name = "panel1";
            this.panel1.Size = new System.Drawing.Size(500, 500);
            this.panel1.TabIndex = 0;
            // 
            // FrmMain
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(520, 600);
            this.Controls.Add(this.panel1);
            this.Controls.Add(this.btnQuitter);
            this.Controls.Add(this.btnInitialisation);
            this.Name = "FrmMain";
            this.Text = "Le Cavalier Déchainé";
            this.Load += new System.EventHandler(this.FrmMain_Load);
            this.ResumeLayout(false);
		}
        #endregion

        /// <summary>
        /// Point d'entrée principal de l'application.
        /// </summary>
        [STAThread]
        static void Main() 
		{
			Application.Run(new FrmMain());
		}

        private void FrmMain_Load(object sender, EventArgs e)
        {
            CreerBouton();
        }

        private void btnInitialisation_Click(object sender, EventArgs e)
        {
            InitialiserJeu();
        }

        private void btnTab_Click(object sender, EventArgs e)
        {
            InitialiserJeu();
        }

	}


}