Imports System.IO

Public Class commndstile
    Private player13 As New MediaPlayer()
    Private Sub UserControl_MouseLeftButtonUp(sender As Object, e As MouseButtonEventArgs)
        PlayAccentSound()
        Process.Start("c:/ia")
    End Sub


    Private Sub UserControl_Loaded(sender As Object, e As RoutedEventArgs)
        Try
            My.Settings.Reload()
        Catch

            My.Settings.mecolor = "#19A2DE"

            Dim bluecolor As Color = CType(ColorConverter.ConvertFromString(My.Settings.mecolor), Color)
            cmndst.Background = New System.Windows.Media.SolidColorBrush(bluecolor)
        End Try

        Dim colortile2Timer = New System.Windows.Threading.DispatcherTimer()
        AddHandler colortile2Timer.Tick, AddressOf colortile2Timer_Tick
        colortile2Timer.Interval = New TimeSpan(0, 0, 1)
        colortile2Timer.Start()
    End Sub


    Private Sub colortile2Timer_Tick(sender As Object, e As EventArgs)
        Try
            Dim mytilecolor As Color = CType(ColorConverter.ConvertFromString(My.Settings.mecolor), Color)
            cmndst.Background = New System.Windows.Media.SolidColorBrush(mytilecolor)
        Catch
        End Try

        Dim folderPath As String = "C:\ia"

        If Directory.Exists(folderPath) Then
            Dim fileCount As Integer = Directory.GetFiles(folderPath, "*.txt").Length
            itemlbl.Content = fileCount.ToString() & " items"

        End If
    End Sub

    Private Sub itemlbl_Loaded(sender As Object, e As RoutedEventArgs) Handles itemlbl.Loaded

        Dim folderPath As String = "C:\ia"

        If Directory.Exists(folderPath) Then
            Dim fileCount As Integer = Directory.GetFiles(folderPath, "*.txt").Length
            itemlbl.Content = fileCount.ToString() & " items"

        End If

    End Sub
    Private Sub PlayAccentSound()
        Try
            player13.Volume = 1.0
            player13.Open(New Uri("beltonen/wp7_pressed.mp3", UriKind.Relative))
            player13.Play()
        Catch ex As Exception
            MessageBox.Show("Error playing sound: " & ex.Message)
        End Try
    End Sub


End Class
