使用 Silverlight 2 Web 部件打造更为出色的 SharePoint
2008-12-01 11:52:42 来源:WEB开发网应用程序代码
要为 Silverlight 应用程序添加隐藏代码,在“解决方案资源管理器”中右键单击 Page.xaml 文件,然后单击“查看代码”。您也可以展开 Page.xaml 节点,右键单击 Page.xaml.cs 文件,然后选择“查看代码”。此视图中的代码与我们之前构建的 UI 相对应,我们就在这里设置 Silverlight 控件的特定属性。图 5 显示了我们添加到 Page.xaml.cs 文件中的代码。
图 5 媒体播放器隐藏代码
namespace MediaPlayer {
public partial class Page : UserControl {
public Page() {
InitializeComponent();
}
private void timeline_ValueChanged(
object sender, RoutedPropertyChangedEventArgs<double> e) {
long ticks = (long)((sender as Slider).Value *
this.moviePlayer.NaturalDuration.TimeSpan.Ticks);
TimeSpan movieTimespan = new TimeSpan(ticks);
this.moviePlayer.Position = movieTimespan;
if (this.moviePlayer.CurrentState == MediaElementState.Playing) {
this.moviePlay.IsChecked = true;
this.moviePlay.Content = "Pause";
}
}
private void movieStop_Click(object sender, RoutedEventArgs e) {
this.timeline.Value = 0;
this.moviePlayer.Stop();
this.moviePlay.Content = "Play";
}
private void moviePlay_Click(object sender, RoutedEventArgs e) {
if (moviePlay.IsChecked == true) {
moviePlay.Content = "Pause";
this.moviePlayer.Play();
}
else {
moviePlay.Content = "Play";
this.moviePlayer.Pause();
}
}
private void movieMute_Click(object sender, RoutedEventArgs e) {
if (movieMute.IsChecked == true) {
movieMute.Content = "Sound On";
this.moviePlayer.IsMuted = true;
}
else {
movieMute.Content = "Sound Off";
this.moviePlayer.IsMuted = false;
}
}
}
}
Tags:使用 Silverlight Web
编辑录入:爽爽 [复制链接] [打 印]更多精彩
赞助商链接