Ejemplo n.º 1
0
        public void AddItem(LogItem item)
        {
            if (LogLevel == LogLevel.None || item == null || string.IsNullOrWhiteSpace(item.Exception.ToString()))
            {
                return;
            }

            try
            {
                OnItemAdded.RaiseEvent(item, new EventArgs());

                var text = item.Exception.ToString();
                text = item.Exception.Data.Cast <DictionaryEntry>()
                       .Aggregate(
                    text,
                    (current, entry) =>
                    current + string.Format("{0}{1}: {2}", Environment.NewLine, entry.Key, entry.Value));


                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine(text);
                Console.ResetColor();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Ejemplo n.º 2
0
        /// <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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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
                });
            }
        }
Ejemplo n.º 5
0
    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);
    }
Ejemplo n.º 6
0
    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);
    }
Ejemplo n.º 7
0
        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
                });
            }
        }
Ejemplo n.º 8
0
            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();
                }
            }
Ejemplo n.º 9
0
 public void AddItem(ItemBase item)
 {
     Items.Add(item);
     AllEffects.UnionWith(item.Effects);
     item.UpdateTower(this);
     UpdateStats();
     OnItemAdded?.Invoke(this, item);
 }
Ejemplo n.º 10
0
    public void AddItem(GameItem item)
    {
        CheckUsefulItems(item.itemType);
        _itemList.Add(item);
        OnItemAdded?.Invoke(this, item);

        Debug.Log("Inventory Size:" + _itemList.Count);
    }
        public async Task UpdateItem(Income item)
        {
            await Init();

            await database.UpdateAsync(item);

            OnItemAdded?.Invoke(this, item);
        }
 public new void Add(T item)
 {
     base.Add(item);
     if (OnItemAdded != null && OnItemAdded.GetInvocationList().Any())
     {
         OnItemAdded();
     }
 }
 public void Add(IContainable item)
 {
     if (item != null)
     {
         Contents.Add(item);
         OnItemAdded?.Invoke(item, EventArgs.Empty);
     }
 }
Ejemplo n.º 14
0
 public new void Add(T item)
 {
     lock (this)
     {
         InsertItem(GetIndexToAdd(item), item);
     }
     OnItemAdded?.Invoke(this, new ItemEventArgs <T>(item));
 }
Ejemplo n.º 15
0
    public void UpdateItem(Item itemToUpdate, string newName, string newDescription, string newPath)
    {
        itemToUpdate.name        = newName;
        itemToUpdate.description = newDescription;
        itemToUpdate.imagePath   = newPath;

        OnItemAdded?.Invoke();
    }
        public async Task AddItem(TodoItem item)
        {
            await CreateConnection();

            await connection.InsertAsync(item);

            OnItemAdded?.Invoke(this, item);
        }
Ejemplo n.º 17
0
    public void UpdateItem(Item itemToUpdate, Item newValues)
    {
        itemToUpdate.name        = newValues.name;
        itemToUpdate.description = newValues.description;
        itemToUpdate.imagePath   = newValues.imagePath;

        OnItemAdded?.Invoke();
    }
Ejemplo n.º 18
0
    public void AddItem()
    {
        Item          emptyItem = new Item("Empty item", "", "");
        InventorySlot newItem   = new InventorySlot(emptyItem);

        items.Add(newItem);

        OnItemAdded?.Invoke();
    }
Ejemplo n.º 19
0
 public void Add(T item)
 {
     if (content.Contains(item) || content.Count >= MaxSize)
     {
         return;
     }
     content.Add(item);
     OnItemAdded?.Invoke(item);
 }
Ejemplo n.º 20
0
 public void AddItem(Item itemToAdd)
 {
     if (CanAddItem(itemToAdd) == false)
     {
         ItemAddFail(itemToAdd);
         return;
     }
     Items.Add(itemToAdd);
     OnItemAdded?.Invoke(itemToAdd);
 }
Ejemplo n.º 21
0
        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);
        }
Ejemplo n.º 22
0
    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();
    }
Ejemplo n.º 23
0
    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);
        }
    }
Ejemplo n.º 24
0
        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);
        }
Ejemplo n.º 25
0
 public void pushAllItemsToHandlers()
 {
     if (OnItemAdded == null)
     {
         return;
     }
     foreach (var item in Items)
     {
         OnItemAdded.Invoke(this, item.Value);
     }
 }
Ejemplo n.º 26
0
 public void AddItem(T item)
 {
     lock (_lock)
     {
         bool notify = !(items.Count == 0);
         items.AddLast(item);
         if (notify)
         {
             OnItemAdded?.Invoke();
         }
     }
 }
Ejemplo n.º 27
0
        public async Task OnValidSubmit(EditContext editContext)
        {
            if (IsAddInProgress)
            {
                await OnItemAdded.InvokeAsync(CurrentEditItem);
            }
            else
            {
                await OnItemEdited.InvokeAsync(CurrentEditItem);
            }

            await CloseEdit();
        }
Ejemplo n.º 28
0
        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);
        }
Ejemplo n.º 29
0
 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;
 }
Ejemplo n.º 30
0
        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();
        }