本文整理汇总了C#中System.Windows.Media.GradientStop.BeginAnimation方法的典型用法代码示例。如果您正苦于以下问题:C# GradientStop.BeginAnimation方法的具体用法?C# GradientStop.BeginAnimation怎么用?C# GradientStop.BeginAnimation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.GradientStop
的用法示例。
在下文中一共展示了GradientStop.BeginAnimation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PropertyChanged
public static void PropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
TextBlock element = (TextBlock)d;
PlaylistItem curr = (PlaylistItem)element.GetValue(AnimatedCurrentItemProperty);
PlaylistItem item = element.DataContext as PlaylistItem;
if (curr != null && item != null && curr.UID == item.UID)
{
GradientStop stop1 = new GradientStop(Color1, -2d);
GradientStop stop2 = new GradientStop(Color2, -1d);
GradientStop stop3 = new GradientStop(Color1, 0d);
GradientStop stop4 = new GradientStop(Color2, 1d);
element.Background = new LinearGradientBrush(new GradientStopCollection(new List<GradientStop> { stop1, stop2, stop3, stop4 }));
stop1.BeginAnimation(GradientStop.OffsetProperty, new DoubleAnimation(-2, 0, duration) { RepeatBehavior = RepeatBehavior.Forever });
stop2.BeginAnimation(GradientStop.OffsetProperty, new DoubleAnimation(-1, 1, duration) { RepeatBehavior = RepeatBehavior.Forever });
stop3.BeginAnimation(GradientStop.OffsetProperty, new DoubleAnimation(0, 2, duration) { RepeatBehavior = RepeatBehavior.Forever });
stop4.BeginAnimation(GradientStop.OffsetProperty, new DoubleAnimation(1, 3, duration) { RepeatBehavior = RepeatBehavior.Forever });
}
else
{
element.Background = Brushes.Transparent;
}
}
示例2: startProgress
private void startProgress(object sender, RoutedEventArgs e)
{
progressBar1.Width = this.width;
progressBar1.Height = this.height;
progressBar1.Margin = new Thickness(3, 3, 0, 0);
border1.Margin = new Thickness(0);
border1.Width = this.width + 6;
border1.Height = this.height + 6;
SolidColorBrush scb = new SolidColorBrush(Colors.PaleGreen);
LinearGradientBrush lgb = new LinearGradientBrush();
GradientStop stop1 = new GradientStop(Colors.GreenYellow, 0.0);
GradientStop stop2 = new GradientStop(Colors.LightBlue, 0.5);
GradientStop stop3 = new GradientStop(Colors.Violet, 1.0);
lgb.GradientStops.Add(stop1);
lgb.GradientStops.Add(stop2);
lgb.GradientStops.Add(stop3);
Rectangle r = (Rectangle)progressBar1.Template.FindName("bar", progressBar1);
r.Fill = lgb;
progressBar1.ValueChanged += new RoutedPropertyChangedEventHandler<double>(progressBar1_ValueChanged);
DoubleAnimation da = new DoubleAnimation();
da.From = 0;
da.To = 100;
da.Duration = new Duration(TimeSpan.FromSeconds(totalTime));
progressBar1.BeginAnimation(ProgressBar.ValueProperty, da);
ColorAnimation ca1 = new ColorAnimation();
ca1.To = Colors.Yellow;
ca1.Duration = new Duration(TimeSpan.FromSeconds(totalTime));
stop1.BeginAnimation(GradientStop.ColorProperty, ca1);
ColorAnimation ca2 = new ColorAnimation();
ca2.To = Colors.Orange;
ca2.Duration = new Duration(TimeSpan.FromSeconds(totalTime));
stop2.BeginAnimation(GradientStop.ColorProperty, ca2);
ColorAnimation ca3 = new ColorAnimation();
ca3.To = Colors.Tomato;
ca3.Duration = new Duration(TimeSpan.FromSeconds(totalTime));
stop3.BeginAnimation(GradientStop.ColorProperty, ca3);
}