Exemplo n.º 1
0
        void btnAdd_Click(object sender, EventArgs e)
        {
            using (FormShieldDetail frmShieldDetails = new FormShieldDetail())
            {
                frmShieldDetails.ShowDialog();

                if (frmShieldDetails.Shield != null)
                {
                    AddShield(frmShieldDetails.Shield);
                }
            }
        }
Exemplo n.º 2
0
        void btnEdit_Click(object sender, EventArgs e)
        {
            if (lbDetails.SelectedItem != null)
            {
                string   detail = lbDetails.SelectedItem.ToString();
                string[] parts  = detail.Split(',');
                string   entity = parts[0].Trim();

                ShieldData data    = itemManager.ShieldData[entity];
                ShieldData newData = null;

                using (FormShieldDetail frmShieldData = new FormShieldDetail())
                {
                    frmShieldData.Shield = data;
                    frmShieldData.ShowDialog();

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

                    if (frmShieldData.Shield.Name == entity)
                    {
                        itemManager.ShieldData[entity] = frmShieldData.Shield;
                        FillListBox();

                        return;
                    }

                    newData = frmShieldData.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 (itemManager.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);
            }
        }