iMamad
iMamad

Reputation: 21

Play and Pause .GIF animations in winform

I chose a GIF image for somethings like "Button Control"(Not PictureBox) and it can play .GIF images.

private void radApplicationMenu1_MouseHover(object sender, EventArgs e) 
{ 
    ImageAnimator.StopAnimate(radApplicationMenu1.Image, null); // <-- returns null!
    radApplicationMenu1.DropDownButtonElement.ShowDropDown(); 
}

Now, I want the image would be played or paused is using different mouse events(e.g. leave or mouse hover) till the moment that fire event of mouse hover fixed and immediately after receiving an event will be played (e.g. after four seconds). Again, stay pause till the next mouse and will be played to the end and stay paused after that. In other words, event and plays of images happen simultaneously by the events.

Upvotes: 2

Views: 1906

Answers (1)

DirtyNative
DirtyNative

Reputation: 2834

Try it with:

// start
System.Drawing.ImageAnimator.Animate(yourImage, OnFrameChanged);

// stop
System.Drawing.ImageAnimator.StopAnimate(yourImage, OnFrameChanged);

private void OnFrameChanged(object sender, EventArgs args)
{
}

Edit

You could also show this Image inside a PictureBox and if you want the .gif to stop, just call pictureBox.Enabled = false

Edit 2

private void radApplicationMenu1_MouseHover(object sender, EventArgs e) 
{ 
    // This stops the animation
    ImageAnimator.StopAnimate(radApplicationMenu1.Image, null);
    .
    .
    .
}

Upvotes: 1

Related Questions