Изменение цвета формы с течением времени - C#
Формулировка задачи:
Здрасте! )
В C#, vs 2008.
Вопрос вообщем в чем: Как изменить цвет формы с течением времени? (допустим, прошла 1 секунда, поменялся цвет, еще одна, другой цвет и т.д).
Решение задачи: «Изменение цвета формы с течением времени»
textual
Листинг программы
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace WindowsFormsApplication
{
public partial class program : Form
{
[STAThread]
static void Main()
{
Application.Run(new program());
}
Random rand = new Random();
Timer timer = new Timer();
public program()
{
this.Paint += new PaintEventHandler(program_Paint);
timer.Interval = 1000;
timer.Enabled = true;
timer.Tick += new EventHandler(timer_Tick);
}
void timer_Tick(object sender, EventArgs e)
{
Invalidate();
}
void program_Paint(object sender, PaintEventArgs e)
{
Color c = Color.FromArgb(rand.Next(255), rand.Next(255), rand.Next(255));
e.Graphics.Clear (c);
}
}
}