Exemplo n.º 1
0
        private void AddArmour(ArmourData armourData)
        {
            if (FormDetails.ItemDataManager.ArmourData.ContainsKey(armourData.Name))
            {
                DialogResult result = MessageBox.Show(
                    armourData.Name + " already exists. Overwrite it?",
                    "Existing Armour",
                    MessageBoxButtons.YesNo);

                if (result == DialogResult.No)
                    return;

                ItemDataManager.ArmourData[armourData.Name] = armourData;
                FillListBox();
                return;
            }
            ItemDataManager.ArmourData.Add(armourData.Name, armourData);
            lbDetails.Items.Add(armourData);
        }
Exemplo n.º 2
0
        void btnOK_Click(object sender, EventArgs e)
        {
            int price, defVal, defMod;
            float weight;

            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(mtbDefenceValue.Text, out defVal))
            {
                MessageBox.Show("Defence value must be an integer value.");
                return;
            }

            if (!int.TryParse(mtbDefenceModifier.Text, out defMod))
            {
                MessageBox.Show("Defence value must be an integer value.");
                return;
            }

            List<string> allowedClasses = new List<string>();

            foreach (object o in lbAllowedClasses.Items)
                allowedClasses.Add(o.ToString());

            Armour = new ArmourData();
            Armour.Name = tbName.Text;
            Armour.Type = tbType.Text;
            Armour.Price = price;
            Armour.Weight = weight;
            Armour.ArmourLocation = (ArmourLocation)cboArmourLocation.SelectedIndex;
            Armour.DefenceValue = defVal;
            Armour.DefenceModifier = defMod;
            Armour.AllowableClasses = allowedClasses.ToArray();

            this.FormClosing -= FormArmourDetails_FormClosing;
            this.Close();
        }
Exemplo n.º 3
0
 void btnCancel_Click(object sender, EventArgs e)
 {
     Armour = null;
     this.FormClosing -= FormArmourDetails_FormClosing;
     this.Close();
 }