本文整理汇总了C#中Sandbox.Graphics.GUI.MyGuiControlGrid类的典型用法代码示例。如果您正苦于以下问题:C# MyGuiControlGrid类的具体用法?C# MyGuiControlGrid怎么用?C# MyGuiControlGrid使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MyGuiControlGrid类属于Sandbox.Graphics.GUI命名空间,在下文中一共展示了MyGuiControlGrid类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MakeInventoryGrid
private MyGuiControlGrid MakeInventoryGrid(MyInventory inventory)
{
var grid = new MyGuiControlGrid();
grid.Name = "InventoryGrid";
grid.VisualStyle = MyGuiControlGridStyleEnum.Inventory;
grid.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
grid.ColumnsCount = 7;
grid.RowsCount = 1;
grid.ShowTooltipWhenDisabled = true;
grid.UserData = inventory;
return grid;
}
示例2: Init
public void Init(IMyGuiControlsParent controlsParent, MyCubeGrid grid)
{
if (grid == null)
{
ShowError(MySpaceTexts.ScreenTerminalError_ShipNotConnected, controlsParent);
return;
}
grid.RaiseGridChanged();
m_assemblerKeyCounter = 0;
m_assemblersByKey.Clear();
foreach (var block in grid.GridSystems.TerminalSystem.Blocks)
{
var assembler = block as MyAssembler;
if (assembler == null) continue;
if (!assembler.HasLocalPlayerAccess()) continue;
m_assemblersByKey.Add(m_assemblerKeyCounter++, assembler);
}
m_controlsParent = controlsParent;
m_terminalSystem = grid.GridSystems.TerminalSystem;
m_blueprintsArea = (MyGuiControlScrollablePanel)controlsParent.Controls.GetControlByName("BlueprintsScrollableArea");
m_queueArea = (MyGuiControlScrollablePanel)controlsParent.Controls.GetControlByName("QueueScrollableArea");
m_inventoryArea = (MyGuiControlScrollablePanel)controlsParent.Controls.GetControlByName("InventoryScrollableArea");
m_blueprintsBgPanel = controlsParent.Controls.GetControlByName("BlueprintsBackgroundPanel");
m_blueprintsLabel = controlsParent.Controls.GetControlByName("BlueprintsLabel");
m_comboboxAssemblers = (MyGuiControlCombobox)controlsParent.Controls.GetControlByName("AssemblersCombobox");
m_blueprintsGrid = (MyGuiControlGrid)m_blueprintsArea.ScrolledControl;
m_queueGrid = (MyGuiControlGrid)m_queueArea.ScrolledControl;
m_inventoryGrid = (MyGuiControlGrid)m_inventoryArea.ScrolledControl;
m_materialsList = (MyGuiControlComponentList)controlsParent.Controls.GetControlByName("MaterialsList");
m_repeatCheckbox = (MyGuiControlCheckbox)controlsParent.Controls.GetControlByName("RepeatCheckbox");
m_slaveCheckbox = (MyGuiControlCheckbox)controlsParent.Controls.GetControlByName("SlaveCheckbox");
m_disassembleAllButton = (MyGuiControlButton)controlsParent.Controls.GetControlByName("DisassembleAllButton");
m_controlPanelButton = (MyGuiControlButton)controlsParent.Controls.GetControlByName("ControlPanelButton");
m_inventoryButton = (MyGuiControlButton)controlsParent.Controls.GetControlByName("InventoryButton");
{
var assemblingButton = (MyGuiControlRadioButton)controlsParent.Controls.GetControlByName("AssemblingButton");
var disassemblingButton = (MyGuiControlRadioButton)controlsParent.Controls.GetControlByName("DisassemblingButton");
assemblingButton.Key = (int)AssemblerMode.Assembling;
disassemblingButton.Key = (int)AssemblerMode.Disassembling;
m_modeButtonGroup.Add(assemblingButton);
m_modeButtonGroup.Add(disassemblingButton);
}
foreach (var entry in m_assemblersByKey)
{
if (entry.Value.IsFunctional == false)
{
m_incompleteAssemblerName.Clear();
m_incompleteAssemblerName.AppendStringBuilder(entry.Value.CustomName);
m_incompleteAssemblerName.AppendStringBuilder(MyTexts.Get(MySpaceTexts.Terminal_BlockIncomplete));
m_comboboxAssemblers.AddItem(entry.Key, m_incompleteAssemblerName);
}
else
{
m_comboboxAssemblers.AddItem(entry.Key, entry.Value.CustomName);
}
}
m_comboboxAssemblers.ItemSelected += Assemblers_ItemSelected;
m_comboboxAssemblers.SelectItemByIndex(0);
m_dragAndDrop = new MyGuiControlGridDragAndDrop(MyGuiConstants.DRAG_AND_DROP_BACKGROUND_COLOR,
MyGuiConstants.DRAG_AND_DROP_TEXT_COLOR,
0.7f,
MyGuiConstants.DRAG_AND_DROP_TEXT_OFFSET, true);
controlsParent.Controls.Add(m_dragAndDrop);
m_dragAndDrop.DrawBackgroundTexture = false;
m_dragAndDrop.ItemDropped += dragDrop_OnItemDropped;
RefreshBlueprints();
Assemblers_ItemSelected();
RegisterEvents();
if (m_assemblersByKey.Count == 0)
ShowError(MySpaceTexts.ScreenTerminalError_NoAssemblers, controlsParent);
}
示例3: OnSelectedItemChanged
private void OnSelectedItemChanged(MyGuiControlGrid arg1, MyGuiControlGrid.EventArgs arg2)
{
OnGridMouseOverIndexChanged(arg1, arg2);
}
示例4: FillGridItem
public override void FillGridItem(MyGuiControlGrid.Item gridItem)
{
if (MyFakes.ENABLE_GATHERING_SMALL_BLOCK_FROM_GRID)
if (m_lastAmount > 0)
gridItem.AddText(String.Format("{0}x", m_lastAmount), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM);
else
gridItem.ClearText(MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM);
}
示例5: grid_ItemDoubleClicked
private void grid_ItemDoubleClicked(MyGuiControlGrid sender, MyGuiControlGrid.EventArgs eventArgs)
{
if (MyInput.Static.IsAnyShiftKeyPressed() ||
MyInput.Static.IsAnyCtrlKeyPressed())
return;
var item = (MyPhysicalInventoryItem)sender.GetItemAt(eventArgs.ItemIndex).UserData;
bool transfered = TransferToOppositeFirst(item);
RefreshSelectedInventoryItem();
//MyAudio.Static.PlayCue(transfered ? MySoundCuesEnum.HudMouseClick : MySoundCuesEnum.HudUnable);
}
示例6: grid_ItemSelected
private void grid_ItemSelected(MyGuiControlGrid sender, MyGuiControlGrid.EventArgs eventArgs)
{
var sourceGrid = (MyGuiControlGrid)sender;
if (m_focusedGridControl != null &&
m_focusedGridControl != sourceGrid)
{
m_focusedGridControl.SelectedIndex = null;
}
m_focusedGridControl = sourceGrid;
m_focusedOwnerControl = (MyGuiControlInventoryOwner)sourceGrid.Owner;
RefreshSelectedInventoryItem();
}
示例7: inventoryGrid_MouseOverIndexChanged
void inventoryGrid_MouseOverIndexChanged(MyGuiControlGrid control, MyGuiControlGrid.EventArgs args)
{
Debug.Assert(control == m_inventoryGrid);
if (CurrentAssemblerMode == AssemblerMode.Assembling)
return;
RefreshMaterialsPreview();
}
示例8: IsToolbarGrid
public bool IsToolbarGrid(MyGuiControlGrid grid)
{
return m_toolbarItemsGrid == grid;
}
示例9: RecreateControls
private void RecreateControls(bool contructor)
{
m_toolbarItemsGrid = new MyGuiControlGrid()
{
OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM,
VisualStyle = MyGuiControlGridStyleEnum.Toolbar,
ColumnsCount = MyToolbarComponent.CurrentToolbar.SlotCount + 1,
RowsCount = 1
};
m_toolbarItemsGrid.ItemDoubleClicked += grid_ItemDoubleClicked;
m_toolbarItemsGrid.ItemClickedWithoutDoubleClick += grid_ItemClicked;
m_selectedItemLabel = new MyGuiControlLabel();
m_colorVariantPanel = new MyGuiControlPanel(size: new Vector2(0.1f, 0.025f));
m_colorVariantPanel.BackgroundTexture = MyGuiConstants.TEXTURE_GUI_BLANK;
m_contextMenu = new MyGuiControlContextMenu();
m_contextMenu.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;
m_contextMenu.Deactivate();
m_contextMenu.ItemClicked += contextMenu_ItemClicked;
Elements.Add(m_colorVariantPanel);
Elements.Add(m_selectedItemLabel);
Elements.Add(m_toolbarItemsGrid);
Elements.Add(m_contextMenu);
m_colorVariantPanel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM;
m_selectedItemLabel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM;
m_toolbarItemsGrid.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM;
m_contextMenu.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;
RefreshInternals();
}
示例10: StartDragging
/// <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;
}
示例11: SetGridItemAt
protected virtual void SetGridItemAt(int slot, MyToolbarItem item, string[] icons, string subicon, String tooltip, MyGuiControlGrid.ColoredIcon? symbol = null, bool clear = false)
{
var gridItem = m_toolbarItemsGrid.GetItemAt(slot);
if (gridItem == null)
{
gridItem = new MyGuiControlGrid.Item(
icons: icons,
subicon: subicon,
toolTip: tooltip,
userData: item);
//By Gregory: Changed to IconText for weapon check MyToolbarItemWeapon IconText override
//if (item != null)
// gridItem.AddText(item.IconText, MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM);
//else
// gridItem.ClearText(MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM);
//gridItem.Enabled = (item != null) ? item.Enabled : true;
//if (symbol.HasValue)
// gridItem.AddIcon(symbol.Value, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
m_toolbarItemsGrid.SetItemAt(slot, gridItem);
}
else
{
gridItem.UserData = item;
gridItem.Icons = icons;
gridItem.SubIcon = subicon;
if (gridItem.ToolTip == null)
gridItem.ToolTip = new MyToolTips();
gridItem.ToolTip.ToolTips.Clear();
gridItem.ToolTip.AddToolTip(tooltip);
//By Gregory: Changed to IconText for weapon check MyToolbarItemWeapon IconText override
//if (item != null)
// gridItem.AddText(item.IconText, MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM);
//else
// gridItem.ClearText(MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM);
//gridItem.Enabled = (item != null) ? item.Enabled : true;
//if (symbol.HasValue)
// gridItem.AddIcon(symbol.Value, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
}
if (item == null || clear)
gridItem.ClearAllText();
if (DrawNumbers)
gridItem.AddText(MyToolbarComponent.GetSlotControlText(slot));
if (item != null)
item.FillGridItem(gridItem);
gridItem.Enabled = (item != null) ? item.Enabled : true;
if (symbol.HasValue)
gridItem.AddIcon(symbol.Value, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
}
示例12: MakeScreenWithIconGrid
private static void MakeScreenWithIconGrid()
{
var screen = new TmpScreen();
var grid = new MyGuiControlGrid();
screen.Controls.Add(grid);
grid.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER;
grid.VisualStyle = MyGuiControlGridStyleEnum.Inventory;
grid.RowsCount = 12;
grid.ColumnsCount = 18;
foreach (var definition in MyDefinitionManager.Static.GetAllDefinitions())
{
grid.Add(new MyGuiControlGrid.Item(
icon: definition.Icon,
toolTip: definition.DisplayNameText));
}
MyGuiSandbox.AddScreen(screen);
}
示例13: OnGridMouseOverIndexChanged
private void OnGridMouseOverIndexChanged(MyGuiControlGrid myGuiControlGrid, MyGuiControlGrid.EventArgs eventArgs)
{
if (m_gridBlocks.Visible)
{
MyGuiControlGrid.Item gridItem = m_gridBlocks.MouseOverItem ?? m_gridBlocks.SelectedItem;
if (gridItem == null)
{
m_blockInfoList.InitControls(new MyGuiControlBase[] { });
return;
}
GridItemUserData userData = gridItem.UserData as GridItemUserData;
if (userData == null)
return;
MyObjectBuilder_ToolbarItemCubeBlock itemData = userData.ItemData as MyObjectBuilder_ToolbarItemCubeBlock;
if (itemData == null)
return;
MyDefinitionBase definition;
if (MyDefinitionManager.Static.TryGetDefinition(itemData.DefinitionId, out definition))
{
var group = MyDefinitionManager.Static.GetDefinitionGroup((definition as MyCubeBlockDefinition).BlockPairName);
if (MyCubeBuilder.Static.CubeBuilderState.CubeSizeMode == MyCubeSize.Small &&
MyCubeBuilder.Static.IsCubeSizeAvailable(group.Small))
{
m_blockInfoList.InitControls(GenerateBlockInfos(group.Small, ref m_blockInfoStyle));
}
else if (MyCubeBuilder.Static.CubeBuilderState.CubeSizeMode == MyCubeSize.Large &&
MyCubeBuilder.Static.IsCubeSizeAvailable(group.Large))
{
m_blockInfoList.InitControls(GenerateBlockInfos(group.Large, ref m_blockInfoStyle));
}
else
{
bool blockSizeLarge = MyCubeBuilder.Static.CubeBuilderState.CubeSizeMode == MyCubeSize.Large;
m_blockInfoList.InitControls(new MyGuiControlBase[]
{
GenerateSizeInfoLabel(blockSizeLarge),
GenerateSizeNotAvailableText(blockSizeLarge)
});
}
}
}
else
{
m_blockInfoList.InitControls(new MyGuiControlBase[] { });
}
}
示例14: queueGrid_ItemClicked
void queueGrid_ItemClicked(MyGuiControlGrid control, MyGuiControlGrid.EventArgs args)
{
Debug.Assert(control == m_queueGrid);
// Changing queue in auto-disassembling mode is forbidden.
if (CurrentAssemblerMode == AssemblerMode.Disassembling && m_selectedAssembler.RepeatEnabled)
return;
if (args.Button == MySharedButtonsEnum.Secondary)
m_selectedAssembler.RemoveQueueItemRequest(args.ItemIndex);
}
示例15: queueGrid_ItemDragged
void queueGrid_ItemDragged(MyGuiControlGrid control, MyGuiControlGrid.EventArgs args)
{
StartDragging(MyDropHandleType.MouseRelease, control, ref args);
}