Esempio n. 1
0
        protected override void InternalDraw(IGraphicsFragment fragment, IGameEngineTime time)
        {
            var texture     = GetStyleStateTexture();
            var color       = Style.Get <Color>($"{UiStyleKeys.Target.Button}\\{(Enabled ? UiStyleKeys.Color.Enabled : UiStyleKeys.Color.Disabled)}");
            var center      = Style.Get <Rectangle>($"{UiStyleKeys.Target.Button}\\{UiStyleKeys.Source.Center}");
            var font        = Style.Get <SpriteFont>($"{UiStyleKeys.Target.Button}\\{UiStyleKeys.Font.Normal}");
            var destination = GetRenderDestinationRectangle();
            var offset      = GetStyleStateOffset();

            destination.X += offset.X;
            destination.Y += offset.Y;

            fragment.DrawSurface(texture, center, destination, color);

            if (string.IsNullOrEmpty(Text))
            {
                return;
            }

            var position = new Vector2(destination.X, destination.Y) + UiCanvas.ToScreenUnits(ActualSize) * 0.5f - font.MeasureString(Text) * 0.5f;

            fragment.DrawSpriteText(position,
                                    Vector2.One,
                                    0.0f,
                                    Vector2.Zero,
                                    font.MeasureString(Text),
                                    Text,
                                    font,
                                    color);
        }
Esempio n. 2
0
        protected override void InternalDraw(IGraphicsFragment fragment, IGameEngineTime time)
        {
            var texture     = Style.Get <Texture2D>($"{UiStyleKeys.Target.Panel}\\{UiStyleKeys.Texture.Normal}");
            var color       = Style.Get <Color>($"{UiStyleKeys.Target.Panel}\\{(Enabled ? UiStyleKeys.Color.Enabled : UiStyleKeys.Color.Disabled)}");
            var center      = Style.Get <Rectangle>($"{UiStyleKeys.Target.Panel}\\{UiStyleKeys.Source.Center}");
            var destination = GetRenderDestinationRectangle();

            fragment.DrawSurface(texture, center, destination, color);

            base.InternalDraw(fragment, time);
        }