///////////////////////////////////////////////////////////////////////////////
//
//  WinnerDisplayControl.xaml.cs
//
// 
// © 2008 Microsoft Corporation. All Rights Reserved.
//
// This file is licensed as part of the Silverlight 1.1 SDK, for details look here: http://go.microsoft.com/fwlink/?LinkID=111970&clcid=0x409
//
///////////////////////////////////////////////////////////////////////////////
namespace SilverlightChess
{
	using System;
	using System.Windows;
	using System.Windows.Controls;
	using System.Windows.Documents;
	using System.Windows.Ink;
	using System.Windows.Input;
	using System.Windows.Media;
	using System.Windows.Media.Animation;
	using System.Windows.Shapes;
	using System.ComponentModel;
    using System.Windows.Data;
    using System.Windows.Browser;

	public partial class WinnerDisplayControl : UserControl, INotifyPropertyChanged

        
	{
		public event RoutedEventHandler Completed;

		private string victor;
		public string Victor
		{
			get { return this.victor; }
			set
			{
				this.victor = value;
				this.onPropertyChanged("Victor");
                //Winner.Text = this.victor;
                
              
			}
		}

		public WinnerDisplayControl()
		{
			// Required to initialize variables
			InitializeComponent();

			this.Loaded += new RoutedEventHandler(WinnerDisplayControl_Loaded);
            var binding = new Binding("Victor") { Source = this };
            Winner.SetBinding(TextBlock.TextProperty,binding);
        
		}

		void WinnerDisplayControl_Loaded(object sender, RoutedEventArgs e)
		{
            
            Storyboard s = this.Resources["Intro"] as Storyboard;
			if (s != null)
			{                 
				s.Begin();
			}
		}

		private void Button_Click(object sender, RoutedEventArgs e)
		{
            //Storyboard s = this.Resources["Outro"] as Storyboard;
            //s.Completed += new EventHandler(s_Completed);
            //if (s != null)
            //{

            //    s.Pause();
            //}
            HtmlPage.Window.Navigate(new Uri("Default.html", UriKind.Relative));           
            
		}

		void s_Completed(object sender, EventArgs e)
		{
			this.Completed(this, new RoutedEventArgs());
		}

		#region INotifyPropertyChanged Members

		public event PropertyChangedEventHandler PropertyChanged;

		#endregion

		private void onPropertyChanged(string name)
		{
			if (this.PropertyChanged != null)
			{
				this.PropertyChanged(this, new PropertyChangedEventArgs(name));
			}
		}
	}
}