/// <inheritdoc />
 public override ThemeBase Clone() => new Button3dTheme()
 {
     _shade            = _shade.Clone(),
     ControlThemeState = ControlThemeState.Clone(),
     ShowEnds          = ShowEnds,
     EndsThemeState    = EndsThemeState.Clone()
 };
        /// <inheritdoc />
        public override void UpdateAndDraw(ControlBase control, TimeSpan time)
        {
            if (!(control is Button button))
            {
                return;
            }
            if (!button.IsDirty)
            {
                return;
            }

            RefreshTheme(control.FindThemeColors(), control);
            ColoredGlyph appearance = ControlThemeState.GetStateAppearance(control.State);

            int middle = button.Height != 1 ? button.Height / 2 : 0;

            var shadowBounds = new Rectangle(0, 0, button.Width, button.Height).WithPosition((2, 1));

            button.Surface.Clear();

            if (appearance.Matches(ControlThemeState.MouseDown))
            {
                middle += 1;

                // Redraw the control
                button.Surface.Fill(shadowBounds,
                                    appearance.Foreground,
                                    appearance.Background,
                                    appearance.Glyph, null);

                button.Surface.Print(shadowBounds.X, middle, button.Text.Align(button.TextAlignment, button.Width));
                button.MouseArea = new Rectangle(0, 0, button.Width + 2, button.Height + 1);
            }
            else
            {
                // Redraw the control
                button.Surface.Fill(new Rectangle(0, 0, button.Width, button.Height),
                                    appearance.Foreground,
                                    appearance.Background,
                                    appearance.Glyph, null);

                button.Surface.Print(0, middle, button.Text.Align(button.TextAlignment, button.Width));

                // Bottom line
                button.Surface.DrawLine(new Point(shadowBounds.X, shadowBounds.MaxExtentY),
                                        new Point(shadowBounds.MaxExtentX, shadowBounds.MaxExtentY), _shade.Glyph, _shade.Foreground, _shade.Background);

                // Side line 1
                button.Surface.DrawLine(new Point(shadowBounds.MaxExtentX - 1, shadowBounds.Y),
                                        new Point(shadowBounds.MaxExtentX, shadowBounds.MaxExtentY), _shade.Glyph, _shade.Foreground, _shade.Background);

                // Side line 2
                button.Surface.DrawLine(new Point(shadowBounds.MaxExtentX, shadowBounds.Y),
                                        new Point(shadowBounds.MaxExtentX, shadowBounds.MaxExtentY), _shade.Glyph, _shade.Foreground, _shade.Background);

                button.MouseArea = new Rectangle(0, 0, button.Width, button.Height);
            }

            button.IsDirty = false;
        }
Example #3
0
 /// <inheritdoc />
 public override ThemeBase Clone()
 {
     return(new HueBar()
     {
         ControlThemeState = ControlThemeState.Clone()
     });
 }
Example #4
0
 /// <inheritdoc />
 public override ThemeBase Clone() => new LabelTheme()
 {
     ControlThemeState      = ControlThemeState.Clone(),
     UseNormalStateOnly     = UseNormalStateOnly,
     DecoratorStrikethrough = DecoratorStrikethrough,
     DecoratorUnderline     = DecoratorUnderline
 };
Example #5
0
 /// <inheritdoc />
 public override ThemeBase Clone()
 {
     return(new ColorPicker()
     {
         ControlThemeState = ControlThemeState.Clone()
     });
 }
Example #6
0
 /// <inheritdoc />
 public override ThemeBase Clone() => new ButtonTheme()
 {
     ShowEnds          = ShowEnds,
     ControlThemeState = ControlThemeState.Clone(),
     EndsThemeState    = EndsThemeState.Clone(),
     RightEndGlyph     = RightEndGlyph,
     LeftEndGlyph      = LeftEndGlyph
 };
Example #7
0
        /// <inheritdoc />
        public override void RefreshTheme(Colors themeColors, ControlBase control)
        {
            base.RefreshTheme(themeColors, control);

            ControlThemeState.SetForeground(ControlThemeState.Normal.Foreground);
            ControlThemeState.SetBackground(ControlThemeState.Normal.Background);

            ControlThemeState.Disabled = _colorsLastUsed.Appearance_ControlDisabled.Clone();
        }
Example #8
0
 /// <inheritdoc />
 public override ThemeBase Clone() => new ScrollBarTheme()
 {
     ControlThemeState          = ControlThemeState.Clone(),
     StartButtonVerticalGlyph   = StartButtonVerticalGlyph,
     EndButtonVerticalGlyph     = EndButtonVerticalGlyph,
     StartButtonHorizontalGlyph = StartButtonHorizontalGlyph,
     EndButtonHorizontalGlyph   = EndButtonHorizontalGlyph,
     BarGlyph    = BarGlyph,
     SliderGlyph = SliderGlyph
 };
