简体   繁体   中英

How to stop GIF at specific Frames in winfoms

basically my question is how to stop GIF at specific frame.

i have a picture box that is already set its image with GIF and i created a 2 events Enter and Leave

    private void pictureBox1_MouseEnter(object sender, EventArgs e)
    {
        pictureBox1.Image = Properties.Resources.LOGODEFAULT1;
    }
    private void pictureBox1_MouseLeave(object sender, EventArgs e)
    {
        pictureBox1.Image = Properties.Resources.LOGOLEAVE1;
    }

what i want is to stop the GIF at last frame(all gif's consist of 7 frames) i tried the ImageAnimator and ImageStop

 private void pictureBox1_MouseEnter(object sender, EventArgs e)
    {
        ImageAnimator.Animate(pictureBox1.Image, OnFrameChanged1);
    }
    private void pictureBox1_MouseLeave(object sender, EventArgs e)
    {
        ImageAnimator.StopAnimate(pictureBox1.Image, OnFrameChanged2); 
    }
    private void OnFrameChanged1(object sender, EventArgs e)
    {
        pictureBox1.Image = Properties.Resources.LOGODENTER;
    }
    private void OnFrameChanged2(object sender, EventArgs e)
    {
        pictureBox1.Image = Properties.Resources.LOGOLEAVE1;
    }

我认为您可以使用Image.SelectActiveFrame方法

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM