public void TestLocateOpeningWithin() { OpeningLocator locator = new OpeningLocator(); Vector2 helloSize = this.unitTestSpriteFont.MeasureString("he"); int openingIndex = locator.FindClosestOpening( this.unitTestSpriteFont, "hello world", helloSize.X ); Assert.AreEqual(2, openingIndex); }
public void TestLocateOpeningBefore() { OpeningLocator locator = new OpeningLocator(); int openingIndex = locator.FindClosestOpening( this.unitTestSpriteFont, "hello world", -10.0f ); Assert.AreEqual(0, openingIndex); }
public void TestLocateOpeningWithin() { OpeningLocator locator = new OpeningLocator(); Vector2 helloSize = this.unitTestSpriteFont.MeasureString("he"); int openingIndex = locator.FindClosestOpening( this.unitTestSpriteFont, "hello world", helloSize.X ); Assert.AreEqual(2, openingIndex); }
public void TestLocateOpeningOnSingleCharacter() { OpeningLocator locator = new OpeningLocator(); Vector2 xSize = this.unitTestSpriteFont.MeasureString("X"); int openingIndex = locator.FindClosestOpening( this.unitTestSpriteFont, "X", xSize.X / 3.0f ); Assert.AreEqual(0, openingIndex); openingIndex = locator.FindClosestOpening( this.unitTestSpriteFont, "X", xSize.X / 3.0f * 2.0f ); Assert.AreEqual(1, openingIndex); }
/// <summary>Initializes a new gui painter</summary> /// <param name="contentManager">Content manager containing the resources for the GUI. The instance takes ownership of the content manager and will dispose it.</param> /// <param name="skinStream">Stream from which the skin description will be read</param> public MultiGuiGraphics(ContentManager contentManager, Stream skinStream) { IGraphicsDeviceService graphicsDeviceService = (IGraphicsDeviceService)contentManager.ServiceProvider.GetService(typeof(IGraphicsDeviceService)); this.spriteBatch = new SpriteBatch(graphicsDeviceService.GraphicsDevice); this.contentManager = contentManager; this.openingLocator = new OpeningLocator(); this.stringBuilder = new StringBuilder(64); this.scissorManager = new ScissorKeeper(this); this.rasterizerState = new RasterizerState() { ScissorTestEnable = true }; this.fonts = new Dictionary<string, SpriteFont>(); this.bitmaps = new Dictionary<string, Texture2D>(); this.frames = new Dictionary<string, Frame>(); loadSkin(skinStream); }
public void TestLocateOpeningBefore() { OpeningLocator locator = new OpeningLocator(); int openingIndex = locator.FindClosestOpening( this.unitTestSpriteFont, "hello world", -10.0f ); Assert.AreEqual(0, openingIndex); }
public void TestLocateOpeningOnSingleCharacter() { OpeningLocator locator = new OpeningLocator(); Vector2 xSize = this.unitTestSpriteFont.MeasureString("X"); int openingIndex = locator.FindClosestOpening( this.unitTestSpriteFont, "X", xSize.X / 3.0f ); Assert.AreEqual(0, openingIndex); openingIndex = locator.FindClosestOpening( this.unitTestSpriteFont, "X", xSize.X / 3.0f * 2.0f ); Assert.AreEqual(1, openingIndex); }