Implementation of the eyesbaby function: Window fading effect

Source: Internet
Author: User

The effect of window fading is mainly to enhance the user experience of the software. Currently, winformProgramThis function is automatically available on Vista/win7, so it is only available in earlier versions such as XP.

Let's talk about the specific implementation :-)

1. Use the timer control to control the transparency of the form (opacity ).

 


///   <Summary>
/// Display form
///   </Summary>
Private   Void Showwin ()
{
This . Tsmishowhide. Text =   " Hide " ;
This . Setwindowstate ();
This . Opacity =   0 ;
// Window fade-in effect
Timer tstart =   New Timer ();
Tstart. Interval =   100 ;
Tstart. tick + =   New Eventhandler (tstart_tick );
Tstart. Start ();
}

///   <Summary>
/// Hide form
///   </Summary>
Private   Void Hidewin ()
{
This . Tsmishowhide. Text =   " Display " ;
// Close the window fade-out effect
Timer tclose =   New Timer ();
Tclose. Interval =   100 ;
Tclose. tick + =   New Eventhandler (tclose_tick );
Tclose. Start ();
}

///   <Summary>
/// Disable form fade-in
///   </Summary>
///   <Param name = "sender"> </param>
///   <Param name = "E"> </param>
Void Tclose_tick ( Object Sender, eventargs E)
{
// Transparency reduced by 10% per execution
This . Opacity -=   0.1 ;
If ( This . Opacity <=   0 )
{
(Timer) sender). Stop ();
}
}

///   <Summary>
/// Enable the form fade-in effect
///   </Summary>
///   <Param name = "sender"> </param>
///   <Param name = "E"> </param>
Void Tstart_tick ( Object Sender, eventargs E)
{
// The transparency of each execution increases by 10%
This . Opacity + =   0.1 ;
If ( This . Opacity =   1 )
{
(Timer) sender). Stop ();
This . Focus ();
}
}

 

 

 

The fading effect is also called a test tool on eyesbaby.

 

Summary

Now, the implementation of the eyesbaby function is written here. I wrote a part above, but the technical content is not much. As evidenced by my technical skills, most of my writing can only be a self-recorded method, and it cannot be used as an example! There are many places to learn, and some bloggers have made a lot of good suggestions. For example, the automatic update part. Thank you!

In the future, I hope to develop more personal software that will help us in our work and life (I believe in "technology changes our lives"). I also hope you can provide more suggestions and technical help!

 

Source code: Http://eyesbaby.codeplex.com/

Installation: http://files.cnblogs.com/yizhuqing/EyesBabySetup10.zip

My first utility-eye protection program (eyesbaby)

Eyesbaby1.0 help documentation

Implementation of the eyesbaby function: Window dragging and Scaling

Add characters to the image control using the eyesbaby Function

Eyesbaby function implementation-Windows foreground color Regulator

Software Update for eyesbaby function implementation

Implementation of the eyesbaby function: Window fading effect

 

Welcome to the eyesbaby Development Team

Eyesbaby demand feedback team

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.