/// <inheritdoc />
        public override void UpdateAndDraw(ControlBase control, TimeSpan time)
        {
            if (!(control is ToggleButtonBase checkbox))
            {
                return;
            }
            if (!control.IsDirty)
            {
                return;
            }

            RefreshTheme(control.FindThemeColors(), control);

            ColoredGlyph appearance        = ControlThemeState.GetStateAppearance(checkbox.State);
            ColoredGlyph bracketAppearance = BracketsThemeState.GetStateAppearance(checkbox.State);
            ColoredGlyph iconAppearance    = IconThemeState.GetStateAppearance(checkbox.State);

            checkbox.Surface.Fill(appearance.Foreground, appearance.Background, null);

            // If we are doing text, then print it otherwise we're just displaying the button part
            if (checkbox.Width <= 2)
            {
                iconAppearance.CopyAppearanceTo(checkbox.Surface[0, 0]);
            }

            if (checkbox.Width >= 3)
            {
                bracketAppearance.CopyAppearanceTo(checkbox.Surface[0, 0]);
                iconAppearance.CopyAppearanceTo(checkbox.Surface[1, 0]);
                bracketAppearance.CopyAppearanceTo(checkbox.Surface[2, 0]);

                checkbox.Surface[0, 0].Glyph = LeftBracketGlyph;
                checkbox.Surface[2, 0].Glyph = RightBracketGlyph;
            }

            if (checkbox.Width >= 5)
            {
                checkbox.Surface.Print(4, 0, checkbox.Text.Align(checkbox.TextAlignment, checkbox.Width - 4));
            }

            checkbox.IsDirty = false;
        }
Example #2
0
            private void SetEditCell(ColoredGlyph cell)
            {
                if (cell == null)
                {
                    return;
                }

                cell.CopyAppearanceTo(this[Width - 3, Height - 3]);

                IsDirty = true;
            }