void Start(Canvas panel)
        {
            Random random = new Random();

            Task.Factory.StartNew(new Action(() =>
            {
                for (int j = 0; j < 25; j++)
                {
                    Thread.Sleep(j * 100);
                    Dispatcher.Invoke(new Action(() =>
                    {
                        int snowCount = random.Next(0, 10);
                        for (int i = 0; i < snowCount; i++)
                        {
                            int width            = random.Next(10, 40);
                            Petal pack           = new Petal();
                            pack.Width           = width;
                            pack.Height          = width;
                            pack.RenderTransform = new RotateTransform();

                            int left = random.Next(0, (int)panel.ActualWidth);
                            Canvas.SetLeft(pack, left);
                            panel.Children.Add(pack);
                            int seconds = random.Next(20, 30);
                            pack.BeginAnimation(OpacityProperty, new DoubleAnimation(0, 1, TimeSpan.FromSeconds(1)));
                            DoubleAnimationUsingPath doubleAnimation = new DoubleAnimationUsingPath()        //下降动画
                            {
                                Duration       = new Duration(new TimeSpan(0, 0, seconds)),
                                RepeatBehavior = RepeatBehavior.Forever,
                                PathGeometry   = new PathGeometry(new List <PathFigure>()
                                {
                                    new PathFigure(new Point(left, 0), new List <PathSegment>()
                                    {
                                        new LineSegment(new Point(left, panel.ActualHeight), false)
                                    }, false)
                                }),
                                Source = PathAnimationSource.Y
                            };
                            pack.BeginAnimation(Canvas.TopProperty, doubleAnimation);
                            DoubleAnimation doubleAnimation1 = new DoubleAnimation(360, new Duration(new TimeSpan(0, 0, 10)))              //旋转动画
                            {
                                RepeatBehavior = RepeatBehavior.Forever,
                            };
                            pack.RenderTransform.BeginAnimation(RotateTransform.AngleProperty, doubleAnimation1);
                        }
                    }));
                }
            }));
        }
        void Start(Canvas panel)
        {
            // SerializSettingClass(setting);


            panel.Children.Clear();

            Random random = new Random();

            task = Task.Factory.StartNew(new Action(() =>
            {
                for (int j = 0; j < 50; j++)
                {
                    Thread.Sleep(j * 200);
                    //Dispatcher.BeginInvoke(new Action(() =>
                    //{
                    int snowCount = random.Next(2, setting.SnowflakeCount);//Count
                    for (int i = 0; i < snowCount; i++)
                    {
                        Dispatcher.BeginInvoke(new Action(() =>
                        {
                            int width = random.Next(5, setting.SnowflakeSize);   //size

                            if (setting.SnowflakeType == 1)
                            {
                                Petal pack  = new Petal();
                                userControl = pack;
                            }
                            else if (setting.SnowflakeType == 2)
                            {
                                BGCFu bGCFu = new BGCFu();
                                userControl = bGCFu;
                            }
                            else if (setting.SnowflakeType == 3)
                            {
                                BGCSnow bGCSnow = new BGCSnow();
                                userControl     = bGCSnow;
                            }
                            else if (setting.SnowflakeType == 4)
                            {
                                BGCStarxaml bGCStarxaml = new BGCStarxaml();
                                userControl             = bGCStarxaml;
                            }
                            else
                            {
                                BGCSnow bGCFu = new BGCSnow();
                                userControl   = bGCFu;
                            }
                            userControl.Width           = width;
                            userControl.Height          = width;
                            userControl.RenderTransform = new RotateTransform();

                            int left = random.Next(0, (int)panel.ActualWidth);
                            Canvas.SetLeft(userControl, left);
                            panel.Children.Add(userControl);
                            int seconds = random.Next(20, 30);
                            userControl.BeginAnimation(OpacityProperty, new DoubleAnimation(0, 1, TimeSpan.FromSeconds(1)));
                            DoubleAnimationUsingPath doubleAnimation = new DoubleAnimationUsingPath()           //下降动画
                            {
                                Duration       = new Duration(new TimeSpan(0, 0, seconds)),
                                RepeatBehavior = RepeatBehavior.Forever,
                                PathGeometry   = new PathGeometry(new List <PathFigure>()
                                {
                                    new PathFigure(new Point(left, 0), new List <PathSegment>()
                                    {
                                        new LineSegment(new Point(left, panel.ActualHeight), false)
                                    }, false)
                                }),
                                Source = PathAnimationSource.Y
                            };
                            userControl.BeginAnimation(Canvas.TopProperty, doubleAnimation);
                            DoubleAnimation doubleAnimation1 = new DoubleAnimation(360, new Duration(new TimeSpan(0, 0, 12)))                 //旋转动画
                            {
                                RepeatBehavior = RepeatBehavior.Forever,
                            };

                            userControl.RenderTransform.BeginAnimation(RotateTransform.AngleProperty, doubleAnimation1);
                        }));
                    }
                }
            }));
        }