Fade effects in Windows forms

后端 未结 2 558
-上瘾入骨i
-上瘾入骨i 2021-01-27 15:01

I am trying to add somefading effects to a button, a picturebox and a text box, using Windows Forms.

I know I should use WPF for this, but I never worked with it and it\

2条回答
  •  孤独总比滥情好
    2021-01-27 15:35

    Let me start by saying, you may not even care anymore about getting an answer as this question is almost 1 year old. I felt the need to post this answer because I think it does help answer the OP's question, and not by providing a solution but by providing a road-map of how to get to the solution...I think that's the best way to learn.

    Let's begin...

    Transitions are choppy because your event handler for "MouseHover" fires continuously as the mouse hovers over the control. This is causing your animations to get interrupted and making them appear choppy.

    My recommendation here, use the "MouseEnter" event to start your timer.

    Investigate a little more and you might find similarities between your two timers and use a single timer to do both tasks by creating your own timer that has a method that can be triggered by these two events to cause the button to grow or shrink.

    Also, though people have suggested WPF (and I don't disagree, WPF can be useful), don't lose faith in System.Windows.Forms.

提交回复
热议问题