c# - Smooth Expanding and Collapsing Animation for WinForms -


im trying smooth expanding , collapsing animation form. current animation jittery , non consistent. heres gif of animation. there way doesnt freeze form?

private void showhidetoggle_checkstatechanged(object sender, eventargs e)     {         if (showhidetoggle.checked) //checked = expand form         {             showhidetoggle.text = "<";             while (width < originalwidth)             {                 width++;                 application.doevents();             }         }         else         {             showhidetoggle.text = ">";             while(width > 24)             {                 width--;                 application.doevents();             }         }     } 

create timer:

timer t = new timer(); t.interval = 14; t.tick += delegate {     if (showhidetoggle.checked)     {         if (this.width > 30) // set form.minimumsize otherwise timer keep going, permanently try decrease size.             this.width -= 10;         else             t.stop();     }     else     {         if (this.width < 300)             this.width += 10;         else             t.stop();     } }; 

and change code to:

private void showhidetoggle_checkstatechanged(object sender, eventargs e) {     t.start(); } 

Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -