Пример #1
0
 private void AddButtonClick(object sender, EventArgs e)
 {
     using (var dataForm = new FormShieldData())
     {
         dataForm.ShowDialog();
         if (dataForm.Shield != null)
             AddShield(dataForm.Shield);
     }
 }
Пример #2
0
        private void EditButtonClick(object sender, EventArgs e)
        {
            if (DetailList.SelectedItem == null)
                return;

            string name = DetailList.SelectedItem.ToString().Split(':')[0];
            ShieldData data = ItemManager.ShieldData[name];
            ShieldData newData;
            using (var dataForm = new FormShieldData())
            {
                dataForm.Shield = data;
                dataForm.ShowDialog();

                if (dataForm.Shield == null)
                    return;

                if (dataForm.Shield.Name == name)
                {
                    ItemManager.ShieldData[name] = dataForm.Shield;
                    LoadShields();
                    return;
                }

                newData = dataForm.Shield;
            }

            DialogResult result = MessageBox.Show("Name has changed. Do you want to add a new entry?", "New Entry",
                                                  MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (result != DialogResult.Yes)
                return;

            if (ItemManager.ShieldData.ContainsKey(newData.Name))
            {
                MessageBox.Show("Entry already exists. Use Edit to modify the entry.", "Entry Exists",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            DetailList.Items.Add(newData);
            ItemManager.ShieldData.Add(newData.Name, newData);
        }