ciao,
io tempo fa mi ero fatto un controllo, che si preoccupava di fare questo "refresh" usando un timer, con un codice così:
public partial class PictureBoxAnimated : PictureBox
{
System.Timers.Timer timeRefresh = new System.Timers.Timer(100);
List<Image> pagine = new List<Image>();
Image immagine;
public new Image Image
{
get { return immagine; }
set
{
immagine = value;
FrameDimension frameDim = new FrameDimension(immagine.FrameDimensionsList[0]);
int frameCount = immagine.GetFrameCount(frameDim);
//--- se ha piu' immagini dentro (quindi gif animata)
if (frameCount > 1)
{
for (int i = 0; i < frameCount; i++)
{
immagine.SelectActiveFrame(frameDim, i);
pagine.Add(immagine.Clone() as Image);
}
timeRefresh.Enabled = true;
}
else
base.Image = immagine;
}
}
public PictureBoxAnimated()
{
InitializeComponent();
Control.CheckForIllegalCrossThreadCalls = false;
timeRefresh.Elapsed += new System.Timers.ElapsedEventHandler(timeRefresh_Elapsed);
}
int i = 0;
void timeRefresh_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
if (!DesignMode)
{
try
{
using (Graphics graph = this.CreateGraphics())
{
graph.Clear(this.BackColor);
graph.DrawImage(pagine[i++ % pagine.Count],0,0,this.Width,this.Height);
}
}
catch { }
}
}
}
quindi estendevo una picturebox normale, in modo da avere comode tutte le sue proprietà, e poter fare il Drag&Drop del controllo sulle form che mi interessavano.
Prova a vedere se magari ti può essere utile come spunto.
ciao.
Matteo Raumer
[MCAD .net]
http://blogs.dotnethell.it/freeteo