PDA

View Full Version : سوال: کار با flashcontrol



Bahar_HS
شنبه 29 مرداد 1390, 16:12 عصر
با سلام
برای ایجاد حالت چشمک زن در برنامه این کلاس رو نوشتم:



class Blinking
{
Control control;
Color colorControl;
Color backColor;
static Timer timer1;
static Timer timer2;
bool switchh = true;
//
public Blinking(Control ctrl, Color ColorControl, Color BackColor)
{
control = ctrl;
colorControl = ColorControl;
backColor = BackColor;
//
timer1 = new Timer();
timer1.Interval = 500;
timer1.Tick += new EventHandler(tmrBlinking_Tick);
}
public static void StartBlinking(Control Ctr, Color ColorControl, Color BackColor)
{
Blinking blink = new Blinking(Ctr, ColorControl, BackColor);
timer1.Enabled = true;
}
private void tmrBlinking_Tick(object sender, EventArgs e)
{
switch (switchh)
{
case true:
{
control.BackColor = colorControl;
switchh = false;
}
break;
case false:
{
control.BackColor = backColor;
switchh = true;
}
break;
}
}
public static void FinshBlinking()
{
Blinking.timer1.Enabled = false;
}

مثلا برای یک pictureBox روی فرم ،اینطوری فراخوانی ش کردم:

Blinking.StartBlinking(pictureBox3, Color.WhiteSmoke, Color.Lime);
و وقتی روی همین pictureBoxکلیک میشه،حالت چشمک زن باید متوقف بشه:


Blinking.FinshBlinking();

pictureBoxهای مختلفی روی فرم هست،حالت متوقف شدن برای بعضی از این pictureBoxهاانجام میشه و برای بعضی از pictureBoxها انجام نمیشه،با این که Eneable=false قرار می گیره ولی حالت چشمک زن تکرار میشه
اشکال از کجاست؟به تعداد کنترل هایی که این کلاس براشون فراخوانی میشه بستگی داره؟(تعدادpictureBoxهای روی فرم)
(توقف حالت چشمک زن به کلیک کاربر بستگی داره،یعنی هر زمان که روی کنترلی که چشمک زنه کلیک شد،چشمک زدن متوقف بشه )