• 大小: 204KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-20
  • 语言: C#
  • 标签: 图片  滚动  循环  

资源简介

主要实现在工程文件夹下的所有图片循环滚动

资源截图

代码片段和文件信息

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.IO;
using System.Collections;
using System.Configuration;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        ArrayList picAL = new ArrayList();

        List list = new List();

        int count = 0;

        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender EventArgs e)
        {
            //string strPicPath = @“G:\备份\图片视频\云南游\在天上“;
            string strPicPath = Application.StartupPath + @“\Images“;
            DirectoryInfo di = new DirectoryInfo(strPicPath);
            FileInfo[] fiArray = di.GetFiles();
            foreach (FileInfo fi in fiArray)
            {
                if (fi.Extension.ToLower() == “.jpg“
                    || fi.Extension.ToLower() == “.bmp“
                    || fi.Extension.ToLower() == “.gif“
                    || fi.Extension.ToLower() == “.png“)
                {
                    picAL.Add(fi.FullName);
                }
            }
            for (int i = 0; i < picAL.Count; i++)
            {
                Image image = Image.FromFile(picAL[i].ToString());

                PictureBox pb = new PictureBox();
                pb.Width = 150;
                pb.Height = 150;
                pb.Top = 0;
                pb.Left = panel1.Left + i * 200;
                pb.SizeMode = PictureBoxSizeMode.StretchImage;
                pb.Image = image;
                panel1.Controls.Add(pb);
                list.Add(pb);
            }

            timer1.Enabled = true;
        }

        private void timer1_Tick(object sender EventArgs e)
        {
            if (count > panel1.Controls.Count)
                count = 0;

            foreach (Control pb in panel1.Controls)
            {
                if (pb.Right < panel1.Left)
                {
                    if (panel1.Right - pb.Right >= 20 && count==panel1.Controls.Count)
                    {
                        pb.Left = panel1.Controls.Count * 150 - pb.Left;
                    }
                    count++;
                }
                else
                {
                    pb.Left -= 10;
                }
            }
        }

        private void button2_Click(object sender EventArgs e)
        {
            for (int i = 0; i < list.Count; i++)
            {
                Image image = list[i].Image;
                list[i].Image = null;
                image.Dispose();
            }
            list.Clear();
            picAL.Clear();
            timer1.Enabled = false;
            panel1.Controls.Clear();
        }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        184  2010-10-13 00:25  滚动图片\WindowsFormsApplication1\App.config

     文件       4241  2011-09-01 16:44  滚动图片\WindowsFormsApplication1\bin\Debug\Images\2006_005s.jpg

     文件       3639  2011-09-01 16:41  滚动图片\WindowsFormsApplication1\bin\Debug\Images\200907280544031946.jpg

     文件       4413  2011-09-01 16:30  滚动图片\WindowsFormsApplication1\bin\Debug\Images\209313MY7-1-lp.jpg

     文件     130945  2011-09-01 16:49  滚动图片\WindowsFormsApplication1\bin\Debug\Images\7330601_1302880598258_1024x1024soft.jpg

     文件      10351  2011-09-02 18:08  滚动图片\WindowsFormsApplication1\bin\Debug\Images\bz.jpg

     文件       6479  2011-09-01 16:27  滚动图片\WindowsFormsApplication1\bin\Debug\Images\images.jpg

     文件      11264  2011-10-19 10:39  滚动图片\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe

     文件        184  2010-10-13 00:25  滚动图片\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe.config

     文件      42496  2011-10-19 10:39  滚动图片\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.pdb

     文件      14328  2011-10-19 10:43  滚动图片\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe

     文件        184  2010-10-13 00:25  滚动图片\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe.config

     文件        490  2009-06-11 05:14  滚动图片\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe.manifest

     文件       2956  2010-10-13 09:28  滚动图片\WindowsFormsApplication1\Form1.cs

     文件       3418  2010-10-13 00:39  滚动图片\WindowsFormsApplication1\Form1.Designer.cs

     文件       6008  2010-10-13 00:39  滚动图片\WindowsFormsApplication1\Form1.resx

     文件       5705  2011-10-19 10:43  滚动图片\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csproj.FileListAbsolute.txt

     文件        847  2010-10-13 00:43  滚动图片\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csproj.GenerateResource.Cache

     文件      11264  2011-10-19 10:39  滚动图片\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.exe

     文件        180  2011-10-19 10:39  滚动图片\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.Form1.resources

     文件      42496  2011-10-19 10:39  滚动图片\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.pdb

     文件        180  2011-10-19 10:39  滚动图片\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.Properties.Resources.resources

     文件        505  2010-10-12 18:39  滚动图片\WindowsFormsApplication1\Program.cs

     文件       1414  2010-10-12 18:39  滚动图片\WindowsFormsApplication1\Properties\AssemblyInfo.cs

     文件       2898  2010-10-12 18:39  滚动图片\WindowsFormsApplication1\Properties\Resources.Designer.cs

     文件       5612  2010-10-12 18:39  滚动图片\WindowsFormsApplication1\Properties\Resources.resx

     文件       1109  2010-10-12 18:39  滚动图片\WindowsFormsApplication1\Properties\Settings.Designer.cs

     文件        249  2010-10-12 18:39  滚动图片\WindowsFormsApplication1\Properties\Settings.settings

     文件       3947  2010-10-13 00:37  滚动图片\WindowsFormsApplication1\WindowsFormsApplication1.csproj

     文件        168  2010-10-13 00:31  滚动图片\WindowsFormsApplication1\WindowsFormsApplication1.csproj.user

............此处省略14个文件信息

评论

共有 条评论