Example #9
0
 /// <inheritdoc />
 public override ThemeBase Clone() => new RadioButtonTheme()
 {
     ControlThemeState  = ControlThemeState.Clone(),
     BracketsThemeState = BracketsThemeState.Clone(),
     IconThemeState     = IconThemeState.Clone(),
     CheckedIconColor   = CheckedIconColor,
     UncheckedIconColor = UncheckedIconColor,
     CheckedIconGlyph   = CheckedIconGlyph,
     UncheckedIconGlyph = UncheckedIconGlyph
 };
Example #10
0
        /// <inheritdoc />
        public override void UpdateAndDraw(ControlBase control, TimeSpan time)
        {
            if (!control.IsDirty)
            {
                return;
            }
            if (!(control is Label label))
            {
                return;
            }

            RefreshTheme(control.FindThemeColors(), control);
            ColoredGlyph appearance;

            if (!UseNormalStateOnly)
            {
                appearance = ControlThemeState.GetStateAppearance(control.State);
            }
            else
            {
                appearance = ControlThemeState.Normal;
            }

            label.Surface.Fill(label.TextColor ?? appearance.Foreground, appearance.Background, 0);
            label.Surface.Print(0, 0, label.DisplayText.Align(label.Alignment, label.Surface.Width));

            IFont font  = label.AlternateFont ?? label.Parent?.Host?.ParentConsole?.Font;
            Color color = label.TextColor ?? appearance.Foreground;

            if (font != null)
            {
                if (label.ShowUnderline && label.ShowStrikethrough)
                {
                    label.Surface.SetDecorator(0, label.Surface.Width, GetStrikethrough(font, color), GetUnderline(font, color));
                }
                else if (label.ShowUnderline)
                {
                    label.Surface.SetDecorator(0, label.Surface.Width, GetUnderline(font, color));
                }
                else if (label.ShowStrikethrough)
                {
                    label.Surface.SetDecorator(0, label.Surface.Width, GetStrikethrough(font, color));
                }
            }

            label.IsDirty = false;
        }
        /// <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 #12
0
        /// <inheritdoc />
        public override void UpdateAndDraw(ControlBase control, TimeSpan time)
        {
            if (!(control is DrawingArea drawingSurface))
            {
                return;
            }

            RefreshTheme(control.FindThemeColors(), control);

            if (!UseNormalStateOnly)
            {
                Appearance = ControlThemeState.GetStateAppearance(control.State);
            }
            else
            {
                Appearance = ControlThemeState.Normal;
            }

            drawingSurface.OnDraw?.Invoke(drawingSurface, time);
            control.IsDirty = false;
        }
Example #13
0
        /// <inheritdoc />
        public override void UpdateAndDraw(ControlBase control, TimeSpan time)
        {
            if (SkipDrawing || !(control is Panel))
            {
                return;
            }

            RefreshTheme(control.FindThemeColors(), control);

            if (!UseNormalStateOnly)
            {
                Appearance = ControlThemeState.GetStateAppearance(control.State);
            }
            else
            {
                Appearance = ControlThemeState.Normal;
            }

            control.Surface.Fill(Appearance.Foreground, Appearance.Background, Appearance.Glyph);

            control.IsDirty = false;
        }
Example #14
0
        /// <inheritdoc />
        public override void UpdateAndDraw(ControlBase control, TimeSpan time)
        {
            if (!(control is Button button))
            {
                return;
            }
            if (!button.IsDirty)
            {
                return;
            }

            RefreshTheme(control.FindThemeColors(), control);
            ColoredGlyph appearance         = ControlThemeState.GetStateAppearance(control.State);
            ColoredGlyph endGlyphAppearance = EndsThemeState.GetStateAppearance(control.State);

            int middle = (button.Height != 1 ? button.Height / 2 : 0);

            // Redraw the control
            button.Surface.Fill(
                appearance.Foreground,
                appearance.Background,
                appearance.Glyph, null);

            if (ShowEnds && button.Width >= 3)
            {
                var lines = control.State == ControlStates.Disabled ? appearance.Foreground : _colorsLastUsed.Lines;
                button.Surface.Print(1, middle, (button.Text).Align(button.TextAlignment, button.Width - 2));
                button.Surface.SetCellAppearance(0, middle, endGlyphAppearance);
                button.Surface[0, middle].Glyph = LeftEndGlyph;
                button.Surface.SetCellAppearance(button.Width - 1, middle, endGlyphAppearance);
                button.Surface[button.Width - 1, middle].Glyph = RightEndGlyph;
            }
            else
            {
                button.Surface.Print(0, middle, button.Text.Align(button.TextAlignment, button.Width));
            }

            button.IsDirty = false;
        }
