コード例 #1
0
        void btnOK_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 lbSelectedClasses.Items)
            {
                allowedClasses.Add(o.ToString());
            }

            shield = new ShieldData();
            shield.name = tbName.Text;
            shield.type = tbType.Text;
            shield.price = price;
            shield.weight = weight;
            shield.defenseValue = defVal;
            shield.defenseModifier = defMod;
            shield.allowableClasses = allowedClasses.ToArray();

            this.FormClosing -= new FormClosingEventHandler(Form_Close);
            this.Close();
        }
コード例 #2
0
 void btnCancel_Click(object sender, EventArgs e)
 {
     shield = null;
     this.FormClosing -= new FormClosingEventHandler(Form_Close);
     this.Close();
 }
コード例 #3
0
ファイル: FormShield.cs プロジェクト: brollins90/eotd
        private void AddShield(ShieldData shieldData)
        {
            if (FormDetails.ItemManager.ShieldData.ContainsKey(shieldData.Name))
            {
                DialogResult result = MessageBox.Show(
                    shieldData.Name + " already exists. Overwrite it?",
                    "Existing shield",
                    MessageBoxButtons.YesNo);

                if (result == DialogResult.No)
                    return;

                itemManager.ShieldData[shieldData.Name] = shieldData;
                FillListBox();
                return;
            }

            itemManager.ShieldData.Add(shieldData.Name, shieldData);
            lbDetails.Items.Add(shieldData);
        }
コード例 #4
0
 public Shield(ShieldData shieldData)
     : base(shieldData.Name, shieldData.Type, shieldData.Price, shieldData.Weight, shieldData.AllowableClasses)
 {
     DefenseValue    = shieldData.DefenseValue;
     DefenseModifier = shieldData.DefenseModifier;
 }
コード例 #5
0
ファイル: FormShieldDetails.cs プロジェクト: brollins90/eotd
 void btnCancel_Click(object sender, EventArgs e)
 {
     shield = null;
     this.FormClosing -= FormShieldDetails_FormClosing;
     this.Close();
 }
コード例 #6
0
ファイル: FormShieldDetails.cs プロジェクト: brollins90/eotd
        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());

            shield = new ShieldData();
            shield.Name = tbName.Text;
            shield.Type = tbType.Text;
            shield.Price = price;
            shield.Weight = weight;
            shield.DefenseValue = defVal;
            shield.DefenseModifier = defMod;
            shield.AllowableClasses = allowedClasses.ToArray();

            this.FormClosing -= FormShieldDetails_FormClosing;
            this.Close();
        }