private void Btn_NaechstesNomen_Click(object sender, EventArgs e) { this.ausgewaehltesNomen = CollectionExtension.RandomElement(this.NomensListe); this.txtBox_NominativSingular.Text = this.ausgewaehltesNomen.NominativSingular; this.ClearTextBoxes(); }
private void FillNomensListeFromTextFile() { if (!Directory.Exists(@"C:\ProgramData\learnLatin")) { Directory.CreateDirectory(@"C:\ProgramData\learnLatin"); } if (!File.Exists(@"C:\ProgramData\learnLatin\Nomen.txt")) { return; } this.NomensListe.Clear(); var stream = new FileStream(@"C:\ProgramData\learnLatin\Nomen.txt", FileMode.Open, FileAccess.Read); var reader = new StreamReader(stream); var line = String.Empty; while ((line = reader.ReadLine()) != null) { var nomen = new Nomen(String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty); var singular = line.Split('#')[0].Split(';'); var plural = line.Split('#')[1].Split(';'); var zuDeutsch = line.Split('#')[2]; nomen.NominativSingular = singular[0]; nomen.GenitivSingular = singular[1]; nomen.DativSingular = singular[2]; nomen.AkkusativSingular = singular[3]; nomen.AblativSingular = singular[4]; nomen.VokativSingular = singular[5]; nomen.LokativSingular = singular[6]; nomen.NominativPlural = plural[0]; nomen.GenitivPlural = plural[1]; nomen.DativPlural = plural[2]; nomen.AkkusativPlural = plural[3]; nomen.AblativPlural = plural[4]; nomen.VokativPlural = plural[5]; nomen.LokativPlural = plural[6]; nomen.ZuDeutsch = zuDeutsch; this.NomensListe.Add(nomen); } reader.Close(); stream.Close(); }
private void Btn_NomenHinzufuegen_Click(object sender, EventArgs e) { var nomen = new Nomen(this.txtBox_NominativSingular.Text, this.txtBox_GenitivSingular.Text, this.txtBox_DativSingular.Text, this.txtBox_AkkusativSingular.Text, this.txtBox_AblativSingular.Text, this.txtBox_NominativPlural.Text, this.txtBox_GenitivPlural.Text, this.txtBox_DativPlural.Text, this.txtBox_AkkusativPlural.Text, this.txtBox_AblativPlural.Text, this.txtBox_ZuDeutsch.Text); nomen.AddLokativ(String.Empty, String.Empty); nomen.AddVokativ(String.Empty, String.Empty); this.NomensListe.Add(nomen); nomen = null; this.SaveNomensListeAsTextFile(); MessageBox.Show("Das Nomen wurde erfolgreich hinzugefügt!"); this.btn_NaechstesNomen.PerformClick(); }