ciao,
al tempo mi ero fatto un componentino molto "spartano" per visualizzare le gif animate, con questo codice abbastanza intuitivo:
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)
{
try
{
using (Graphics graph = this.CreateGraphics())
{
graph.Clear(this.BackColor);
graph.DrawImage(pagine[i++ % pagine.Count], 0, 0);
}
}
catch {}
}
}
se vuoi puoi provare a darci un'occhiata.
Come vedi la proprieta' "CheckForIllegalCrossThreadCalls" ti aiuta per evitare il Cross-Thread.
ps: non ho capito cosa intendi qui:
>...settando il tag (proprietà dell'immagine della picture box) a it just works. Questa funziona.
cosa vuole dire "a it just works" ? e poi perche' la proprieta "tag" e non "image"?
ciao.
Matteo Raumer
[MCAD .net]
http://blogs.dotnethell.it/freeteo