private void GoToPauseState()
        {
            ME_MainShow.LoadedBehavior = MediaState.Manual;
            ME_MainShow.Pause();
            CurrentState = VideoState.Pause;
            progressTimer.Start();

            //BTN_KuaiJin.IsEnabled = true;
            //BTN_KuaiTui.IsEnabled = true;
            // UC_ProgressBar.ProgressValue = 0;
            UC_ProgressBar.IsEnabled = true;

            BTN_Vdown.IsEnabled = true;
            BTN_Vup.IsEnabled   = true;

            BTN_Pause.Visibility = Visibility.Collapsed;
            BTN_Play.Visibility  = Visibility.Visible;
            BTN_Pause.IsEnabled  = true;
            BTN_Play.IsEnabled   = true;

            TBK_Fail.Visibility       = Visibility.Collapsed;
            BD_DownConsole.Visibility = Visibility.Visible;
            this.RTF_Buffering.BeginAnimation(RotateTransform.AngleProperty, null);
            EP_Buffering.Visibility = Visibility.Collapsed;
        }
 private void InitEventHandler()
 {
     this.Loaded             += (sender, e) => { GoToBufferingState(); };
     this.progressTimer.Tick += new EventHandler(progresstimer_Tick);
     this.tagTimer.Tick      += new EventHandler(tagtimer_Tick);
     #region 触摸操作
     Point startPoint = new Point();
     //Point lastPoint = new Point();
     LayoutRoot.PreviewMouseDown += new MouseButtonEventHandler((sender, e) =>
     {
         //isDrag = true;
         startPoint = e.GetPosition(LayoutRoot);
         //lastPoint = startPoint;
     });
     #region
     //LayoutRoot.PreviewMouseMove += new MouseEventHandler((sender, e) =>
     //{
     //    if (e.LeftButton == MouseButtonState.Pressed && isDrag)
     //    {
     //        Point currentPoint = e.GetPosition(LayoutRoot);
     //        if (GetDistence(lastPoint, currentPoint) > 5)
     //        {
     //            double DeltaX = currentPoint.X - startPoint.X;
     //            double DeltaY = currentPoint.Y - startPoint.Y;
     //            if (JudgeDirection(DeltaX, DeltaY))
     //            {
     //                double pecentage = DeltaX / Width;
     //                double currentPercentage = ME_MainShow.Position.TotalMilliseconds / ME_MainShow.NaturalDuration.TimeSpan.TotalMilliseconds;
     //                double result = (currentPercentage + pecentage);
     //                if (result < 0)
     //                    CurrentTag = "进度 : " + 0 + "%";
     //                else if (result >= 1)
     //                    CurrentTag = "进度 : " + 99 + "%";
     //                else
     //                    CurrentTag = "进度 : " + (int)(result * 100) + "%";
     //            }
     //            else
     //            {
     //                if (Math.Abs(DeltaY) > bound_dy)
     //                {
     //                    ShowConsole();
     //                    double deltaRate = DeltaY / this.Width;
     //                    SeekVolume(ME_MainShow.Volume-deltaRate*vrate);
     //                   // SetVolume(deltaRate);
     //                }
     //            }
     //            lastPoint = currentPoint;
     //        }
     //    }
     //});
     #endregion
     LayoutRoot.PreviewMouseUp += new MouseButtonEventHandler((sender, e) =>
     {
         if (startPoint.X != 0 && startPoint.Y != 0 && GetDistence(e.GetPosition(LayoutRoot), startPoint) < 3)
         {
             if (BD_DownConsole.Visibility == Visibility.Visible)
             {
                 HideConsole();
             }
             else
             {
                 ShowConsole();
             }
         }
         #region
         //else
         //{
         //    Point currentPoint = e.GetPosition(LayoutRoot);
         //    if (GetDistence(startPoint, currentPoint) > 3)
         //    {
         //        double DeltaX = currentPoint.X - startPoint.X;
         //        double DeltaY = currentPoint.Y - startPoint.Y;
         //        if (JudgeDirection(DeltaX, DeltaY))
         //        {
         //            double pecentage = DeltaX / Width;
         //            double currentPercentage = ME_MainShow.Position.TotalMilliseconds / ME_MainShow.NaturalDuration.TimeSpan.TotalMilliseconds;
         //            SeekProgress(currentPercentage + pecentage);
         //        }
         //    }
         //}
         #endregion
         //isDrag = false;
     });
     #endregion
     #region 媒体自身状态的事件
     ME_MainShow.MediaEnded += new RoutedEventHandler((sender, e) =>
     {
         int index = videoList.IndexOf(currentVideo);
         if (index != -1)
         {
             currentVideo = videoList[(index + 1) % videoList.Count];
             ReLoadMedia();
         }
     });
     ME_MainShow.MediaFailed += new EventHandler <ExceptionRoutedEventArgs>((sender, e) =>
     {
         GoToFailState();
     });
     ME_MainShow.MediaOpened += new RoutedEventHandler((sender, e) =>
     {
         UC_ProgressBar.SL_Progress.IsEnabled = ME_MainShow.IsLoaded;
         // this.UC_VolumeBar.SL_Progress.IsEnabled = ME_MainShow.IsLoaded;
         GoToPlayState();
     });
     ME_MainShow.SourceUpdated += new EventHandler <DataTransferEventArgs>((sender, e) =>
     {
         GoToPlayState();
     });
     ME_MainShow.BufferingStarted += new RoutedEventHandler((sender, e) =>
     {
         GoToBufferingState();
     });
     ME_MainShow.BufferingEnded += new RoutedEventHandler((sender, e) =>
     {
         GoToPlayState();
     });
     #endregion
     #region  钮事件
     BTN_GoForward.Click += new RoutedEventHandler((sender, e) =>
     {
         int index = videoList.IndexOf(currentVideo);
         if (index != -1)
         {
             currentVideo = videoList[(index + 1) % videoList.Count];
             ReLoadMedia();
         }
     });
     BTN_Back.Click += new RoutedEventHandler((sender, e) =>
     {
         ME_MainShow.Close();
         this.Visibility = Visibility.Collapsed;
         if (Closed != null)
         {
             Closed(this, e);
         }
     });
     BTN_GoBackward.Click += new RoutedEventHandler((sender, e) =>
     {
         int index = videoList.IndexOf(currentVideo);
         if (index != -1)
         {
             currentVideo = videoList[(index - 1 + videoList.Count) % videoList.Count];
             ReLoadMedia();
         }
     });
     BTN_Play.Click   += (sender, e) => { GoToPlayState(); };
     BTN_Pause.Click  += (sender, e) => { GoToPauseState(); };
     BTN_Vdown.Click  += (sender, e) => { SeekVolume(ME_MainShow.Volume - 0.05); };
     BTN_Vup.Click    += (sender, e) => { SeekVolume(ME_MainShow.Volume + 0.05); };
     BTN_Screen.Click += (sender, e) => { SwitchScreenSize(); };
     #endregion
     #region 滑竿事件
     UC_ProgressBar.ProgressDragEnd += new MyProgressBar.ProgressDragEndEventHandler((sender, e) =>
     {
         SeekProgress(e / this.UC_ProgressBar.Maximum);
     });
     UC_ProgressBar.ProgressValueChanged += (sender, e) =>
     {
         CurrentTag = "进度 : " + (int)(e.NewValue / UC_ProgressBar.Maximum * 100) + "%";
     };
     #endregion
 }