예제 #1
0
        private void AddArmor(ArmorData data)
        {
            if (ItemManager.ArmorData.ContainsKey(data.Name))
            {
                DialogResult result = MessageBox.Show(data.Name + " already exists. Do you want to overwrite it?",
                                                      "Existing Armor", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (result != DialogResult.Yes)
                    return;

                ItemManager.ArmorData[data.Name] = data;
                LoadArmor();
                return;
            }

            DetailList.Items.Add(data.ToString());
            ItemManager.ArmorData.Add(data.Name, data);
        }
예제 #2
0
 private void CancelButtonClick(object sender, EventArgs e)
 {
     Armor = null;
     CloseForm();
 }
예제 #3
0
        private void OkButtonClick(object sender, EventArgs e)
        {
            if (!IsValid() || AllowedList.Items.Count <= 0)
            {
                MessageBox.Show("Name and/or Type cannot be empty, there must be at least one allowed class!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            var allowed = (from object item in AllowedList.Items select item.ToString()).ToList();
            Armor = new ArmorData
            {
                Name = NameBox.Text,
                Type = TypeBox.Text,
                Price = (int) PriceBox.Value,
                Weight = (float) WeightBox.Value,
                ArmorLocation = (ArmorLocation) ArmorLocationBox.SelectedIndex,
                DefenseValue = (int) DefenseValueBox.Value,
                DefenseModifier = (int) DefenseModifierBox.Value,
                AllowedClasses = allowed.ToArray()
            };

            CloseForm();
        }