Imports System.IO
Imports System.Numerics
Imports System.Windows
Imports System.Windows.Media
Imports System.Windows.Media.Imaging
Imports TagLib
Imports System.Configuration
Imports System.Windows.Controls
Imports System.Windows.Media.Animation
Imports System.Windows.Threading
Public Class MediaTile

    Private player2 As New MediaPlayer()

    Private Sub UserControl_MouseLeftButtonUp(sender As Object, e As MouseButtonEventArgs)
        Dim musdeo As New musdeo()
        musdeo.Show()

    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)
            mediat.Background = New System.Windows.Media.SolidColorBrush(bluecolor)
        End Try


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

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

    End Sub

    Private Sub UserControl_MouseLeftButtonDown(sender As Object, e As MouseButtonEventArgs)
        PlayAccentSound()
    End Sub

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

    Private Sub userControl_MouseEnter(sender As Object, e As MouseEventArgs) Handles userControl.MouseEnter
        Dim sbani2 As Storyboard = CType(Me.Resources("mouseover"), Storyboard)
        sbani2.Begin()
    End Sub

    Private Sub userControl_MouseLeave(sender As Object, e As MouseEventArgs) Handles userControl.MouseLeave
        Dim sbani23 As Storyboard = CType(Me.Resources("mouseover"), Storyboard)
        sbani23.Stop()
    End Sub
End Class