Example #15
0
 /// <inheritdoc />
 public override ThemeBase Clone() => new ProgressBarTheme()
 {
     ControlThemeState = ControlThemeState.Clone(),
     Foreground        = Foreground?.Clone(),
     Background        = Background?.Clone()
 };
Example #16
0
 /// <inheritdoc />
 public override ThemeBase Clone() =>
 new ColorBar()
 {
     ControlThemeState = ControlThemeState.Clone()
 };
Example #17
0
 /// <inheritdoc />
 public override ThemeBase Clone() => new PanelTheme()
 {
     ControlThemeState  = ControlThemeState.Clone(),
     UseNormalStateOnly = UseNormalStateOnly,
     SkipDrawing        = SkipDrawing
 };
Example #18
0
 /// <inheritdoc />
 public override ThemeBase Clone() => new DrawingAreaTheme()
 {
     ControlThemeState  = ControlThemeState.Clone(),
     UseNormalStateOnly = UseNormalStateOnly
 };
Example #19
0
        /// <inheritdoc />
        public override void UpdateAndDraw(ControlBase control, TimeSpan time)
        {
            if (!(control is ScrollBar scrollbar))
            {
                return;
            }

            if (!scrollbar.IsDirty)
            {
                return;
            }

            RefreshTheme(control.FindThemeColors(), control);

            ColoredGlyph appearance = ControlThemeState.GetStateAppearance(scrollbar.State);

            scrollbar.Surface.Clear();

            if (scrollbar.Orientation == Orientation.Horizontal)
            {
                scrollbar.Surface.SetCellAppearance(0, 0, appearance);
                scrollbar.Surface.SetGlyph(0, 0, StartButtonVerticalGlyph);

                scrollbar.Surface.SetCellAppearance(scrollbar.Width - 1, 0, appearance);
                scrollbar.Surface.SetGlyph(scrollbar.Width - 1, 0, EndButtonVerticalGlyph);

                if (scrollbar.SliderBarSize != 0)
                {
                    for (int i = 1; i <= scrollbar.SliderBarSize; i++)
                    {
                        scrollbar.Surface.SetCellAppearance(i, 0, appearance);
                        scrollbar.Surface.SetGlyph(i, 0, BarGlyph);
                    }

                    if (scrollbar.IsEnabled)
                    {
                        scrollbar.Surface.SetCellAppearance(1 + scrollbar.CurrentSliderPosition, 0, appearance);
                        scrollbar.Surface.SetGlyph(1 + scrollbar.CurrentSliderPosition, 0, SliderGlyph);
                    }
                }
            }
            else
            {
                scrollbar.Surface.SetCellAppearance(0, 0, appearance);
                scrollbar.Surface.SetGlyph(0, 0, StartButtonHorizontalGlyph);

                scrollbar.Surface.SetCellAppearance(0, scrollbar.Height - 1, appearance);
                scrollbar.Surface.SetGlyph(0, scrollbar.Height - 1, EndButtonHorizontalGlyph);

                if (scrollbar.SliderBarSize != 0)
                {
                    for (int i = 0; i < scrollbar.SliderBarSize; i++)
                    {
                        scrollbar.Surface.SetCellAppearance(0, i + 1, appearance);
                        scrollbar.Surface.SetGlyph(0, i + 1, BarGlyph);
                    }

                    if (scrollbar.IsEnabled)
                    {
                        scrollbar.Surface.SetCellAppearance(0, 1 + scrollbar.CurrentSliderPosition, appearance);
                        scrollbar.Surface.SetGlyph(0, 1 + scrollbar.CurrentSliderPosition, SliderGlyph);
                    }
                }
            }

            if (scrollbar.IsSliding)
            {
                scrollbar.MouseArea = new Rectangle(-2, -2, scrollbar.Width + 4, scrollbar.Height + 4);
            }
            else
            {
                scrollbar.MouseArea = new Rectangle(0, 0, scrollbar.Width, scrollbar.Height);
            }

            scrollbar.IsDirty = false;
        }
 /// <inheritdoc />
 public override ThemeBase Clone() => new SurfaceViewerTheme()
 {
     ControlThemeState = ControlThemeState.Clone(),
 };