Public Class FrmPrinc
    Inherits System.Windows.Forms.Form



#Region " Code généré par le Concepteur Windows Form "

    Public Sub New()
        MyBase.New()

        'Cet appel est requis par le Concepteur Windows Form.
        InitializeComponent()

        'Ajoutez une initialisation quelconque après l'appel InitializeComponent()

    End Sub

    'La méthode substituée Dispose du formulaire pour nettoyer la liste des composants.
    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

    'Requis par le Concepteur Windows Form
    Private components As System.ComponentModel.IContainer

    'REMARQUE : la procédure suivante est requise par le Concepteur Windows Form
    'Elle peut être modifiée en utilisant le Concepteur Windows Form.  
    'Ne la modifiez pas en utilisant l'éditeur de code.
    Friend WithEvents TxtSrc As System.Windows.Forms.TextBox
    Friend WithEvents CmdCalc As System.Windows.Forms.Button
    Friend WithEvents TxtDest As System.Windows.Forms.TextBox
    Friend WithEvents CmdAbout As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.TxtSrc = New System.Windows.Forms.TextBox
        Me.CmdCalc = New System.Windows.Forms.Button
        Me.TxtDest = New System.Windows.Forms.TextBox
        Me.CmdAbout = New System.Windows.Forms.Button
        Me.SuspendLayout()
        '
        'TxtSrc
        '
        Me.TxtSrc.Location = New System.Drawing.Point(0, 2)
        Me.TxtSrc.Name = "TxtSrc"
        Me.TxtSrc.Size = New System.Drawing.Size(362, 20)
        Me.TxtSrc.TabIndex = 0
        Me.TxtSrc.Text = "TextBox1"
        '
        'CmdCalc
        '
        Me.CmdCalc.Location = New System.Drawing.Point(61, 30)
        Me.CmdCalc.Name = "CmdCalc"
        Me.CmdCalc.Size = New System.Drawing.Size(226, 36)
        Me.CmdCalc.TabIndex = 1
        Me.CmdCalc.Text = "&Calculer"
        '
        'TxtDest
        '
        Me.TxtDest.Font = New System.Drawing.Font("Courier New", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.TxtDest.Location = New System.Drawing.Point(1, 71)
        Me.TxtDest.Multiline = True
        Me.TxtDest.Name = "TxtDest"
        Me.TxtDest.ReadOnly = True
        Me.TxtDest.ScrollBars = System.Windows.Forms.ScrollBars.Both
        Me.TxtDest.Size = New System.Drawing.Size(391, 174)
        Me.TxtDest.TabIndex = 2
        Me.TxtDest.Text = "TextBox2"
        '
        'CmdAbout
        '
        Me.CmdAbout.Location = New System.Drawing.Point(313, 32)
        Me.CmdAbout.Name = "CmdAbout"
        Me.CmdAbout.Size = New System.Drawing.Size(70, 24)
        Me.CmdAbout.TabIndex = 3
        Me.CmdAbout.Text = "&A propos"
        '
        'FrmPrinc
        '
        Me.AcceptButton = Me.CmdCalc
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(441, 315)
        Me.Controls.Add(Me.CmdAbout)
        Me.Controls.Add(Me.TxtDest)
        Me.Controls.Add(Me.TxtSrc)
        Me.Controls.Add(Me.CmdCalc)
        Me.Name = "FrmPrinc"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "Calculateur d'equations booléennes et de table de vérité"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub CmdCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdCalc.Click
        Dim lStr As String = TxtSrc.Text
        Dim lEqu As TEquation()
        Dim i As Integer
        Dim j As Integer

        Try
            If lStr <> "" Then
                lStr = lStr.Replace("*", " ")
                lStr = lStr.Replace(".", " ")
                lStr = lStr.Replace("-", " ")
                lStr = lStr.Replace("+", " ")
                lStr = lStr.Replace("(", " ")
                lStr = lStr.Replace(")", " ")
                lStr = lStr.Replace("0", " ")
                lStr = lStr.Replace("1", " ")
                lStr = lStr.Replace("/", " ")
                lStr = lStr.Trim
                If lStr <> "" Then
                    lEqu = CalcBoolTablExpParam(TxtSrc.Text)
                    lStr = ""
                    With lEqu(0).Params
                        For i = 0 To .GetUpperBound(0)
                            lStr += CType(.GetValue(i), TValue).Orig + "|"
                        Next
                        lStr += "|Sortie" + vbCrLf
                    End With

                    For i = 0 To lEqu.GetUpperBound(0)
                        With lEqu(i)
                            For j = 0 To .Params.GetUpperBound(0)
                                lStr += .Params(j).Dest + Space(.Params(j).Orig.Length - .Params(j).Dest.Length) + "|"
                            Next
                            lStr += "|" + .Result + vbCrLf
                        End With
                    Next


                    TxtDest.Text = lStr
                Else
                    TxtDest.Text = CalcBooleanExpression(TxtSrc.Text)
                End If
            End If
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub

    Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize
        With TxtSrc
            .Top = 0
            .Left = 0
            .Height = 16
            .Width = Me.ClientSize.Width
        End With
        With CmdCalc
            .Left = 0
            .Top = TxtSrc.Height
            .Height = 20
            .Width = TxtSrc.Width - CmdAbout.Width
        End With
        With CmdAbout
            .Left = CmdCalc.Width
            .Top = CmdCalc.Top
            .Height = 20
            '.Width = 
        End With
        With TxtDest
            .Left = 0
            .Top = CmdCalc.Top + CmdCalc.Height
            .Height = Me.ClientSize.Height - .Top
            .Width = TxtSrc.Width
        End With
    End Sub
    Private Sub CmdAbout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdAbout.Click
        Dim lFrm As New FrmAbout
        lFrm.ShowDialog()
        lFrm = Nothing
    End Sub
End Class
