protected override void OnInventoryModelUpdate()
        {
            Dictionary <InventoryItem, int[]> currentItems = CurrentItemsInView();

            int numRows = 0;

            //If inventory size changes, need to reinitialize the grid with a different number of slots

            if (_inventoryModel.HasMaxCapacity)
            {
                numRows = _inventoryModel.MaxCapacity / _numCols;

                if (_inventoryModel.MaxCapacity % _numCols > 0)
                {
                    numRows += 1;
                }
            }

            InventorySlot[,] updatedGrid = InitializeGrid(_numCols, numRows); //InitializeGrid(_inventoryGrid.GetLength(0),_inventoryGrid.GetLength(1));

            foreach (InventoryItem item in _inventoryModel.Items)
            {
                if (item != null)
                {
                    //1.If item has desired position (i.e. has been moved) add it to that position
                    if (desiredPositions.ContainsKey(item))
                    {
                        int posX = desiredPositions[item][0];
                        int posY = desiredPositions[item][1];

                        //1.1 If updated grid does not have item in desired position
                        if (!updatedGrid[posX, posY].ContainsItem())
                        {
                            updatedGrid[posX, posY] = new InventorySlot(_inventoryGrid[posX, posY].PositionAbsolute - _positionAbsolute, _positionAbsolute, item, this);
                        }
                        //1.2 If updated grid does have item in desired position
                        else
                        {
                            int[] pos = GetFirstAvailablePosition(updatedGrid);

                            posX = pos[0];
                            posY = pos[1];
                            updatedGrid[posX, posY] = new InventorySlot(_inventoryGrid[posX, posY].PositionAbsolute - _positionAbsolute, _positionAbsolute, item, this);
                        }

                        //If item was already in the view, remove it, as it has been moved
                        if (currentItems.ContainsKey(item))
                        {
                            currentItems.Remove(item);
                        }
                        //Remove from update list as it has been added
                        desiredPositions.Remove(item);
                    }
                    //2.Item is already in view and hasn't changed view
                    else if (currentItems.ContainsKey(item))
                    {
                        int posX = currentItems[item][0];
                        int posY = currentItems[item][1];
                        //2.1 If updated grid does not have item in desired position
                        if (!updatedGrid[posX, posY].ContainsItem())
                        {
                            updatedGrid[posX, posY] = new InventorySlot(_inventoryGrid[posX, posY].PositionAbsolute - _positionAbsolute, _positionAbsolute, item, this);
                        }
                        //2.2 If updated grid does have item in desired position
                        else
                        {
                            int[] pos = GetFirstAvailablePosition(updatedGrid);

                            posX = pos[0];
                            posY = pos[1];
                            updatedGrid[posX, posY] = new InventorySlot(_inventoryGrid[posX, posY].PositionAbsolute - _positionAbsolute, _positionAbsolute, item, this);
                        }
                        //Remove from update list as it has been added
                        currentItems.Remove(item);
                    }
                    //3.Item not already in view, and does not have desired position - add at first available
                    else
                    {
                        int[] pos = GetFirstAvailablePosition(updatedGrid);

                        int posX = pos[0];
                        int posY = pos[1];
                        updatedGrid[posX, posY] = new InventorySlot(_inventoryGrid[posX, posY].PositionAbsolute - _positionAbsolute, _positionAbsolute, item, this);
                    }
                }
            }
            //Clear all desired positions once inventory updated
            desiredPositions.Clear();
            //Update inventory
            _inventoryGrid = updatedGrid;
        }
        public InventoryItemView(InventoryItem item, Vector2 positionRelative, Vector2 parentPosition, InventorySlot owner)
        {
            RequestAddTooltipEvent    += GameHUDScreen.GetInstance().AddTooltip;
            RequestRemoveTooltipEvent += GameHUDScreen.GetInstance().RemoveTooltip;

            _owner            = owner;
            _positionRelative = positionRelative;
            _positionAbsolute = positionRelative + parentPosition;
            _releasedPosition = new Vector2(_positionAbsolute.X, _positionAbsolute.Y);
            _inventoryItem    = item;

            _icon = ScreenManager.GetInstance().ContentManager.Load <Texture2D>(_inventoryItem.IconLocation);
            // _icon = ScreenManager.GetInstance().ContentManager.Load<Texture2D>("Textures\\UI\\TestIcon");

            _boundingBox = new Rectangle((int)_positionAbsolute.X, (int)_positionAbsolute.Y, 40, 40);
        }
 public override bool ContainsSlot(InventorySlot slot)
 {
     throw new NotImplementedException();
 }
 public InventoryItemView(InventoryItem item, Vector2 positionRelative, Vector2 parentPosition, InventorySlot owner, bool isDraggable)
     : this(item, positionRelative, parentPosition, owner)
 {
     _isDraggable = isDraggable;
 }
 public override int[] GetSlotPosition(InventorySlot slot)
 {
     throw new NotImplementedException();
 }