using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace FadeInFadeOut
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
//Formun Görülebilirliğini Opacity Özelliği ile set edebiliriz.
//0-1 arasında bir deger alabilir
//this.Opacity = 0.5;
//yavas yavas görünürlük artsın
this.Opacity = 0;
//timer çalışmaya başlasın opacity azar azar artsın
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
//opacity degeri artsın
//opacity degeri 1 e ulaşınca artış dursun timer stop etsin
if (this.Opacity == 1)
timer1.Stop();
else
this.Opacity += 0.1;
}
private void timer2_Tick(object sender, EventArgs e)
{
if (this.Opacity == 0)
{
timer2.Stop();
this.Close();
}
else
this.Opacity -= 0.1;
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
//önce kapatma işlemini iptal et ardından opacity değerini azaltmaya başla
if (this.Opacity != 0)
{
e.Cancel = true;
timer2.Start();
//this.Opacity = 1;
}
}
}
}
Dosyayı İndir

