iconos animados

13/09/2006 - 17:37 por Carmelo J. Morales Muñoz | Informe spam
hola!

en vs2005 en un timage coloco un icono animado y se mueve.

Lo que quiero es que no se mueva hasta que yo lo indique. Algo así como lo
que hace el indicador del internet explorer. Quiero que el gif animado se
mueva mientras está haciendo peticiónes al servidor solamente.

¿Pueden indicarme como?

lo único que se me ha ocurrido es cambiar de imagen por otra estática.

bye!

Preguntas similare

Leer las respuestas

#1 Oswaldo
13/09/2006 - 17:53 | Informe spam
Una idea
Podrías tener dos gifs uno estatico y uno animado, el dinamico lo
desplegarás en el momento en que se realiza la petición y al ser procesada
esta, lo regresas al gif estatico. Toma en cuenta que se ejecuta primero el
código del lado del cliente y luego el del lado del servidor, para determinar
en que parte debes de poner el cambio de imagen.
Saludos!

"Carmelo J. Morales Muñoz" wrote:

hola!

en vs2005 en un timage coloco un icono animado y se mueve.

Lo que quiero es que no se mueva hasta que yo lo indique. Algo así como lo
que hace el indicador del internet explorer. Quiero que el gif animado se
mueva mientras está haciendo peticiónes al servidor solamente.

¿Pueden indicarme como?

lo único que se me ha ocurrido es cambiar de imagen por otra estática.

bye!



Respuesta Responder a este mensaje
#2 Carmelo J. Morales Muñoz
13/09/2006 - 21:24 | Informe spam
ok,es una buena idea

gracias!
Respuesta Responder a este mensaje
#3 RAlvare
19/09/2006 - 22:28 | Informe spam
ok,es una buena idea



Hay que reconocer que lo más sencillo es lo mejor.

Pero, os pongo un fragmento del libro Windows Forms 2.0 Programming, de
Chris Sells y
Michael Weinhardt, que está relacionado con este hilo:

Animation
Just as some raster formats support transparency as a native color, some
also support animation. One in particular is the GIF format. Images expose
support for animation by supporting more than one image in a single file.
GIFs support animation by storing two or more images in an array that
represents a time dimension, but other formats (such as TIFF files) can
support different resolutions or multiple images as pages. You can count how
many pages are in each "dimension" by calling the GetFrameCount method with
FrameDimension objects exposed by properties from the FrameDimension class:

// Will throw exceptions if image format doesn't support// multiple images
along requested dimensionBitmap gif = new Bitmap(typeof(AnimationForm),
"animatedgif.gif");int timeFrames =
gif.GetFrameCount(FrameDimension.Time);int pageFrames =
gif.GetFrameCount(FrameDimension.Page);int resolutionFrames =
gif.GetFrameCount(FrameDimension.Resolution);

Selecting which frame to be displayed when the image is drawn is a matter of
selecting the "active" frame along a dimension:

int frame = 4; // Needs to be between 0 and frame count -1
gif.SelectActiveFrame(FrameDimension.Time, frame); g.DrawImage(gif,
this.ClientRectangle);

In addition to the multiple frames, the GIF format encodes timing
information for each frame. However, that's where things get tricky. Because
different image formats support different information, the Image class
exposes "extra" information via its GetPropertyItem method. This method
takes a numeric ID and returns a generic PropertyItem object. The IDs
themselves are defined only in a GDI+ header file and the PropertyItem
object's Value property. The Value property exposes the actual data as an
array of bytes that must be interpreted, making usage from .NET difficult.
For example, here's how to get the timings for a GIF file:

// Get bytes describing each frame's time delayint PropertyTagFrameDelay =
0x5100; // From GdiPlusImaging.hPropertyItem prop =
gif.GetPropertyItem(PropertyTagFrameDelay);byte[] bytes = prop.Value; //
Convert bytes into an array of time delaysint frames =
gif.GetFrameCount(FrameDimension.Time);int[] delays = new int[frames];for(
int frame = 0; frame != frames; ++frame ) { // Convert each 4-byte chunk
into an integer delays[frame] = BitConverter.ToInt32(bytes, frame * 4);}

After you have the time delays, you can start a timer and use the
SelectActiveFrame method to do the animation. If you do it that way, make
sure to convert the delays to milliseconds (1/1000 second), which is what
.NET timers like, from centiseconds (1/100 second), which is what GIF time
delays are specified in. Or just use the ImageAnimator helper class, which
can do all this for you:

// Load animated GIFBitmap gif = new Bitmap(@"c:\animatedgif.gif"); void
AnimationForm_Load(object sender, EventArgs e) { ... // Check whether
image supports animation if( ImageAnimator.CanAnimate(gif) ) { //
Subscribe to an event indicating the next frame should be shown
ImageAnimator.Animate(gif, gif_FrameChanged); } ...} void
gif_FrameChanged(object sender, EventArgs e) { if( this.InvokeRequired )
{ // Transition from worker thread to UI thread
this.BeginInvoke( new EventHandler(gif_FrameChanged), new
object[] { sender, e }); } else { currentFrame++;
this.toolStripStatusLabel1.Text = string.Format("Frame {0} of
{1}", currentFrame, frameCount); if( currentFrame == frameCount )
currentFrame = 0; // Trigger Paint event to draw next frame
this.Invalidate(); }}void AnimationForm_Paint(object sender,
PaintEventArgs e) { // Update image's current frame
ImageAnimator.UpdateFrames(gif); // Draw image's active frame Graphics g
= e.Graphics; Rectangle rect = this.ClientRectangle; rect.Height -=
this.statusStrip1.Height; g.DrawImage(gif, rect);}The ImageAnimator knows
how to pull the timing information out of an image and call you back when
it's time to show a new frame, which is what calling ImageAnimator.Animate
does. When the event is fired, invalidating the rectangle being used to draw
the animated GIF triggers the Paint event. The Paint event sets the next
active frame by calling ImageAnimator.UpdateFrames before drawing the active
frame. Figure 5.30 shows an image being animated.



The only thing that's a bit tricky is that the animated event is called back
on a worker thread, not on the main UI thread, because it's not legal for
the former to make any method calls on objects executing from the latter,
such as forms. To avoid breaking the law, we used the BeginInvoke method to
transition back from the worker thread to the UI thread to make the call.
This technique is discussed in gory detail in Chapter 18: Multithreaded User
Interfaces.

Many of the animation capabilities discussed so far are automatically
provided by the PictureBox control, which basically wraps the appropriate
ImageAnimator method calls, such as Animate. All you need to do is set the
PictureBox's Image property with an image that supports animation, and it
takes care of the rest:

void AnimatedPictureBoxForm_Load(object sender, EventArgs e) { Bitmap gif =
new Bitmap(@"c:\animatedgif.gif"); this.animatedPictureBox.Image = gif; //
Automatically begins animating}

PictureBox is perfect if all you need is to simply animate your image.
Unfortunately, PictureBox doesn't provide hooks into the animation process
(as the FrameChanged event does). This means that you need to code directly
against ImageAnimator for such support. However, some controls, including
Button, Label, and ToolStripItem, do support animation natively. Simply set
the control's Image property to the animated GIF directly:

this.animatedLabel.Image = Image.FromFile(@"c:\animatedgif.gif");
email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaRespuesta Tengo una respuesta
Search Busqueda sugerida