示例#1
0
        internal virtual void UpdateOnce(SpriteBatch spriteBatch)
        {
            this.spriteBatch = spriteBatch;

            if (Size.X <= 0 || Size.Y <= 0)
            {
                throw new Exception("Components size cannot be less or equal than zero");
            }

            fontRenderer.UpdateOnce(spriteBatch);

            if (NormalComponentTexture != null)
            {
                NormalComponentTexture.CreateTexture(spriteBatch, Vector2.Zero, Size, CornerSize, borderThickness);
            }

            if (HoveredComponentTexture != null)
            {
                HoveredComponentTexture.CreateTexture(spriteBatch, Vector2.Zero, Size, CornerSize, borderThickness);
            }

            if (PressedComponentTexture != null)
            {
                PressedComponentTexture.CreateTexture(spriteBatch, Vector2.Zero, Size, CornerSize, borderThickness);
            }

            CurrentComponentTexture = NormalComponentTexture;

            if (CurrentComponentTexture.RendererMode == ComponentTexture.RenderMode.Scalable)
            {
                Rectangle = new Rectangle((int)Position.X, (int)Position.Y, (int)Size.X, (int)Size.Y);

                if (NormalComponentTexture != null)
                {
                    NormalComponentTexture.Size = this.Size;
                }

                if (HoveredComponentTexture != null)
                {
                    HoveredComponentTexture.Size = this.Size;
                }

                if (PressedComponentTexture != null)
                {
                    PressedComponentTexture.Size = this.Size;
                }
            }
        }