//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
     {
     }
 }
        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;
                }
            }
        }
 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
     {
     }
 }
 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;
 }
 /// <summary>
 /// Generates multiline text control indicating that block is not available.
 /// </summary>
 /// <param name="blockSizeLarge">Is block size large.</param>
 /// <returns>Multiline text control with block not available info.</returns>
 private MyGuiControlMultilineText GenerateSizeNotAvailableText(bool blockSizeLarge)
 {
     MyGuiControlMultilineText textControl = new MyGuiControlMultilineText(size: new Vector2(0.2f, 0.1f), font: MyFontEnum.Red, showTextShadow: true, textAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
     string blockTypeLabelText = MyTexts.GetString(!blockSizeLarge ? MySpaceTexts.HudBlockInfo_LargeShip_Station : MySpaceTexts.HudBlockInfo_SmallShip);
     textControl.AppendText(string.Format(MyTexts.GetString(MySpaceTexts.BlockSize_NotAvailable), blockTypeLabelText));
     return textControl;
 }
        public void RecreateControls()
        {
            if (QuestInfo == null || Elements == null)
                return;
            Elements.Clear();

            Vector2 topleft = -this.Size / 2;
            Vector2 textOffset = new Vector2(0.015f, 0.015f);

            // Title
            MyGuiControlLabel title = new MyGuiControlLabel();
            title.Text = QuestInfo.QuestTitle;
            title.Position = topleft + textOffset;
            title.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            title.Visible = true;
            Elements.Add(title);

            // Pages
            if (QuestInfo.MaxPages != 0)
            {
                MyGuiControlLabel numbers = new MyGuiControlLabel();
                numbers.Text = QuestInfo.Page + "/" + QuestInfo.MaxPages;
                numbers.Position = topleft + Vector2.UnitX * this.Size - textOffset * new Vector2(1, -1);
                numbers.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP;
                Elements.Add(numbers);
            }

            // Separator
            MyGuiControlSeparatorList m_separator;
            m_separator = new MyGuiControlSeparatorList();
            m_separator.AddHorizontal(topleft + textOffset + new Vector2(0, 0.03f), this.Size.X - 2 * textOffset.X, 0.003f); // Title separator
            m_separator.Visible = true;
            Elements.Add(m_separator);

            // Details
            var rowOffset = new Vector2(0, 0.025f);
            string[] details = QuestInfo.GetQuestGetails();
            int idx = 0;
            for (int i = 0; i < details.Length; i++)
            {
                if (details[i] == null)
                    continue;
                MyGuiControlMultilineText textBox = new MyGuiControlMultilineText(
                    size: new Vector2(Size.X * 0.92f, rowOffset.Y * 5),
                    position: topleft + textOffset + new Vector2(0, 0.04f) + rowOffset * idx,
                    textAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                    textBoxAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                    //Debug purpose
                    //backgroundColor: Vector4.One,
                    //backgroundTexture: BackgroundTexture,
                    drawScrollbar: false
                    );
                textBox.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
                textBox.TextScale = 0.9f;
                textBox.AppendText(details[i]);
                textBox.Visible = true;
                idx += textBox.NumberOfRows;
                Elements.Add(textBox);
            }
        }