示例#1
0
        public void Drop()
        {
            if (!IsActive())
            {
                return;
            }

            MyDragAndDropInfo dropTo = null;

            foreach (MyGuiControlListbox listbox in m_listboxesToDrop)
            {
                Point?mouseOverItemIndexes = listbox.GetMouseOverIndexes();
                if (mouseOverItemIndexes != null && listbox.Enabled)
                {
                    dropTo           = new MyDragAndDropInfo();
                    dropTo.Listbox   = listbox;
                    dropTo.RowIndex  = mouseOverItemIndexes.Value.Y;
                    dropTo.ItemIndex = mouseOverItemIndexes.Value.X;
                    break;
                }
            }

            ListboxItemDropped(this, new MyDragAndDropEventArgs()
            {
                DragFrom = m_draggingFrom, DropTo = dropTo, ListboxItem = m_draggingListboxItem
            });
        }
示例#2
0
 /// <summary>
 /// Starts dragging item
 /// </summary>
 /// <param name="dropHandleType">On which action released drop event</param>
 /// <param name="draggingItem">Item which is dragging</param>
 /// <param name="draggingFrom">Information about item's origin</param>
 public void StartDragging(MyDropHandleType dropHandleType, MyGuiControlListboxItem draggingItem, MyDragAndDropInfo draggingFrom)
 {
     m_currentDropHandleType = dropHandleType;
     m_draggingListboxItem   = draggingItem;
     m_draggingFrom          = draggingFrom;
     m_toolTip = draggingItem.ToolTip;
 }
        private void StartDragging(MyDropHandleType dropHandlingType, MyGuiControlListbox listbox, int rowIndex, int itemIndex)
        {
            MyDragAndDropInfo dragAndDropInfo = new MyDragAndDropInfo();
            dragAndDropInfo.Listbox = listbox;
            dragAndDropInfo.RowIndex = rowIndex;
            dragAndDropInfo.ItemIndex = itemIndex;

            MyGuiControlListboxItem draggingItem = dragAndDropInfo.Listbox.GetItem(dragAndDropInfo.RowIndex, dragAndDropInfo.ItemIndex);            

            // if inventory screen is in god editor mode, then we want use other side inventory items as templates
            if (m_inventoryScreenType == MyGuiScreenInventoryType.GodEditor && listbox == m_otherSideInventoryListBox)
            {
                draggingItem = CreateCopyOfListboxItem(draggingItem);
            }
            else
            {
                dragAndDropInfo.Listbox.RemoveItem(dragAndDropInfo.RowIndex, dragAndDropInfo.ItemIndex, false);
            }

            m_dragAndDrop.StartDragging(dropHandlingType, draggingItem, dragAndDropInfo);
            listbox.HideToolTip();
            DisabledInvalidListboxesForDrop(m_itemsRepository.GetItem(draggingItem.Key));

            if (listbox != m_shipInventoryListBox && IsListboxFull(m_shipInventoryListBox)) 
            {
                m_shipInventoryListBox.Enabled = false;
            }
            else if (listbox != m_otherSideInventoryListBox && IsListboxFull(m_otherSideInventoryListBox)) 
            {
                m_otherSideInventoryListBox.Enabled = false;
            }
        }
        public void Drop()
        {
            if (!IsActive())
                return;

            MyDragAndDropInfo dropTo = null;
            foreach (MyGuiControlListbox listbox in m_listboxesToDrop)
            {
                Point? mouseOverItemIndexes = listbox.GetMouseOverIndexes();
                if (mouseOverItemIndexes != null && listbox.Enabled)
                {
                    dropTo = new MyDragAndDropInfo();
                    dropTo.Listbox = listbox;
                    dropTo.RowIndex = mouseOverItemIndexes.Value.Y;
                    dropTo.ItemIndex = mouseOverItemIndexes.Value.X;
                    break;
                }
            }

            ListboxItemDropped(this, new MyDragAndDropEventArgs() { DragFrom = m_draggingFrom, DropTo = dropTo, ListboxItem = m_draggingListboxItem });
        }
 /// <summary>
 /// Stops dragging item
 /// </summary>
 public void Stop()
 {
     m_draggingFrom = null;
     m_draggingListboxItem = null;
     m_currentDropHandleType = null;
 }
 /// <summary>
 /// Starts dragging item
 /// </summary>
 /// <param name="dropHandleType">On which action released drop event</param>
 /// <param name="draggingItem">Item which is dragging</param>
 /// <param name="draggingFrom">Information about item's origin</param>
 public void StartDragging(MyDropHandleType dropHandleType, MyGuiControlListboxItem draggingItem, MyDragAndDropInfo draggingFrom)
 {
     m_currentDropHandleType = dropHandleType;
     m_draggingListboxItem = draggingItem;
     m_draggingFrom = draggingFrom;
     m_toolTip = draggingItem.ToolTip;
 }
示例#7
0
 /// <summary>
 /// Stops dragging item
 /// </summary>
 public void Stop()
 {
     m_draggingFrom          = null;
     m_draggingListboxItem   = null;
     m_currentDropHandleType = null;
 }
        private void ListboxItemDrag(object sender, MyGuiControlListboxItemEventArgs eventArgs)
        {
            MyGuiControlListbox senderListbox = (MyGuiControlListbox)sender;            

            MyDragAndDropInfo dragAndDropInfo = new MyDragAndDropInfo();
            dragAndDropInfo.ItemIndex = eventArgs.ItemIndex;
            dragAndDropInfo.RowIndex = eventArgs.RowIndex;
            dragAndDropInfo.Listbox = senderListbox;

            MyGuiControlListboxItem listBoxItem;
            if (senderListbox == m_allItemsInventoryListbox)
            {
                listBoxItem = CreateCopy(senderListbox.GetItem(eventArgs.Key));
            }
            else 
            {
                listBoxItem = senderListbox.GetItem(eventArgs.Key);
                senderListbox.RemoveItem(eventArgs.Key, false);
            }

            m_dragAndDrop.StartDragging(MyDropHandleType.LeftMousePressed, listBoxItem, dragAndDropInfo);            
        }