private static extern void Internal_settextVertAlign(IntPtr thisPtr, TextVertAlign value);
private static extern void Internal_SetTextVertAlign(IntPtr nativeInstance, TextVertAlign value);
public void DrawText(string text, Point position, Color color, Rectangle?bounds, float rotation, Point origin, float scale, TextHoriAlign horiAlign = TextHoriAlign.Left, TextVertAlign vertAlign = TextVertAlign.Bottom, SpriteEffects spriteEffects = SpriteEffects.None, float layerDepth = 0f) { Vector2 textSize = this.Font.MeasureString(text); textSize = new Vector2(textSize.X * scale, textSize.Y * scale); if (bounds == null) { bounds = new Rectangle(origin, new Point((int)Math.Ceiling(textSize.X), (int)Math.Ceiling(textSize.Y))); } Vector2 vOrigin = new Vector2(0, 0); switch (horiAlign) { case TextHoriAlign.Left: vOrigin.X = origin.X; break; case TextHoriAlign.Middle: vOrigin.X -= origin.X - (bounds.Value.Width / 2 - textSize.X / 2); break; case TextHoriAlign.Right: vOrigin.X -= origin.X - (bounds.Value.Width - textSize.X); break; } switch (vertAlign) { case TextVertAlign.Top: vOrigin.Y -= origin.Y; break; case TextVertAlign.Middle: vOrigin.Y -= origin.Y - (bounds.Value.Height / 2 - textSize.Y / 2); break; case TextVertAlign.Bottom: vOrigin.Y -= origin.Y - (bounds.Value.Height - textSize.Y); break; } this.sb.DrawString(this.Font, text, new Vector2(position.X, position.Y) + vOrigin, color, rotation, Vector2.Zero, scale, spriteEffects, layerDepth); }
public void DrawText(string text, Point position, Color color, int fontSize, Rectangle bounds, TextHoriAlign horiAlign = TextHoriAlign.Left, TextVertAlign vertAlign = TextVertAlign.Bottom) { float scale = (float)fontSize / RenderContext.FONT_SIZE; this.DrawText(text, position, color, bounds, 0f, Point.Zero, scale, horiAlign, vertAlign); }
public UIButton() : base() { this.HorizontalAlign = TextHoriAlign.Middle; this.VerticalAlign = TextVertAlign.Middle; this.HoverColor = new Color(1f, 1f, 1f, 0.3f); }
private static extern void Internal_SetTextVertAlign(IntPtr nativeInstance, TextVertAlign value);