Imports Microsoft.VisualBasic
Public Class InterpForm
  Inherits System.Windows.Forms.Form
  Private kdata As KidData

  Private Sub init()
    kdata = New KidData("50free.txt")
  End Sub

#Region " Windows Form Designer generated code "

  Public Sub New()
    MyBase.New()

    'This call is required by the Windows Form Designer.
    InitializeComponent()

    'Add any initialization after the InitializeComponent() call
    init()
  End Sub

  'Form overrides dispose to clean up the component list.
  Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
    If disposing Then
      If Not (components Is Nothing) Then
        components.Dispose()
      End If
    End If
    MyBase.Dispose(disposing)
  End Sub
  Friend WithEvents Compute As System.Windows.Forms.Button
  Friend WithEvents txCommand As System.Windows.Forms.TextBox
  Friend WithEvents lsResults As System.Windows.Forms.ListBox

  'Required by the Windows Form Designer
  Private components As System.ComponentModel.Container

  'NOTE: The following procedure is required by the Windows Form Designer
  'It can be modified using the Windows Form Designer.  
  'Do not modify it using the code editor.
  <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    Me.txCommand = New System.Windows.Forms.TextBox()
    Me.Compute = New System.Windows.Forms.Button()
    Me.lsResults = New System.Windows.Forms.ListBox()
    Me.SuspendLayout()
    '
    'txCommand
    '
    Me.txCommand.Location = New System.Drawing.Point(24, 16)
    Me.txCommand.Name = "txCommand"
    Me.txCommand.Size = New System.Drawing.Size(216, 20)
    Me.txCommand.TabIndex = 0
    Me.txCommand.Text = " "
    '
    'Compute
    '
    Me.Compute.Location = New System.Drawing.Point(88, 48)
    Me.Compute.Name = "Compute"
    Me.Compute.Size = New System.Drawing.Size(88, 24)
    Me.Compute.TabIndex = 1
    Me.Compute.Text = "Compute"
    '
    'lsResults
    '
    Me.lsResults.Location = New System.Drawing.Point(8, 88)
    Me.lsResults.Name = "lsResults"
    Me.lsResults.Size = New System.Drawing.Size(272, 173)
    Me.lsResults.TabIndex = 2
    '
    'InterpForm
    '
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(292, 277)
    Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.lsResults, Me.Compute, Me.txCommand})
    Me.Name = "InterpForm"
    Me.Text = "Interpreter demo"
    Me.ResumeLayout(False)

  End Sub

#End Region

  Private Sub Compute_Click(ByVal sender As System.Object, _
          ByVal e As System.EventArgs) Handles Compute.Click
    parse()                       'Wywołaj analizator
  End Sub
  '-----
  Private Sub parse()
    'Parsuj polecenia wprowadzone w polu tekstowym
    Dim par As New Parser( _
            txCommand.Text, kdata, lsResults)
    par.Execute()
  End Sub

  Private Sub txCommand_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txCommand.KeyDown
    'Naciśnięcie Enter powoduje rozpoczęcie analizy
    Dim key As Integer
    key = e.KeyCode
    If key = Keys.Enter Then
      parse()                     'Wywołaj analizator
    End If
  End Sub
End Class
