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

Public Class CALLTILE
    Private player 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)
            callt.Background = New System.Windows.Media.SolidColorBrush(bluecolor)
        End Try

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

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

    Private Sub UserControl_MouseLeftButtonUp(sender As Object, e As MouseButtonEventArgs)
        Dim callcenter As New callhub
        callcenter.Show()
    End Sub

    Private Sub UserControl_MouseLeftButtonDown(sender As Object, e As MouseButtonEventArgs)
        PlayAccentSound()
        Dim sbani As Storyboard = CType(Me.Resources("animeenter"), Storyboard)
        sbani.Begin()
    End Sub

    Private Sub PlayAccentSound()
        Try
            player.Volume = 1.0
            player.Open(New Uri("beltonen/wp7_pressed.mp3", UriKind.Relative))
            player.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)

        Dim sbani2 As Storyboard = CType(Me.Resources("animepressed"), Storyboard)
        sbani2.Begin()

    End Sub

    Private Sub UserControl_MouseLeave(sender As Object, e As MouseEventArgs)
        Dim sbani As Storyboard = CType(Me.Resources("animeenter"), Storyboard)
        sbani.Stop()

        Dim sbani2 As Storyboard = CType(Me.Resources("animepressed"), Storyboard)
        sbani2.Stop()
    End Sub
End Class
