I am trying to implement custom syntax highlighting programmatically as shown here:
https://help.syncfusion.com/windowsforms/syntax-editor/syntax-highlighting#configure-custom-language-using-code
I can't work out how to simply change the default text color. Using the Config.xml method you can accomplish this with:
<formats>
<format name="Text" Font="Consolas, 12pt"/>
</formats>
What is the equivalent of this using IConfigLanguage / ISnippetFormat / ConfigLexem?
I tried this:
ISnippetFormat thetext = this.editControl1.Language.Add("text");
thetext.FontColor = Color.Blue;
thetext.Font = new Font("Consolas", 12);
But it's not working for me. I think it's because I need to assign this custom format to something as well?
From what I understand, the below code would change all occurances of the word "stuff" to have a back color of blue:
IConfigLanguage currentConfigLanguage = this.editControl1.Configurator.CreateLanguageConfiguration("Custom_Language");
this.editControl1.ApplyConfiguration(currentConfigLanguage);
ISnippetFormat formatMethod = this.editControl1.Language.Add("BlueBackColor");
formatMethod.Font = new Font("Consolas", 12);
formatMethod.BackColor = Color.Blue;
ConfigLexem stuff = new ConfigLexem("stuff", "", FormatType.Custom, false);
stuff.FormatName = "BlueBackColor";
this.editControl1.Language.Lexems.Add(stuff);
this.editControl1.Language.ResetCaches();
But what I don't understand is how I can apply a custom ISnippetFormat instance to all default text. The examples only show how to link a format method to a ConfigLexem.
Here are my questions:
- How do I change the default text color of EditControl programmatically?
- What are ALL the ways I can use an ISnippetFormat other than with ConfigLexem?
Thank you for any help. I am new to C# so apologies if this is too basic. I've tried everything I can think of.