Skip to content
Snippets Groups Projects

Main

Merged BARDOU VINCENT requested to merge vbardou/sae_a21_d21:main into main
Compare and
4 files
+ 65
47
Preferences
Compare changes
Files
4
@@ -7,6 +7,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using SAE_D21_A21_Jeroglifico.Utils;
namespace SAE_D21_A21_Jeroglifico.Components.Lesson
{
@@ -54,8 +55,8 @@ namespace SAE_D21_A21_Jeroglifico.Components.Lesson
Console.WriteLine(sentence_cut[i]);
if (words_hide_index.Contains(i))
{
head = TrimHead(ref sentence_cut[i]);
tail = TrimTail(ref sentence_cut[i]);
head = StringUtils.TrimHead(ref sentence_cut[i]);
tail = StringUtils.TrimTail(ref sentence_cut[i]);
if (!string.IsNullOrEmpty(head))
{
@@ -116,31 +117,6 @@ namespace SAE_D21_A21_Jeroglifico.Components.Lesson
}
private string TrimHead(ref string str)
{
string trimed = "";
while(str.Length > 0 && char.IsPunctuation(str[0]))
{
trimed += str[0];
str = str.Remove(0, 1);
}
return trimed;
}
private string TrimTail(ref string str)
{
string trimed = "";
int len;
while ((len = str.Length) > 0 && char.IsPunctuation(str[len - 1]))
{
trimed += str[len- 1];
str = str.Remove(len - 1, 1);
}
return trimed;
}
public override void Init()
{
Padding tmpPad = new Padding();
@@ -187,18 +163,6 @@ namespace SAE_D21_A21_Jeroglifico.Components.Lesson
Height = container.Bottom + 10;
}
public static string RemoveAccents(string text)
{
StringBuilder sbReturn = new StringBuilder();
var arrayText = text.Normalize(NormalizationForm.FormD).ToCharArray();
foreach (char letter in arrayText)
{
if (CharUnicodeInfo.GetUnicodeCategory(letter) != UnicodeCategory.NonSpacingMark)
sbReturn.Append(letter);
}
return sbReturn.ToString();
}
public override bool Verify()
{
string normalized_ans;
@@ -206,9 +170,8 @@ namespace SAE_D21_A21_Jeroglifico.Components.Lesson
bool isRight = true;
for (int i = 0; i < answers.Count && isRight; i++)
{
normalized_ans = RemoveAccents(answers[i].Text.Trim().ToLower());
normalized_corect = RemoveAccents(words_hide[i].ToLower());
//MessageBox.Show(normalized_ans + " " + normalized_corect + " " + answers[i].Text + " " + words_hide[i]);
normalized_ans = StringUtils.Normalize(answers[i].Text);
normalized_corect = StringUtils.Normalize(words_hide[i]);
if (!normalized_ans.Equals(normalized_corect))
{
isRight = false;
@@ -222,9 +185,9 @@ namespace SAE_D21_A21_Jeroglifico.Components.Lesson
string normalized_ans;
string normalized_corect;
for (int i = 0; i < answers.Count; i++)
{
normalized_ans = RemoveAccents(answers[i].Text.Trim().ToLower());
normalized_corect = RemoveAccents(words_hide[i].ToLower());
{
normalized_ans = StringUtils.Normalize(answers[i].Text);
normalized_corect = StringUtils.Normalize(words_hide[i]);
if (normalized_ans.Equals(normalized_corect))
{
answers[i].SetBackColor(Color.Green);