/// <summary> /// Renders text to the screen /// </summary> /// <param name="rect">The shape of box to render the text in</param> /// <param name="text">The text to render</param> /// <param name="style">The TextAreaStyle used to render this text</param> internal static void InternalTextArea(RectangleShape rect, string text, GUITextArea.GUITextAreaStyle style) { Bitmap textBitmap = new Bitmap((int)rect.Width, (int)rect.Height); Graphics g = Graphics.FromImage(textBitmap); g.FillRectangle(ActiveInstance.GetColouredBrush(style.Colour), 0, 0, rect.Width, rect.Height); g.DrawString(text, new Font(GetFontFamily(style.FontFamilyId), style.FontSize, FontStyle.Regular), ActiveInstance.GetColouredBrush(style.FontColour), new Rectangle(0, 0, (int)rect.Width, (int)rect.Height), ActiveInstance.GenerateTextFormat(style.HorizontalAlignment, style.VerticalAlignment)); Sprite textSprite = Sprite.LoadFromBitmap(textBitmap); textSprite.Create(false); // Border operation GUIOperation borderOperation = new GUIOperation(0, 1); borderOperation.Bounds = rect; borderOperation.DrawLevel = 1; borderOperation.Sprite = Sprite.DefaultSprite; borderOperation.Colour = style.Border.Colour; // Text operation GUIOperation operation = new GUIOperation(1, 1); operation.Bounds = new RectangleShape(rect.X + style.Border.Left, rect.Y + style.Border.Up, rect.Width - (style.Border.Left + style.Border.Right), rect.Height - (style.Border.Up + style.Border.Bottom)); operation.DrawLevel = 1; operation.Sprite = textSprite; operation.Colour = Colour4b.White; g.Dispose(); textBitmap.Dispose(); ActiveInstance.m_guiOperations.Add(borderOperation); ActiveInstance.m_guiOperations.Add(operation); }
internal GUITextArea.GUITextAreaStyle ConvertToGUITextStyle() { GUITextArea.GUITextAreaStyle style = new GUITextArea.GUITextAreaStyle(); style.Border = Border; style.Colour = new Colour4b(Colour.R, Colour.G, Colour.B, 0); style.FontColour = FontColour; style.FontFamilyId = FontFamilyId; style.FontSize = FontSize; style.HorizontalAlignment = HorizontalAlignment.Left; style.VerticalAlignment = VerticalAlignment.Middle; style.Scrollable = false; style.ScrollPosition = 0.0f; return(style); }
internal GUITextArea.GUITextAreaStyle ConvertToGUITextStyle() { GUITextArea.GUITextAreaStyle style = new GUITextArea.GUITextAreaStyle(); style.Border = Border; style.Colour = Colour; style.FontColour = FontColour; style.FontFamilyId = FontFamilyId; style.FontSize = FontSize; style.HorizontalAlignment = HorizontalAlignment; style.VerticalAlignment = VerticalAlignment; style.Scrollable = Scrollable; style.ScrollPosition = ScrollPosition; return(style); }