зеркало из https://github.com/telerik/xaml-sdk.git
42 строки
1.6 KiB
C#
42 строки
1.6 KiB
C#
using System.IO;
|
|
using System.Reflection;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Media;
|
|
using Telerik.Windows.Controls;
|
|
using Telerik.Windows.Controls.SyntaxEditor.Taggers;
|
|
using Telerik.Windows.Controls.SyntaxEditor.UI;
|
|
using Telerik.Windows.DragDrop;
|
|
using Telerik.Windows.SyntaxEditor.Core.Tagging;
|
|
using Telerik.Windows.SyntaxEditor.Core.Text;
|
|
|
|
namespace CustomLanguage
|
|
{
|
|
public partial class MainWindow : Window
|
|
{
|
|
public MainWindow()
|
|
{
|
|
InitializeComponent();
|
|
|
|
var assembly = Assembly.GetExecutingAssembly();
|
|
using (Stream stream = assembly.GetManifestResourceStream("CustomLanguage.script.py"))
|
|
{
|
|
using (StreamReader reader = new StreamReader(stream))
|
|
{
|
|
this.syntaxEditor.Document = new TextDocument(reader);
|
|
}
|
|
}
|
|
|
|
var pythonTagger = new PythonTagger(this.syntaxEditor);
|
|
if (!this.syntaxEditor.TaggersRegistry.IsTaggerRegistered(pythonTagger))
|
|
{
|
|
this.syntaxEditor.TaggersRegistry.RegisterTagger(pythonTagger);
|
|
}
|
|
|
|
this.syntaxEditor.TextFormatDefinitions.AddLast(ClassificationTypes.NumberLiteral, new TextFormatDefinition(new SolidColorBrush(Colors.Red)));
|
|
this.syntaxEditor.TextFormatDefinitions.AddLast(ClassificationTypes.Operator, new TextFormatDefinition(new SolidColorBrush(Colors.YellowGreen)));
|
|
this.syntaxEditor.TextFormatDefinitions.AddLast(PythonTagger.FruitsClassificationType, new TextFormatDefinition(new SolidColorBrush(Colors.LightCoral)));
|
|
}
|
|
}
|
|
}
|