In the use of the excitement of the process, want to give the program to do a splash screen, I used the display aform, over a period of time, hide this aform,showdialog next bform,closeaform this method to do, do not know if you have a good way.
Set the program bundle Aform to start:
[C-sharp]View Plaincopy < param name= "allowfullscreen" value= "false" >< param name= "wmode" value= "Transparent" >
- static void Main ()
- {
- Application.enablevisualstyles ();
- Application.setcompatibletextrenderingdefault (false);
- Application.Run (new Aform ());
- }
The following timer is defined in Aform
Startwindowshowtime Hidewindowstart hidewindowspeed Showwindowstart
Define their properties Startwindowshowtime (display aform time length) enabled=true interval=5000 (100=1 seconds)
Hidewindowstart (The process of starting to hide aform) enabled=true interval=4500
Hidewindowspeed (hide aform gradient interval) enabled=false interval=10
Showwindowstart (shows aform gradient interval) enabled=true interval=10
Ok, the following begins to define the tick of these timer in events can be directly filled in, timer on this one, can also write background, but I think it is more convenient to fill out here, and can automatically generate a declaration of methods, do not have to find. Take a lazy look.
Startwindowshowtime Tick:showmainwindow
Hidewindowstart Tick:hidewindow
Hidewindowspeed Tick:hidewindowspeedstart
Showwindowstart Tick:showwindow
Okay, here's what I'm going to say. Windows Form achieves transparency, gradients, fades the most important part of the implementation of the effect, that is, the opacity in the form attribute, with this. I have verified that only more than 2000 of the system supports this attribute.
Let's set Aform's opacity to 0, and start writing aform code.
[C-sharp]View Plaincopy
- Public partial class Aform:form
- {
- Public Form ()
- {
- InitializeComponent ();
- }
- private void Start_load (object sender, EventArgs e)
- {
- Startwindowshowtime.start ();
- Hidewindowstart.start ();
- }
- private void Showmainwindow (object sender, EventArgs e)
- {
- Bform showmainwindows = new Bform ();
- This . Hide ();
- Startwindowshowtime.stop ();
- Hidewindowstart.stop ();
- Hidewindowspeed.stop ();
- Showmainwindows. ShowDialog ();
- This . Close ();
- }
- private void Hidewindow (object sender, EventArgs e)
- {
- Hidewindowspeed.start ();
- }
- private void Hidewindowspeedstart (object sender, EventArgs e)
- {
- This . Opacity = This . Opacity-0.02;
- }
- private void ShowWindow (object sender, EventArgs e)
- {
- if (this. Opacity = = 1)
- {
- Showwindowstart.stop ();
- }
- Else
- {
- This . Opacity = This . Opacity + 0.02;
- }
- }
- }
Well, this time everyone run to see, hehe fade.
I originally set the value of opacity each change to 0.1, but found that if the fade-out is not very moist, so the value and interval time are reduced. It looks so much more moist. I feel good about myself.
If everyone's program only needs to be transparent, then just set opacity this.
Gradients and fades Tiger with a timer and opacity this, you can do it.
Small experience, and share with you. I hope to make a friend with you all.
Everyone remember to contact me Ah!
C # WinForm Gradient effect