Beispiel #1
0
 /// <summary>
 /// Stops dragging item
 /// </summary>
 public void Stop()
 {
     m_draggingFrom          = null;
     m_draggingGridItem      = null;
     m_currentDropHandleType = null;
     m_dragButton            = null;
 }
Beispiel #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, MySharedButtonsEnum dragButton, MyGuiControlGrid.Item draggingItem, MyDragAndDropInfo draggingFrom, bool includeTooltip = true)
 {
     m_currentDropHandleType = dropHandleType;
     m_dragButton            = dragButton;
     m_draggingGridItem      = draggingItem;
     m_draggingFrom          = draggingFrom;
     m_toolTip = (includeTooltip) ? draggingItem.ToolTip : null;
 }
Beispiel #3
0
        public void Drop()
        {
            if (!IsActive())
            {
                return;
            }

            MyDragAndDropInfo dropTo = null;

            m_dropToControls.Clear();

            MyScreenManager.GetControlsUnderMouseCursor(m_dropToControls, true);

            foreach (var control in m_dropToControls)
            {
                var grid = control as MyGuiControlGrid;
                if (grid != null)
                {
                    if (grid.Enabled && grid.MouseOverIndex != MyGuiControlGrid.INVALID_INDEX)
                    {
                        dropTo           = new MyDragAndDropInfo();
                        dropTo.Grid      = grid;
                        dropTo.ItemIndex = grid.MouseOverIndex;
                        break;
                    }
                }
            }

            ItemDropped(this, new MyDragAndDropEventArgs()
            {
                DragFrom   = m_draggingFrom,
                DropTo     = dropTo,
                Item       = m_draggingGridItem,
                DragButton = m_dragButton.Value,
            });

            Stop();
        }
        private void dragDrop_OnItemDropped(object sender, MyDragAndDropEventArgs eventArgs)
        {
            if (eventArgs.DropTo != null)
            {
                MyGuiAudio.PlaySound(MyGuiSounds.HudItem);

                MyPhysicalInventoryItem inventoryItem = (MyPhysicalInventoryItem)eventArgs.Item.UserData;

                var srcGrid = eventArgs.DragFrom.Grid;
                var dstGrid = eventArgs.DropTo.Grid;

                var srcControl = (MyGuiControlInventoryOwner)srcGrid.Owner;
                var dstControl = dstGrid.Owner as MyGuiControlInventoryOwner;
                Debug.Assert(dstControl != null);
                if (dstControl == null)
                    return;
                var srcInventory = (MyInventory)srcGrid.UserData;
                var dstInventory = (MyInventory)dstGrid.UserData;

                if (srcGrid == dstGrid)
                {
                    //GR: Why alter ItemIndex? This caused invalid swapping of items
                    //if (eventArgs.DragFrom.ItemIndex < eventArgs.DropTo.ItemIndex)
                    //    eventArgs.DropTo.ItemIndex++;
                    if (eventArgs.DragButton == MySharedButtonsEnum.Secondary)
                    {
                        ShowAmountTransferDialog(inventoryItem, delegate(float amount)
                        {
                            if (amount == 0)
                                return;
                            if (!srcInventory.IsItemAt(eventArgs.DragFrom.ItemIndex))
                                return;
                            inventoryItem.Amount = (MyFixedPoint)amount;
                            CorrectItemAmount(ref inventoryItem);
                            MyInventory.TransferByUser(srcInventory, srcInventory, inventoryItem.ItemId, eventArgs.DropTo.ItemIndex, inventoryItem.Amount);
                            if (dstGrid.IsValidIndex(eventArgs.DropTo.ItemIndex))
                                dstGrid.SelectedIndex = eventArgs.DropTo.ItemIndex;
                            else
                                dstGrid.SelectLastItem();
                            RefreshSelectedInventoryItem();
                        });
                    }
                    else
                    {
                        MyInventory.TransferByUser(srcInventory, srcInventory, inventoryItem.ItemId, eventArgs.DropTo.ItemIndex);
                        if (dstGrid.IsValidIndex(eventArgs.DropTo.ItemIndex))
                            dstGrid.SelectedIndex = eventArgs.DropTo.ItemIndex;
                        else
                            dstGrid.SelectLastItem();
                        RefreshSelectedInventoryItem();
                    }
                }
                else if (eventArgs.DragButton == MySharedButtonsEnum.Secondary)
                {
                    ShowAmountTransferDialog(inventoryItem, delegate(float amount)
                    {
                        if (amount == 0)
                            return;
                        if (!srcInventory.IsItemAt(eventArgs.DragFrom.ItemIndex))
                            return;
                        inventoryItem.Amount = (MyFixedPoint)amount;
                        CorrectItemAmount(ref inventoryItem);
                        MyInventory.TransferByUser(srcInventory, dstInventory, inventoryItem.ItemId, eventArgs.DropTo.ItemIndex, inventoryItem.Amount);
                        RefreshSelectedInventoryItem();
                    });
                }
                else
                {
                    MyInventory.TransferByUser(srcInventory, dstInventory, inventoryItem.ItemId, eventArgs.DropTo.ItemIndex);
                    RefreshSelectedInventoryItem();
                }
            }

            ClearDisabledControls();

            m_dragAndDropInfo = null;
        }
        private void StartDragging(MyDropHandleType dropHandlingType, MyGuiControlGrid gridControl, ref MyGuiControlGrid.EventArgs args)
        {
            m_dragAndDropInfo = new MyDragAndDropInfo();
            m_dragAndDropInfo.Grid = gridControl;
            m_dragAndDropInfo.ItemIndex = args.ItemIndex;

            DisableInvalidWhileDragging();

            var draggingItem = m_dragAndDropInfo.Grid.GetItemAt(m_dragAndDropInfo.ItemIndex);
            m_dragAndDrop.StartDragging(dropHandlingType, args.Button, draggingItem, m_dragAndDropInfo, includeTooltip: false);
        }
        public void Close()
        {
            foreach (var system in m_registeredConveyorSystems)
            {
                system.BlockAdded -= ConveyorSystem_BlockAdded;
                system.BlockRemoved -= ConveyorSystem_BlockRemoved;
            }
            m_registeredConveyorSystems.Clear();
            
            m_leftTypeGroup.Clear();
            m_leftFilterGroup.Clear();
            m_rightTypeGroup.Clear();
            m_rightFilterGroup.Clear();
            m_controlsDisabledWhileDragged.Clear();

            m_leftOwnersControl = null;
            m_leftSuitButton = null;
            m_leftGridButton = null;
            m_leftFilterStorageButton = null;
            m_leftFilterSystemButton = null;
            m_leftFilterEnergyButton = null;
            m_leftFilterAllButton = null;
            m_rightOwnersControl = null;
            m_rightSuitButton = null;
            m_rightGridButton = null;
            m_rightFilterStorageButton = null;
            m_rightFilterSystemButton = null;
            m_rightFilterEnergyButton = null;
            m_rightFilterAllButton = null;
            m_throwOutButton = null;
            m_dragAndDrop = null;
            m_dragAndDropInfo = null;
            m_focusedOwnerControl = null;
            m_focusedGridControl = null;
            m_selectedInventory = null;

            m_hideEmptyLeft.IsCheckedChanged      -= HideEmptyLeft_Checked;
            m_hideEmptyRight.IsCheckedChanged     -= HideEmptyRight_Checked;
            m_blockSearchLeft.TextChanged         -= BlockSearchLeft_TextChanged;
            m_blockSearchClearLeft.ButtonClicked  -= BlockSearchClearLeft_ButtonClicked;
            m_blockSearchRight.TextChanged        -= BlockSearchRight_TextChanged;
            m_blockSearchClearRight.ButtonClicked -= BlockSearchClearRight_ButtonClicked;

            m_hideEmptyLeft         = null;
            m_hideEmptyLeftLabel    = null;
            m_hideEmptyRight        = null;
            m_hideEmptyRightLabel   = null;
            m_blockSearchLeft       = null;
            m_blockSearchClearLeft  = null;
            m_blockSearchRight      = null;
            m_blockSearchClearRight = null;
        }
        private void dragDrop_OnItemDropped(object sender, MyDragAndDropEventArgs eventArgs)
        {
            if (m_selectedAssembler != null && eventArgs.DropTo != null)
            {
                var queueItem = (MyProductionBlock.QueueItem)eventArgs.Item.UserData;

                m_selectedAssembler.MoveQueueItemRequest(queueItem.ItemId, eventArgs.DropTo.ItemIndex);
            }

            m_dragAndDropInfo = null;
        }
        internal void Close()
        {
            UnregisterEvents();
            UnregisterAssemblerEvents(m_selectedAssembler);

            m_assemblersByKey.Clear();
            m_blueprintButtonGroup.Clear();
            m_modeButtonGroup.Clear();

            m_selectedAssembler = null;
            m_controlsParent = null;
            m_terminalSystem = null;
            m_comboboxAssemblers = null;

            m_dragAndDrop = null;
            m_dragAndDropInfo = null;
        }
        public void Drop()
        {
            if (!IsActive())
                return;

            MyDragAndDropInfo dropTo = null;

            m_dropToControls.Clear();

            MyScreenManager.GetControlsUnderMouseCursor(m_dropToControls, true);

            foreach (var control in m_dropToControls)
            {
                var grid = control as MyGuiControlGrid;
                if (grid != null)
                {
                    if (grid.Enabled && grid.MouseOverIndex != MyGuiControlGrid.INVALID_INDEX)
                    {
                        dropTo = new MyDragAndDropInfo();
                        dropTo.Grid = grid;
                        dropTo.ItemIndex = grid.MouseOverIndex;
                        break;
                    }
                }
            }

            ItemDropped(this, new MyDragAndDropEventArgs()
            {
                DragFrom = m_draggingFrom,
                DropTo = dropTo,
                Item = m_draggingGridItem,
                DragButton = m_dragButton.Value,
            });

            Stop();
        }
 /// <summary>
 /// Stops dragging item
 /// </summary>
 public void Stop()
 {
     m_draggingFrom = null;
     m_draggingGridItem = null;
     m_currentDropHandleType = null;
     m_dragButton = 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, MySharedButtonsEnum dragButton, MyGuiControlGrid.Item draggingItem, MyDragAndDropInfo draggingFrom, bool includeTooltip = true)
 {
     m_currentDropHandleType = dropHandleType;
     m_dragButton = dragButton;
     m_draggingGridItem = draggingItem;
     m_draggingFrom = draggingFrom;
     m_toolTip = (includeTooltip) ? draggingItem.ToolTip : null;
 }