using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Timers;
namespace DrawARectangle2
{
public partial class Form1 : Form
{
private static System.Timers.Timer aTimer;
public static int t_msec = 0; // tenmiliseconds
public static string formattime;
public static int rad = 3;
public Form1()
{
InitializeComponent();
}
private void DrawIt()
{
System.Drawing.Graphics graphics = this.CreateGraphics();
this.Invalidate();
System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle(
100, 100, rad, 150);
graphics.DrawEllipse(System.Drawing.Pens.Black, rectangle);
}
private void button1_Click(object sender, EventArgs e)
{
aTimer = new System.Timers.Timer(1);
// Hook up the Elapsed event for the timer.
aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
// Set the Interval to 2 seconds (2000 milliseconds).
//aTimer.Interval = 2000;
aTimer.Enabled = true;
}
private void OnTimedEvent(object sender, EventArgs eArgs)
{
DrawIt();
rad++;
}
}
}
0 comments:
Post a Comment