Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
FOL Parser - Form1.vb

Form1.vb

Caricato da: Totem
Scarica il programma completo

  1. Public Class Form1
  2.     Dim Sol As New SecondOrderParser()
  3.     Dim Fol As New FirstOrderParser()
  4.     Dim General As Parser
  5.  
  6.     Private CurrentFile As String = ""
  7.  
  8.     Private Sub btnCompose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCompose.Click
  9.         If Not String.IsNullOrEmpty(General.LoadedFileName) Then
  10.             txtSentence.Text = General.CreateSentence(nudWordsNumber.Value)
  11.         Else
  12.             MessageBox.Show("Nessun file caricato!", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
  13.         End If
  14.     End Sub
  15.  
  16.     Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoad.Click
  17.         Dim Open As New OpenFileDialog
  18.         Open.Filter = "File di testo|*.txt"
  19.         If Open.ShowDialog = Windows.Forms.DialogResult.OK Then
  20.             CurrentFile = Open.FileName
  21.             If General.LoadedFileName = CurrentFile Then
  22.                 MessageBox.Show("Questo testo è già stato caricato!", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
  23.                 Exit Sub
  24.             End If
  25.             General.Clear()
  26.             General.Parse(Open.FileName)
  27.             lblStatus.Text = "Parsing completato"
  28.             btnCompose.Enabled = True
  29.         End If
  30.     End Sub
  31.  
  32.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  33.         General = Sol
  34.     End Sub
  35.  
  36.     Private Sub rdbFirst_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rdbFirst.CheckedChanged
  37.         If rdbFirst.Checked Then
  38.             General = Fol
  39.         Else
  40.             General = Sol
  41.         End If
  42.         If General.LoadedFileName <> CurrentFile Then
  43.             lblStatus.Text = "Dopo lo scambio di parser, caricare nuovamente il file"
  44.             btnCompose.Enabled = False
  45.         ElseIf Not String.IsNullOrEmpty(General.LoadedFileName) Then
  46.             lblStatus.Text = "Parsing già eseguito"
  47.             btnCompose.Enabled = True
  48.         End If
  49.     End Sub
  50. End Class