Beispiel #1
0
        void btnCancel_Click(object sender, EventArgs e)
        {
            armor = null;

            this.FormClosing -= FormArmorDetails_FormClosing;
            this.Close();
        }
Beispiel #2
0
        private void AddArmor(ArmorData armorData)
        {
            if (FormDetails.ItemManager.ArmorData.ContainsKey(armorData.Name))
            {
                DialogResult result = MessageBox.Show(
                    armorData.Name + " already exists. Do you want to Overwrite it?",
                    "Entry exists",
                    MessageBoxButtons.YesNo);

                if (result == DialogResult.No)
                {
                    return;
                }

                itemManager.ArmorData[armorData.Name] = armorData;
                FillListBox();
                return;
            }

            itemManager.ArmorData.Add(armorData.Name, armorData);
            lbDetails.Items.Add(armorData);
        }
Beispiel #3
0
        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("Name must not be blank.");
            }

            if (!int.TryParse(mtbPrice.Text, out price))
            {
                MessageBox.Show("Price must not be blank.");
            }

            weight = (float)nudWeight.Value;

            if (!int.TryParse(mtbDefenseValue.Text, out defVal))
            {
                MessageBox.Show("Defense Value must not be blank.");
            }

            if (!int.TryParse(mtbDefenseModifier.Text, out defMod))
            {
                MessageBox.Show("Defense Modifier must not be blank.");
            }

            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();
        }