ObjectAnimationUsingKeyFrames oa;
ObjectAnimationUsingKeyFrames oa_2;
private void BgSwitch(string imgPath)
{
oa = bgstoryboard.Children.FirstOrDefault(c => c is ObjectAnimationUsingKeyFrames) as ObjectAnimationUsingKeyFrames;
oa.KeyFrames[0].Value = new BitmapImage(new Uri(imgPath));
}
Storyboard bgstoryboard = null;
private void BgSwitchIni()
{
//动画占用过高CPU及GPU
//此动画效果为渲染所有的像素,效率过低
//应更改为 多区块渲染过渡 / 线性渲染过渡 / 淡化渲染过渡 / 模糊重叠过渡渲染
DoubleAnimationUsingKeyFrames da = new DoubleAnimationUsingKeyFrames();
EasingDoubleKeyFrame sd = new EasingDoubleKeyFrame(0, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(200)));
da.KeyFrames.Add(sd);
Storyboard.SetTargetName(da, musicPlayer_Main_UserControl.Grid_down_Singer_Photo.Name);
DependencyProperty[] propertyChain = new DependencyProperty[]
{
Panel.BackgroundProperty,
Brush.OpacityProperty
};
Storyboard.SetTargetProperty(da, new PropertyPath("(0).(1)", propertyChain));
ObjectAnimationUsingKeyFrames oa = new ObjectAnimationUsingKeyFrames();
DiscreteObjectKeyFrame diso = new DiscreteObjectKeyFrame(new BitmapImage(new Uri(Path_App + @"\Button_Image_Ico\Space.png", UriKind.Absolute)), KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(10)));
oa.KeyFrames.Add(diso);
oa.BeginTime = new TimeSpan(0, 0, 0, 1, 0);
Storyboard.SetTargetName(oa, musicPlayer_Main_UserControl.Grid_down_Singer_Photo.Name);
DependencyProperty[] propertyChain2 = new DependencyProperty[]
{
Panel.BackgroundProperty,
ImageBrush.ImageSourceProperty
};
Storyboard.SetTargetProperty(oa, new PropertyPath("(0).(1)", propertyChain2));
DoubleAnimationUsingKeyFrames da2 = new DoubleAnimationUsingKeyFrames();
da2.BeginTime = new TimeSpan(0, 0, 0, 1, 5);
EasingDoubleKeyFrame sd2 = new EasingDoubleKeyFrame(1, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(200)));
da2.KeyFrames.Add(sd2);
Storyboard.SetTargetName(da2, musicPlayer_Main_UserControl.Grid_down_Singer_Photo.Name);
Storyboard.SetTargetProperty(da2, new PropertyPath("(0).(1)", propertyChain));
bgstoryboard.Children.Add(da);
bgstoryboard.Children.Add(oa);
bgstoryboard.Children.Add(da2);
}