private void btn_save_Click(object sender, EventArgs e) { DBAdapter.UpdateLabel(dbFilePath, "nativeLanguage", tb_EigeneSprache.Text); DBAdapter.UpdateLabel(dbFilePath, "translationLanguage", tb_Fremdsprache.Text); File.Move(dbFilePath, Miscellaneous.GenealValues.APPDATA_PATH + tb_Name.Text + ".db"); Application.Restart(); }
public LearnBox(string boxNameFromRecent) { InitializeComponent(); dbFilePath = Miscellaneous.GenealValues.APPDATA_PATH + boxNameFromRecent + ".db"; lb_Title.Text = boxNameFromRecent; startWindow = DateTime.Now; lb_EigeneSprache.Text = DBAdapter.GetLabelEntry(dbFilePath, "nativeLanguage") + ":"; lb_Fremdsprache.Text = DBAdapter.GetLabelEntry(dbFilePath, "translationLanguage") + ":"; lb_DirectionEF.Text = DBAdapter.GetLabelEntry(dbFilePath, "nativeLanguage") + " > " + DBAdapter.GetLabelEntry(dbFilePath, "translationLanguage"); lb_DirectionFE.Text = DBAdapter.GetLabelEntry(dbFilePath, "translationLanguage") + " > " + DBAdapter.GetLabelEntry(dbFilePath, "nativeLanguage"); Fach[0] = DBAdapter.GetVocsByClass(dbFilePath, 0); Fach[1] = DBAdapter.GetVocsByClass(dbFilePath, 1); Fach[2] = DBAdapter.GetVocsByClass(dbFilePath, 2); Fach[3] = DBAdapter.GetVocsByClass(dbFilePath, 3); Fach[4] = DBAdapter.GetVocsByClass(dbFilePath, 4); Fach[5] = DBAdapter.GetVocsByClass(dbFilePath, 5); Fach[6] = DBAdapter.GetVocsByClass(dbFilePath, 6); Fach[7] = DBAdapter.GetVocsByClass(dbFilePath, 7); Fach[8] = DBAdapter.GetVocsByClass(dbFilePath, 8); Fach[9] = DBAdapter.GetVocsByClass(dbFilePath, 9); Fach[10] = DBAdapter.GetVocsByClass(dbFilePath, 10); if (DBAdapter.GetLabelEntry(dbFilePath, "lastClass") == "none") { if (!FindNewClass()) { MessageBox.Show("In der Ausgewählten Box sind keine Vokabeln enthalten. Gehe zu Hauptmenü > Vorhandene Box öffnen > Vokabeln verwalten um neue Vokabeln hinzufügen", "Keine Vokabeln gefunden", MessageBoxButtons.OK, MessageBoxIcon.Error); CloseMeFunction?.Invoke(this, null); } } else { currentClass = Convert.ToInt32(DBAdapter.GetLabelEntry(dbFilePath, "lastClass")); } DBAdapter.UpdateLabel(dbFilePath, "lastClass", currentClass.ToString()); NextExercise(); UpdateClassVisibility(); sts_info.BackColor = Miscellaneous.CustomColors.LearnBox; }
/// <summary> /// Löscht eine Vokabel Aus /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void act_DeleteVoc(object sender, EventArgs e) { switch (classNumber) { case 1: Fach1.Remove(currentVoc); if (Fach1.Count == 0) { DBAdapter.UpdateLabel(dbFilePath, "lastClass", "none"); } break; case 2: Fach2.Remove(currentVoc); if (Fach2.Count == 0) { DBAdapter.UpdateLabel(dbFilePath, "lastClass", "none"); } break; case 3: Fach3.Remove(currentVoc); if (Fach3.Count == 0) { DBAdapter.UpdateLabel(dbFilePath, "lastClass", "none"); } break; case 4: Fach4.Remove(currentVoc); if (Fach4.Count == 0) { DBAdapter.UpdateLabel(dbFilePath, "lastClass", "none"); } break; case 5: Fach5.Remove(currentVoc); if (Fach5.Count == 0) { DBAdapter.UpdateLabel(dbFilePath, "lastClass", "none"); } break; case 6: Fach6.Remove(currentVoc); if (Fach6.Count == 0) { DBAdapter.UpdateLabel(dbFilePath, "lastClass", "none"); } break; case 7: Fach7.Remove(currentVoc); if (Fach7.Count == 0) { DBAdapter.UpdateLabel(dbFilePath, "lastClass", "none"); } break; case 8: Fach8.Remove(currentVoc); if (Fach8.Count == 0) { DBAdapter.UpdateLabel(dbFilePath, "lastClass", "none"); } break; case 9: Fach9.Remove(currentVoc); if (Fach9.Count == 0) { DBAdapter.UpdateLabel(dbFilePath, "lastClass", "none"); } break; case 10: Fach10.Remove(currentVoc); if (Fach10.Count == 0) { DBAdapter.UpdateLabel(dbFilePath, "lastClass", "none"); } break; } UpdateElements(); UpdateDatabase(); pnl_Info.Visible = false; lb_Info_Title.Text = "Wählen sie eine Vokabel aus, um sie zu bearbeiten"; }
/// <summary> /// Wenn der benutzer auf WEITER klickt /// </summary> private void act_Continue() { if (btn_Continue.Text == "BESTÄTIGEN") { // Abfragerichtung bestimmen if (direction) { string writtenAnswer = tb_Fremdsprache.Text; string withoutComment = Regex.Replace(transVoc, @"\[.*?\]", "").Trim(); if (!cb_GrossKleinSchreibung.Checked) { withoutComment = withoutComment.ToLower(); } if (!cb_GrossKleinSchreibung.Checked) { writtenAnswer = writtenAnswer.ToLower(); } // Aufteilung in mehrere Bedeutungen für das selbe Wort if (withoutComment.Split(Miscellaneous.BoxValues.MULTIPLE_MEANING_SEPERATOR).Contains(writtenAnswer)) { wasRight = true; } else { wasRight = false; } tb_Fremdsprache.Text = string.Join(" | ", withoutComment.Split('|')); } else { string writtenAnswer = tb_EigeneSprache.Text; string withoutComment = Regex.Replace(currentVoc, @"\[.*?\]", "").Trim(); if (!cb_GrossKleinSchreibung.Checked) { withoutComment = withoutComment.ToLower(); } if (!cb_GrossKleinSchreibung.Checked) { writtenAnswer = writtenAnswer.ToLower(); } // Aufteilung in mehrere Bedeutungen für das selbe Wort if (withoutComment.Split(Miscellaneous.BoxValues.MULTIPLE_MEANING_SEPERATOR).Contains(writtenAnswer)) { wasRight = true; } else { wasRight = false; } tb_EigeneSprache.Text = string.Join(" | ", withoutComment.Split('|')); } // Farbe ändern if (wasRight) { tb_EigeneSprache.ForeColor = Color.Green; tb_Fremdsprache.ForeColor = Color.Green; btn_Continue.ForeColor = Color.Green; } else { tb_EigeneSprache.ForeColor = Color.Red; tb_Fremdsprache.ForeColor = Color.Red; btn_Continue.ForeColor = Color.Red; btn_Vertippt.Visible = true; } gb_Optionen.Enabled = false; btn_Continue.Text = "WEITER"; } else if (btn_Continue.Text == "WEITER") { DBAdapter.UpdateLabel(dbFilePath, "lastLearned", DateTime.Today.ToString("d")); // Alte Vokabel Verwaltung if (wasRight) { StatsAddEntry(true); if (currentClass != 10) { Fach[currentClass].Remove(currentVoc); Fach[currentClass + 1].Add(currentVoc, transVoc); DBAdapter.ChangeVocableClass(dbFilePath, currentVoc, currentClass + 1); } else { Fach[currentClass].Remove(currentVoc); Fach[0].Add(currentVoc, transVoc); DBAdapter.ChangeVocableClass(dbFilePath, currentVoc, 0); } UpdateClassVisibility(); } else { StatsAddEntry(false); if (cb_BackToOne.Checked) { Fach[currentClass].Remove(currentVoc); Fach[1].Add(currentVoc, transVoc); DBAdapter.ChangeVocableClass(dbFilePath, currentVoc, 1); } UpdateClassVisibility(); } btn_Vertippt.Visible = false; btn_Continue.ForeColor = SystemColors.ControlText; btn_Continue.Text = "BESTÄTIGEN"; gb_Optionen.Enabled = true; tb_EigeneSprache.ForeColor = SystemColors.ControlText; tb_Fremdsprache.ForeColor = SystemColors.ControlText; // Nächste Vokabel int countCurrentClass = Fach[currentClass].Count(); if (countCurrentClass > 0) { NextExercise(); } else { if (currentClass == 1) { FindNewClass(); DBAdapter.UpdateLabel(dbFilePath, "lastClass", currentClass.ToString()); if (MessageBox.Show("Du hast die Box nun einmal durchgelernt. Es ist empfohlen in regelmäßigen Abständen zu lernen. Möchtest du weiter lernen?", "Weiter lernen?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { NextExercise(); } else { CloseMeFunction?.Invoke(this, null); } } else { while (!FindNextClass()) { currentClass--; if (currentClass == 0) { FindNewClass(); DBAdapter.UpdateLabel(dbFilePath, "lastClass", currentClass.ToString()); if (MessageBox.Show("Du hast die Box nun einmal durchgelernt. Es ist empfohlen in regelmäßigen Abständen zu lernen. Möchtest du weiter lernen?", "Weiter lernen?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { NextExercise(); } else { CloseMeFunction?.Invoke(this, null); } } } NextExercise(); } } } }