本文整理汇总了C#中Sandbox.Graphics.GUI.MyGuiControlListbox类的典型用法代码示例。如果您正苦于以下问题:C# MyGuiControlListbox类的具体用法?C# MyGuiControlListbox怎么用?C# MyGuiControlListbox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MyGuiControlListbox类属于Sandbox.Graphics.GUI命名空间,在下文中一共展示了MyGuiControlListbox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MyGuiControlContextMenu
public MyGuiControlContextMenu()
{
m_itemsList = new MyGuiControlListbox();
m_itemsList.Name = "ContextMenuListbox";
m_itemsList.VisibleRowsCount = NUM_VISIBLE_ITEMS;
Enabled = false;
m_keys = new MyContextMenuKeyTimerController[3];
m_keys[(int)MyContextMenuKeys.UP] = new MyContextMenuKeyTimerController(MyKeys.Up);
m_keys[(int)MyContextMenuKeys.DOWN] = new MyContextMenuKeyTimerController(MyKeys.Down);
m_keys[(int)MyContextMenuKeys.ENTER] = new MyContextMenuKeyTimerController(MyKeys.Enter);
Name = "ContextMenu";
Elements.Add(m_itemsList);
}
示例2: MyGuiDetailScreenBase
public MyGuiDetailScreenBase(bool isTopMostScreen, MyGuiBlueprintScreenBase parent, string thumbnailTexture, MyGuiControlListbox.Item selectedItem, float textScale)
: base(new Vector2(0.37f, 0.325f), new Vector2(0.725f, 0.4f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, isTopMostScreen)
{
m_thumbnailImage = new MyGuiControlImage()
{
BackgroundTexture = MyGuiConstants.TEXTURE_RECTANGLE_DARK,
};
m_thumbnailImage.SetPadding(new MyGuiBorderThickness(3f, 2f, 3f, 2f));
m_thumbnailImage.SetTexture(thumbnailTexture);
m_selectedItem = selectedItem;
m_blueprintName = selectedItem.Text.ToString();
m_textScale = textScale;
m_parent = parent;
}
示例3: MyGuiDetailScreenBase
public MyGuiDetailScreenBase(bool isTopMostScreen, MyGuiBlueprintScreenBase parent, MyGuiCompositeTexture thumbnailTexture, MyGuiControlListbox.Item selectedItem, float textScale)
: base(new Vector2(0.37f, 0.325f), new Vector2(0.725f, 0.4f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, isTopMostScreen)
{
m_thumbnailImage = new MyGuiControlImageButton(true);
if (thumbnailTexture == null)
{
m_thumbnailImage.Visible = false;
}
else
{
m_thumbnailImage.BackgroundTexture = thumbnailTexture;
}
m_selectedItem = selectedItem;
m_blueprintName = selectedItem.Text.ToString();
m_textScale = textScale;
m_parent = parent;
}
示例4: Init
public void Init(IMyGuiControlsParent controlsParent)
{
m_playerList = (MyGuiControlListbox)controlsParent.Controls.GetControlByName("PlayerListbox");
m_factionList = (MyGuiControlListbox)controlsParent.Controls.GetControlByName("FactionListbox");
m_chatHistory = (MyGuiControlMultilineText)controlsParent.Controls.GetControlByName("ChatHistory");
m_chatbox = (MyGuiControlTextbox)controlsParent.Controls.GetControlByName("Chatbox");
m_playerList.ItemsSelected += m_playerList_ItemsSelected;
m_playerList.MultiSelect = false;
m_factionList.ItemsSelected += m_factionList_ItemsSelected;
m_factionList.MultiSelect = false;
m_sendButton = (MyGuiControlButton)controlsParent.Controls.GetControlByName("SendButton");
m_sendButton.ButtonClicked += m_sendButton_ButtonClicked;
m_chatbox.TextChanged += m_chatbox_TextChanged;
m_chatbox.EnterPressed += m_chatbox_EnterPressed;
if (MySession.Static.LocalCharacter != null)
{
MySession.Static.ChatSystem.PlayerMessageReceived += MyChatSystem_PlayerMessageReceived;
MySession.Static.ChatSystem.FactionMessageReceived += MyChatSystem_FactionMessageReceived;
MySession.Static.ChatSystem.GlobalMessageReceived += MyChatSystem_GlobalMessageReceived;
MySession.Static.ChatSystem.FactionHistoryDeleted += ChatSystem_FactionHistoryDeleted;
MySession.Static.ChatSystem.PlayerHistoryDeleted += ChatSystem_PlayerHistoryDeleted;
}
MySession.Static.Players.PlayersChanged += Players_PlayersChanged;
RefreshLists();
m_chatbox.SetText(m_emptyText);
m_sendButton.Enabled = false;
if (MyMultiplayer.Static != null)
{
MyMultiplayer.Static.ChatMessageReceived += Multiplayer_ChatMessageReceived;
}
m_closed = false;
}
示例5: OnSelectItem
void OnSelectItem(MyGuiControlListbox list)
{
if (list.SelectedItems.Count == 0)
{
return;
}
m_selectedItem = list.SelectedItems[0];
m_detailsButton.Enabled = true;
m_screenshotButton.Enabled = true;
m_replaceButton.Enabled = m_clipboard.HasCopiedGrids();
var type = (m_selectedItem.UserData as MyBlueprintItemInfo).Type;
var id = (m_selectedItem.UserData as MyBlueprintItemInfo).PublishedItemId;
var path = "";
if (type == MyBlueprintTypeEnum.LOCAL)
{
path = Path.Combine(m_localBlueprintFolder, m_selectedItem.Text.ToString(), "thumb.png");
m_deleteButton.Enabled = true;
}
else if (type == MyBlueprintTypeEnum.STEAM)
{
path = Path.Combine(m_workshopBlueprintFolder, "temp", id.ToString(), "thumb.png");
m_screenshotButton.Enabled = false;
m_replaceButton.Enabled = false;
m_deleteButton.Enabled = false;
}
else if (type == MyBlueprintTypeEnum.SHARED)
{
m_replaceButton.Enabled = false;
m_screenshotButton.Enabled = false;
m_detailsButton.Enabled = false;
m_deleteButton.Enabled = false;
}
else if (type == MyBlueprintTypeEnum.DEFAULT)
{
path = Path.Combine(m_defaultBlueprintFolder, m_selectedItem.Text.ToString(), "thumb.png");
m_replaceButton.Enabled = false;
m_screenshotButton.Enabled = false;
m_deleteButton.Enabled = false;
}
if (File.Exists(path))
{
m_selectedImage.SetTexture(path);
}
else
{
m_selectedImage.BackgroundTexture = null;
}
}
示例6: RecreateControls
public override void RecreateControls(bool constructor)
{
base.RecreateControls(constructor);
float hiddenPartTop = (SCREEN_SIZE.Y - 1.0f) / 2.0f;
Vector2 controlPadding = new Vector2(0.02f, 0);
// Position the Caption
var caption = AddCaption("Scripting Tools", Color.White.ToVector4(), controlPadding + new Vector2(-HIDDEN_PART_RIGHT, hiddenPartTop));
m_currentPosition.Y = caption.PositionY + caption.Size.Y + ITEM_VERTICAL_PADDING;
// Position all the controls under the caption
// Debug draw checkbox
PositionControls(new MyGuiControlBase[]
{
CreateLabel("Debug Draw"),
CreateCheckbox(DebugDrawCheckedChanged, MyDebugDrawSettings.ENABLE_DEBUG_DRAW)
});
// Selected entity controls
m_selectedEntityNameBox = CreateTextbox("");
PositionControls(new MyGuiControlBase[]
{
CreateLabel("Selected Entity: "),
m_selectedEntityNameBox,
CreateButton("Rename", RenameSelectedEntityOnClick)
});
m_selectedFunctionalBlockNameBox = CreateTextbox("");
PositionControls(new MyGuiControlBase[]
{
CreateLabel("Selected Block: "),
m_selectedFunctionalBlockNameBox,
CreateButton("Rename", RenameFunctionalBlockOnClick)
});
// Spawn entity button
PositionControls(new MyGuiControlBase[]
{
CreateButton("Spawn Entity", SpawnEntityClicked),
CreateButton("Delete Entity", DeleteEntityOnClicked)
});
// Trigger section
PositionControl(CreateLabel("Triggers"));
// Attach new trigger
PositionControl(CreateButton("Attach to selected entity", AttachTriggerOnClick));
m_enlargeTriggerButton = CreateButton("+", EnlargeTriggerOnClick);
m_shrinkTriggerButton = CreateButton("-", ShrinkTriggerOnClick);
m_setTriggerSizeButton = CreateButton("Size", SetSizeOnClick);
// Enlarge, Set size, Shrink
PositionControls(new MyGuiControlBase[]
{
m_enlargeTriggerButton,
m_setTriggerSizeButton,
m_shrinkTriggerButton
});
// Snap, Select, Delete
PositionControls(new MyGuiControlBase[]
{
CreateButton("Snap", SnapTriggerToCameraOrEntityOnClick),
CreateButton("Select", SelectTriggerOnClick),
CreateButton("Delete", DeleteTriggerOnClick)
}
);
// Selected trigger section
m_selectedTriggerNameBox = CreateTextbox("Trigger not selected");
PositionControls(new MyGuiControlBase[] {CreateLabel("Selected Trigger:"), m_selectedTriggerNameBox});
// Listbox for queried triggers
m_triggersListBox = CreateListBox();
m_triggersListBox.Size = new Vector2(0f, 0.06f);
m_triggersListBox.ItemDoubleClicked += TriggersListBoxOnItemDoubleClicked;
PositionControl(m_triggersListBox);
// Because something is reseting the value
m_triggersListBox.ItemSize = new Vector2(SCREEN_SIZE.X, ITEM_SIZE.Y);
// Running Level Scripts
PositionControl(CreateLabel("Running Level Scripts"));
m_levelScriptListBox = CreateListBox();
m_levelScriptListBox.Size = new Vector2(0f, 0.06f);
PositionControl(m_levelScriptListBox);
// Because something is reseting the value
m_triggersListBox.ItemSize = new Vector2(SCREEN_SIZE.X, ITEM_SIZE.Y);
// Fill with levelscripts -- they wont change during the process
if (m_scriptManager.RunningLevelScriptNames != null)
{
foreach (var runningLevelScriptName in m_scriptManager.RunningLevelScriptNames)
{
// user data are there to tell if the script already failed or not
m_levelScriptListBox.Add(new MyGuiControlListbox.Item(new StringBuilder(runningLevelScriptName),
userData: false));
}
}
// Running State machines
PositionControl(CreateLabel("Running state machines"));
m_smListBox = CreateListBox();
//.........这里部分代码省略.........
示例7: OnMouseOverItem
void OnMouseOverItem(MyGuiControlListbox listBox)
{
var item = listBox.MouseOverItem;
var path = "";
if (item != null)
{
if ((item.UserData as MyBlueprintItemInfo).Type == MyBlueprintTypeEnum.LOCAL)
{
path = Path.Combine(m_localBlueprintFolder, item.Text.ToString(), "thumb.png");
}
else if ((item.UserData as MyBlueprintItemInfo).Type == MyBlueprintTypeEnum.STEAM)
{
var id = (item.UserData as MyBlueprintItemInfo).PublishedItemId;
if (id != null)
{
path = Path.Combine(m_workshopBlueprintFolder, "temp", id.ToString(), "thumb.png");
}
}
else if ((item.UserData as MyBlueprintItemInfo).Type == MyBlueprintTypeEnum.DEFAULT)
{
path = Path.Combine(m_defaultBlueprintFolder, item.Text.ToString(), "thumb.png");
}
if (File.Exists(path))
{
m_thumbnailImage.SetTexture(path);
if (!m_activeDetail)
{
if (m_thumbnailImage.BackgroundTexture != null)
{
m_thumbnailImage.Visible = true;
}
}
}
else
{
m_thumbnailImage.Visible = false;
m_thumbnailImage.BackgroundTexture = null;
}
}
else
{
m_thumbnailImage.Visible = false;
}
}
示例8: list_ItemClicked
void list_ItemClicked(MyGuiControlListbox sender)
{
if (!Visible)
return;
int selectedIndex = -1;
object userData = null;
foreach (var item in sender.SelectedItems)
{
selectedIndex = sender.Items.IndexOf(item);
userData = item.UserData;
break;
}
if (ItemClicked != null)
ItemClicked(this, new EventArgs { ItemIndex = selectedIndex, UserData = userData });
//GK: If the item list have scrollbar and we are over the caret then let scrollbar hanlde input. In any other case disappear when clicked
if(!m_itemsList.IsOverScrollBar())
Deactivate();
}
示例9: MyGuiDetailScreenLocal
public MyGuiDetailScreenLocal(Action<MyGuiControlListbox.Item> callBack, MyGuiControlListbox.Item selectedItem, MyGuiBlueprintScreenBase parent , MyGuiCompositeTexture thumbnailTexture, float textScale) :
base(false, parent, thumbnailTexture, selectedItem, textScale)
{
var prefabPath = Path.Combine(m_localBlueprintFolder, m_blueprintName, "bp.sbc");
this.callBack = callBack;
if (File.Exists(prefabPath))
{
m_loadedPrefab = LoadPrefab(prefabPath);
if (m_loadedPrefab == null)
{
MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
buttonType: MyMessageBoxButtonsType.OK,
styleEnum: MyMessageBoxStyleEnum.Error,
messageCaption: new StringBuilder("Error"),
messageText: new StringBuilder("Failed to load the blueprint file.")
));
m_killScreen = true;
}
else
{
RecreateControls(true);
}
}
else
{
m_killScreen = true;
}
}
示例10: m_factionList_ItemsSelected
void m_factionList_ItemsSelected(MyGuiControlListbox obj)
{
if (m_factionList.SelectedItems.Count > 0)
{
var selectedItem = m_factionList.SelectedItems[0];
var faction = (MyFaction)selectedItem.UserData;
RefreshFactionChatHistory(faction);
var factions = MySession.Static.Factions;
var localFaction = factions.TryGetPlayerFaction(MySession.Static.LocalPlayerId);
if (localFaction != null)
{
MyFactionChatHistory factionChat = MyChatSystem.FindFactionChatHistory(faction.FactionId, localFaction.FactionId);
if (factionChat != null)
{
factionChat.UnreadMessageCount = 0;
UpdateFactionList(true);
}
}
m_chatbox.SetText(m_emptyText);
}
}
示例11: list_ItemClicked
void list_ItemClicked(MyGuiControlListbox sender)
{
if (!Visible)
return;
int selectedIndex = -1;
object userData = null;
foreach (var item in sender.SelectedItems)
{
selectedIndex = sender.Items.IndexOf(item);
userData = item.UserData;
break;
}
if (ItemClicked != null)
ItemClicked(this, new EventArgs { ItemIndex = selectedIndex, UserData = userData });
//A context menu always disappears when clicked
Deactivate();
}
示例12: OnItemDoubleClick
void OnItemDoubleClick(MyGuiControlListbox list)
{
m_selectedItem = list.SelectedItems[0];
Ok();
}
示例13: CreateTerminalControls
protected override void CreateTerminalControls()
{
if (MyTerminalControlFactory.AreControlsCreated<MyRemoteControl>())
return;
base.CreateTerminalControls();
var controlBtn = new MyTerminalControlButton<MyRemoteControl>("Control", MySpaceTexts.ControlRemote, MySpaceTexts.Blank, (b) => b.RequestControl());
controlBtn.Enabled = r => r.CanControl();
controlBtn.SupportsMultipleBlocks = false;
var action = controlBtn.EnableAction(MyTerminalActionIcons.TOGGLE);
if (action != null)
{
action.InvalidToolbarTypes = new List<MyToolbarType> { MyToolbarType.ButtonPanel };
action.ValidForGroups = false;
}
MyTerminalControlFactory.AddControl(controlBtn);
var autoPilotSeparator = new MyTerminalControlSeparator<MyRemoteControl>();
MyTerminalControlFactory.AddControl(autoPilotSeparator);
var autoPilot = new MyTerminalControlOnOffSwitch<MyRemoteControl>("AutoPilot", MySpaceTexts.BlockPropertyTitle_AutoPilot, MySpaceTexts.Blank);
autoPilot.Getter = (x) => x.m_autoPilotEnabled;
autoPilot.Setter = (x, v) => x.SetAutoPilotEnabled(v);
autoPilot.Enabled = r => r.CanEnableAutoPilot();
autoPilot.EnableToggleAction();
autoPilot.EnableOnOffActions();
MyTerminalControlFactory.AddControl(autoPilot);
var collisionAv = new MyTerminalControlOnOffSwitch<MyRemoteControl>("CollisionAvoidance", MySpaceTexts.BlockPropertyTitle_CollisionAvoidance, MySpaceTexts.Blank);
collisionAv.Getter = (x) => x.m_useCollisionAvoidance;
collisionAv.Setter = (x, v) => x.SetCollisionAvoidance(v);
collisionAv.Enabled = r => true;
collisionAv.EnableToggleAction();
collisionAv.EnableOnOffActions();
MyTerminalControlFactory.AddControl(collisionAv);
var dockignMode = new MyTerminalControlOnOffSwitch<MyRemoteControl>("DockingMode", MySpaceTexts.BlockPropertyTitle_EnableDockingMode, MySpaceTexts.Blank);
dockignMode.Getter = (x) => x.m_dockingModeEnabled;
dockignMode.Setter = (x, v) => x.SetDockingMode(v);
dockignMode.Enabled = r => r.IsWorking;
dockignMode.EnableToggleAction();
dockignMode.EnableOnOffActions();
MyTerminalControlFactory.AddControl(dockignMode);
var cameraList = new MyTerminalControlCombobox<MyRemoteControl>("CameraList", MySpaceTexts.BlockPropertyTitle_AssignedCamera, MySpaceTexts.Blank);
cameraList.ComboBoxContentWithBlock = (x, list) => x.FillCameraComboBoxContent(list);
cameraList.Getter = (x) => (long)x.m_bindedCamera;
cameraList.Setter = (x, y) => x.m_bindedCamera.Value = y;
MyTerminalControlFactory.AddControl(cameraList);
m_cameraList = cameraList;
var flightMode = new MyTerminalControlCombobox<MyRemoteControl>("FlightMode", MySpaceTexts.BlockPropertyTitle_FlightMode, MySpaceTexts.Blank);
flightMode.ComboBoxContent = (x) => FillFlightModeCombo(x);
flightMode.Getter = (x) => (long)x.m_currentFlightMode.Value;
flightMode.Setter = (x, v) => x.ChangeFlightMode((FlightMode)v);
flightMode.SetSerializerRange((int)MyEnum<FlightMode>.Range.Min, (int)MyEnum<FlightMode>.Range.Max);
MyTerminalControlFactory.AddControl(flightMode);
var directionCombo = new MyTerminalControlCombobox<MyRemoteControl>("Direction", MySpaceTexts.BlockPropertyTitle_ForwardDirection, MySpaceTexts.Blank);
directionCombo.ComboBoxContent = (x) => FillDirectionCombo(x);
directionCombo.Getter = (x) => (long)x.m_currentDirection.Value;
directionCombo.Setter = (x, v) => x.ChangeDirection((Base6Directions.Direction)v);
MyTerminalControlFactory.AddControl(directionCombo);
if (MyFakes.ENABLE_VR_REMOTE_BLOCK_AUTOPILOT_SPEED_LIMIT)
{
var sliderSpeedLimit = new MyTerminalControlSlider<MyRemoteControl>("SpeedLimit", MySpaceTexts.BlockPropertyTitle_RemoteBlockSpeedLimit,
MySpaceTexts.BlockPropertyTitle_RemoteBlockSpeedLimit);
sliderSpeedLimit.SetLimits(1, 200);
sliderSpeedLimit.DefaultValue = MyObjectBuilder_RemoteControl.DEFAULT_AUTOPILOT_SPEED_LIMIT;
sliderSpeedLimit.Getter = (x) => x.m_autopilotSpeedLimit;
sliderSpeedLimit.Setter = (x, v) => x.m_autopilotSpeedLimit.Value = v;
sliderSpeedLimit.Writer = (x, sb) => sb.Append(MyValueFormatter.GetFormatedFloat(x.m_autopilotSpeedLimit, 0));
sliderSpeedLimit.EnableActions();
MyTerminalControlFactory.AddControl(sliderSpeedLimit);
}
var waypointList = new MyTerminalControlListbox<MyRemoteControl>("WaypointList", MySpaceTexts.BlockPropertyTitle_Waypoints, MySpaceTexts.Blank, true);
waypointList.ListContent = (x, list1, list2) => x.FillWaypointList(list1, list2);
waypointList.ItemSelected = (x, y) => x.SelectWaypoint(y);
if (!MySandboxGame.IsDedicated)
{
m_waypointGuiControl = (MyGuiControlListbox)((MyGuiControlBlockProperty)waypointList.GetGuiControl()).PropertyControl;
}
MyTerminalControlFactory.AddControl(waypointList);
var toolbarButton = new MyTerminalControlButton<MyRemoteControl>("Open Toolbar", MySpaceTexts.BlockPropertyTitle_AutoPilotToolbarOpen, MySpaceTexts.BlockPropertyPopup_AutoPilotToolbarOpen,
delegate(MyRemoteControl self)
{
var actions = self.m_selectedWaypoints[0].Actions;
if (actions != null)
{
for (int i = 0; i < actions.Length; i++)
{
if (actions[i] != null)
{
self.m_actionToolbar.SetItemAtIndex(i, actions[i]);
}
}
//.........这里部分代码省略.........
示例14: OnItemDoubleClick
void OnItemDoubleClick(MyGuiControlListbox list)
{
m_selectedItem = list.SelectedItems[0];
var itemInfo = m_selectedItem.UserData as MyBlueprintItemInfo;
OpenSelectedSript();
}
示例15: OnMouseOverItem
void OnMouseOverItem(MyGuiControlListbox listBox)
{
var item = listBox.MouseOverItem;
var path = "";
if (item != null)
{
MyBlueprintItemInfo blueprintInfo = (item.UserData as MyBlueprintItemInfo);
if (blueprintInfo.Type == MyBlueprintTypeEnum.LOCAL)
{
path = Path.Combine(m_localBlueprintFolder, item.Text.ToString(), "thumb.png");
}
else if (blueprintInfo.Type == MyBlueprintTypeEnum.STEAM)
{
var id = blueprintInfo.PublishedItemId;
if (id != null)
{
path = Path.Combine(TEMP_PATH, id.ToString(), "thumb.png");
if (blueprintInfo.Item != null)
{
bool isQueued = m_downloadQueued.Contains(blueprintInfo.Item.PublishedFileId);
bool isDownloaded = m_downloadFinished.Contains(blueprintInfo.Item.PublishedFileId);
MySteamWorkshop.SubscribedItem worshopData = blueprintInfo.Item;
if (isDownloaded && IsExtracted(worshopData) == false)
{
m_blueprintList.Enabled = false;
m_okButton.Enabled = false;
ExtractWorkshopItem(worshopData);
m_blueprintList.Enabled = true;
m_okButton.Enabled = true;
}
if (isQueued == false && isDownloaded == false)
{
m_blueprintList.Enabled = false;
m_okButton.Enabled = false;
m_downloadQueued.Add(blueprintInfo.Item.PublishedFileId);
Task = Parallel.Start(() =>
{
DownloadBlueprintFromSteam(worshopData);
}, () => { OnBlueprintDownloadedThumbnail(worshopData); });
}
}
}
}
else if (blueprintInfo.Type == MyBlueprintTypeEnum.DEFAULT)
{
path = Path.Combine(m_defaultBlueprintFolder, item.Text.ToString(), "thumb.png");
}
if (File.Exists(path))
{
m_thumbnailImage.SetTexture(path);
if (!m_activeDetail)
{
if (m_thumbnailImage.BackgroundTexture != null)
{
m_thumbnailImage.Visible = true;
}
}
}
else
{
m_thumbnailImage.Visible = false;
m_thumbnailImage.BackgroundTexture = null;
}
}
else
{
m_thumbnailImage.Visible = false;
}
}