ProjectsForTest/WPF.NET5TeeChart-NET-Pro-Samples/TeeChart.Xaml.WPF Demo/MainWindow.xaml.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System.IO;
using System.Windows;
using System.Windows.Media;
using GalaSoft.MvvmLight;
using ICSharpCode.AvalonEdit;
using ICSharpCode.AvalonEdit.Highlighting;
using XamlWPFDemo.ViewModel;

namespace XamlWPFDemo
{
  public partial class MainWindow
  {
    public MainWindow()
    {
      InitializeComponent();

      VisualStudioStyle(CodeEditor);

      UpdateCodeEditor((MainViewModel)DataContext);
      ((ViewModelBase)DataContext).PropertyChanged += (sender, args) =>
      {
        if (args.PropertyName == "File")
        {
          UpdateCodeEditor((MainViewModel)sender);
        }
      };
    }

    private void UpdateCodeEditor(MainViewModel vm)
    {
      if (vm.File == null) return;
      var extension = Path.GetExtension(vm.File);
      CodeEditor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinitionByExtension(extension);
      CodeEditor.Load(Path.Combine("..\\..\\..\\Demos", vm.File));
    }

    private void VisualStudioStyle(TextEditor editor)
    {
      // TODO: Style XAML to VisualStudio as well...
      var syntaxHighlighting = HighlightingManager.Instance.GetDefinitionByExtension(".cs");

      var keywords = new[]
      {
        "ValueTypeKeywords", "ReferenceTypeKeywords", "ThisOrBaseReference", "NullOrValueKeywords", "Keywords",
        "GotoKeywords", "ContextKeywords", "ExceptionKeywords", "CheckedKeyword", "UnsafeKeywords", "OperatorKeywords",
        "ParameterModifiers", "Modifiers", "Visibility", "NamespaceKeywords", "GetSetAddRemove", "TrueFalse",
        "TypeKeywords"
      };

      foreach (var keyword in keywords)
      {
        var color = syntaxHighlighting.GetNamedColor(keyword);
        color.Foreground = new SimpleHighlightingBrush(Colors.Blue);
        color.FontWeight = FontWeights.Normal;
      }

      syntaxHighlighting.GetNamedColor("String").Foreground = new SimpleHighlightingBrush(Colors.Brown);
      syntaxHighlighting.GetNamedColor("Char").Foreground = new SimpleHighlightingBrush(Colors.Brown);
      syntaxHighlighting.GetNamedColor("Preprocessor").Foreground = new SimpleHighlightingBrush(Colors.LightGray);
      syntaxHighlighting.GetNamedColor("NumberLiteral").Foreground = new SimpleHighlightingBrush(Colors.Black);

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。