本文整理汇总了C#中Sandbox.Graphics.GUI.MyGuiControlMultilineText类的典型用法代码示例。如果您正苦于以下问题:C# MyGuiControlMultilineText类的具体用法?C# MyGuiControlMultilineText怎么用?C# MyGuiControlMultilineText使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MyGuiControlMultilineText类属于Sandbox.Graphics.GUI命名空间,在下文中一共展示了MyGuiControlMultilineText类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseText
//implementation without RegularExpressions
public static void ParseText(string text, ref MyGuiControlMultilineText label)
{
try
{
var substrings = text.Split(']');
foreach (var substring in substrings)
{
var textAndMarkup = substring.Split('[');
if (textAndMarkup.Length == 2)
{
label.AppendText(textAndMarkup[0]);
var indexOfSpace = textAndMarkup[1].IndexOf(' ');
if (indexOfSpace != -1)
{
label.AppendLink(textAndMarkup[1].Substring(0, indexOfSpace), textAndMarkup[1].Substring(indexOfSpace + 1));
}
else
{
System.Diagnostics.Debug.Assert(false);
label.AppendText(textAndMarkup[1]);
}
} else {
label.AppendText(substring);
}
}
}
catch
{
}
}
示例2: ParseMarkup
private static void ParseMarkup(MyGuiControlMultilineText label, string markup)
{
var s = m_markupRegex.Match(markup);
if (s.Value.Contains('|'))
{
var sub = s.Value.Substring(5);
var split = sub.Split('|');
var match = m_digitsRegex.Matches(split[1]);
int width, height;
if(int.TryParse(match[0].Value, out width) && int.TryParse(match[1].Value, out height))
label.AppendImage(split[0], MyGuiManager.GetNormalizedSizeFromScreenSize(new VRageMath.Vector2(width, height)), Vector4.One);
}
else
label.AppendLink(s.Value.Substring(0, s.Value.IndexOf(' ')), s.Value.Substring(s.Value.IndexOf(' ') + 1));
}
示例3: MyHudControlChat
public MyHudControlChat(Vector2 position, Vector2 size)
{
m_chatMultilineControl = new MyGuiControlMultilineText(
position: position,
size: size,
backgroundColor: null,
font: MyFontEnum.White,
textScale: 0.7f,
textAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM,
contents: null,
drawScrollbar: false,
textBoxAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM);
//m_chatMultilineControl.BackgroundTexture = MyGuiConstants.TEXTURE_MESSAGEBOX_BACKGROUND_BLUE.Texture;
m_chatMultilineControl.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;
Elements.Add(m_chatMultilineControl);
}
示例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: ParseText
public static void ParseText(string text, ref MyGuiControlMultilineText label)
{
try
{
var texts = m_splitRegex.Split(text);
var matches = m_splitRegex.Matches(text);
for (int i = 0; i < matches.Count || i < texts.Count(); i++)
{
if (i < texts.Count())
label.AppendText(m_stringCache.Clear().Append(texts[i]));
if (i < matches.Count)
ParseMarkup(label, matches[i].Value);
}
}
catch
{
}
}
示例6: RecreateControls
public override void RecreateControls(bool constructor)
{
base.RecreateControls(constructor);
var layout = new MyLayoutTable(this);
layout.SetColumnWidthsNormalized(50, 250, 150, 250, 50);
layout.SetRowHeightsNormalized(50, 450, 30, 50);
m_mainLabel = new MyGuiControlLabel(text: MyTexts.GetString(MySpaceTexts.GuiScenarioDescription), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
layout.AddWithSize(m_mainLabel, MyAlignH.Left, MyAlignV.Center, 0, 1, colSpan: 3);
//BRIEFING:
m_descriptionBox = new MyGuiControlMultilineText(
position: new Vector2(0.0f, 0.0f),
size: new Vector2(0.2f, 0.2f),
textBoxAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
selectable: false);
layout.AddWithSize(m_descriptionBox, MyAlignH.Left, MyAlignV.Top, 1, 1, rowSpan: 1, colSpan: 3);
m_okButton = new MyGuiControlButton(text: MyTexts.Get(MyCommonTexts.Ok), visualStyle: MyGuiControlButtonStyleEnum.Rectangular, highlightType: MyGuiControlHighlightType.WHEN_ACTIVE,
size: new Vector2(200, 48f) / MyGuiConstants.GUI_OPTIMAL_SIZE, onButtonClick: OnOkClicked);
layout.AddWithSize(m_okButton, MyAlignH.Left, MyAlignV.Top, 2, 2);
}
示例7: Draw
public void Draw(MyGuiControlMultilineText control)
{
if (Visible)
{
if (IsDirty)
{
control.Clear();
control.AppendText(CameraName);
control.AppendLine();
control.AppendText(ShipName);
IsDirty = false;
}
}
else
{
if (IsDirty)
{
control.Clear();
IsDirty = false;
}
}
}
示例8: AddMultilineText
protected MyGuiControlMultilineText AddMultilineText(Vector2? size = null, Vector2? offset = null, float textScale = 1.0f, bool selectable = false)
{
Vector2 textboxSize = size ?? this.Size ?? new Vector2(0.5f, 0.5f);
MyGuiControlMultilineText textbox = new MyGuiControlMultilineText(
position: offset ?? Vector2.Zero,
size: textboxSize,
//backgroundColor: m_defaultColor,
//textScale: this.m_scale * textScale,
textAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
textBoxAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
selectable: selectable,
font: MyFontEnum.Blue);
//textbox.BackgroundTexture = MyGuiConstants.TEXTURE_NEWS_BACKGROUND;
//textbox.TextSize = new Vector2(0.2f, 0.2f);
return textbox;
}
示例9: CreateTextField
protected void CreateTextField()
{
var textPosition = new Vector2(-0.325f, -0.175f) + m_offset;
var textSize = new Vector2(0.175f, 0.175f);
var padding = new Vector2(0.005f, 0f);
var textBackgroundPanel = AddCompositePanel(MyGuiConstants.TEXTURE_RECTANGLE_DARK, textPosition, textSize, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
m_textField = new MyGuiControlMultilineText();
m_textField = AddMultilineText(offset: textPosition + padding, textScale: m_textScale, size: textSize - padding);
RefreshTextField();
}
示例10: SelectAll
public void SelectAll(MyGuiControlMultilineText sender)
{
m_startIndex = 0;
m_endIndex = sender.Text.Length;
sender.CarriagePositionIndex = sender.Text.Length;
}
示例11: ComputeLineDataFromString
private MultilineData ComputeLineDataFromString(string value)
{
MultilineData ret;
ret.data = value;
MyGuiControlMultilineText textBox = new MyGuiControlMultilineText(size: new Vector2(QuestlogSize.X * 0.92f, 1), drawScrollbar: false);
textBox.Visible = false;
textBox.TextScale = 0.9f;
textBox.AppendText(value);
ret.lines = textBox.NumberOfRows;
return ret;
}
示例12: Init
public void Init(IMyGuiControlsParent controlsParent)
{
m_controlsParent = controlsParent;
RefreshUserInfo();
m_tableFactions = (MyGuiControlTable)controlsParent.Controls.GetControlByName("FactionsTable");
m_tableFactions.SetColumnComparison(0, (a, b) => ((StringBuilder)a.UserData).CompareToIgnoreCase((StringBuilder)b.UserData));
m_tableFactions.SetColumnComparison(1, (a, b) => ((StringBuilder)a.UserData).CompareToIgnoreCase((StringBuilder)b.UserData));
m_tableFactions.ItemSelected += OnFactionsTableItemSelected;
RefreshTableFactions();
m_tableFactions.SortByColumn(1);
m_buttonCreate = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonCreate");
m_buttonJoin = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonJoin");
m_buttonCancelJoin = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonCancelJoin");
m_buttonLeave = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonLeave");
m_buttonSendPeace = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonSendPeace");
m_buttonCancelPeace = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonCancelPeace");
m_buttonAcceptPeace = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonAcceptPeace");
m_buttonMakeEnemy = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonEnemy");
m_buttonCreate.ShowTooltipWhenDisabled = true;
m_buttonCreate.TextEnum = MySpaceTexts.TerminalTab_Factions_Create;
m_buttonJoin.TextEnum = MySpaceTexts.TerminalTab_Factions_Join;
m_buttonCancelJoin.TextEnum = MySpaceTexts.TerminalTab_Factions_CancelJoin;
m_buttonLeave.TextEnum = MySpaceTexts.TerminalTab_Factions_Leave;
m_buttonSendPeace.TextEnum = MySpaceTexts.TerminalTab_Factions_Friend;
m_buttonCancelPeace.TextEnum = MySpaceTexts.TerminalTab_Factions_CancelPeaceRequest;
m_buttonAcceptPeace.TextEnum = MySpaceTexts.TerminalTab_Factions_AcceptPeaceRequest;
m_buttonMakeEnemy.TextEnum = MySpaceTexts.TerminalTab_Factions_Enemy;
m_buttonJoin.SetToolTip(MySpaceTexts.TerminalTab_Factions_JoinToolTip);
m_buttonSendPeace.SetToolTip(MySpaceTexts.TerminalTab_Factions_FriendToolTip);
m_buttonCreate.ButtonClicked += OnCreateClicked;
m_buttonJoin.ButtonClicked += OnJoinClicked;
m_buttonCancelJoin.ButtonClicked += OnCancelJoinClicked;
m_buttonLeave.ButtonClicked += OnLeaveClicked;
m_buttonSendPeace.ButtonClicked += OnFriendClicked;
m_buttonCancelPeace.ButtonClicked += OnCancelPeaceRequestClicked;
m_buttonAcceptPeace.ButtonClicked += OnAcceptFriendClicked;
m_buttonMakeEnemy.ButtonClicked += OnEnemyClicked;
// RIGHT SIDE
m_labelFactionName = (MyGuiControlLabel)controlsParent.Controls.GetControlByName("labelFactionName");
m_labelFactionDesc = (MyGuiControlLabel)controlsParent.Controls.GetControlByName("labelFactionDesc");
m_labelFactionPriv = (MyGuiControlLabel)controlsParent.Controls.GetControlByName("labelFactionPrivate");
m_labelMembers = (MyGuiControlLabel)controlsParent.Controls.GetControlByName("labelFactionMembers");
m_labelAutoAcceptMember = (MyGuiControlLabel)controlsParent.Controls.GetControlByName("labelFactionMembersAcceptEveryone");
m_labelAutoAcceptPeace = (MyGuiControlLabel)controlsParent.Controls.GetControlByName("labelFactionMembersAcceptPeace");
m_labelFactionDesc.Text = MyTexts.Get(MySpaceTexts.TerminalTab_Factions_CreateFactionDescription).ToString();
m_labelFactionPriv.Text = MyTexts.Get(MySpaceTexts.TerminalTab_Factions_Private).ToString();
m_labelMembers.Text = MyTexts.Get(MySpaceTexts.TerminalTab_Factions_Members).ToString();
m_labelAutoAcceptMember.Text = MyTexts.Get(MySpaceTexts.TerminalTab_Factions_AutoAccept).ToString();
m_labelAutoAcceptPeace.Text = MyTexts.Get(MySpaceTexts.TerminalTab_Factions_AutoAcceptRequest).ToString();
m_labelAutoAcceptMember.SetToolTip(MySpaceTexts.TerminalTab_Factions_AutoAcceptToolTip);
m_labelAutoAcceptPeace.SetToolTip(MySpaceTexts.TerminalTab_Factions_AutoAcceptRequestToolTip);
m_textFactionDesc = (MyGuiControlMultilineText)controlsParent.Controls.GetControlByName("textFactionDesc");
m_textFactionPriv = (MyGuiControlMultilineText)controlsParent.Controls.GetControlByName("textFactionPrivate");
m_textFactionDesc.BackgroundTexture = MyGuiConstants.TEXTURE_HIGHLIGHT_DARK;
m_textFactionPriv.BackgroundTexture = MyGuiConstants.TEXTURE_HIGHLIGHT_DARK;
m_tableMembers = (MyGuiControlTable)controlsParent.Controls.GetControlByName("tableMembers");
m_tableMembers.SetColumnComparison(1, (a, b) => ((int)((MyMemberComparerEnum)a.UserData)).CompareTo((int)((MyMemberComparerEnum)b.UserData)));
m_tableMembers.ItemSelected += OnTableItemSelected;
m_checkAutoAcceptMember = (MyGuiControlCheckbox)controlsParent.Controls.GetControlByName("checkFactionMembersAcceptEveryone");
m_checkAutoAcceptPeace = (MyGuiControlCheckbox)controlsParent.Controls.GetControlByName("checkFactionMembersAcceptPeace");
m_checkAutoAcceptMember.SetToolTip(MySpaceTexts.TerminalTab_Factions_AutoAcceptToolTip);
m_checkAutoAcceptPeace.SetToolTip(MySpaceTexts.TerminalTab_Factions_AutoAcceptRequestToolTip);
m_checkAutoAcceptMember.IsCheckedChanged += OnAutoAcceptChanged;
m_checkAutoAcceptPeace.IsCheckedChanged += OnAutoAcceptChanged;
m_buttonEdit = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonEdit");
m_buttonPromote = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonPromote");
m_buttonKick = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonKick");
m_buttonAcceptJoin = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonAcceptJoin");
m_buttonDemote = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonDemote");
m_buttonAddNpc = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonAddNpc");
m_buttonEdit.TextEnum = MyCommonTexts.Edit;
m_buttonPromote.TextEnum = MyCommonTexts.Promote;
m_buttonKick.TextEnum = MyCommonTexts.Kick;
m_buttonAcceptJoin.TextEnum = MyCommonTexts.Accept;
m_buttonDemote.TextEnum = MyCommonTexts.Demote;
m_buttonAddNpc.TextEnum = MySpaceTexts.AddNpcToFaction;
m_buttonAddNpc.SetToolTip(MySpaceTexts.AddNpcToFactionHelp);
m_buttonEdit.ButtonClicked += OnCreateClicked;
m_buttonPromote.ButtonClicked += OnPromotePlayerClicked;
m_buttonKick.ButtonClicked += OnKickPlayerClicked;
m_buttonAcceptJoin.ButtonClicked += OnAcceptJoinClicked;
//.........这里部分代码省略.........
示例13: AddMultilineText
protected virtual MyGuiControlMultilineText AddMultilineText(Vector2? size = null, Vector2? offset = null, float textScale = 1.0f, bool selectable = false, MyGuiDrawAlignEnum textAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, MyGuiDrawAlignEnum textBoxAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP)
{
Vector2 textboxSize = size ?? this.Size ?? new Vector2(1.2f, 0.5f);
MyGuiControlMultilineText textbox = null;
if (m_enableEdit)
{
textbox = new MyGuiControlMultilineEditableText(
position: textboxSize / 2.0f + (offset ?? Vector2.Zero),
size: textboxSize,
backgroundColor: Color.White.ToVector4(),
textAlign: textAlign,
textBoxAlign: textBoxAlign,
font: MyFontEnum.White);
}
else
{
textbox = new MyGuiControlMultilineText(
position: textboxSize / 2.0f + (offset ?? Vector2.Zero),
size: textboxSize,
backgroundColor: Color.White.ToVector4(),
textAlign: textAlign,
textBoxAlign: textBoxAlign,
selectable: m_enableEdit,
font: MyFontEnum.White);
}
Controls.Add(textbox);
return textbox;
}
示例14: CreateFactionsPageControls
//.........这里部分代码省略.........
{
OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
Position = new Vector2(-0.05f, top),
Size = new Vector2(0.5f, 0.69f),
Name = "compositeFaction"
};
left += spacingH;
top += spacingV;
var factionNamePanel = new MyGuiControlPanel()
{
OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
Position = new Vector2(left, top),
Size = new Vector2(factionComposite.Size.X - 0.012f, 0.035f),
BackgroundTexture = MyGuiConstants.TEXTURE_HIGHLIGHT_DARK,
Name = "panelFactionName"
};
var factionName = new MyGuiControlLabel(
originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
position: new Vector2(left + spacingH, top),
size: factionNamePanel.Size - new Vector2(0.01f, 0.01f)
) { Name = "labelFactionName" };
top += factionsLabel.Size.Y + (2f * spacingV);
var size = factionNamePanel.Size - new Vector2(0.14f, 0.01f);
var factionDescLabel = new MyGuiControlLabel(
originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
position: new Vector2(left, top),
size: factionNamePanel.Size - new Vector2(0.01f, 0.01f)
) { Name = "labelFactionDesc" };
top += factionDescLabel.Size.Y + spacingV;
var factionDesc = new MyGuiControlMultilineText(
textBoxAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
textAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
textScale: MyGuiConstants.TOOL_TIP_TEXT_SCALE,
position: new Vector2(left, top),
size: new Vector2(size.X, 0.08f)
)
{
OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
Name = "textFactionDesc",
};
top += factionDesc.Size.Y + 2f * spacingV;
var factionPrivateLabel = new MyGuiControlLabel(
originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
position: new Vector2(left, top),
size: factionNamePanel.Size - new Vector2(0.01f, 0.01f)
) { Name = "labelFactionPrivate" };
top += factionPrivateLabel.Size.Y + spacingV;
var factionPrivate = new MyGuiControlMultilineText(
textBoxAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
textAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
textScale: MyGuiConstants.TOOL_TIP_TEXT_SCALE,
position: new Vector2(left, top),
size: new Vector2(size.X, 0.08f)
)
{
OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
Name = "textFactionPrivate",
};
top += factionDesc.Size.Y + 0.0275f;
示例15: PasteText
public void PasteText(MyGuiControlMultilineText sender)
{
//First we erase the selection
EraseText(sender);
var prefix = sender.Text.ToString().Substring(0, sender.CarriagePositionIndex);
var suffix = sender.Text.ToString().Substring(sender.CarriagePositionIndex);
Thread myth;
myth = new Thread(new System.Threading.ThreadStart(PasteFromClipboard));
myth.ApartmentState = ApartmentState.STA;
myth.Start();
//We have to wait for the thread to end to make sure we got the text
myth.Join();
sender.Text = new StringBuilder(prefix).Append(Regex.Replace(ClipboardText, "\r\n", " \n")).Append(suffix);
sender.CarriagePositionIndex = prefix.Length + ClipboardText.Length;
Reset(sender);
}