The built-in fonts incorrectly named themselves IBM_16x8, even though the glyphs were 8x16. The name has been corrected in SadConsole. If you deserialize an object and it can't find the IBM_16x8 font you have two solutions:
- Edit the json and fix the font name.
- Use the configuration
FixOldFontName()option.
The theme concept has been removed from v10. If you had a control with its own theme, you need to migrate the theme code to the control itself. Here are some tips and notes:
-
ControlThemeStatechanges toThemeState -
_colorsLastUsedwas declared by the theme whenRefreshThemewas called. This member no longer exists andRefreshThemehas changed. If you used this member, instead declare aColorsobject in theUpdateAndRedrawmethod:Colors _colorsLastUsed = FindThemeColors();This resolves any references to_colorsLastUsed. Next, rename the variable to something more useful likecolorsorcurrentColors. -
If
GetOffColoris used, this has been moved fromThemeStateto theColorsclass, for example,currentColors.GetOffColor -
If your theme declared various properties, variables, and methods, move them to the control. I suggest making the control a partial class, then creating a new class with the file name
.Theme.csappended. For example, SadConsole has theCheckbox.csandCheckbox.Theme.csfiles. The "theme" code file contains all of the properties, methods, and variables used to draw the control.
When drawing a control override the UpdateAndRedraw method and do the following:
-
Check if
IsDirty == falseand return. -
Get the current colors for the control
Colors currentColors = FindThemeColors(); -
Call
RefreshThemeStateColors(currentColors);If migrating a v9 theme, override
RefreshThemeStateColorsand copy any code in the theme'sRefreshThememethod (if overridden). -
(If migrating a v9 theme)
- Copy any code in the theme's
UpdateAndDrawmethod. - If your code used the
controlparameter or castcontrolto a specific type, do a find and replace operation withcontrol.and a blank value. You no longer need to reference the control since the drawing code now lives in the control itself. - Replace references of
ControlThemeStatewithThemeState.
- Copy any code in the theme's
-
Draw the control by using the
Surfaceproperty. -
Set
IsDirty = false
Here is the drawing code for the button control:
public override void UpdateAndRedraw(TimeSpan time)
{
// Step 1
if (!IsDirty) return;
// Step 2
Colors currentColors = FindThemeColors();
// Step 3
RefreshThemeStateColors(currentColors);
// Steps 4 and 5: Draw the control
ColoredGlyph appearance = ThemeState.GetStateAppearance(State);
ColoredGlyph endGlyphAppearance = ThemeState.GetStateAppearance(State);
endGlyphAppearance.Foreground = currentColors.Lines;
int middle = (Height != 1 ? Height / 2 : 0);
// Redraw the control
Surface.Fill(
appearance.Foreground,
appearance.Background,
appearance.Glyph, null);
if (ShowEnds && Width >= 3)
{
Surface.Print(1, middle, Text.Align(TextAlignment, Width - 2));
Surface.SetCellAppearance(0, middle, endGlyphAppearance);
Surface[0, middle].Glyph = LeftEndGlyph;
Surface.SetCellAppearance(Width - 1, middle, endGlyphAppearance);
Surface[Width - 1, middle].Glyph = RightEndGlyph;
}
else
Surface.Print(0, middle, Text.Align(TextAlignment, Width));
// Step 6
IsDirty = false;
}