DrawString() public method

public DrawString ( string String, SpriteFont Font, Vector2 Position, Origin Origin, Microsoft.Xna.Framework.Color Fore, Microsoft.Xna.Framework.Color Back = null, float Angle, float Scale = 1, SpriteEffects Effect = SpriteEffects.None, float Layer ) : void
String string
Font Microsoft.Xna.Framework.Graphics.SpriteFont
Position Microsoft.Xna.Framework.Vector2
Origin Origin
Fore Microsoft.Xna.Framework.Color
Back Microsoft.Xna.Framework.Color
Angle float
Scale float
Effect SpriteEffects
Layer float
return void
 public static void Draw(Batch Batch, int Width)
 {
     Start("Profiler");
     int x = (Screen.BackBufferWidth - (Width + 5)), y = 5;
     Batch.DrawRectangle(new Rectangle(x, y, Width, (Screen.BackBufferHeight - 10)), (Color.Black * .8f),
         (Color.White * .8f));
     var String = string.Format("Update FPS: {0} (Avg: {1}) - Draw FPS: {2} (Avg: {3})",
         Math.Round(Performance.UpdateFramesPerSecond), Math.Round(Performance.AverageUpdateFramesPerSecond),
         Performance.DrawFramesPerSecond, Math.Round(Performance.AverageDrawFramesPerSecond));
     var Font = Fonts.Get("Default/ExtraSmall");
     Batch.DrawString(String, Font, new Vector2((x + (Width / 2f)), (y + (Font.MeasureString(String).Y / 2))),
         Origin.Center, (Color.White * .8f), (Color.Black * .8f));
     new Line(new Vector2(x, (y + (int)Font.MeasureString(String).Y)),
         new Vector2((x + Width), (y + (int)Font.MeasureString(String).Y))).Draw(Batch, (Color.White * .8f));
     y += (int)Font.MeasureString(String).Y;
     new Line(new Vector2(x, (y + 20)), new Vector2((x + Width), (y + 20))).Draw(Batch, (Color.White * .8f));
     new Line(new Vector2((x + ((Width / 5) * 2)), y),
         new Vector2((x + ((Width / 5) * 2)), (y + (Screen.BackBufferHeight - 25)))).Draw(Batch, (Color.White * .8f));
     new Line(new Vector2((x + ((Width / 5) * 3)), y),
         new Vector2((x + ((Width / 5) * 3)), (y + (Screen.BackBufferHeight - 25)))).Draw(Batch, (Color.White * .8f));
     new Line(new Vector2((x + ((Width / 5) * 4)), y),
         new Vector2((x + ((Width / 5) * 4)), (y + (Screen.BackBufferHeight - 25)))).Draw(Batch, (Color.White * .8f));
     x += 5;
     Font = Fonts.Get("Default/Small");
     Batch.DrawString("Name", Font, new Vector2(x, y), Origin.None, (Color.White * .8f), (Color.Black * .8f));
     Batch.DrawString("Avg Ms", Font, new Vector2((x + ((Width / 5) * 2)), y), Origin.None, (Color.White * .8f),
         (Color.Black * .8f));
     Batch.DrawString("Avg Sec(s)", Font, new Vector2((x + ((Width / 5) * 3)), y), Origin.None, (Color.White * .8f),
         (Color.Black * .8f));
     Batch.DrawString("Avg Ticks", Font, new Vector2((x + ((Width / 5) * 4)), y), Origin.None, (Color.White * .8f),
         (Color.Black * .8f));
     if (Profiles != null)
         foreach (var Key in Profiles.Keys)
         {
             y += 21;
             new Line(new Vector2((x - 5), (y + 20)), new Vector2((x + Width), (y + 20))).Draw(Batch,
                 (Color.Silver * .4f));
             Batch.DrawString(Key, Font, new Vector2(x, y), Origin.None, (Color.White * .8f), (Color.Black * .8f));
             Batch.DrawString((Math.Round(AverageMilliseconds(Key), 3) + " ms"), Font,
                 new Vector2((x + ((Width / 5) * 2)), y), Origin.None, (Color.White * .8f), (Color.Black * .8f));
             Batch.DrawString((Math.Round(AverageSeconds(Key), 4) + "s"), Font,
                 new Vector2((x + ((Width / 5) * 3)), y), Origin.None, (Color.White * .8f), (Color.Black * .8f));
             var AverageTicksString = AverageTicks(Key).ToString("0,00");
             while (AverageTicksString.StartsWith("0")) AverageTicksString = AverageTicksString.Substring(1);
             Batch.DrawString(AverageTicksString, Font, new Vector2((x + ((Width / 5) * 4)), y), Origin.None,
                 (Color.White * .8f), (Color.Black * .8f));
         }
     Stop("Profiler");
 }
Esempio n. 2
0
 public static void Draw(Batch Batch, SpriteFont Font, Vector2 Position, Origin Origin, Color Fore,
     Color? Back = null, float Angle = 0, float Scale = 1, SpriteEffects Effect = SpriteEffects.None,
     float Layer = 0)
 {
     Batch.DrawString(
         string.Format("Update FPS: {0} (Avg. {1})\nDraw FPS: {2} (Avg. {3})", Math.Round(UpdateFramesPerSecond),
             Math.Round(AverageUpdateFramesPerSecond),
             DrawFramesPerSecond, Math.Round(AverageDrawFramesPerSecond)), Font, Position, Origin, Fore, Back,
         Angle, Scale, Effect, Layer);
 }
Esempio n. 3
0
 public static void DrawString(Batch Batch, string String, SpriteFont Font, Vector2 Position, Origin Origin,
                               Color Fore, Color?Back = null, float Angle = 0, float Scale = 1, SpriteEffects Effect = SpriteEffects.None,
                               float Layer            = 0)
 {
     Batch.DrawString(String, Font, Position, Origin, Fore, Back, Angle, Scale, Effect, Layer);
 }
Esempio n. 4
0
 public static void DrawString(Batch Batch, string String, SpriteFont Font, Vector2 Position, Origin Origin,
     Color Fore, Color? Back = null, float Angle = 0, float Scale = 1, SpriteEffects Effect = SpriteEffects.None,
     float Layer = 0)
 {
     Batch.DrawString(String, Font, Position, Origin, Fore, Back, Angle, Scale, Effect, Layer);
 }