/// <summary> /// append the text string \a text to the RenderedString \a rs. /// </summary> /// <param name="rs"></param> /// <param name="text"></param> private void AppendRenderedText(RenderedString rs, string text) { var cpos = 0; // split the given string into lines based upon the newline character while (text.Length > cpos) { // find next newline var nlpos = text.IndexOf("\n", cpos); // calculate length of this substring var len = ((nlpos != -1) ? nlpos : text.Length) - cpos; // construct new text component and append it. var rtc = new RenderedStringTextComponent(text.Substring(cpos, len), d_fontName); rtc.SetPadding(d_padding); rtc.SetColours(new ColourRect(d_colours)); rtc.SetVerticalFormatting(d_vertAlignment); rtc.SetAspectLock(d_aspectLock); rs.AppendComponent(rtc); // break line if needed if (nlpos != -1) { rs.AppendLineBreak(); } // advance current position. +1 to skip the \n char cpos += len + 1; } }
private void HandleWindow(RenderedString rs, string value) { var rwc = new RenderedStringWidgetComponent(value); rwc.SetPadding(d_padding); rwc.SetVerticalFormatting(d_vertAlignment); rwc.SetAspectLock(d_aspectLock); rs.AppendComponent(rwc); }
private void HandleImage(RenderedString rs, string value) { var ric = new RenderedStringImageComponent(PropertyHelper.FromString <Image>(value)); ric.SetPadding(d_padding); ric.SetColours(d_colours); ric.SetVerticalFormatting(d_vertAlignment); ric.SetSize(d_imageSize); ric.SetAspectLock(d_aspectLock); rs.AppendComponent(ric); }