private MyGuiControlListboxItem CreateCopy(MyGuiControlListboxItem original)
        {
            MyInventoryItem templateInventoryItem = m_inventoryItemsRepository.GetItem(original.Key);
            MyInventoryItem newInventoryItem      = MyInventory.CreateInventoryItemFromObjectBuilder(templateInventoryItem.GetInventoryItemObjectBuilder(true));

            newInventoryItem.Amount = templateInventoryItem.Amount;
            MyGuiControlListboxItem newItem = CreateListboxItemAndAddToRepository(newInventoryItem);

            newItem.IconTexts = original.IconTexts;
            m_itemsAdded.Add(newInventoryItem);
            return(newItem);
        }
        private void ListboxItemDoubleClick(object sender, MyGuiControlListboxItemEventArgs eventArgs)
        {
            MyGuiControlListbox senderListbox = (MyGuiControlListbox)sender;

            if (senderListbox == m_allItemsInventoryListbox)
            {
                MyGuiControlListboxItem listBoxItem = CreateCopy(m_allItemsInventoryListbox.GetItem(eventArgs.Key));
                MoveItemToListbox(m_entityInventoryListbox, listBoxItem);
            }
            else
            {
                m_entityInventoryListbox.RemoveItem(eventArgs.Key, false);
                RemoveCopy(eventArgs.Key);
            }
        }
        private MyGuiControlListboxItem CreateListboxItemAndAddToRepository(MyInventoryItem inventoryItem)
        {
            int inventoryItemKey = m_inventoryItemsRepository.AddItem(inventoryItem);

            StringBuilder description = null;

            if (inventoryItem.Icon == null)
            {
                description = inventoryItem.MultiLineDescription;
            }

            MyToolTips toolTips = new MyToolTips();

            toolTips.AddToolTip(inventoryItem.MultiLineDescription, Color.White, 0.7f);

            MyGuiControlListboxItem listboxItem = new MyGuiControlListboxItem(inventoryItemKey, description, inventoryItem.Icon, toolTips, MyGuiConstants.LABEL_TEXT_SCALE);

            listboxItem.IconTexts = new MyIconTexts();

            // add amount icon's text
            if (inventoryItem.Amount != 1f || inventoryItem.Amount != inventoryItem.MaxAmount)
            {
                StringBuilder amount = new StringBuilder();
                amount.Append(inventoryItem.Amount.ToString());
                MyGuiDrawAlignEnum align;
                Vector2            offset;
                if (inventoryItem.AmountTextAlign == MyInventoryAmountTextAlign.MiddleRight)
                {
                    align  = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER;
                    offset = new Vector2(-0.004f, 0.0038f);
                }
                else if (inventoryItem.AmountTextAlign == MyInventoryAmountTextAlign.BottomRight)
                {
                    align  = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM;
                    offset = new Vector2(-0.004f, -0.0025f);
                }
                else
                {
                    throw new MyMwcExceptionApplicationShouldNotGetHere();
                }
                listboxItem.IconTexts[align] = new MyColoredText(amount, Color.White, Color.White, MyGuiManager.GetFontMinerWarsWhite(), 0.5f, offset);
            }

            return(listboxItem);
        }
 private void MoveItemToListbox(MyGuiControlListbox moveTo, MyGuiControlListboxItem item, int?rowIndex = null, int?itemIndex = null)
 {
     if (moveTo == m_allItemsInventoryListbox)
     {
         RemoveCopy(item.Key);
     }
     else
     {
         if (rowIndex != null && itemIndex != null)
         {
             moveTo.AddItem(item, rowIndex.Value, itemIndex.Value);
         }
         else
         {
             moveTo.AddItem(item);
         }
     }
 }
 string GetCheckpointNameFromItem(MyGuiControlListboxItem item)
 {
     return(item.Value.ToString());
 }