Game1.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System;
  2. using Microsoft.Xna.Framework;
  3. using Microsoft.Xna.Framework.Graphics;
  4. namespace BatteryStatusDemo
  5. {
  6. public class Game1 : Game
  7. {
  8. GraphicsDeviceManager graphics;
  9. SpriteBatch spriteBatch;
  10. SpriteFont font;
  11. public Game1()
  12. {
  13. graphics = new GraphicsDeviceManager(this);
  14. Content.RootDirectory = "Content";
  15. #if __MOBILE__
  16. graphics.IsFullScreen = true;
  17. #endif
  18. }
  19. protected override void Initialize()
  20. {
  21. base.Initialize();
  22. }
  23. protected override void LoadContent()
  24. {
  25. spriteBatch = new SpriteBatch(GraphicsDevice);
  26. font = Content.Load<SpriteFont>("SpriteFont1");
  27. }
  28. protected override void Update(GameTime gameTime)
  29. {
  30. base.Update(gameTime);
  31. }
  32. protected override void Draw(GameTime gameTime)
  33. {
  34. graphics.GraphicsDevice.Clear(Color.CornflowerBlue);
  35. spriteBatch.Begin();
  36. spriteBatch.DrawString(font, "[Battery Status]\n" + PowerStatus.BatteryChargeStatus, new Vector2(10, 100), Color.Black);
  37. spriteBatch.DrawString(font, "[PowerLine Status]\n" + PowerStatus.PowerLineStatus, new Vector2(10, 200), Color.Black);
  38. spriteBatch.DrawString(font, "[Charge]\n" + PowerStatus.BatteryLifePercent + "%", new Vector2(10, 300), Color.Black);
  39. spriteBatch.End();
  40. base.Draw(gameTime);
  41. }
  42. }
  43. }