Imports System
Imports System.ComponentModel
Imports System.Drawing
Imports System.Windows.Forms
Imports System.Collections

Public Class UndoCommand
  Implements Command
  Private undoList As ArrayList

  Public Sub New()
    MyBase.New()
    undoList = New ArrayList()
  End Sub

  Public Sub add(ByVal cmd As Command)
    If Not (cmd.isUndo) Then
      undoList.Add(cmd)
    End If
  End Sub

  Public Sub Execute() Implements Command.Execute
    Dim Index As Integer
    Dim cmd As Command
    Index = undoList.Count - 1

    If Index >= 0 Then
      cmd = CType(undoList(Index), Command)
      cmd.Undo()
      undoList.RemoveAt(Index)

    End If
  End Sub

  Public Function isUndo() As Boolean Implements Command.isUndo
    Return True
  End Function


  Private Sub Undo() Implements Command.Undo
    'Pusta
  End Sub

End Class
