最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Winform 顯示Gif圖片的實例代碼

 更新時間:2014年01月20日 15:42:19   作者:  
這篇文章主要介紹了Winform 顯示Gif圖片的實例代碼,有需要的朋友可以參考一下

復(fù)制代碼 代碼如下:

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;
using System.Diagnostics;

namespace DysncPicTest
{
    public partial class Form1 : Form
    {
        private Image m_imgImage = null;
        private EventHandler m_evthdlAnimator = null;
        public Form1()
        {
            InitializeComponent();
            this.SetStyle(ControlStyles.UserPaint, true);
            this.SetStyle(ControlStyles.DoubleBuffer, true);
            this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);

            m_evthdlAnimator = new EventHandler(OnImageAnimate);
            Debug.Assert(m_evthdlAnimator != null);
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            if (m_imgImage != null)
            {
                UpdateImage();
                e.Graphics.DrawImage(m_imgImage, new Rectangle(100, 100, m_imgImage.Width, m_imgImage.Height));
            }
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            m_imgImage = Image.FromFile("1.gif"); // 加載測試用的Gif圖片
            BeginAnimate();
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
             if (m_imgImage != null)
            {
                StopAnimate();
                m_imgImage = null;
            }
        }

        private void BeginAnimate()
        {
           if (m_imgImage == null)
                return;

           if (ImageAnimator.CanAnimate(m_imgImage))
           {
                ImageAnimator.Animate(m_imgImage,m_evthdlAnimator);
           }
        }

        private void StopAnimate()
        {
            if (m_imgImage == null)
                return;

            if (ImageAnimator.CanAnimate(m_imgImage))
            {
                ImageAnimator.StopAnimate(m_imgImage,m_evthdlAnimator);
            }
        }

        private void UpdateImage()
        {
            if (m_imgImage == null)
                return;

            if (ImageAnimator.CanAnimate(m_imgImage))
            {
                ImageAnimator.UpdateFrames(m_imgImage);
            }
        }

        private void OnImageAnimate(Object sender,EventArgs e)
        {
            this.Invalidate();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
    }
}        

相關(guān)文章

  • C#連接mysql數(shù)據(jù)庫完整實例

    C#連接mysql數(shù)據(jù)庫完整實例

    這篇文章主要介紹了C#連接mysql數(shù)據(jù)庫的方法,以一個完整實例形式分析了C#操作mysql數(shù)據(jù)庫連接的基本技巧,非常具有實用價值,需要的朋友可以參考下
    2015-05-05
  • C#如何從byte[]中直接讀取Structure實例詳解

    C#如何從byte[]中直接讀取Structure實例詳解

    這篇文章主要給大家介紹了關(guān)于利用C#如何從byte[]里直接讀取Structure的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-03-03
  • Winform窗口實現(xiàn)多顯示屏顯示的2種方法

    Winform窗口實現(xiàn)多顯示屏顯示的2種方法

    這篇文章主要介紹了Winform窗口實現(xiàn)多顯示屏顯示的2種方法,本文直接給出了實現(xiàn)代碼,并對其中的一些重要參數(shù)做了解釋,需要的朋友可以參考下
    2015-06-06
  • 在C# 8中如何使用默認(rèn)接口方法詳解

    在C# 8中如何使用默認(rèn)接口方法詳解

    這篇文章主要給大家介紹了關(guān)于在C# 8中如何使用默認(rèn)接口方法的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-01-01
  • C#中標(biāo)準(zhǔn)的IDispose模式代碼詳解

    C#中標(biāo)準(zhǔn)的IDispose模式代碼詳解

    在本篇文章中小編給大家分享的是關(guān)于C#中標(biāo)準(zhǔn)的IDispose模式的實例用法相關(guān)內(nèi)容,有需要的朋友們測試下。
    2019-09-09
  • C#隨機(jī)設(shè)置900-1100毫秒延遲的方法

    C#隨機(jī)設(shè)置900-1100毫秒延遲的方法

    這篇文章主要介紹了C#隨機(jī)設(shè)置900-1100毫秒延遲的方法,涉及C#中Thread.Sleep方法的使用技巧,需要的朋友可以參考下
    2015-04-04
  • WPF中使用WebView2控件的方法及常見問題

    WPF中使用WebView2控件的方法及常見問題

    WebView2為WPF網(wǎng)頁瀏覽工具,具有簡單易用,頁面顯示清晰的優(yōu)點,下面這篇文章主要給大家介紹了關(guān)于WPF中使用WebView2控件的方法及常見問題,文中通過實例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2023-02-02
  • 詳解C#中的字符串拼接@ $

    詳解C#中的字符串拼接@ $

    這篇文章主要介紹了C#中的字符串拼接@,$的相關(guān)知識,代碼簡單易懂,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下
    2019-09-09
  • C#操作字符串方法總結(jié)實例代碼

    C#操作字符串方法總結(jié)實例代碼

    這篇文章主要介紹了C#操作字符串方法總結(jié)實例代碼,需要的朋友可以參考下
    2017-10-10
  • C#中的矩形數(shù)組(多維數(shù)組)和鋸齒數(shù)組的實現(xiàn)

    C#中的矩形數(shù)組(多維數(shù)組)和鋸齒數(shù)組的實現(xiàn)

    本文主要介紹了C#中的矩形數(shù)組(多維數(shù)組)和鋸齒數(shù)組的實現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-04-04

最新評論

蒲江县| 韩城市| 邻水| 庆安县| 长寿区| 延长县| 怀安县| 临江市| 全南县| 秭归县| 翁源县| 岗巴县| 鄂托克前旗| 沽源县| SHOW| 新巴尔虎右旗| 彰武县| 互助| 平安县| 湟源县| 那曲县| 格尔木市| 东光县| 镇安县| 四会市| 淮南市| 河北区| 会宁县| 九龙县| 铜陵市| 海晏县| 十堰市| 德惠市| 云龙县| 嘉定区| 阳山县| 漠河县| 湖北省| 岳池县| 潞西市| 嘉荫县|