Анимация - C# (213275)

Узнай цену своей работы

Формулировка задачи:

Ребята, как можно на форму загрузить анимацию?

Решение задачи: «Анимация»

textual
Листинг программы
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
 
namespace MainMenu
{
    public partial class men : Form
    {
        public men()
        {
            InitializeComponent();
        }
        //Create a Bitmpap Object.
        Bitmap animatedImage = new Bitmap("SampleAnimation.gif");
        bool currentlyAnimating = false;
 
        //This method begins the animation.
        public void AnimateImage()
        {
            if (!currentlyAnimating)
            {
 
                //Begin the animation only once.
                ImageAnimator.Animate(animatedImage, new EventHandler(this.OnFrameChanged));
                currentlyAnimating = true;
            }
        }
 
        private void OnFrameChanged(object o, EventArgs e)
        {
 
            //Force a call to the Paint event handler.
            this.Invalidate();
        }
 
        protected override void OnPaint(PaintEventArgs e)
        {
 
            //Begin the animation.
            AnimateImage();
 
            //Get the next frame ready for rendering.
            ImageAnimator.UpdateFrames();
 
            //Draw the next frame in the animation.
            e.Graphics.DrawImage(this.animatedImage, new Point(0, 0));
        }
    }
}

ИИ поможет Вам:


  • решить любую задачу по программированию
  • объяснить код
  • расставить комментарии в коде
  • и т.д
Попробуйте бесплатно

Оцени полезность:

11   голосов , оценка 3.909 из 5
Похожие ответы