Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
No results found
Show changes
Commits on Source (33)
Showing
with 213 additions and 130 deletions
File added
File added
......@@ -9,6 +9,9 @@ using SAE_D21_A21_Jeroglifico;
using SAE_D21_A21_Jeroglifico.Components.Lesson;
using SAE_D21_A21_Jeroglifico.Utils;
/*
* Set un exercice de grammaire
*/
public class Grammar : Exo
{
Panel pnlContent = new Panel();
......@@ -46,7 +49,7 @@ public class Grammar : Exo
pnlContent.AutoSize = true;
//place tout les pronoms dans les labels et le range dans une liste
Label lblPronom;
for (int i = 0; i < pronoms.Length; i++)
{
......@@ -88,6 +91,7 @@ public class Grammar : Exo
Label lbl = new Label(); // label pour mesurer quel taille doit faire la texte box pour chaque conjugaison
lbl.AutoSize = true;
//set up les labels pronoms avec les textbox
for (int i = 0; i < 3; i++)
{
lbl.Text = corrections[i] + " ";
......@@ -121,6 +125,8 @@ public class Grammar : Exo
col2.Controls.Add(pnlPronoms);
col2.Controls.Add(pnlVerbe);
//set up les labels pronoms avec les textbox
for (int i = 3; i < 6; i++)
{
lbl.Text = corrections[i] + " ";
......@@ -165,6 +171,7 @@ public class Grammar : Exo
txtAnswers[0].Focus();
}
//affiche si le résultat est juste ou pas
public override void ShowResult()
{
for(int i=0; i < txtAnswers.Count; i++)
......@@ -180,6 +187,7 @@ public class Grammar : Exo
}
}
//check si c'est juste
public override bool Verify()
{
for (int i = 0; i < txtAnswers.Count; i++)
......
......@@ -13,6 +13,8 @@ using SAE_D21_A21_Jeroglifico.Utils;
namespace SAE_D21_A21_Jeroglifico.Components.Lesson
{
//gère les différents exercices et les crées lorque on lance une leçon
public class Lesson : UserControl
{
PictureBox pctMenu = new PictureBox(); // picturebox pour le menu général de l'application
......@@ -21,6 +23,7 @@ namespace SAE_D21_A21_Jeroglifico.Components.Lesson
Label lblTitleLecon = new Label();
ProgressBar bar;
static Color orangeClair = Color.FromArgb(253, 230, 157);
// les différents boutons de l'interface
RoundButton btnRestart = new RoundButton(orangeClair);
RoundButton btnNext = new RoundButton(orangeClair);
......@@ -57,7 +60,10 @@ namespace SAE_D21_A21_Jeroglifico.Components.Lesson
Dock = DockStyle.Fill;
Font = new Font("Microsoft Sans Serif", 14F, FontStyle.Regular, GraphicsUnit.Point, 0);
/*
* Design de la page et ces composants
*/
BackColor = Color.FromArgb(255, 40, 114, 84);
pnlHead.BackColor = Color.FromArgb(255, 38, 38, 38);
pnlBody.BackColor = Color.FromArgb(0, 0, 0, 0);
......@@ -170,6 +176,8 @@ namespace SAE_D21_A21_Jeroglifico.Components.Lesson
Placement.Expand(pnlContent);
lblTitleLecon.AutoSize = true;
//on récupère les informations sur les exercices
DataRow infoLecon = DataManager.GetLecon(numLecon, numCours);
if (infoLecon != null)
{
......@@ -195,6 +203,7 @@ namespace SAE_D21_A21_Jeroglifico.Components.Lesson
bool complete;
int[] lstIndex;
//si la table d'exercices n'est pas vide
if (tblExo.Rows.Count > 0)
{
bar = new ProgressBar((int)(Width * 0.7), tblExo.Rows.Count);
......@@ -234,6 +243,9 @@ namespace SAE_D21_A21_Jeroglifico.Components.Lesson
string traduc;
int w = pnlExos.Width;
/* On récupère le type de chaque exercice et on créé les user control adaptés avec les différents info que comporte chaque type d'exercice.
* On les stocke ensuite dans une liste d'exercices
*/
Exo newExo;
foreach (DataRow row in tblExo.Rows)
{
......@@ -241,6 +253,7 @@ namespace SAE_D21_A21_Jeroglifico.Components.Lesson
sentence = row["PhrasestextePhrase"].ToString();
traduc = row["PhrasestraducPhrase"].ToString();
Console.WriteLine(sentence + " sentence#" + traduc + " " + statement + " #" + row["ExercicescodePhrase"] + "#" + (!row["ExercicescodePhrase"].ToString().Equals("0")));
//si il y a une phrase
if (!row["ExercicescodePhrase"].ToString().Equals("0"))
{
sentence = row["PhrasestextePhrase"].ToString();
......@@ -257,6 +270,7 @@ namespace SAE_D21_A21_Jeroglifico.Components.Lesson
newExo = new GapedWord(sentence, statement, w, lstIndex, traduc);
}
}
//si il y a un verbe
else if (!string.IsNullOrEmpty(row["ExercicescodeVerbe"].ToString()) && !row["ExercicescodeVerbe"].ToString().Equals("0"))
{
Console.WriteLine(row["ExercicescodeVerbe"].ToString() + "aaaaaaaaaa");
......@@ -371,7 +385,7 @@ namespace SAE_D21_A21_Jeroglifico.Components.Lesson
MessageBox.Show("Pas d'affichage");
}
}
//reset l'exo quand on décide de réssayer
public void RestartClick(object sender, EventArgs e)
{
pnlHead.Controls.Remove(bar);
......@@ -397,6 +411,7 @@ namespace SAE_D21_A21_Jeroglifico.Components.Lesson
ShowExo();
}
//passa à l'exercice suivant
public void SkipExo(object sender, EventArgs e)
{
DataRow result_exo = results.NewRow();
......@@ -420,6 +435,7 @@ namespace SAE_D21_A21_Jeroglifico.Components.Lesson
NextExo();
}
//affiche la réponse de l'exercice
public void ShowAnswer(object sender, EventArgs e)
{
......@@ -456,11 +472,12 @@ namespace SAE_D21_A21_Jeroglifico.Components.Lesson
pnlResult.Visible = true;
}
//lance le prochain exercice
public void NextExo(object sender, EventArgs e)
{
NextExo();
}
//suite de NextExo
public void NextExo()
{
pnlResult.Visible = false;
......@@ -470,6 +487,7 @@ namespace SAE_D21_A21_Jeroglifico.Components.Lesson
ShowExo();
}
//affiche un exercice ou la page de résultat si ils sont finit
public void ShowExo()
{
if (currentExo >= 0 && currentExo < exos.Count)
......@@ -506,6 +524,7 @@ namespace SAE_D21_A21_Jeroglifico.Components.Lesson
}
}
//si on clique sur reessayer
public void Retry(object sender, EventArgs e)
{
pnlResult.Visible = false;
......@@ -514,6 +533,7 @@ namespace SAE_D21_A21_Jeroglifico.Components.Lesson
trysCount++;
}
//si on clique sur le bouton valider
public void ValidateClick(object sender, EventArgs e)
{
Exo exo = exos[currentExo];
......@@ -521,7 +541,7 @@ namespace SAE_D21_A21_Jeroglifico.Components.Lesson
int prog_status;
bool result_status = exo.Verify();
if (result_status)
if (true)
{
prog_status = 1;
......@@ -542,6 +562,7 @@ namespace SAE_D21_A21_Jeroglifico.Components.Lesson
}
//vérifier que on a pas déja échoué une fois afin de pas ajouter l'exercice comme étant réussi
if (trysCount == 0)
{
bar.AddProgress(prog_status);
......@@ -568,6 +589,7 @@ namespace SAE_D21_A21_Jeroglifico.Components.Lesson
pnlResult.Visible = true;
}
//sauvegarde la progression dans la base de donnée
private void SaveProgress()
{
if (results.Select("status=false").Length == 0)
......
......@@ -115,7 +115,7 @@ namespace SAE_D21_A21_Jeroglifico.Components.Lesson
if (e.KeyChar == (char)Keys.Enter) { }
// Traitement de la touche Retour
else if (e.KeyChar == (char)Keys.Back) { }
// Ce qu'on accepte dans la cbo : des lettres et un tiret pour les noms composés
// Ce qu'on accepte dans la cbo : des lettres pour les noms composés
else if (e.KeyChar >= 65 && e.KeyChar <= 90 || e.KeyChar >= 97 && e.KeyChar <= 122) { }
// Sinon on accepte rien
else
......
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SAE_D21_A21_Jeroglifico.Components.Lesson
......@@ -15,12 +10,16 @@ namespace SAE_D21_A21_Jeroglifico.Components.Lesson
private int seg_width;
private int spacing = 20;
private Color front_color_done = Color.FromArgb(255, 120, 185, 106);
private Color front_color_to_do = Color.FromArgb(255, 200, 200, 200);
private Color front_color_false = Color.FromArgb(255, 248, 109, 98);
// Initialisation de couleurs pour la progressbar
private Color front_color_done = Color.FromArgb(255, 120, 185, 106); // Si c'est pas encore fait
private Color front_color_to_do = Color.FromArgb(255, 200, 200, 200); // Si c'est bon
private Color front_color_false = Color.FromArgb(255, 248, 109, 98); // Si c'est faux
int[] status;
int current = 0;
// Initialisation de la progressbar (longueur, division, ...)
public ProgressBar(int width, int len)
{
status = new int[len];
......@@ -32,6 +31,7 @@ namespace SAE_D21_A21_Jeroglifico.Components.Lesson
this.Paint += new PaintEventHandler(OnPaint);
}
// Dessine la bare de progression en fonction de status
private void OnPaint(object sender, PaintEventArgs e)
{
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
......@@ -46,8 +46,6 @@ namespace SAE_D21_A21_Jeroglifico.Components.Lesson
for (int i = 0; i < len; i++)
{
//left = i * seg_width;
//right = (i + 1) * seg_width - spacing;
switch (status[i])
{
case -1:
......@@ -55,7 +53,6 @@ namespace SAE_D21_A21_Jeroglifico.Components.Lesson
break;
case 1:
DrawSection(pen_done, brush_front_done, e.Graphics, i);
//e.Graphics.DrawLine(pen_done_b, left + 2 + spacing/2, Height/2, right, Height/2);
break;
default:
DrawSection(pen__to_do, brush_front, e.Graphics, i);
......@@ -64,6 +61,7 @@ namespace SAE_D21_A21_Jeroglifico.Components.Lesson
}
}
// Ajout de la progression
public void AddProgress(int stat)
{
status[current] = stat;
......@@ -71,6 +69,7 @@ namespace SAE_D21_A21_Jeroglifico.Components.Lesson
current += 1;
}
// Stoque l'état de chaque section
public void SetProgress(int i, int stat)
{
if (i < len)
......@@ -80,6 +79,7 @@ namespace SAE_D21_A21_Jeroglifico.Components.Lesson
}
}
// Dessine les petits ovales
private void DrawSection(Pen p, SolidBrush b, Graphics g, int i)
{
int left = i * seg_width + spacing / 2;
......@@ -91,16 +91,5 @@ namespace SAE_D21_A21_Jeroglifico.Components.Lesson
g.FillEllipse(b, right - radius, middleY - radius, radius * 2, radius * 2);
g.FillEllipse(b, left - radius, middleY - radius, radius * 2, radius * 2);
}
private void DrawTriangle(Graphics g, SolidBrush brush, PointF a, PointF b, PointF c)
{
g.FillPolygon(brush, new PointF[] { a, b, c });
Pen filler = new Pen(brush.Color, 1);
PointF af = new PointF(a.X, a.Y + 1);
PointF bf = new PointF(b.X, b.Y - 1);
g.DrawLine(filler, af, bf);
}
}
}
......@@ -96,6 +96,7 @@ namespace SAE_D21_A21_Jeroglifico.Components.Lesson
}
}
//permet d'ajouter un mot a une certaine posi
public void AddWordAt(WordLabel lbl, bool shadow)
{
Point pos = PointToClient(MousePosition);
......
......@@ -35,6 +35,7 @@ namespace SAE_D21_A21_Jeroglifico
id.Dock = DockStyle.Fill;
}
//sauvegarde la progression quand on ferme le formulaire
private void FrmProjet_FormClosing(object sender, FormClosingEventArgs e)
{
// enregistrement des données de l'utilisateur
......@@ -47,17 +48,12 @@ namespace SAE_D21_A21_Jeroglifico
/*
* Désactive l'a touche espace et tab
* Désactive la touche espace et tab
*/
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == Keys.Space && space == false)
{
//instead of checkBox1.Focused condition, you check if your DataGridView contains focus and active cell is of checkBox type
return true;
}
if(keyData == Keys.Tab)
{
return true;
}
......
using SAE_A21_D21.Components;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Text.RegularExpressions;
......@@ -140,15 +136,46 @@ namespace SAE_D21_A21_Jeroglifico.Pages
private void txtNom_KeyPress(object sender, KeyPressEventArgs e)
{
erpMessageNom.Clear();
// Traitement de la touche Entrée
if (e.KeyChar == (char)Keys.Enter) { }
// Traitement de la touche Retour
else if (e.KeyChar == (char)Keys.Back) { }
// Ce qu'on accepte dans la cbo : des lettres et un tiret pour les noms composés
else if (char.IsLetter(e.KeyChar) || e.KeyChar == '-') { }
// Sinon on accepte rien
if (txtNom.Text.Length <= 30 || e.KeyChar == (char)Keys.Back)
{
// Traitement de la touche retour
if (e.KeyChar == (char)Keys.Back) { }
// Ce qu'on accepte dans la texteBox : des lettres et un tiret pour les noms composés
// Il peut y avoir un nom composé donc on accepte plusieurs tirets,
// mais pas d'affilée
else if (char.IsLetter(e.KeyChar))
{
erpMessageNom.Clear();
}
else if (e.KeyChar == '-')
{
try
{
if (txtNom.SelectionStart == 0)
{
// empecher l'évènement
e.Handled = true;
}
else if (txtNom.Text[txtNom.Text.Length - 1] == '-')
{
// empecher l'évènement
e.Handled = true;
}
}
catch (IndexOutOfRangeException)
{
}
}
// Sinon on accepte rien
else
{
e.Handled = true;
}
}
else
{
erpMessageNom.SetError(txtNom, "C'est beaucoup trop long!");
e.Handled = true;
}
}
......@@ -156,15 +183,46 @@ namespace SAE_D21_A21_Jeroglifico.Pages
private void txtPrenom_KeyPress(object sender, KeyPressEventArgs e)
{
erpMessagePrenom.Clear();
// Traitement de la touche Entrée
if (e.KeyChar == (char)Keys.Enter) { }
// Traitement de la touche Retour
else if (e.KeyChar == (char)Keys.Back) { }
// Ce qu'on accepte dans la cbo : des lettres et un tiret pour les noms composés
else if (char.IsLetter(e.KeyChar) || e.KeyChar == '-') { }
// Sinon on accepte rien
if (txtPrenom.Text.Length <= 30 || e.KeyChar == (char)Keys.Back)
{
// Traitement de la touche retour
if (e.KeyChar == (char)Keys.Back) { }
// Ce qu'on accepte dans le txt : des lettres et un tiret pour les noms composés
// Il peut avoir un prénom composé donc on accèpte plusieurs tirets,
// mais pas d'affilée
else if (char.IsLetter(e.KeyChar))
{
erpMessagePrenom.Clear();
}
else if (e.KeyChar == '-')
{
try
{
if (txtPrenom.SelectionStart == 0)
{
// empecher l'évènement
e.Handled = true;
}
else if (txtPrenom.Text[txtPrenom.Text.Length - 1] == '-')
{
// empecher l'évènement
e.Handled = true;
}
}
catch (IndexOutOfRangeException)
{
}
}
// Sinon on accepte rien
else
{
e.Handled = true;
}
}
else
{
erpMessagePrenom.SetError(txtPrenom, "C'est beaucoup trop long!");
e.Handled = true;
}
}
......@@ -265,6 +323,8 @@ namespace SAE_D21_A21_Jeroglifico.Pages
// Execution de la requete
OleDbCommand cd = new OleDbCommand(requete, connec);
cd.ExecuteNonQuery();
MessageBox.Show("Vous avez bien été ajouté!");
}
catch (InvalidOperationException)
{
......@@ -333,17 +393,27 @@ namespace SAE_D21_A21_Jeroglifico.Pages
private void txtMail_KeyPress(object sender, KeyPressEventArgs e)
{
// Traitement de la touche Entrée
if (e.KeyChar == (char)Keys.Enter){
// Check si le mail est correctement construit
if (IsValidEmail(txtMail.Text) == true) { }
else
erpMessageMail.Clear();
if (txtMail.Text.Length <= 30 || e.KeyChar == (char)Keys.Back)
{
// Traitement de la touche Entrée
if (e.KeyChar == (char)Keys.Enter)
{
erpMessageMail.SetError(txtMail, "Mail non valide");
// Check si le mail est correctement construit
if (IsValidEmail(txtMail.Text) == true) { }
else
{
erpMessageMail.SetError(txtMail, "Mail non valide");
}
}
// Traitement de la touche retour
else if (e.KeyChar == (char)Keys.Back) { }
}
else
{
erpMessageMail.SetError(txtMail, "C'est beaucoup trop long!");
e.Handled = true;
}
// Traitement de la touche retour
else if (e.KeyChar == (char)Keys.Back) { }
}
private void check_focus(object sender, EventArgs e)
......
......@@ -201,7 +201,7 @@ namespace SAE_D21_A21_Jeroglifico.Pages
}
else
{
MessageBox.Show("sd");
MessageBox.Show("Vous n'avez pas accès, car vous avez une leçon en cours");
}
}
......
......@@ -57,15 +57,6 @@ namespace SAE_D21_A21_Jeroglifico.Pages
utils.Add(ro.Row[0].ToString().ToLower());
ids.Add(ro.Row[1].ToString());
}
// Parcours du datareader pour mettre tous les utilisateurs dans la cbo
/*if (dr.HasRows)
{
while (dr.Read())
{
cboIdentification.Items.Add(dr.GetString(0) + " " + dr.GetString(1));
cboIdentification.ValueMember.
}
}*/
}
catch (InvalidOperationException)
{
......@@ -103,6 +94,7 @@ namespace SAE_D21_A21_Jeroglifico.Pages
}
}
//charge la page accueil
private void cboEnter()
{
// Regarder si le champs est rempli
......@@ -144,70 +136,80 @@ namespace SAE_D21_A21_Jeroglifico.Pages
private void cboIdentification_KeyPress(object sender, KeyPressEventArgs e)
{
// Traitement de la touche retour
if (e.KeyChar == (char)Keys.Back) { }
// Ce qu'on accepte dans la cbo : des lettres et un tiret pour les noms composés
// Il peut avoir un prénom composé et un nom composé, donc on accèpte plusieurs tirets
else if (char.IsLetter(e.KeyChar) || e.KeyChar == '-') {
erpMessage.Clear();
}
else if(e.KeyChar == ' ')
if (cboIdentification.Text.Length <= 60 || e.KeyChar == (char)Keys.Back)
{
if (cboIdentification.Text.Contains(' '))
// Traitement de la touche retour
if (e.KeyChar == (char)Keys.Back) { }
// Ce qu'on accepte dans la cbo : des lettres et un tiret pour les noms composés
// Il peut avoir un prénom composé et un nom composé, donc on accèpte plusieurs tirets,
// mais pas d'affilée
else if (char.IsLetter(e.KeyChar))
{
// empecher l'évènement
e.Handled = true;
erpMessage.Clear();
}
else if (cboIdentification.SelectionStart == 0)
else if (e.KeyChar == '-')
{
try
{
if (cboIdentification.SelectionStart == 0)
{
// empecher l'évènement
e.Handled = true;
}
else if (cboIdentification.Text[cboIdentification.Text.Length - 1] == '-')
{
// empecher l'évènement
e.Handled = true;
}
else if (cboIdentification.Text[cboIdentification.Text.Length - 1] == ' ')
{
// empecher l'évènement
e.Handled = true;
}
}
catch (IndexOutOfRangeException)
{
}
}
else if (e.KeyChar == ' ')
{
if (cboIdentification.Text.Contains(' '))
{
// empecher l'évènement
e.Handled = true;
}
else if (cboIdentification.Text[cboIdentification.Text.Length - 1] == '-')
{
// empecher l'évènement
e.Handled = true;
}
else if (cboIdentification.SelectionStart == 0)
{
// empecher l'évènement
e.Handled = true;
}
}
// Sinon on accepte rien
else
{
// empecher l'évènement
e.Handled = true;
}
}
// Sinon on accepte rien
else
{
erpMessage.SetError(cboIdentification, "C'est beaucoup trop long!");
e.Handled = true;
}
}
/*
* Au click sur le boutton connexion
*/
private void btnConnexion_Click(object sender, EventArgs e)
{
// Regarder si le champs est rempli
if (string.IsNullOrEmpty(cboIdentification.Text))
{
erpMessage.SetError(cboIdentification, "Veuillez remplir ce champs");
}
// Regarde si la cbo contient l'utilisateur
else if (utils.Contains(cboIdentification.Text.Trim().ToLower()))
{
SetUser();
// On trouve le formulaire de base (ici FrmProjet)
FrmProjet form = (FrmProjet)this.FindForm();
// On affiche le nom de la page à l'en-tête du formulaire
form.Text = "Accueil";
// Création de la page accueil
Accueil accueil = new Accueil();
//bloque la touche espace
form.space = false;
// Ajout de la page au formulaire
form.Controls.Add(accueil);
// On le met en premier plan
accueil.BringToFront();
// full screen
accueil.Dock = DockStyle.Fill;
}
else
{
erpMessage.SetError(cboIdentification, "Cet utilisateur n'existe pas");
}
cboEnter();
}
// Pour le copier-coller
......@@ -261,6 +263,9 @@ namespace SAE_D21_A21_Jeroglifico.Pages
btnConnexion.BackColor = Color.FromArgb(68, 112, 77);
}
/*
* Permet d'activer la touche entrée pour valider la cbo
*/
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if ((this.ActiveControl == cboIdentification) && (keyData == Keys.Enter))
......
......@@ -17,14 +17,6 @@ namespace SAE_D21_A21_Jeroglifico
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
DataManager.Init();
//Application.Run(new FrmProjet());
//Application.Run(new FormTestIdentification());
//Application.Run(new FormTestAdmin());
//Application.Run(new FormTestAccueil());
//Application.Run(new FormTestVocab());
//Application.Run(new FormTestMenu());
//Application.Run(new FormTestCours());
//Application.Run(new FormTestExoMotsManquants());
Application.Run(new FrmProjet());
}
}
......
......@@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace SAE_D21_A21_Jeroglifico.Utils
{
//permet d'accerder aux informations sur l'utilisateur actuellement connecté
//permet de stocker les informations sur l'utilisateur actuellement connecté et y acceder
class GlobalUser
{
public static User user;
......
......@@ -146,7 +146,7 @@ namespace SAE_A21_D21
}
//on dessine le rectangle en fonction du nombre d'acquis
iText.Kernel.Geom.Rectangle rect = new iText.Kernel.Geom.Rectangle(50, (rTop-65) - (31 * acc.Count), 495, padd + (25 * acc.Count));
iText.Kernel.Geom.Rectangle rect = new iText.Kernel.Geom.Rectangle(50, (rTop-95) - (30 * acc.Count), 495, padd + (30 * acc.Count));
//on personalise les parametres du rectangle
canv.SetStrokeColor(ColorConstants.GREEN);
......
File deleted