private void btnOK_Click(object sender, RoutedEventArgs e) { try { if (editMode) { Waffe tmp = new Waffe(txtName.Text, Int32.Parse(txtAufw.Text), Int32.Parse(txtSchaden.Text), txtEffekt.Text, Double.Parse(txtGewicht.Text, CultureInfo.InvariantCulture)); tmp.Stufe = EDWerte.WerteTab[AttributTranslation["STR"]][0] + tmp.Schaden + tmp.Aufwertung; parent.aktChar.Waffen[parent.aktChar.Waffen.IndexOf(wep)] = tmp; Waffe sav = parent.aktChar.Waffen[parent.aktChar.Waffen.IndexOf(wep)]; if (!parent.CalcGewicht()) { parent.aktChar.Waffen[parent.aktChar.Waffen.IndexOf(wep)] = sav; parent.CalcGewicht(); } else { parent.UpdateGUI(); this.Close(); } } else { Waffe tmp = new Waffe(txtName.Text, Int32.Parse(txtAufw.Text), Int32.Parse(txtSchaden.Text), txtEffekt.Text, Double.Parse(txtGewicht.Text, CultureInfo.InvariantCulture)); tmp.Stufe = EDWerte.WerteTab[AttributTranslation["STR"]][0] + tmp.Schaden + tmp.Aufwertung; parent.aktChar.Waffen.Add(tmp); if (!parent.CalcGewicht()) { parent.aktChar.Waffen.Remove(tmp); parent.CalcGewicht(); } else { parent.UpdateGUI(); this.Close(); } } } catch (Exception) { MessageBox.Show("Alle Textboxen überprüfen!"); } }
public winWaffe(MainWindow _parent, Waffe _wep) { InitializeComponent(); parent = _parent; wep = _wep; AttributTranslation.Add("GES", parent.aktChar.GES); AttributTranslation.Add("ZAH", parent.aktChar.ZAH); AttributTranslation.Add("STR", parent.aktChar.STR); AttributTranslation.Add("WAH", parent.aktChar.WAH); AttributTranslation.Add("WIL", parent.aktChar.WIL); AttributTranslation.Add("CHA", parent.aktChar.CHA); txtName.Text = wep.Name; txtAufw.Text = wep.Aufwertung.ToString(); txtSchaden.Text = wep.Schaden.ToString(); txtEffekt.Text = wep.Effekt; editMode = true; }