public MenuElement(string id, Rectangle bounds, Color hover, Color fill, Color border, Color font, string text, string fontId, FontAlignment alignment ) { this.id = id; hoverColor = hover; fillColor = fill; borderColor = border; fontColor = font; this.text = text; this.bounds = bounds; this.fontId = fontId; this.alignment = alignment; }
/// <inheritdoc /> /// <summary> /// Aplica o alinhamento especificado /// </summary> /// <param name="alignment">Alinhamento para ser aplicado</param> public virtual void SetAlignment(FontAlignment alignment) { // If "keep current" justification is set, do nothing if (alignment == FontAlignment.NOP) { return; } Alignment = alignment; if (JustificationCommands.ContainsKey(alignment)) { byte[] cmd = JustificationCommands[alignment]; if (cmd != null) { internalSend(cmd); } } }
/// <summary> /// OnDraw text on scene /// </summary> /// <param name="batch">The batch.</param> /// <param name="font">The font.</param> /// <param name="position">The position.</param> /// <param name="alignment">The alignment.</param> /// <param name="color">The color.</param> /// <param name="input">The input.</param> public static void DrawFont(this SpriteBatch batch, BitmapFont font, Vector2 position, FontAlignment alignment, Color color, string input) { var tempPos = Vector2.Zero; using (var reader = new StringReader(input)) { tempPos.X = position.X; tempPos.Y = position.Y + font.Offset.Y; // -(FontHeight / 2); string line; while ((line = reader.ReadLine()) != null) { switch (alignment) { case FontAlignment.Left: tempPos.X += font.Offset.X; break; case FontAlignment.Center: { var size = font.MeasureString(line); tempPos.X -= (int) (size.X/2) - font.Offset.X; break; } case FontAlignment.Right: { var size = font.MeasureString(line); tempPos.X -= size.X - font.Offset.Width; break; } default: // do the defalut action break; } font.DrawLine(batch, tempPos, color, line); tempPos.X = position.X; tempPos.Y += font.FontHeight + font.VerticalGap; } } }
public LoadScreenTypeData(string Tag = null) : base(Tag) { Type = new LoadScreenTypeEnum(); X = new UInt32(); Y = new UInt32(); Width = new UInt32(); Height = new UInt32(); Orientation = new Single(); Font1 = new FontType(); Font1Red = new Single(); Font1Green = new Single(); Font1Blue = new Single(); Font1Alignment = new FontAlignment(); Unknown1 = new byte[20]; Font2 = new FontType(); Font2Red = new Single(); Font2Green = new Single(); Font2Blue = new Single(); Unknown2 = new byte[4]; Stats = new UInt32(); }
public override void SetImage(Imaging.PrinterImage image, IDocument doc, int index, FontAlignment justification) { while (index > doc.Sections.Count) { doc.Sections.Add(new Placeholder()); } doc.Sections[index] = new GenericImageSection() { Image = image, Justification = justification }; }
public static void DrawTextLines(string theText, Color textColor, Color bgColor, Font font, FontAlignment fontAlignment, Rectangle toDraw) { //SwinGame.DrawText(theText, textColor, font, toDraw.X, toDraw.Y,); SwinGame.DrawText(theText, textColor, bgColor, font, fontAlignment, toDraw); //throw new NotImplementedException(); }
public static void DrawText(string text, Font font, Color color, int x, int y, int width, FontAlignment align = FontAlignment.AlignLeft) { Text.DrawTextLines(text, Color.Black, Color.Transparent, font, align, x + 1, y + 1, width, font.TextHeight(text)); Text.DrawTextLines(text, color, Color.Transparent, font, align, x, y, width, font.TextHeight(text)); }
public LoadScreenTypeData(LoadScreenTypeEnum Type, UInt32 X, UInt32 Y, UInt32 Width, UInt32 Height, Single Orientation, FontType Font1, Single Font1Red, Single Font1Green, Single Font1Blue, FontAlignment Font1Alignment, Byte[] Unknown1, FontType Font2, Single Font2Red, Single Font2Green, Single Font2Blue, Byte[] Unknown2, UInt32 Stats) { this.Type = Type; this.X = X; this.Y = Y; this.Width = Width; this.Height = Height; this.Orientation = Orientation; this.Font1 = Font1; this.Font1Red = Font1Red; this.Font1Green = Font1Green; this.Font1Blue = Font1Blue; this.Font1Alignment = Font1Alignment; this.Unknown1 = Unknown1; this.Font2 = Font2; this.Font2Red = Font2Red; this.Font2Green = Font2Green; this.Font2Blue = Font2Blue; this.Unknown2 = Unknown2; this.Stats = Stats; }
/// <summary> /// Draws text using this font, at a given position /// </summary> public override void Write( float x, float y, float z, FontAlignment align, Color colour, string str ) { Point3 screenPt = Graphics.Renderer.Project( new Point3( x, y, z ) ); Write( ( int )screenPt.X, ( int )screenPt.Y, align, colour, str ); }
public abstract void Write( float x, float y, float z, FontAlignment alignment, Color colour, string str );
/// <summary> /// OnDraw text on scene /// </summary> /// <param name="batch">The batch.</param> /// <param name="font">The font.</param> /// <param name="position">Position to begin drawing</param> /// <param name="alignment">The alignment.</param> /// <param name="input">A formated string</param> /// <param name="args">Optional parameters for the formated string</param> public static void DrawFont(this SpriteBatch batch, BitmapFont font, Vector2 position, FontAlignment alignment, string input, params object[] args) { batch.DrawFont(font, position, alignment, font.Color, String.Format(CultureInfo.CurrentCulture, input, args)); }
/// <summary> /// OnDraw text on scene /// </summary> /// <param name="batch">The batch.</param> /// <param name="font">The font.</param> /// <param name="position">The position.</param> /// <param name="alignment">The alignment.</param> /// <param name="color">The color.</param> /// <param name="input">The input.</param> public static void DrawString(this SpriteBatch batch, SpriteFont font, Vector2 position, FontAlignment alignment, Color color, string input, int gap = 2) { Vector2 tempPos = Vector2.Zero; using (StringReader reader = new StringReader(input)) { tempPos.X = position.X; tempPos.Y = position.Y;// -(FontHeight / 2); string line; while ((line = reader.ReadLine()) != null) { var size = font.MeasureString(line); switch (alignment) { case FontAlignment.Center: { tempPos.X -= (int)(size.X / 2); } break; case FontAlignment.Right: { tempPos.X -= size.X; } break; } batch.DrawString(font, line, tempPos, color); tempPos.X = position.X; tempPos.Y += size.Y + gap; } } }
/// <summary> /// OnDraw text on scene /// </summary> /// <param name="batch">The batch.</param> /// <param name="font">The font.</param> /// <param name="position">The position.</param> /// <param name="alignment">The alignment.</param> /// <param name="color">The color.</param> /// <param name="input">The input.</param> public static void DrawFont(this SpriteBatch batch, BitmapFont font, Vector2 position, FontAlignment alignment, Color color, string input) { Vector2 tempPos = Vector2.Zero; using (StringReader reader = new StringReader(input)) { tempPos.X = position.X; tempPos.Y = position.Y + font.Offset.Y;// -(FontHeight / 2); string line; while ((line = reader.ReadLine()) != null) { switch (alignment) { case FontAlignment.Left: tempPos.X += font.Offset.X; break; case FontAlignment.Center: { var size = font.MeasureString(line); tempPos.X -= (int)(size.X / 2) - font.Offset.X; break; } case FontAlignment.Right: { var size = font.MeasureString(line); tempPos.X -= size.X - font.Offset.Width; break; } default: // do the defalut action break; } font.DrawLine(batch, tempPos, color, line); tempPos.X = position.X; tempPos.Y += font.FontHeight + font.VerticalGap; } } }
/// <summary> /// OnDraw text on scene /// </summary> /// <param name="batch">The batch.</param> /// <param name="font">The font.</param> /// <param name="position">Position to begin drawing</param> /// <param name="alignment">The alignment.</param> /// <param name="input">A formated string</param> /// <param name="args">Optional parameters for the formated string</param> public static void DrawFont(this SpriteBatch batch, BitmapFont font, Vector2 position, FontAlignment alignment, string input, params object[] args) { batch.DrawFont(font, position, alignment, font.Color, string.Format(CultureInfo.CurrentCulture, input, args)); }
/// <summary> /// OnDraw text on scene /// </summary> /// <param name="batch">The batch.</param> /// <param name="font">The font.</param> /// <param name="position">The position.</param> /// <param name="alignment">The alignment.</param> /// <param name="color">The color.</param> /// <param name="input">The input.</param> public static void DrawString(this SpriteBatch batch, SpriteFont font, Vector2 position, FontAlignment alignment, Color color, string input, int gap = 2) { var tempPos = Vector2.Zero; using (var reader = new StringReader(input)) { tempPos.X = position.X; tempPos.Y = position.Y; // -(FontHeight / 2); string line; while ((line = reader.ReadLine()) != null) { var size = font.MeasureString(line); switch (alignment) { case FontAlignment.Center: { tempPos.X -= (int) (size.X/2); } break; case FontAlignment.Right: { tempPos.X -= size.X; } break; } batch.DrawString(font, line, tempPos, color); tempPos.X = position.X; tempPos.Y += size.Y + gap; } } }
public void Write( float x, float y, float z, FontAlignment alignment, Color colour, string format, params object[] args ) { Write( x, y, z, FontAlignment.TopLeft, colour, string.Format( format, args ) ); }
public abstract void Write( int x, int y, FontAlignment alignment, Color colour, string str );
public abstract void SetImage(Imaging.PrinterImage image, IDocument doc, int index, FontAlignment justification);
/// <summary> /// Writes a string to the renderer /// </summary> public override void Write( int x, int y, FontAlignment align, Color colour, string str ) { Graphics.Renderer.Push2d( ); Graphics.Renderer.PushTextures( ); Graphics.Renderer.PushRenderState( m_RenderState ); m_FontTextureSampler.Begin( ); Gl.glColor3ub( colour.R, colour.G, colour.B ); Gl.glBegin( Gl.GL_QUADS ); int curX = x; int curY = y; float rcpWidth = 1.0f / m_FontTextureSampler.Texture.Width; float rcpHeight = 1.0f / m_FontTextureSampler.Texture.Height; AlignText( align, str, ref curX, ref curY ); for ( int charIndex = 0; charIndex < str.Length; ++charIndex ) { char curCh = str[ charIndex ]; if ( curCh == ' ' ) { curX += 8; } CharacterData charData = m_CharacterData[ curCh ]; float u = ( charData.U ) * rcpWidth; float v = ( charData.V ) * rcpHeight; float maxU = u + ( charData.Width ) * rcpWidth; float maxV = v + ( charData.Height ) * rcpWidth; int maxX = curX + charData.Width; int maxY = curY + charData.Height; Gl.glTexCoord2f( u, v ); Gl.glVertex2i( curX, curY ); Gl.glTexCoord2f( maxU, v ); Gl.glVertex2i( maxX, curY ); Gl.glTexCoord2f( maxU, maxV ); Gl.glVertex2i( maxX, maxY ); Gl.glTexCoord2f( u, maxV ); Gl.glVertex2i( curX, maxY ); curX = maxX + 1; } Gl.glEnd( ); m_FontTextureSampler.End( ); Graphics.Renderer.PopTextures( ); Graphics.Renderer.PopRenderState( ); Graphics.Renderer.Pop2d( ); }
/// <summary> /// Create a UIFont that includes it's font, color, and alignment. /// </summary> /// <param name="f">font</param> /// <param name="c">color</param> /// <param name="a">alignment in window.</param> public UIFont(SpriteFont f, Color c, FontAlignment a) { Font = f; FontColor = c; Align = a; }
/// <summary> /// Sets the (x,y) starting position of text, for a given alignment /// </summary> private void AlignText( FontAlignment align, string str, ref int x, ref int y ) { if ( align == FontAlignment.TopLeft ) { return; } Size size = MeasureString( str ); switch ( align ) { case FontAlignment.TopCentre : { x -= size.Width / 2; break; } case FontAlignment.TopRight: { x -= size.Width; break; } case FontAlignment.MiddleLeft : { y -= size.Height / 2; break; } case FontAlignment.MiddleCentre: { x -= size.Width / 2; y -= size.Height / 2; break; } case FontAlignment.MiddleRight: { x -= size.Width; y -= size.Height / 2; break; } case FontAlignment.BottomLeft: { y -= size.Height; break; } case FontAlignment.BottomCentre: { x -= size.Width / 2; y -= size.Height; break; } case FontAlignment.BottomRight: { x -= size.Width; y -= size.Height; break; } } }
//#---------------------------------------------------------- //# * Draw Text //#---------------------------------------------------------- public static void DrawText(string text, Font font, int x, int y, int width, FontAlignment align = FontAlignment.AlignLeft) { DrawText(text, font, Color.White, x, y, width, align); }