Try using a System.Windows.Forms.Timer
This is a timer for windows forms.
Toggle a ShowGraphic boolean variable in the timer tick event.
Then test the value of ShowGraphic in the form paint event.
nick.crane
Nearly a Posting Virtuoso
1,230 posts since Feb 2010
Reputation Points: 375
Solved Threads: 187
To make a Graphic dissapear you could first draw one.
Wait 3 secs or watever.
Draw the same grhaphic again but with the Brush in the backgroundcolor of the form.
Wait 3 secs or whatever.
Draw the graphic again with a Brush in the color you had before.
ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661
When drawing graphics an a form the best place to do this is the forms Paint event.
Select your form, then in the properties window click on the little lighining button; this opens the events list.
Scroll to the Paint event and double click to add the event handler in your code.
Now in the handler write the code to draw the graphics.
You should use the Graphics object from the PaintEventArgs object (ie. e.Graphics) to do this.
Adding a Timer is easy.
In the toolbox expand the Components group.
Just drag the timer (at the bottom of the group) on to you form.
In the properties of the timer set the interval (in your case 3000 ms).
Now double click on the timer to add the Tick event handler.
Add code in the timer tick event to turn on and off a boolean variable that you can test in the forms paint event.
The code below draws a line from the top left to bottom right of the form when checkBox1 is checked and disapears when checkBox1 is unckecked.
private void Form1_Paint(object sender, PaintEventArgs e)
{
if (checkBox1.Checked)
{
e.Graphics.DrawLine(Pens.Black, new Point(0, 0), (Point)this.Size);
}
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
this.Invalidate(); // force form to re-paint
}
nick.crane
Nearly a Posting Virtuoso
1,230 posts since Feb 2010
Reputation Points: 375
Solved Threads: 187
That probably does not even compile.
Based on what you need to do, the TMR1.Start(); should be done only after the password has been entered correctly and not in the timer tick event.
The timer interval can be set in the properties and is not needed here. e.Graphics.Visible = true; will not compile as the 'e' is a basic EventArgs object.
You should look at my code example again. The Graphics object is in the Form_Paint event handler.
Get things working bit by bit with test code first.
Then, as you add new bits, add/change your existing code to suit what you now need.
The timer event should only need a call to this.Invalidate(); ('this' being the form).
nick.crane
Nearly a Posting Virtuoso
1,230 posts since Feb 2010
Reputation Points: 375
Solved Threads: 187
I think these few mods might help with your timing.
boolean _showGraphics = false;
private void Form1_Paint(object sender, PaintEventArgs e)
{
if (_showGraphics)
{
// draw graphics here
}
}
private void Timer1_Tick(object sender, EventArgs e)
{
_showGraphics = !_showGraphics;
this.Invalidate();
}
nick.crane
Nearly a Posting Virtuoso
1,230 posts since Feb 2010
Reputation Points: 375
Solved Threads: 187
If solved then please mark the thread solved.
nick.crane
Nearly a Posting Virtuoso
1,230 posts since Feb 2010
Reputation Points: 375
Solved Threads: 187