Option Strict On
Option Explicit On

Imports System

Namespace Nexamas.UI.TextInput

    ' CONTRACT:
    ' One undoable text operation.
    ' BeforeSnapshot is restored by Undo.
    ' AfterSnapshot is restored by Redo.
    ' The unit may be merged only by MASTextUndoManager.
    Friend NotInheritable Class MASTextUndoUnit

        Friend ReadOnly Property Kind As MASTextEditKind
        Friend ReadOnly Property BeforeSnapshot As MASTextInputSnapshot
        Friend Property AfterSnapshot As MASTextInputSnapshot
        Friend ReadOnly Property CreatedTick As Integer
        Friend Property LastMergedTick As Integer

        Friend Sub New(kind As MASTextEditKind,
                       beforeSnapshot As MASTextInputSnapshot,
                       afterSnapshot As MASTextInputSnapshot)

            If beforeSnapshot Is Nothing Then Throw New ArgumentNullException(NameOf(beforeSnapshot))
            If afterSnapshot Is Nothing Then Throw New ArgumentNullException(NameOf(afterSnapshot))

            Me.Kind = kind
            Me.BeforeSnapshot = beforeSnapshot
            Me.AfterSnapshot = afterSnapshot
            Me.CreatedTick = Nexamas.UI.Timing.MASInteractionClock.TickCount()
            Me.LastMergedTick = Me.CreatedTick
        End Sub

    End Class

End Namespace
