예제 #1
0
        private void addCancelbtn_Click(object sender, EventArgs e)
        {
            AddItem reset = new AddItem(_blueprints, _relics, _mods, _ownedBlueprints, _ownedRelics, _ownedMods, _parent);

            reset.FormClosing += Reset_FormClosing;
            reset.Show();
            this.Dispose(false);
        }
예제 #2
0
        private void addItembtn_Click(object sender, EventArgs e)
        {
            AddItem add = new AddItem(_blueprints, _relics, _mods, _ownedBlueprints, _ownedRelics, _ownedMods, this);

            add.FormClosing += Add_FormClosing;
            add.Show();
            this.Dispose(false);
        }
예제 #3
0
        private void addItembtn_Click(object sender, EventArgs e)
        {
            string ownedItemPath = ".\\OwnedItems.json";

            if (!File.Exists(ownedItemPath))
            {
                File.Create(ownedItemPath);
            }
            InventoryItem addVal = null; //_ownedBlueprints.FirstOrDefault(item => item.item_name == addValueddl.SelectedValue.ToString());

            if (_selectedType == "bp")
            {
                addVal = _ownedBlueprints.FirstOrDefault(item => item.item_name == addValueddl.SelectedValue.ToString());
                if (addVal != null)
                {
                    InventoryItem val = _ownedBlueprints.FirstOrDefault(item => item.item_name == addValueddl.SelectedValue.ToString());
                    val.quantity = (int)addQuantitytxt.Value;
                }
                else
                {
                    addVal          = _blueprints.First(item => item.item_name == addValueddl.SelectedValue.ToString());
                    addVal.quantity = (int)addQuantitytxt.Value;
                    _ownedBlueprints.Add(addVal);
                }
            }
            else if (_selectedType == "mod")
            {
                addVal = _ownedMods.FirstOrDefault(item => item.item_name == addValueddl.SelectedValue.ToString());
                if (addVal != null)
                {
                    InventoryItem val = _ownedMods.FirstOrDefault(item => item.item_name == addValueddl.SelectedValue.ToString());
                    val.quantity = (int)addQuantitytxt.Value;
                }
                else
                {
                    addVal          = _mods.First(item => item.item_name == addValueddl.SelectedValue.ToString());
                    addVal.quantity = (int)addQuantitytxt.Value;
                    _ownedMods.Add(addVal);
                }
            }
            else
            {
                addVal = _ownedRelics.FirstOrDefault(item => item.item_name == addValueddl.SelectedValue.ToString());
                if (addVal != null)
                {
                    InventoryItem val = _ownedRelics.FirstOrDefault(item => item.item_name == addValueddl.SelectedValue.ToString());
                    val.quantity = (int)addQuantitytxt.Value;
                }
                else
                {
                    addVal          = _relics.First(item => item.item_name == addValueddl.SelectedValue.ToString());
                    addVal.quantity = (int)addQuantitytxt.Value;
                    _ownedRelics.Add(addVal);
                }
            }

            _ownedAll.AddRange(_ownedMods);
            _ownedAll.AddRange(_ownedBlueprints);
            _ownedAll.AddRange(_ownedRelics);

            File.WriteAllText(ownedItemPath, JsonConvert.SerializeObject(_ownedAll));

            AddItem reset = new AddItem(_blueprints, _relics, _mods, _ownedBlueprints, _ownedRelics, _ownedMods, _parent);

            reset.FormClosing += Reset_FormClosing;
            reset.Show();
            this.Dispose(false);
        }