Imports System.Configuration
Imports System.IO
Imports System.Numerics
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Media
Imports System.Windows.Threading

Public Class cdrivetile
    Private player10 As New MediaPlayer()
    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)
            cdrivet.Background = New System.Windows.Media.SolidColorBrush(bluecolor)
        End Try

        Dim driveC As New DriveInfo("C")
        Dim freeSpaceInGB As Long = driveC.AvailableFreeSpace \ (1024 * 1024 * 1024)
        spacelbl.Content = freeSpaceInGB.ToString() & " GB"
        
        Dim colortile23Timer = New System.Windows.Threading.DispatcherTimer()
        AddHandler colortile23Timer.Tick, AddressOf colortile23Timer_Tick
        colortile23Timer.Interval = New TimeSpan(0, 0, 1)
        colortile23Timer.Start()
    End Sub

    Private Sub colortile23Timer_Tick(sender As Object, e As EventArgs)
        Try
            Dim mytilecolor As Color = CType(ColorConverter.ConvertFromString(My.Settings.mecolor), Color)
            cdrivet.Background = New System.Windows.Media.SolidColorBrush(mytilecolor)
        Catch
        End Try
        Dim driveC As New DriveInfo("C")
        Dim freeSpaceInGB As Long = driveC.AvailableFreeSpace \ (1024 * 1024 * 1024)
        spacelbl.Content = freeSpaceInGB.ToString() & " GB"

    End Sub

    Private Sub UserControl_MouseLeftButtonUp(sender As Object, e As MouseButtonEventArgs)
        PlayAccentSound()
        Process.Start("c:/")
    End Sub

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

End Class
