public void Add() { string newName; for (int i = 0;; ++i) { newName = DefaultName + i.ToString(); bool nameGood = true; foreach (T item in items) { if (item.ToString() == newName) { nameGood = false; break; } } if (nameGood) { break; } } T newItem = CreateNewItem(newName); int index = items.InsertAlphabetically(newItem); if (index <= selectedIndex) { ++selectedIndex; } CreateListEntry(newItem, index); SubAdd(index); OnItemAdded?.Invoke(index); }
public override bool AddItem(CollectableItem collectableItem) { if (collectableItem == null || collectableItem.inventoryItem == null) { return(false); } InventoryItem invItem = collectableItem.inventoryItem; invItem.CollectableItem = collectableItem; switch (invItem.Category) { case InventoryItemType.Consumable: AddFoodItem(invItem as InventoryItemFood, collectableItem); break; case InventoryItemType.Weapon: AddWeaponItem(invItem as InventoryItemWeapon, collectableItem as CollectableWeapon); break; case InventoryItemType.Ammunition: AddAmmoItem(invItem as InventoryItemAmmo, collectableItem); break; } OnItemAdded.Invoke(invItem); return(false); }
private void Source_CollectionChanged(object aSender, NotifyCollectionChangedEventArgs aArgs) { switch (aArgs.Action) { case NotifyCollectionChangedAction.Add: //CheckOneOrNone(aArgs.NewItems); OnItemAdded?.Invoke(Source, aArgs.NewStartingIndex, (T)aArgs.NewItems[0]); break; case NotifyCollectionChangedAction.Move: //CheckOneOrNone(aArgs.NewItems); OnItemMoved?.Invoke(Source, aArgs.OldStartingIndex, aArgs.NewStartingIndex, (T)aArgs.NewItems[0]); break; case NotifyCollectionChangedAction.Remove: //CheckOneOrNone(aArgs.OldItems); OnItemRemoved?.Invoke(Source, aArgs.OldStartingIndex, (T)aArgs.OldItems[0]); break; case NotifyCollectionChangedAction.Replace: //CheckOneOrNone(aArgs.NewItems); OnItemReplaced?.Invoke(Source, aArgs.OldStartingIndex, (T)aArgs.OldItems[0], (T)aArgs.NewItems[0]); break; case NotifyCollectionChangedAction.Reset: OnCleared?.Invoke(Source); break; default: throw new NotImplementedException(); } }
/// <summary> /// Tries to add the given item to the bag. Succeeds if the bag can hold this item type and is not full yet or can still stack this item. /// </summary> /// <param name="item">The item to add</param> /// <returns>True if it successfully added the item</returns> public bool TryAddItem(Item item) { bool success = false; // Item is not yet in inventory, add it if (!_inventoryItems.ContainsKey(item)) { // only add items if inventory is not full if (_inventoryItems.Count >= _capacity) { return(false); } _inventoryItems.Add(item, 1); success = true; } // Item is already in inventory, stack it up if possible else { // Only items that are not unique can be stacked if (!item.IsUnique) { _inventoryItems[item]++; success = true; } } if (success) { // we added something so broadcast it to whoever listens. OnItemAdded?.Invoke(item, this); } return(success); }
public override void AddItem(string result) { Website website = null; if (!EditMode && bool.Parse(result)) { if (Regular) { website = new Website(Title, Path.GetFileName(ImageLocation), EdgeColor, MiddleColor, HighlightColor, Description, Link); } else if (TVShow) { website = new TVShow(Title, Path.GetFileName(ImageLocation), EdgeColor, MiddleColor, HighlightColor, Description, Link, 0, 0, 0, 0, DateTime.Now); } website.ContextMenuMap = this.ContextMenuMap; OnItemAdded?.Invoke(this, new DialogRoutedEventArgs() { Object = website }); } else { OnItemAdded?.Invoke(this, new DialogRoutedEventArgs() { Object = null }); } }
public override void AddItem(string result) { if (!EditMode && bool.Parse(result)) { if (!String.IsNullOrEmpty(GameLocation)) { ContextMenuMap.Add(new ContextMenuItem("Open Directory", Path.GetDirectoryName(GameLocation))); } var game = new VideoGame(Title, Path.GetFileName(ImageLocation), EdgeColor.ToString(), MiddleColor.ToString(), HighlightColor.ToString(), GameLocation, TargetParameters, true); game.ContextMenuMap = this.ContextMenuMap; OnItemAdded?.Invoke(this, new DialogRoutedEventArgs() { Object = game }); } else { OnItemAdded?.Invoke(this, new DialogRoutedEventArgs() { Object = null }); } }
public void AddItem(Item itemToAdd, int amountToAdd) { if (CheckIfItemExists(itemToAdd)) { itemDict[itemToAdd] += amountToAdd; } else { itemDict.Add(itemToAdd, amountToAdd); } if (OnItemAdded != null) { OnItemAdded.Invoke(itemToAdd); } /* if (itemToAdd.itemTypes == ItemTypes.Ammo) * { * if (OnItemAdded != null) * { * OnItemAdded.Invoke(item); * } * } */ Debug.Log("Added: " + amountToAdd + " of " + itemToAdd.itemName); }
public new void Add(T item) { lock (this) { InsertItem(GetIndexToAdd(item), item); } OnItemAdded?.Invoke(this, new ItemEventArgs <T>(item)); }
public void AddItem(GameItem item) { CheckUsefulItems(item.itemType); _itemList.Add(item); OnItemAdded?.Invoke(this, item); Debug.Log("Inventory Size:" + _itemList.Count); }
public void Add(IContainable item) { if (item != null) { Contents.Add(item); OnItemAdded?.Invoke(item, EventArgs.Empty); } }
public void AddItem(ItemBase item) { Items.Add(item); AllEffects.UnionWith(item.Effects); item.UpdateTower(this); UpdateStats(); OnItemAdded?.Invoke(this, item); }
public async Task AddItem(TodoItem item) { await CreateConnection(); await connection.InsertAsync(item); OnItemAdded?.Invoke(this, item); }
public void UpdateItem(Item itemToUpdate, Item newValues) { itemToUpdate.name = newValues.name; itemToUpdate.description = newValues.description; itemToUpdate.imagePath = newValues.imagePath; OnItemAdded?.Invoke(); }
public async Task UpdateItem(Income item) { await Init(); await database.UpdateAsync(item); OnItemAdded?.Invoke(this, item); }
public void UpdateItem(Item itemToUpdate, string newName, string newDescription, string newPath) { itemToUpdate.name = newName; itemToUpdate.description = newDescription; itemToUpdate.imagePath = newPath; OnItemAdded?.Invoke(); }
public void Add(T item) { if (content.Contains(item) || content.Count >= MaxSize) { return; } content.Add(item); OnItemAdded?.Invoke(item); }
public void AddItem() { Item emptyItem = new Item("Empty item", "", ""); InventorySlot newItem = new InventorySlot(emptyItem); items.Add(newItem); OnItemAdded?.Invoke(); }
public async Task AddItem(TodoItem item) { await CreateConnection(); await connection.InsertAsync(item); // After an item has been inserted into the table, // we invoke the OnItemAdded event to notify any subscribers OnItemAdded?.Invoke(this, item); }
public void AddItem(Item itemToAdd) { if (CanAddItem(itemToAdd) == false) { ItemAddFail(itemToAdd); return; } Items.Add(itemToAdd); OnItemAdded?.Invoke(itemToAdd); }
public Camera PlaceIn(string deviceKey, Camera value) { var result = _cameraCollection.AddOrUpdate(deviceKey, value, (k, v) => v); if (result != null) { OnItemAdded?.Invoke(this, value); } return(result); }
public void pushAllItemsToHandlers() { if (OnItemAdded == null) { return; } foreach (var item in Items) { OnItemAdded.Invoke(this, item.Value); } }
private void DropItem() { int rand = UnityEngine.Random.Range(0, 5); if (rand == 0) { ItemObject obj = Instantiate(ItemObjects.GetRandom()) as ItemObject; Player.AddItem(obj); OnItemAdded?.Invoke(obj); } }
public void MergeItemLists(List <InventorySlot> list) { /* * foreach (InventorySlot slot in list) * if (!items.Exists((s) => s.item.name == slot.item.name)) * items.Add(slot); */ items.AddRange(list); OnItemAdded?.Invoke(); }
/// <summary> /// Adds an item to the inventory. Will not add a new item if the inventory is already full. /// </summary> /// <param name="itemToAdd"></param> /// <returns>True if successful, false if the inventory is full and can longer add more items.</returns> public bool AddItem(Item itemToAdd) { Debug.Log($"adding {itemToAdd.name} to inventory"); if (items.Count >= size) { return(false); } items.Add(itemToAdd); ONItemAddedCallback?.Invoke(); return(true); }
public void AddItem(T item) { lock (_lock) { bool notify = !(items.Count == 0); items.AddLast(item); if (notify) { OnItemAdded?.Invoke(); } } }
public void Add(T item) { int id = Items.Count + 1; while (Items.ContainsKey(id.ToString())) { id += 1; } Items.Add(id.ToString(), item); lastAddedItemId = id; OnItemAdded?.Invoke(this, item); }
void OnTriggerStay(Collider other) { if (ItemInstance == null) { return; } if (ItemInstance.isDragging || !ItemInstance.transform.hasChanged) { return; } OnItemAdded.Invoke(ItemInstance.data, groupId); ItemInstance.SetLocalPoseFromData(); ItemInstance.transform.hasChanged = false; }
private void btn_save_Click(object sender, EventArgs e) { //Kopia by mieć niezależy obiekt od tego w liście var entity = _entity.Clone() as ShopEntity; if (entity != null) { entity.Amout = (int)numeric_amout.Value; OnItemAdded?.Invoke(entity); } Close(); }
public async Task AddItems(Income item) { await Init(); var temp = new Income { ID = Guid.NewGuid().ToString(), IncomeAmount = item.IncomeAmount, IncomeSource = item.IncomeSource }; await database.InsertAsync(temp); OnItemAdded?.Invoke(this, temp); }
public async Task AddItems(Saving item) { await Init(); Saving temp = new Saving { ID = Guid.NewGuid().ToString(), SavingAmount = item.SavingAmount, SavingDate = item.SavingDate }; await database.InsertAsync(temp); OnItemAdded?.Invoke(this, temp); }