www.pudn.com > WPFIce-animation.rar > snowcanvas.cs, change:2010-12-31,size:3852b


using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Windows; 
using System.Windows.Media; 
using System.Windows.Media.Animation; 
using System.Windows.Threading; 
using System.Windows.Controls; 
using System.Windows.Shapes; 
 
namespace WPF中的冰雪效果2 
{ 
    class snowcanvas : Canvas 
    { 
 
        private void AddEllipse() 
        { 
            double d = G_random_int.Next(myMinWidth1, myMaxWidth1); 
            MyEllipse P_ellipse = new MyEllipse( 
                new Ellipse() 
                { 
                    Width = d, 
                    Height = d, 
                    Fill = new RadialGradientBrush( 
                        new GradientStopCollection()  
                                                {  
                                                    new GradientStop( 
                                                            Color.FromArgb( 
                                                            255,255,255,255 
                                                    ),0.001), 
                                                    new GradientStop( 
                                                            Color.FromArgb( 
                                                            0,255,255,255 
                                                    ), 1.0) 
                                                }) 
                    { 
                        GradientOrigin = new System.Windows.Point(0.5, 0.5) 
                    } 
 
                }, 
                G_random_int.Next(MinVelocity, MaxVelocity)); 
            Canvas.SetTop(P_ellipse.ellipse, G_random_int.Next(0, (int)this.Height - 40)); 
            Canvas.SetLeft(P_ellipse.ellipse, G_random_int.Next(0, (int)(this.Width - P_ellipse.ellipse.Width * 2))); 
            G_Ellipse_List.Add(P_ellipse); 
            this.Children.Add(P_ellipse.ellipse); 
        } 
 
 
        public override void EndInit() 
        { 
            base.EndInit(); 
            CompositionTarget.Rendering += new EventHandler(CompositionTarget_Ren