Table of Contents

Property AutoInsertSnippet

Namespace
Alternet.Editor.Wpf
Assembly
Alternet.Editor.Wpf.v9.dll

AutoInsertSnippet

Gets or sets current ICodeSnippetRange object.

[Browsable(false)]
public virtual ICodeSnippetRange AutoInsertSnippet { get; set; }

Property Value

ICodeSnippetRange

Examples

Here is how to use a AutoInsertSnippet in the C# code:

using System.Windows;
using Alternet.Editor.Wpf;

public partial class MainWindow : Window
{
    private TextSource textSource;
    private void Window_Loaded(object sender, RoutedEventArgs e)
    {
        var textEdit1 = new TextEditor();
        textSource = new TextSource();
        textSource.LoadFile("myfile.txt");
        textEdit1.Source = this.textSource;
        textEdit1.SourceStateChanged += SyntaxEdit_SourceStateChanged;
    }

    private void SyntaxEdit_SourceStateChanged(object sender, NotifyEventArgs e)
    {
        if ((e.State & NotifyState.Edit) != 0)
        {
            if (textSource.AutoInsertSnippet != null)
                MessageBox.Show(textSource.AutoInsertSnippet.ID);
        }
    }
}

Here is how to use a AutoInsertSnippet in the Visual Basic code:

Imports System.Windows
Imports Alternet.Editor.Wpf

Partial Public Class MainWindow
    Inherits Window

    Private textSource As TextSource

    Private Sub Window_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
        Dim textEdit1 = New TextEditor()
        textSource = New TextSource()
        textSource.LoadFile("myfile.txt")
        textEdit1.Source = Me.textSource
        AddHandler textEdit1.SourceStateChanged, AddressOf SyntaxEdit_SourceStateChanged
    End Sub

    Private Sub SyntaxEdit_SourceStateChanged(ByVal sender As Object, ByVal e As NotifyEventArgs)
        If (e.State And NotifyState.Edit) <> 0 Then
            If textSource.AutoInsertSnippet IsNot Nothing Then MessageBox.Show(textSource.AutoInsertSnippet.ID)
        End If
    End Sub
End Class

Remarks

TextEditor can be configured to complete matching braces quote characters, when the user types opening brace, i.e., characters like '{', '[', '"' or '''.

AutoInsertSnippet contains information about the inserted brace or quote character.