private void _characterItemPanel_NewItemSelected_Event(ItemPanel sender, InventoryItem item) { _eventSender = sender; l_selectedItem.Text = item.Item.Name; if (item.Item.StackSize > 1) { l_selectedItem.Text += " (x" + item.Item.StackSize.ToString() + ")"; } l_selectedItem.Tag = item; }
private void UnregisterItemEvents(InventoryItem item) { item.Click -= new EventHandler(item_Click); }
private void InitInventory(UnitWrapper2 unit, ItemPanel itemPanel) { itemPanel.Controls.Clear(); try { CharacterInventoryType inv = unit.CharacterWrapper.CharacterInventory.GetInventoryById((int)INVENTORYTYPE); if (inv == null) return; foreach (CharacterItems item in inv.Items) { //Unit.StatBlock.Stat atat = item.Stats.GetStatById((int)ItemValueNames.applied_affix); itemPanel.IsMale = _isMale; InventoryItem iItem = new InventoryItem(item); iItem.InitButton(_displayNamesAndQuantity); itemPanel.AddItem(iItem, true); } } catch (Exception ex) { MessageBox.Show(ex.Message, "InitInventory: " + unit.Name); } }
private bool OutOfScreen(InventoryItem item) { int width = this.Size.Width / _itemUnitSize; int height = this.Size.Height / _itemUnitSize; width -= (item.UnitSize.Width - 1); height -= (item.UnitSize.Height - 1); // if the item dimensions range beyond the inventory bounds if (item.Position.X < width && item.Position.Y < height) { return false; } return true; }
private bool OverlapsWithOtherControls(InventoryItem item) { foreach (Control control in this.Controls) { if (item != (InventoryItem)control) { if (item.Bounds.IntersectsWith(control.Bounds)) { return true; } } } return false; }
private bool IsRoomAvailable(InventoryItem item) { int width = this.Size.Width / _itemUnitSize; int height = this.Size.Height / _itemUnitSize; int itemWidth = item.UnitSize.Width; int itemHeight = item.UnitSize.Height; width -= (itemWidth - 1); height -= (itemHeight - 1); Point originalLocation = item.Position; for (int counterY = 0; counterY < height; counterY++) { for (int counterX = 0; counterX < width; counterX++) { item.Position = new Point(counterX, counterY); if (!OverlapsWithOtherControls(item)) { return true; } else { item.Position = originalLocation; continue; } } } return false; }
private void CreateToolTip(InventoryItem item) { CharacterItems tmpItem = item.Item; string questString = String.Empty; if(tmpItem.IsQuestItem) { questString = "[Questitem]" + Environment.NewLine; } string toolTip = questString + tmpItem.Name + Environment.NewLine + "Item quantity: " + tmpItem.StackSize + "/" + tmpItem.MaxStackSize + Environment.NewLine + "Item quality: " + tmpItem.Quality.ToString() + Environment.NewLine + Environment.NewLine + "Upgrades: " + tmpItem.NumberOfUpgrades + "/" + tmpItem.MaxNumberOfUpgrades + Environment.NewLine + "Augments: " + tmpItem.NumberOfAugmentations + "/" + tmpItem.MaxNumberOfAugmentations + Environment.NewLine + "Affixes: " + tmpItem.NumberOfAffixes + Environment.NewLine + "Age: " + tmpItem.PlayTime / 60 + " ingame minutes"; toolTip1.SetToolTip(item, toolTip); }
public void RemoveItem(InventoryItem item) { UnregisterItemEvents(item); this.Controls.Remove(item); }
public void PreviewItem(InventoryItem item) { //_previewItem = item; }
public bool AddItem(InventoryItem item, bool isOnInit) { if (isOnInit) { RegisterItemEvents(item); item.ButtonUnitSize = _itemUnitSize; if (_displayItemIcons)// && _manager.ImagesAvailable) { Image img = _manager.GetImage(new Size(item.Size.Width / _itemUnitSize, item.Size.Height / _itemUnitSize), item.Item.GetItemImagePath(_isMale)); if (img != null) { item.BackgroundImage = img; } } CreateToolTip(item); this.Controls.Add(item); return true; } else { bool canTransfer = IsRoomAvailable(item); if (canTransfer) { RegisterItemEvents(item); item.ButtonUnitSize = _itemUnitSize; this.Controls.Add(item); return true; } } return false; }