示例#1
0
 void btnAdd_Click(object sender, EventArgs e)
 {
     using (FormChestDetails frmChestDetails = new FormChestDetails())
     {
         frmChestDetails.ShowDialog();
         if (frmChestDetails.Chest != null)
         {
             AddChest(frmChestDetails.Chest);
         }
     }
 }
示例#2
0
        void btnAdd_Click(object sender, EventArgs e)
        {
            using (FormChestDetails frmChestDetails = new FormChestDetails())
            {
                frmChestDetails.ShowDialog();

                if (frmChestDetails.Chest != null)
                {
                    AddChest(frmChestDetails.Chest);
                }
            }
        }
示例#3
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();

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

                using (FormChestDetails frmChestData = new FormChestDetails())
                {
                    frmChestData.Chest = data;
                    frmChestData.ShowDialog();

                    if (frmChestData.Chest == null)
                    {
                        return;
                    }

                    if (frmChestData.Chest.Name == entity)
                    {
                        itemManager.ChestData[entity] = frmChestData.Chest;
                        FillListBox();

                        return;
                    }

                    newData = frmChestData.Chest;
                }

                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.ChestData.ContainsKey(newData.Name))
                {
                    MessageBox.Show("Entry already exists. Use Edit to modify the entry.");
                    return;
                }

                lbDetails.Items.Add(newData);
                itemManager.ChestData.Add(newData.Name, newData);
            }
        }
示例#4
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();

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

                using (FormChestDetails frmChestData = new FormChestDetails())
                {
                    frmChestData.Chest = data;
                    frmChestData.ShowDialog();

                    if (frmChestData.Chest == null)
                        return;

                    if (frmChestData.Chest.Name == entity)
                    {
                        itemManager.ChestData[entity] = frmChestData.Chest;
                        FillListBox();
                        return;
                    }

                    newData = frmChestData.Chest;
                }

                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.ChestData.ContainsKey(newData.Name))
                {
                    MessageBox.Show("Entry already exists. Use Edit to modify the entry.");
                    return;
                }

                lbDetails.Items.Add(newData);
                itemManager.ChestData.Add(newData.Name, newData);
            }
        }