c# - Timer Background transition -


i trying have form's background change when press button transition.

i figured simple , fast way put white panel on form, blank backcolor, , change alpha component 0 250 250 0 when click button. when alpha reaches maximum value, want change background image. technique worked hour ago, color not change @ all, , code not entirely executed. here's function called timer :

private void changeindex(object sender, eventargs e)     {     if (progressbar.value == progressbar.maximum-progressbar.step)     {         t.stop();          btndébut.enabled = true;         btnfin.enabled = true;         btnprécédent.enabled = true;         btnsuivant.enabled = true;          if (indicecourant >= dt.rows.count)         {             this.indicecourant = 0;         }          lblchargement.visible = false;         progressbar.visible = false;         remplitchamps(indicecourant);     }      progressbar.step = 10;     progressbar.maximum = 200;     progressbar.performstep();      messagebox.show(progressbar.value.tostring() + " " + pnlfondecran.backcolor.a.tostring() + " " + progressbar.maximum.tostring());      if(progressbar.value <100)     {         this.pnlfondecran.backcolor = system.drawing.color.fromargb(pnlfondecran.backcolor.a + progressbar.maximum/progressbar.step,255, 255,255);         // wanna add 24 each time, until alpha=240     }                  else     {         messagebox.show("error");         this.pnlfondecran.backcolor = system.drawing.color.fromargb(pnlfondecran.backcolor.a -progressbar.maximum / progressbar.step, 255, 255, 255);         //then substract 24 each time     } } 

the panel's name pnlfondecran. progressbar works fine. messagebox.show(some stuff )'s ouptpur 0,20,40... 200, 0, 200. progressbar.value<100 statement never evaluated until first last time function called, have no idea why.

here's method calling changeindex() :

private void debuttimer()//lance le timer pour la progressbar {     lblchargement.visible = true;     progressbar.visible = true;      progressbar.value = 0;     //gestion du timer     t = new system.windows.forms.timer();     t.interval = 150;     t.enabled = true;     t.tick += new eventhandler(changeindex);     t.start();     //gestion des boutons     btndébut.enabled = false;     btnfin.enabled = false;     btnprécédent.enabled = false;     btnsuivant.enabled = false; } 


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -