Bitmap bmp;
Timer timer = new Timer();
int top = 0;
public Form1()
{
this.Size = new Size(300, 300);
Rectangle r= this.ClientRectangle;
bmp= new Bitmap(r.Width, r.Height * 2);
using (Graphics g = Graphics.FromImage(bmp))
{
g.Clear(Color.LightBlue);
Random ran= new Random();
for (int i = 0; i < 1000; i++)
{
int x = ran.Next() % bmp.Width;
int y = ran.Next() % bmp.Height;
int i= ran.Next() % 5;
g.FillEllipse(Brushes.White, x, y, dot, dot);
g.FillEllipse(Brushes.White, x, y+r.Height, i, i);
}
}
timer.Interval = 200;
timer.Enabled = true;
timer.Tick += delegate { Invalidate(); };
}
protected override void OnPaint(PaintEventArgs e)
{
int height = this.ClientRectangle.Height;
top += 10;
if (top > height) top = 0;
e.Graphics.DrawImageUnscaled(bmp, 0, top - height);
}
protected override void OnPaintBackground(PaintEventArgs e)
{
}