Я оцениваю элемент управления RadRichTextBox от Telerik. Моя основная цель - добавить блоки кода в произвольном формате.
Поэтому я создал свои собственные стили и зарегистрировал их. (см. код ниже)
Проблема: Хотя я могу установить стиль для ключевых слов и комментариев, я не знаю, как стилизовать шрифт для «обычного кода».
Как вы можете видеть ниже, я установил стиль для каждого возможного "ClassificationType", но "нормальный код" остается без стиля.
В результате ключевые слова и комментарии имеют желаемый размер шрифта и цвет, но «нормальный код» не имеет стиля.
Мой вопрос: Как мне установить стиль шрифта в блоке кода для "нормального кода"?
StyleDefinition styleKeyWord = new StyleDefinition(cl.GetCodeLanguage.Name + "StyleKeyword", StyleType.Character);
styleKeyWord.SpanProperties.ForeColor = DarkTheme.LanguageColorKeyword;
styleKeyWord.SpanProperties.FontFamily = DarkTheme.LanguageFontFamily;
styleKeyWord.SpanProperties.FontSize = Unit.PointToDip(DarkTheme.LanguageFontSize);
StyleDefinition styleString = new StyleDefinition(cl.GetCodeLanguage.Name + "StyleString", StyleType.Character);
styleString.SpanProperties.ForeColor = DarkTheme.LanguageColorString;
styleString.SpanProperties.FontFamily = DarkTheme.LanguageFontFamily;
styleString.SpanProperties.FontSize = Unit.PointToDip(DarkTheme.LanguageFontSize);
StyleDefinition styleComment = new StyleDefinition(cl.GetCodeLanguage.Name + "StyleComment", StyleType.Character);
styleComment.SpanProperties.ForeColor = DarkTheme.LanguageColorComment;
styleComment.SpanProperties.FontFamily = DarkTheme.LanguageFontFamily;
styleComment.SpanProperties.FontSize = Unit.PointToDip(DarkTheme.LanguageFontSize);
StyleDefinition styleMethod = new StyleDefinition(cl.GetCodeLanguage.Name + "styleMethod", StyleType.Character);
styleMethod.SpanProperties.ForeColor = DarkTheme.LanguageColorString;
styleMethod.SpanProperties.FontFamily = DarkTheme.LanguageFontFamily;
styleMethod.SpanProperties.FontSize = Unit.PointToDip(DarkTheme.LanguageFontSize);
document.CodeFormatter.RegisterClassificationType(ClassificationTypes.Attributes, codeLanguage, styleComment);
document.CodeFormatter.RegisterClassificationType(ClassificationTypes.CharacterLiteral, codeLanguage, styleComment);
document.CodeFormatter.RegisterClassificationType(ClassificationTypes.Comment, codeLanguage, styleComment); //Ok
document.CodeFormatter.RegisterClassificationType(ClassificationTypes.Constants, codeLanguage, styleComment);
document.CodeFormatter.RegisterClassificationType(ClassificationTypes.Data, codeLanguage, styleComment);
document.CodeFormatter.RegisterClassificationType(ClassificationTypes.ExcludedCode, codeLanguage, styleComment);
document.CodeFormatter.RegisterClassificationType(ClassificationTypes.Identifier, codeLanguage, styleComment);
document.CodeFormatter.RegisterClassificationType(ClassificationTypes.Keyword, codeLanguage, styleKeyWord); //Ok
document.CodeFormatter.RegisterClassificationType(ClassificationTypes.Literal, codeLanguage, styleComment);
document.CodeFormatter.RegisterClassificationType(ClassificationTypes.Method, codeLanguage, styleMethod);
document.CodeFormatter.RegisterClassificationType(ClassificationTypes.NumberLiteral, codeLanguage, styleComment);
document.CodeFormatter.RegisterClassificationType(ClassificationTypes.Operator, codeLanguage, styleComment);
document.CodeFormatter.RegisterClassificationType(ClassificationTypes.PreprocessorKeyword, codeLanguage, styleComment);
document.CodeFormatter.RegisterClassificationType(ClassificationTypes.StringLiteral, codeLanguage, styleString);
document.CodeFormatter.RegisterClassificationType(ClassificationTypes.Variable, codeLanguage, styleComment);
document.CodeFormatter.RegisterClassificationType(ClassificationTypes.WhiteSpace, codeLanguage, styleComment);