Saturday, April 14, 2012

StoryBoard

public void FadeIn(UIElement target, double theseconds)
{
DoubleAnimation da = new DoubleAnimation();
da.From = 0;
da.To = 1.0;
da.Duration = TimeSpan.FromSeconds(theseconds);
da.AutoReverse = true;
//da.RepeatBehavior = RepeatBehavior.Forever;
da.RepeatBehavior = new RepeatBehavior(3);
DoubleAnimation csize = new DoubleAnimation();
csize.From = 150;
csize.To = 187;
csize.Duration = TimeSpan.FromSeconds(theseconds);
csize.AutoReverse = true;
csize.RepeatBehavior = new RepeatBehavior(3);
//da.RepeatBehavior = new System.Windows.Media.Animation.RepeatBehavior
//Storyboard.SetRepeatBehaviorProperty(da, new RepeatBehavior("4x"));
 
Storyboard.SetTargetProperty(da, new PropertyPath("Opacity"));
Storyboard.SetTarget(da, target);
Storyboard.SetTargetProperty(csize, new PropertyPath("Width"));
Storyboard.SetTarget(csize, target);
 
Storyboard sb = new Storyboard();
sb.Children.Add(da);
sb.Children.Add(csize);
 
 
if (mediaElement_C.CurrentState.ToString() == "Opening")
{
image5.Opacity = 1;
}
else
{
image5.Opacity = 0;
}
 
 
//clapping.Play();
//scoresound.Play();
sb.Begin();
}

No comments:

Post a Comment