Exemple #1
0
        public override void Draw(SpriteBatch spriteBatch)
        {
            if (TextureAtlas == null)
            {
                switch (State)
                {
                case ButtonState.None:
                    spriteBatch.FillRectangle(BoundingRect, Color.Red);
                    break;

                case ButtonState.Hovered:
                    spriteBatch.FillRectangle(BoundingRect, Color.Green);
                    break;

                case ButtonState.Pressed:
                    spriteBatch.FillRectangle(BoundingRect, Color.Blue);
                    break;

                case ButtonState.Clicking:
                    spriteBatch.FillRectangle(BoundingRect, Color.Wheat);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            else
            {
                DrawAtlas(spriteBatch);
            }

            if (!string.IsNullOrEmpty(Text) && Font != null)
            {
                spriteBatch.DrawString(Font, Text, BoundingRect.ToRectangle(), Color.Black, TextAlignment.Center);
            }

            base.Draw(spriteBatch);
        }