winforms - How to pause for user control in C#? -


i made little program while reading head first c#. i'm trying program pause user set numericupdown control level of difficulty. here's code...

namespace wack {     public partial class form1 : form     {         public int level;         mole mole;         random random = new random();          public form1()         {             initializecomponent();              mole = new mole(random, new mole.popup(molecallback));             messagebox.show("select level");             if (level == 1)             {                 timer1.interval = random.next(500, 500);             }             if (level == 2)             {                 timer1.interval = random.next(400, 400);             }             if (level == 3)             {                 timer1.interval = random.next(300, 300);             }             timer1.start();         }          private void timer1_tick(object sender, eventargs e)         {             timer1.stop();             togglemole();         }          private void togglemole()         {             if (mole.hidden == true)                 mole.show();             else                 mole.hideagain();             if (level == 1)             {                 timer1.interval = random.next(500, 500);             }             if (level == 2)             {                 timer1.interval = random.next(400, 400);             }             if (level == 3)             {                 timer1.interval = random.next(300, 300);             }             timer1.start();          }          private void molecallback(int molenumber, bool show)         {             if (molenumber < 0)             {                 timer1.stop();                 return;             }             button button;             switch (molenumber)             {                 case 0: button = button1; break;                 case 1: button = button2; break;                 case 2: button = button3; break;                 case 3: button = button4; break;                 case 4: button = button5; break;                 case 5: button = button6; break;                 case 6: button = button7; break;                 case 7: button = button8; break;                 default: button = button9; break;             }              if (show == true)             {                 button.text = "hit me!";                 button.backcolor = color.red;             }             else             {                 button.text = "";                 button.backcolor = systemcolors.control;             }              timer1.interval = random.next(500, 1000);             timer1.start();         }          private void button1_click(object sender, eventargs e)         {             mole.smacked(0);         }          private void numericupdown1_valuechanged(object sender, eventargs e)         {             level = (int)numericupdown1.value;         } 

the rest of button handlers omitted make post shorter. haven't posted mole class because think form pause statement should go. of course wrong.

windows applications aren't designed pause waiting user input - that's console application paradigm.

a better way handle disable (or hide) other controls until difficulty has been set. like: show difficulty numericupdown , start button. once start button has been pressed enable/show remaining controls , begin.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -