WPF桌面下雪效果
2021-04-09 19:26
标签:render nes point cto star add tle actor ever 寄存在canvas面板,目前缺点就是开始的时候效果有点别扭。 直接贴代码: WPF桌面下雪效果 标签:render nes point cto star add tle actor ever 原文地址:https://www.cnblogs.com/RedSky/p/9056648.html 1 void StartSnowing(Canvas panel)
2 {
3 Random random = new Random();
4 Task.Factory.StartNew(new Action(() =>
5 {
6 for (int j = 0; j 10; j++)
7 {
8 Thread.Sleep(j * 100);
9 Dispatcher.Invoke(new Action(() =>
10 {
11 int snowCount = random.Next(0, 20);
12 for (int i = 0; i )
13 {
14 int width = random.Next(10, 20);
15 PackIconFontAwesome pack = new PackIconFontAwesome()
16 {
17 Kind = PackIconFontAwesomeKind.SnowflakeRegular,
18 Width = width,
19 Height = width,
20 Foreground = Brushes.White,
21 BorderThickness = new Thickness(0),
22 RenderTransform = new RotateTransform(),
23 };
24 int left = random.Next(0, (int)panel.ActualWidth);
25 Canvas.SetLeft(pack, left);
26 panel.Children.Add(pack);
27 int seconds = random.Next(10, 20);
28 DoubleAnimationUsingPath doubleAnimation = new DoubleAnimationUsingPath()
29 {
30 Duration = new Duration(new TimeSpan(0, 0, seconds)),
31 RepeatBehavior = RepeatBehavior.Forever,
32 PathGeometry = new PathGeometry(new List