Cartoon C;
private void btnShow_Click(object sender, EventArgs e)
{
C.Show();
}
private void Form1_Load(object sender, EventArgs e)
{
C = new Cartoon(picShow, iLShow);
}
class Cartoon
{
#region Attributi
private ImageList iL;
private PictureBox pic;
private Timer tm = new Timer();
int i = 0; //indice della frame
#endregion Attributi
public Cartoon(PictureBox pic, ImageList iL)
{
this.pic = pic;
this.iL = iL;
tm.Tick += new System.EventHandler(this.tm_Tick);
tm.Interval = 100;
}
#region Metodi Pubblici
public void Show()
{
i = 0;
if (!tm.Enabled) tm.Start();
}
#endregion Metodi Pubblici
#region Metodi Privati
private void tm_Tick(object sender, EventArgs e)
{
if (i < iL.Images.Count)
{
pic.Image = iL.Images[i];
i++;
}
else
tm.Stop();
}
#endregion Metodi Privati
}