Hi,
I’m trying to change some of the highlight colors when using the dark theme to match the vs2019 dark style.
For example, I’ve attached the following image: 
I would like to change the colors of the “if” and “return” statements and also the GetZoneValue method.
I’ve looked at the “Customize” demo, but I do not find which item to change for these statements.
Thanks for your help
Hi,
You can either change these lexical styles after applying dark theme with the code like this:
syntaxEdit1.VisualThemeType = Alternet.Editor.VisualThemeType.Dark;
ApplyColorStyles();
private void ApplyColorStyles()
{
Alternet.Syntax.Lexer.ILexStyle style = GetStyleByName(syntaxEdit1.Lexer?.Scheme?.Styles, Alternet.Common.StringConsts.ReswordsInternalName);
if (style != null)
style.ForeColor = System.Drawing.Color.Red;
style = GetStyleByName(syntaxEdit1.Lexer?.Scheme?.Styles, Alternet.Syntax.Parsers.Roslyn.ParserConsts.MethodInternalName);
if (style != null)
style.ForeColor = System.Drawing.Color.Red;
}
private Alternet.Syntax.Lexer.ILexStyle GetStyleByName(Alternet.Syntax.Lexer.ILexStyles styles, string name)
{
if (styles == null)
return null;
for (int i = 0; i < styles.Count; i++)
{
if (string.Compare(styles[i].Name, name, true) == 0)
return styles[i];
}
return null;
}
Or implement your own custom theme with the code like this:
syntaxEdit1.VisualThemeType = Alternet.Editor.VisualThemeType.Custom;
syntaxEdit1.VisualTheme = new CustomVisualTheme("MyCustomTheme");
public class CustomVisualTheme : Alternet.Editor.StandardVisualTheme
{
public CustomVisualTheme(string name, System.Drawing.Font font = null)
: base(name, font)
{
}
protected override Alternet.Editor.VisualThemeColors GetColors()
{
var colors = Alternet.Editor.DarkVisualTheme.Instance.Colors.Clone();
colors.Reswords = System.Drawing.Color.Red;
colors.WindowBackground = System.Drawing.Color.FromArgb(40, 40, 40);
return colors;
}
}
Regards,
Andrew
Thank you, this is working properly.
As reference for other people, the style item that need to be changed for the if/else and return statements is ParserConsts.ControlKeywordInternalName