接上一贴

bailuyuan88 2010-08-10 10:12:06
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace VC
{
public partial class MainPage : UserControl
{
public bool IsLeftButtonPressed = false;
public bool IsLoop = false;
public MainPage()
{
InitializeComponent();
this.Loaded += new RoutedEventHandler(TstringMovieControl_Loaded);
}
void TstringMovieControl_Loaded(object sender, RoutedEventArgs e)
{
InitializeEvent();
}

private void InitializeEvent()
{
tbInfo.Text = string.Empty;
VolumeSlider.Opacity = 0;
VolumeSlider.MouseEnter += new MouseEventHandler(VolumeSlider_MouseEnter);
VolumeSlider.MouseLeave += new MouseEventHandler(VolumeSlider_MouseLeave);

TstringMovieObject.MediaOpened += new RoutedEventHandler(TstringMovieObject_MediaOpened);
TstringMovieObject.DownloadProgressChanged += new RoutedEventHandler(TstringMovieObject_DownloadProgressChanged);
TstringMovieObject.MarkerReached += new TimelineMarkerRoutedEventHandler(TstringMovieObject_MarkerReached);
TstringMovieObject.MediaEnded += new RoutedEventHandler(TstringMovieObject_MediaEnded);
TstringMovieObject.CurrentStateChanged += new RoutedEventHandler(TstringMovieObject_CurrentStateChanged);


ControlPlay.MouseLeftButtonDown += new MouseButtonEventHandler(ControlPlay_MouseLeftButtonDown);
tMutedButton.MouseLeftButtonDown += new MouseButtonEventHandler(tMutedButton_MouseLeftButtonDown);
tPlayButton.MouseLeftButtonDown += new MouseButtonEventHandler(ControlPlay_MouseLeftButtonDown);
tFullScreenButton.MouseLeftButtonDown += new MouseButtonEventHandler(tFullScreenButton_MouseLeftButtonDown);
tLoop.MouseLeftButtonDown += new MouseButtonEventHandler(tLoop_MouseLeftButtonDown);

TstringPlayState.MouseLeftButtonDown += new MouseButtonEventHandler(TstringPlayState_MouseLeftButtonDown);
TstringPlayState.MouseMove += new MouseEventHandler(TstringPlayState_MouseMove);
TstringPlayState.MouseLeftButtonUp += new MouseButtonEventHandler(TstringPlayState_MouseLeftButtonUp);

DownloadedPercent.MouseLeftButtonDown += new MouseButtonEventHandler(TstringPlayState_MouseLeftButtonDown);
DownloadedPercent.MouseMove += new MouseEventHandler(TstringPlayState_MouseMove);
DownloadedPercent.MouseLeftButtonUp += new MouseButtonEventHandler(TstringPlayState_MouseLeftButtonUp);

#region
Application.Current.Host.Content.FullScreenChanged += new EventHandler(Content_FullScreenChanged);

for (int i = 1; i <= 20; i++)
{
Rectangle VolumeItem = (Rectangle)this.FindName(string.Format("_{0}", i));
if (VolumeItem != null)
{
VolumeItem.MouseEnter += new MouseEventHandler(VolumeItem_MouseEnter);
VolumeItem.MouseLeave += new MouseEventHandler(VolumeItem_MouseEnter);
}
}
#endregion
}

void TstringMovieObject_CurrentStateChanged(object sender, RoutedEventArgs e)
{
switch (this.TstringMovieObject.CurrentState)
{
case MediaElementState.Buffering:
this.Info("Buffering");
break;
case MediaElementState.Closed:
this.Info("Closed");
break;
case MediaElementState.Opening:
this.Info("Opening");
break;
case MediaElementState.Paused:
this.Info("Paused");
break;
case MediaElementState.Playing:
this.Info(null);
break;
case MediaElementState.Stopped:
this.Info("Stopped");
break;
default:
this.Info(null);
break;
}
}

void tLoop_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
IsLoop = !IsLoop;
tLoop.Opacity = IsLoop ? 0.5 : 1;
}

void TstringMovieObject_MediaEnded(object sender, RoutedEventArgs e)
{
if (IsLoop)
{
ControlPlay_MouseLeftButtonDown(sender, null);
}
tPlayButton.Opacity = 1;
ControlPlay.Text = "重播";
TstringPlayState.Width = 0;
DownloadedPercent.Width = OffsetLoadedProcessBarLeng();
TstringMovieObject.Position = new TimeSpan(0, 0, 0);
TstringSliderLoadedPercentText.Text = string.Empty;
}
...全文
12 点赞 收藏 回复
写回复
回复
切换为时间正序
请发表友善的回复…
发表回复

还没有回复,快来抢沙发~

发动态
发帖子
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
社区公告
暂无公告