Imports System
Imports System.Threading
Imports System.Windows.Controls
Imports Microsoft.Phone.Controls
Imports Microsoft.Phone.Shell

Partial Public Class MainPage
    Inherits PhoneApplicationPage

    ' Constructor
    Public Sub New()
        InitializeComponent()

        SupportedOrientations = SupportedPageOrientation.Portrait Or SupportedPageOrientation.Landscape

        ' Sample code to localize the ApplicationBar
        'BuildLocalizedApplicationBar()

        'Aktualizace uzivatelskeho rozhrani aplikace Golfovy vozik pomoci
        'globalnich promennych (dulezite, pokud byl proveden tombstoning aplikace)
        TextovyBlokCelkem.Text = CelkoveSkore
        TextovyBlokAktualniJamka.Text = "Jamka: " & AktualniJamka

    End Sub

    ' Sample code for building a localized ApplicationBar
    'Private Sub BuildLocalizedApplicationBar()
    '    ' Set the page's ApplicationBar to a new instance of ApplicationBar.
    '    ApplicationBar = New ApplicationBar()

    '    ' Create a new button and set the text value to the localized string from AppResources.
    '    Dim appBarButton As New ApplicationBarIconButton(New Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative))
    '    appBarButton.Text = AppResources.AppBarButtonText
    '    ApplicationBar.Buttons.Add(appBarButton)

    '    ' Create a new menu item with the localized string from AppResources.
    '    Dim appBarMenuItem As New ApplicationBarMenuItem(AppResources.AppBarMenuItemText)
    '    ApplicationBar.MenuItems.Add(appBarMenuItem)
    'End Sub

    Private Sub TlacitkoSkoreJamky_Click(sender As Object, e As RoutedEventArgs) Handles TlacitkoSkoreJamky.Click
        'pricteni skore aktualni jamky k celkovemu skore a zobrazeni vysledku
        CelkoveSkore = CelkoveSkore + TextovePoleSkoreJamky.Text
        TextovyBlokCelkem.Text = CelkoveSkore
        'zjisteni, zda zbyvaji jeste nejake jamky
        If AktualniJamka = 18 Then
            'konec, je-li dokoncena hra na 18. jamce; zakaz tlacitka
            'Skore jamky a cekani na novou hru
            TlacitkoSkoreJamky.IsEnabled = False
        Else
            'neni-li dokoncena hra na 18. jamce, prechod na dalsi
            'jamku a cekani na zadani dalsiho skore
            AktualniJamka = AktualniJamka + 1
            TextovyBlokAktualniJamka.Text = "Jamka: " & AktualniJamka
        End If
    End Sub

    Private Sub TlacitkoNovaHra_Click(sender As Object, e As RoutedEventArgs) Handles TlacitkoNovaHra.Click
        'zahajeni nove hry, reset hodnot promennych a
        'vycisteni uzivatelskeho rozhrani od starych hodnot
        CelkoveSkore = 0
        TextovyBlokCelkem.Text = CelkoveSkore
        AktualniJamka = 1
        TextovyBlokAktualniJamka.Text = "Jamka: 1"
        TlacitkoSkoreJamky.IsEnabled = True
    End Sub
End Class