Exemple #1
0
        private void loadExample()
        {
            btnNext.Enabled = btnPrevious.Enabled = false;
            //TODO: tratar H, NH, testar todas as sílabas [a-z]+ combinaçoes
            Manager.WordManager wm = new Manager.WordManager();
            int i;

            cleanLesson();
            byte wordsCount = (byte)((i = int.Parse("0" + mtbWordCount.Text.Trim())) == 0 ? 5 : i);

            if (chkRandom.Checked)
            {
                int lessonCount = (lessonCount = int.Parse("0" + mtbLessonCount.Text.Trim())) == 0 ? 5 : lessonCount;

                this.CurrentLesson = wm.GetLessons(maxLessons: (ushort)lessonCount, maxWordsPerLesson: wordsCount);
            }
            else
            {
                var consonants = getConsonants();
                if (!consonants.Any())
                {
                    MessageBox.Show("Não foram encontradas consoantes!", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                this.tbxConsonants.Text = string.Join(", ", consonants.OrderBy(c => c).ToArray());
                this.CurrentLesson      = wm.GetLessons(consonants.Select(c => (c == "q") ? "qu" : c).ToArray(), maxWordsPerLesson: wordsCount); //hack: não se usa q sem u... meu querido
            }
            this.CurrentLesson = this.CurrentLesson.OrderBy(l => l.GetConsonant()).ToList();
            if (CurrentLesson == null || CurrentLesson.Count == 0)
            {
                return;
            }
            loadLesson(CurrentLesson.First());
            btnNext.Enabled     = CurrentLesson.Count > 1;
            btnPrevious.Enabled = false;
        }
 public DataWordsForm()
 {
     InitializeComponent();
     wm         = new Manager.WordManager();
     this.Load += DataWordsForm_Load;
 }