namespace play_stop
{
    public partial class Form1 : Form
    {

        public Form1()
        {
            InitializeComponent();

        }
 private void button4_Click(object sender, EventArgs e)
        {

            timer1.Interval = 1000;
            timer1.Start();
            Counter = 0;
    }

        public void circles()
        {
      Graphics g = panel1.CreateGraphics();
             g.DrawEllipse(
             new Pen(Color.Red),panel1.Width / 2, panel1.Height / 2,75, 75);
              Graphics h = panel1.CreateGraphics();
               h.DrawEllipse(
                new Pen(Color.Blue),
               panel1.Width / 2, panel1.Height / 2, 50, 50);
               Graphics j = panel1.CreateGraphics();
               j.DrawEllipse(
                new Pen(Color.Yellow),
               panel1.Width / 2, panel1.Height / 2, 80,80);
               Graphics k = panel1.CreateGraphics();
               k.DrawEllipse(
                new Pen(Color.Green),
               panel1.Width / 2, panel1.Height / 2, 100,100);



        }
        public int counter;
        public int Counter
        {
            get { return counter; }
            set { counter = value; }
        }


        private void timer1_Tick(object sender, EventArgs e)
        {

            Counter++;
           while ( counter < 5 )
            {
                circles();

            }
  }

    }
    }

Recommended Answers

You just posted your code, please give more info so we can help. What's the problem with your code? What were the result it gave you? What's the result you want to achive? What things did you try?

Jump to Post

You could write your property starting on line 40 in one line. It is called an auto-implemented property. It goes like this: public int counter { get; set; }
Don't know exactly what your problem is, could you tell us a bit more?

Jump to Post

All 6 Replies

help me above one

You just posted your code, please give more info so we can help. What's the problem with your code? What were the result it gave you? What's the result you want to achive? What things did you try?

You could write your property starting on line 40 in one line. It is called an auto-implemented property. It goes like this: public int counter { get; set; }
Don't know exactly what your problem is, could you tell us a bit more?

Actually i want to dispaly circles on a panel with time of 1 sec gap .i was tried but all the circles are displaying at a time and one circle were flickering

help me for above one

Try this

public void Circles() {
    Graphics g = panel1.CreateGraphics;
    if (counter > 0) {
        using (Pen redPen = new Pen(Color.Red)) {
            g.DrawEllipse(redPen, panel1.Width / 2, panel1. Height / 2, 75, 75);
        }
    }

    if (counter > 1) {
        using (Pen bluePen = new Pen(Color.Blue)) {
            g.DrawEllipse(bluePen, panel1.Width / 2, panel1. Height / 2, 50, 50);
        }
    }

    if (counter > 2) {
        using (yellowPen = new Pen(Color.Yellow)) {
            g.DrawEllipse(yellowPen, panel1.Width / 2, panel1. Height / 2, 80, 80);
        }
    }

    if (counter > 3) {
        using (greenPen = new Pen(Color.Green)) {
            g.DrawEllipse(greenPen, panel1.Width / 2, panel1. Height / 2, 100, 100);
        }
    }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.