• 大小: 22.48MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-07-15
  • 语言: C#
  • 标签: C#帧动画  

资源简介

C# Winfom实现的帧动画(Bad Apple),本源码为完整的解决方案。可直接打开运行。开发时用的是 VS2012.

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication2
{

    public partial class Form1 : Form
    {

        public Form1()
        {
            InitializeComponent();
        }

        [System.Runtime.InteropServices.DllImport(“winmm.dll“)]
        public static extern uint mciSendString(string lpstrCommand string lpstrReturnString uint uReturnLength uint hWndCallback);

        private volatile bool isStop;
        private int i = 1;
        private Thread t = null;
        private string pathstr = System.Windows.Forms.Application.StartupPath + @“/BadApple_file“;

        private void button1_Click(object sender EventArgs e)
        {
            Control.CheckForIllegalCrossThreadCalls = false;
            
            string bts = button1.Text;
            if (bts == “开始播放“)
            {
                mciSendString(string.Format(@“open ““{0}/0.mp3““ alias temp_alias“ pathstr) null 0 0);
                mciSendString(“play temp_alias“ null 0 0);
                Start();
                button1.Text = “暂停播放“;
            }
            else
            {
                mciSendString(“Pause temp_alias“ null 0 0);
                Stop();
                button1.Text = “开始播放“;
            }
        }

        public void Start()
        {
            isStop = false;
            t = new Thread(new ThreadStart(Threads));
            t.Start();
        }

        public void Stop()
        {
            isStop = true;

            if (t != null && t.ThreadState == ThreadState.Running)
                t.Abort();
            t = null;
        }

        private void Threads()
        {
            while (!isStop)
            {
                string path = pathstr + “/_“ + i++ + “.jpg“;
                Bitmap bitmap = new Bitmap(path);
                pictureBox1.Image = bitmap;
                label1.Text = path;
                if (i == 6575)
                {
                    mciSendString(@“close temp_alias“ null 0 0);
                    button1.Text = “开始播放“;
                    i = 1;
                    break;
                }
                Thread.Sleep(29);
            }
        }

        private void Form1_FormClosed(object sender FormClosedEventArgs e)
        {
            Stop();
            mciSendString(@“close temp_alias“ null 0 0);
        }

    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-03-01 17:38  WindowsFormsApplication2\
     目录           0  2018-03-15 14:49  WindowsFormsApplication2\TestResults\
     目录           0  2017-03-01 17:37  WindowsFormsApplication2\WindowsFormsApplication2\
     文件         187  2017-03-01 17:37  WindowsFormsApplication2\WindowsFormsApplication2\App.config
     文件        3535  2017-03-06 16:57  WindowsFormsApplication2\WindowsFormsApplication2\Form1.Designer.cs
     文件        2701  2017-03-14 17:11  WindowsFormsApplication2\WindowsFormsApplication2\Form1.cs
     文件        5817  2017-03-02 17:16  WindowsFormsApplication2\WindowsFormsApplication2\Form1.resx
     文件         536  2017-03-01 17:37  WindowsFormsApplication2\WindowsFormsApplication2\Program.cs
     目录           0  2017-03-01 17:37  WindowsFormsApplication2\WindowsFormsApplication2\Properties\
     文件        1386  2017-03-01 17:37  WindowsFormsApplication2\WindowsFormsApplication2\Properties\AssemblyInfo.cs
     文件        2900  2017-03-01 17:37  WindowsFormsApplication2\WindowsFormsApplication2\Properties\Resources.Designer.cs
     文件        5612  2017-03-01 17:37  WindowsFormsApplication2\WindowsFormsApplication2\Properties\Resources.resx
     文件        1111  2017-03-01 17:37  WindowsFormsApplication2\WindowsFormsApplication2\Properties\Settings.Designer.cs
     文件         249  2017-03-01 17:37  WindowsFormsApplication2\WindowsFormsApplication2\Properties\Settings.settings
     文件        3827  2017-03-01 17:42  WindowsFormsApplication2\WindowsFormsApplication2\WindowsFormsApplication2.csproj
     目录           0  2017-03-01 17:37  WindowsFormsApplication2\WindowsFormsApplication2\bin\
     目录           0  2017-03-14 17:03  WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\
     目录           0  2017-03-14 17:03  WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\BadApple_file\
     文件     3507425  2017-03-02 15:58  WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\BadApple_file\0.mp3
     文件        3618  2017-03-01 17:27  WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\BadApple_file\_1.jpg
     文件        3618  2017-03-01 17:27  WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\BadApple_file\_10.jpg
     文件        4876  2017-03-01 17:27  WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\BadApple_file\_100.jpg
     文件        5192  2017-03-01 17:27  WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\BadApple_file\_1000.jpg
     文件        5152  2017-03-01 17:27  WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\BadApple_file\_1001.jpg
     文件        5127  2017-03-01 17:27  WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\BadApple_file\_1002.jpg
     文件        5119  2017-03-01 17:27  WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\BadApple_file\_1003.jpg
     文件        5081  2017-03-01 17:27  WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\BadApple_file\_1004.jpg
     文件        5066  2017-03-01 17:27  WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\BadApple_file\_1005.jpg
     文件        5106  2017-03-01 17:27  WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\BadApple_file\_1006.jpg
     文件        5186  2017-03-01 17:27  WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\BadApple_file\_1007.jpg
     文件        5207  2017-03-01 17:27  WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\BadApple_file\_1008.jpg
............此处省略6585个文件信息

评论

共有 条评论

相关资源