Download DigitalRuneTextEditorBatHighlighting.zip, last updated 23/06/2014 (19.59 KB)

Download
  • md5: c961d4fb5ee06a22c58bc600232d9949
using System;
using System.IO;
using System.Windows.Forms;
using DigitalRune.Windows.TextEditor.Highlighting;
using DigitalRune.Windows.TextEditor.Properties;

// Batch Syntax Highlighting in the DigitalRune Text Editor Control
// http://cyotek.com/blog/batch-syntax-highlighting-in-the-digitalrune-text-editor-control

namespace DigitalRuneTextEditorBatHighlighting
{
  public partial class MainForm : Form
  {
    #region Public Constructors

    public MainForm()
    {
      InitializeComponent();
    }

    #endregion

    #region Event Handlers

    private void MainForm_Load(object sender, EventArgs e)
    {
      string definitionsFolder;

      // load in the custom definitions
      definitionsFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "definitions");
      HighlightingManager.Manager.AddSyntaxModeFileProvider(new FileSyntaxModeProvider(definitionsFolder));

      // setup the text editor control
      textEditorControl.Document.HighlightingStrategy = HighlightingManager.Manager.FindHighlighter("Batch");
      textEditorControl.ShowSpaces = true;
      textEditorControl.ShowTabs = true;
      textEditorControl.ShowMatchingBracket = true;
      textEditorControl.LineViewerStyle = LineViewerStyle.FullRow;
      textEditorControl.ShowHRuler = true;
    }

    private void exitToolStripMenuItem_Click(object sender, EventArgs e)
    {
      this.Close();
    }

    private void openToolStripMenuItem_Click(object sender, EventArgs e)
    {
      if (openFileDialog.ShowDialog(this) == DialogResult.OK)
      {
        textEditorControl.LoadFile(openFileDialog.FileName);
      }
    }

    #endregion
  }
}

Donate

Donate