' Oefening vlaggenQuiz, slide 59, H4
' Niet gecontrolleerd, but works damnd good :p

Imports System.IO
Imports System.Drawing

Public Class frmVlaggenQuiz
    Inherits System.Windows.Forms.Form

#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

    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

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

    '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.
    Friend WithEvents grpVlag As System.Windows.Forms.GroupBox
    Friend WithEvents imgVlag As System.Windows.Forms.PictureBox
    Friend WithEvents txtKeuze As System.Windows.Forms.ComboBox
    Friend WithEvents cmdControleer As System.Windows.Forms.Button
    Friend WithEvents lblResultaat As System.Windows.Forms.Label
    Friend WithEvents cmdVolgende As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmVlaggenQuiz))
        Me.grpVlag = New System.Windows.Forms.GroupBox()
        Me.imgVlag = New System.Windows.Forms.PictureBox()
        Me.txtKeuze = New System.Windows.Forms.ComboBox()
        Me.cmdControleer = New System.Windows.Forms.Button()
        Me.lblResultaat = New System.Windows.Forms.Label()
        Me.cmdVolgende = New System.Windows.Forms.Button()
        Me.grpVlag.SuspendLayout()
        Me.SuspendLayout()
        '
        'grpVlag
        '
        Me.grpVlag.Controls.AddRange(New System.Windows.Forms.Control() {Me.imgVlag})
        Me.grpVlag.Location = New System.Drawing.Point(16, 16)
        Me.grpVlag.Name = "grpVlag"
        Me.grpVlag.Size = New System.Drawing.Size(184, 160)
        Me.grpVlag.TabIndex = 0
        Me.grpVlag.TabStop = False
        Me.grpVlag.Text = " Vlag"
        '
        'imgVlag
        '
        Me.imgVlag.Image = CType(resources.GetObject("imgVlag.Image"), System.Drawing.Bitmap)
        Me.imgVlag.Location = New System.Drawing.Point(8, 16)
        Me.imgVlag.Name = "imgVlag"
        Me.imgVlag.Size = New System.Drawing.Size(168, 136)
        Me.imgVlag.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage
        Me.imgVlag.TabIndex = 0
        Me.imgVlag.TabStop = False
        '
        'txtKeuze
        '
        Me.txtKeuze.Items.AddRange(New Object() {"Denemarken", "Polen", "Duitsland", "Belgie", "Zweden", "Noorwegen", "Finland", "Engeland", "IJsland"})
        Me.txtKeuze.Location = New System.Drawing.Point(216, 56)
        Me.txtKeuze.Name = "txtKeuze"
        Me.txtKeuze.Size = New System.Drawing.Size(160, 21)
        Me.txtKeuze.TabIndex = 1
        Me.txtKeuze.Text = "Maak uw keuze"
        '
        'cmdControleer
        '
        Me.cmdControleer.Location = New System.Drawing.Point(392, 56)
        Me.cmdControleer.Name = "cmdControleer"
        Me.cmdControleer.Size = New System.Drawing.Size(112, 21)
        Me.cmdControleer.TabIndex = 2
        Me.cmdControleer.Text = "Controleer"
        '
        'lblResultaat
        '
        Me.lblResultaat.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
        Me.lblResultaat.Location = New System.Drawing.Point(216, 112)
        Me.lblResultaat.Name = "lblResultaat"
        Me.lblResultaat.Size = New System.Drawing.Size(160, 21)
        Me.lblResultaat.TabIndex = 3
        '
        'cmdVolgende
        '
        Me.cmdVolgende.Enabled = False
        Me.cmdVolgende.Location = New System.Drawing.Point(392, 112)
        Me.cmdVolgende.Name = "cmdVolgende"
        Me.cmdVolgende.Size = New System.Drawing.Size(112, 21)
        Me.cmdVolgende.TabIndex = 4
        Me.cmdVolgende.Text = "Volgende Vlag"
        '
        'frmVlaggenQuiz
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(520, 190)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.cmdVolgende, Me.lblResultaat, Me.cmdControleer, Me.txtKeuze, Me.grpVlag})
        Me.Name = "frmVlaggenQuiz"
        Me.Text = "VlaggenQuiz"
        Me.grpVlag.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Dim vlaggenArray As String(,) = New String(8, 2) {}
    Dim huidigeVlag As Integer = 0

    Private Sub frmVlaggenQuiz_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        '
        ' Landnamen in array steken
        '
        vlaggenArray(0, 0) = "Belgie"
        vlaggenArray(1, 0) = "Denemarken"
        vlaggenArray(2, 0) = "Duitsland"
        vlaggenArray(3, 0) = "Engeland"
        vlaggenArray(4, 0) = "Finland"
        vlaggenArray(5, 0) = "IJsland"
        vlaggenArray(6, 0) = "Noorwegen"
        vlaggenArray(7, 0) = "Polen"
        vlaggenArray(8, 0) = "Zweden"
        '
        ' Pad naar afbeeldingen in array steken
        '
        vlaggenArray(0, 1) = Directory.GetCurrentDirectory & "\images\Belgie.gif"
        vlaggenArray(1, 1) = Directory.GetCurrentDirectory & "\images\Denemarken.gif"
        vlaggenArray(2, 1) = Directory.GetCurrentDirectory & "\images\Duitsland.gif"
        vlaggenArray(3, 1) = Directory.GetCurrentDirectory & "\images\Engeland.gif"
        vlaggenArray(4, 1) = Directory.GetCurrentDirectory & "\images\Finland.gif"
        vlaggenArray(5, 1) = Directory.GetCurrentDirectory & "\images\IJsland.gif"
        vlaggenArray(6, 1) = Directory.GetCurrentDirectory & "\images\Noorwegen.gif"
        vlaggenArray(7, 1) = Directory.GetCurrentDirectory & "\images\Polen.gif"
        vlaggenArray(8, 1) = Directory.GetCurrentDirectory & "\images\Zweden.gif"

    End Sub


    Function volgendeVlag()
        '
        ' Volgende vlag laten zien
        '
        huidigeVlag += 1
        If huidigeVlag > 8 Then ' Er zijn maar een beperkt aantal vlaggies.. 
            huidigeVlag = 0
        End If
        imgVlag.Image = Image.FromFile(vlaggenArray(huidigeVlag, 1))
        '
        ' Enkele properties instellen
        '
        lblResultaat.Text = ""
        cmdVolgende.Enabled = False
        cmdControleer.Enabled = True
        txtKeuze.Enabled = True
    End Function


    Private Sub cmdControleer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdControleer.Click
        Dim strLandInput As String
        strLandInput = Convert.ToString(txtKeuze.SelectedItem)

        If strLandInput = vlaggenArray(huidigeVlag, 0) Then
            '
            ' Als het juist is, label aanpassen
            '
            lblResultaat.Text = "Juist!"
            '
            ' Enkele properties instellen
            '
            cmdVolgende.Enabled = True
            cmdControleer.Enabled = False
            txtKeuze.Enabled = False
        Else
            lblResultaat.Text = "Fout"
        End If


    End Sub

    Private Sub cmdVolgende_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdVolgende.Click
        volgendeVlag()
    End Sub

End Class
