|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Media.Animation;
using System.Diagnostics;
namespace Channel9Explorer.UserControls
{
/// <summary>
/// Interaction logic for BackDisplayControl.xaml
/// </summary>
public partial class BackDisplayControl : UserControl
{
public BackDisplayControl()
{
InitializeComponent();
this.MouseDoubleClick += new MouseButtonEventHandler(BackDisplayControl_MouseLeftButtonUp);
}
#region Properties
public string VideoLink
{
get;
set;
}
#endregion
#region Event handlers
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
}
void StartStoryBoarrd(Storyboard sb, int from, int to)
{
DoubleAnimation animation = sb.Children[0] as DoubleAnimation;
animation.From = from;
animation.To = to;
//sb.Children[0] = animation;
sb.Begin();
}
bool play;
void BackDisplayControl_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
if (play == false)
{
if (this.VideoLink == null) return;
if (Uri.IsWellFormedUriString(this.VideoLink, UriKind.Absolute) == false) return;
play = true;
Storyboard sb = this.FindResource("PlayImageFadeStoryBoard") as Storyboard;
this.StartStoryBoarrd(sb, 1, 0);
Storyboard sb1 = this.FindResource("PauseImageFadeStoryBoard") as Storyboard;
this.StartStoryBoarrd(sb1, 0, 1);
this.MyPlayer.Source = new Uri(this.VideoLink);
this.MyPlayer.LoadedBehavior = MediaState.Manual;
this.MyPlayer.Play();
}
else
{
Storyboard sb = this.FindResource("PauseImageFadeStoryBoard") as Storyboard;
this.StartStoryBoarrd(sb, 1, 0);
Storyboard sb1 = this.FindResource("PlayImageFadeStoryBoard") as Storyboard;
this.StartStoryBoarrd(sb1, 0, 1);
play = false;
this.MyPlayer.Pause();
}
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.