public Armor(ArmorData armorData) : base(armorData.Name, armorData.Type, armorData.Price, armorData.Weight, armorData.AllowableClasses) { Location = armorData.ArmorLocation; DefenseValue = armorData.DefenseValue; DefenseModifier = armorData.DefenseModifier; }
private void AddArmor(ArmorData armorData) { if (FormDetails.ItemManager.ArmorData.ContainsKey(armorData.Name)) { DialogResult result = MessageBox.Show( armorData.Name + " already exists. Overwrite it?", "Existing armor", MessageBoxButtons.YesNo); if (result == DialogResult.No) return; itemManager.ArmorData[armorData.Name] = armorData; FillListBox(); return; } itemManager.ArmorData.Add(armorData.Name, armorData); lbDetails.Items.Add(armorData); }
void btnCancel_Click(object sender, EventArgs e) { armor = null; this.FormClosing -= FormArmorDetails_FormClosing; this.Close(); }
void btnOK_Click(object sender, EventArgs e) { int price = 0; float weight = 0f; int defVal = 0; int defMod = 0; if (string.IsNullOrEmpty(tbName.Text)) { MessageBox.Show("You must enter a name for the item."); return; } if (!int.TryParse(mtbPrice.Text, out price)) { MessageBox.Show("Price must be an integer value."); return; } weight = (float)nudWeight.Value; if (!int.TryParse(mtbDefenseValue.Text, out defVal)) { MessageBox.Show("Defense valule must be an interger value."); return; } if (!int.TryParse(mtbDefenseModifier.Text, out defMod)) { MessageBox.Show("Defense valule must be an interger value."); return; } List<string> allowedClasses = new List<string>(); foreach (object o in lbAllowedClasses.Items) allowedClasses.Add(o.ToString()); armor = new ArmorData(); armor.Name = tbName.Text; armor.Type = tbType.Text; armor.Price = price; armor.Weight = weight; armor.ArmorLocation = (ArmorLocation)cboArmorLocation.SelectedIndex; armor.DefenseValue = defVal; armor.DefenseModifier = defMod; armor.AllowableClasses = allowedClasses.ToArray(); this.FormClosing -= FormArmorDetails_FormClosing; this.Close(); }
public void Cancel_Click(object sender, EventArgs e) { armor = null; this.FormClosing -= new FormClosingEventHandler(Form_Close); this.Close(); }
public void Ok_Click(object sender, EventArgs e) { int price = 0, defVal = 0, defMod = 0; float weight = 0f; if (string.IsNullOrEmpty(tbName.Text)) { MessageBox.Show("You must enter a name for the item"); return; } if (!int.TryParse(mtbPrice.Text, out price)) { MessageBox.Show("Price must be a value greater than '1'"); return; } weight = (float) nudWeight.Value; if (!int.TryParse(mtbDefenseVal.Text, out defVal)) { MessageBox.Show("Defense Value must be greater than '1'"); return; } if (!int.TryParse(mtbDefenseMod.Text, out defMod)) { MessageBox.Show("Defense Modifier must be greater than '1'"); return; } List<string> allowedClasses = new List<string>(); foreach (object o in lbAllowedClasses.Items) { allowedClasses.Add(o.ToString()); } armor = new ArmorData(); armor.name = tbName.Text; armor.type = tbType.Text; armor.price = price; armor.weight = weight; armor.ArmorLocation = (ArmorLocation) cbLocations.SelectedIndex; armor.defenseValue = defVal; armor.defenseModifier = defMod; armor.allowableClasses = allowedClasses.ToArray(); this.FormClosing -= new FormClosingEventHandler(Form_Close); this.Close(); }