Thursday, September 15, 2011

Creating Visual State Manager(Media Player)

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;

namespace SLVSMMediaPlayer
{
    public partial class VSMPlayer1 : UserControl
    {
        public VSMPlayer1()
        {
            // Required to initialize variables
            InitializeComponent();
            Loaded +=new RoutedEventHandler(VSMPlayer1_Loaded);
        }
      
        void VSMPlayer1_Loaded(object sender, RoutedEventArgs e)
        {
          
            LayoutRoot.MouseEnter +=new MouseEventHandler(LayoutRoot_MouseEnter);
            LayoutRoot.MouseLeave += new MouseEventHandler(LayoutRoot_MouseLeave);
            button.Click += new RoutedEventHandler(button_Click);
            button1.Click += new RoutedEventHandler(button1_Click);
           
           
        }

        void button1_Click(object sender, RoutedEventArgs e)
        {
            //throw new NotImplementedException();
            mymedia.Pause();
        }

        void button_Click(object sender, RoutedEventArgs e)
        {
           // throw new NotImplementedException();
            mymedia.Play();
        }

        void LayoutRoot_MouseLeave(object sender, MouseEventArgs e)
        {
            //throw new NotImplementedException();
            VisualStateManager.GoToState(this,"MouseLeave", true);
        }

        void LayoutRoot_MouseEnter(object sender, MouseEventArgs e)
        {
            //throw new NotImplementedException();
            VisualStateManager.GoToState(this, "MouseEnter", true);
        }
    }
}

No comments:

Post a Comment