From 65f6d5ea68f3828d7433620073dc2c95312a9323 Mon Sep 17 00:00:00 2001
From: Antoine Tritschberger <antoine.tritschberger@etu.unistra.fr>
Date: Fri, 3 Apr 2020 14:02:48 +0200
Subject: [PATCH] Option rejouer

---
 .../psychorientation/InterfaceClasse.cs           |  7 +++++--
 .../psychorientation/Message.Designer.cs          | 15 +++++++++++++++
 psychorientation/psychorientation/Message.cs      | 15 ++++++++++++++-
 3 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/psychorientation/psychorientation/InterfaceClasse.cs b/psychorientation/psychorientation/InterfaceClasse.cs
index 970b29a..65a9bee 100644
--- a/psychorientation/psychorientation/InterfaceClasse.cs
+++ b/psychorientation/psychorientation/InterfaceClasse.cs
@@ -45,7 +45,7 @@ namespace psychorientation
         }
 
         private void Form1_Load(object sender, EventArgs e)
-        {
+        {            
             AjouterEleveImage();
             GenererBase();
             TransmitKeyDown();
@@ -220,11 +220,14 @@ namespace psychorientation
                         moyenneInitiale,
                         effortFinal,
                         competenceFinal,
-                        moyenneFinale
+                        moyenneFinale,
+                        isRandom
                     );
                     m_fin.ShowDialog();
                     UntransmitKeyDown();
                     pb_action_suivante.Click -= new System.EventHandler(Pb_action_suivante_Click);
+                    this.FormClosing -= new System.Windows.Forms.FormClosingEventHandler(InterfaceClasse_FormClosing);
+                    Close();
                     break;
             }
 
diff --git a/psychorientation/psychorientation/Message.Designer.cs b/psychorientation/psychorientation/Message.Designer.cs
index 62ae444..20be13d 100644
--- a/psychorientation/psychorientation/Message.Designer.cs
+++ b/psychorientation/psychorientation/Message.Designer.cs
@@ -35,6 +35,7 @@
             this.lblEffort = new System.Windows.Forms.Label();
             this.lblCompetence = new System.Windows.Forms.Label();
             this.lblMoyenen = new System.Windows.Forms.Label();
+            this.btnRejouer = new System.Windows.Forms.Button();
             this.SuspendLayout();
             // 
             // lblMessage
@@ -115,12 +116,25 @@
             this.lblMoyenen.Visible = false;
             this.lblMoyenen.Click += new System.EventHandler(this.lblMoyenen_Click);
             // 
+            // btnRejouer
+            // 
+            this.btnRejouer.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+            this.btnRejouer.Location = new System.Drawing.Point(548, 284);
+            this.btnRejouer.Name = "btnRejouer";
+            this.btnRejouer.Size = new System.Drawing.Size(172, 51);
+            this.btnRejouer.TabIndex = 9;
+            this.btnRejouer.Text = "Rejouer";
+            this.btnRejouer.UseVisualStyleBackColor = true;
+            this.btnRejouer.Visible = false;
+            this.btnRejouer.Click += new System.EventHandler(this.btnRejouer_Click);
+            // 
             // Message
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.BackgroundImage = global::psychorientation.Properties.Resources.paternFeuille;
             this.ClientSize = new System.Drawing.Size(986, 347);
+            this.Controls.Add(this.btnRejouer);
             this.Controls.Add(this.lblMoyenen);
             this.Controls.Add(this.lblCompetence);
             this.Controls.Add(this.lblEffort);
@@ -148,5 +162,6 @@
         private System.Windows.Forms.Label lblEffort;
         private System.Windows.Forms.Label lblCompetence;
         private System.Windows.Forms.Label lblMoyenen;
+        private System.Windows.Forms.Button btnRejouer;
     }
 }
\ No newline at end of file
diff --git a/psychorientation/psychorientation/Message.cs b/psychorientation/psychorientation/Message.cs
index d6d9b84..c350742 100644
--- a/psychorientation/psychorientation/Message.cs
+++ b/psychorientation/psychorientation/Message.cs
@@ -38,6 +38,8 @@ namespace psychorientation
         double competenceLimite;
         double moyenneLimite;
 
+        bool isRandom;
+
         public Message(string messageAffiche,string titreAffiche,TypeMessage typeMessage)
         {
             InitializeComponent();
@@ -46,7 +48,7 @@ namespace psychorientation
             titre = titreAffiche;
         }
 
-        public void setParamRes(double effortInitial, double competenceInitial, double moyenneInitiale, double effortFinal, double competenceFinal, double moyenneFinale)
+        public void setParamRes(double effortInitial, double competenceInitial, double moyenneInitiale, double effortFinal, double competenceFinal, double moyenneFinale,bool isRandom)
         {
             effortScore = Math.Round(100 * (effortFinal - effortInitial) / effortInitial, 1);
             competenceScore = Math.Round(100 * (competenceFinal - competenceInitial) / competenceInitial, 1); 
@@ -57,6 +59,7 @@ namespace psychorientation
             effortScoreRouge = effortFinal > ((10 - effortInitial) / 3) + effortInitial;
             competenceScoreRouge = competenceFinal > ((10 - competenceInitial) / 4) + competenceInitial;
             moyenneScoreRouge = moyenneFinale > moyenneInitiale;
+            this.isRandom = isRandom;
         }
 
         public bool getReponseBool
@@ -82,6 +85,8 @@ namespace psychorientation
 
         private void Message_Load(object sender, EventArgs e)
         {
+            btnRejouer.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+
             lblMessage.Text = message;
             lblScore.Text = message;
             lblTitre.Text = titre;
@@ -101,6 +106,7 @@ namespace psychorientation
                     this.Controls.Add(b);
                     break;
                 case TypeMessage.RESULTAT:
+                    btnRejouer.Visible = true;
                     lblCompetence.Visible = true;
                     lblEffort.Visible = true;
                     lblMoyenen.Visible = true;
@@ -196,5 +202,12 @@ namespace psychorientation
         {
 
         }
+
+        private void btnRejouer_Click(object sender, EventArgs e)
+        {
+            this.DialogResult = DialogResult.OK;
+            InterfaceClasse iC = new InterfaceClasse(isRandom);
+            iC.Show();
+        }
     }
 }
-- 
GitLab