Skip to content

How to change a label based on console size? #3236

Answered by RonSijm
RonSijm asked this question in Q&A
Discussion options

You must be logged in to vote

Ok, I simply got it to work now by creating this class:

public class HeaderLabel : Label
{
    private bool? _currentLayout;

    private const string HorizontalBanner = "";

    private const string VerticalBanner ="VerticalBanner";

    public HeaderLabel()
    {
        DrawBanner();
    }

    public override bool OnDrawFrames()
    {
        DrawBanner();
        return base.OnDrawFrames();
    }

    public void DrawBanner()
    {
        var horizonLayout = LayoutSizes.HorizontalLayout;

        if (_currentLayout == horizonLayout)
        {
            return;
        }

        _currentLayout = horizonLayout;
        Text = horizonLayout ? HorizontalBanner : VerticalBanner;
    }
}

Replies: 2 comments 12 replies

Comment options

You must be logged in to vote
12 replies
@dodexahedron
Comment options

@BDisp
Comment options

@dodexahedron
Comment options

@RonSijm
Comment options

Answer selected by RonSijm
@RonSijm
Comment options

@dodexahedron
Comment options

@dodexahedron
Comment options

@RonSijm
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants