Пример #1
0
        public void btnAdd_Click(object sender, EventArgs e)
        {
            using (ShieldDetails frmShieldDetails = new ShieldDetails())
            {
                frmShieldDetails.ShowDialog();

                if (frmShieldDetails.Shield != null)
                {
                    AddShield(frmShieldDetails.Shield);
                }
            }
        }
Пример #2
0
        public void btnEdit_Click(object sender, EventArgs e)
        {
            if (lbDetails.SelectedItem != null)
            {
                string detail = Convert.ToString(lbDetails.SelectedItem);
                string[] parts = detail.Split(',');
                string entity = (string)parts[0].Trim();

                ShieldData shield = itemDataManager.ShieldData[entity];
                ShieldData newData = null;

                using (ShieldDetails frmShieldDetails = new ShieldDetails())
                {
                    frmShieldDetails.Shield = shield;
                    frmShieldDetails.ShowDialog();

                    if (frmShieldDetails.Shield == null)
                    {
                        return;
                    }

                    if (frmShieldDetails.Shield.name == entity)
                    {
                        itemDataManager.ShieldData[entity] = frmShieldDetails.Shield;
                        FillListBox();
                        return;
                    }

                    newData = frmShieldDetails.Shield;
                }

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

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

                if (itemDataManager.ShieldData.ContainsKey(newData.name))
                {
                    MessageBox.Show("Entry already exists. Use Edit to modify the entry");
                    return;
                }

                lbDetails.Items.Add(newData);
                ItemManager.ShieldData.Add(newData.name, newData);
            }
        }