using System;
using System.IO;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Navigation;
using FingersDance.Factory;

namespace FingersDance.Control.Pivot
{
	public partial class UserControlPivot
	{
        //Events pour chaque Boutton du Pivot
        public event EventHandler EH_SurfaceButtonPlayer_ContactDown;

		public UserControlPivot()
		{
			this.InitializeComponent();
            
			// Insert code required on object creation below this point.
		}

        private void SurfaceButtonPlayer1_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e)
        {
            if(EH_SurfaceButtonPlayer_ContactDown!=null)
                EH_SurfaceButtonPlayer_ContactDown(1, new EventArgs());
        }

        private void SurfaceButtonPlayer2_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e)
        {
            if (EH_SurfaceButtonPlayer_ContactDown != null)
                EH_SurfaceButtonPlayer_ContactDown(2, new EventArgs());
        }

        private void SurfaceButtonPlayer3_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e)
        {
            if (EH_SurfaceButtonPlayer_ContactDown != null)
                EH_SurfaceButtonPlayer_ContactDown(3, new EventArgs());
        }

        private void SurfaceButtonPlayer4_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e)
        {
            if (EH_SurfaceButtonPlayer_ContactDown != null)
                EH_SurfaceButtonPlayer_ContactDown(4, new EventArgs());
        }

        private void SurfaceButtonPlayer1_Click(object sender, RoutedEventArgs e)
        {
            SurfaceButtonPlayer1_ContactDown(this,null);
        }

        private void SurfaceButtonPlayer2_Click(object sender, RoutedEventArgs e)
        {
            SurfaceButtonPlayer2_ContactDown(this, null);
        }

        private void SurfaceButtonPlayer3_Click(object sender, RoutedEventArgs e)
        {
            SurfaceButtonPlayer3_ContactDown(this, null);
        }

        private void SurfaceButtonPlayer4_Click(object sender, RoutedEventArgs e)
        {
            SurfaceButtonPlayer4_ContactDown(this, null);
        }

        public void ApplyColor(int id, string color)
        {
            try
            {
                switch (id)
                {
                    case 1:
                        SurfaceButtonPlayer1.Background = (Brush)FindResource((new ColorFactory()).Colors[color]);
                        break;
                    case 2:
                        SurfaceButtonPlayer2.Background = (Brush)FindResource((new ColorFactory()).Colors[color]);
                        break;
                    case 3:
                        SurfaceButtonPlayer3.Background = (Brush)FindResource((new ColorFactory()).Colors[color]);
                        break;
                    case 4:
                        SurfaceButtonPlayer4.Background = (Brush)FindResource((new ColorFactory()).Colors[color]);
                        break;
                }
            }
            catch (Exception) { }
        }
	}
}