博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
10.WinFor练习--自动播放图片小程序
阅读量:5893 次
发布时间:2019-06-19

本文共 2085 字,大约阅读时间需要 6 分钟。

namespace _10Picture和Timer小程序

{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)    {        //程序加载时播放音乐        SoundPlayer sp = new SoundPlayer();        sp.SoundLocation = @"C:\Users\Administrator.USER-20180925HC\Desktop\1.wav";        sp.Play();        //程序运行时加载图片到picBox        pictureBox1.Image = Image.FromFile(@"C:\Users\Administrator.USER-20180925HC\Desktop\pic\1.jpg");        pictureBox2.Image = Image.FromFile(@"C:\Users\Administrator.USER-20180925HC\Desktop\pic\2.jpg");        pictureBox3.Image = Image.FromFile(@"C:\Users\Administrator.USER-20180925HC\Desktop\pic\3.jpg");        pictureBox4.Image = Image.FromFile(@"C:\Users\Administrator.USER-20180925HC\Desktop\pic\4.jpg");        pictureBox5.Image = Image.FromFile(@"C:\Users\Administrator.USER-20180925HC\Desktop\pic\5.jpg");        pictureBox6.Image = Image.FromFile(@"C:\Users\Administrator.USER-20180925HC\Desktop\pic\6.jpg");        //图片的显示方式        pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;        pictureBox2.SizeMode = PictureBoxSizeMode.StretchImage;        pictureBox3.SizeMode = PictureBoxSizeMode.StretchImage;        pictureBox4.SizeMode = PictureBoxSizeMode.StretchImage;        pictureBox5.SizeMode = PictureBoxSizeMode.StretchImage;        pictureBox6.SizeMode = PictureBoxSizeMode.StretchImage;    }    string[] path = Directory.GetFiles(@"C:\Users\Administrator.USER-20180925HC\Desktop\pic");    Random r = new Random();    private void timer1_Tick(object sender, EventArgs e)    {        //每隔一秒钟换一张图片        //开始赋值        pictureBox1.Image = Image.FromFile(path[r.Next(0,path.Length)]);        pictureBox2.Image = Image.FromFile(path[r.Next(0, path.Length)]);        pictureBox3.Image = Image.FromFile(path[r.Next(0, path.Length)]);        pictureBox4.Image = Image.FromFile(path[r.Next(0, path.Length)]);        pictureBox5.Image = Image.FromFile(path[r.Next(0, path.Length)]);        pictureBox6.Image = Image.FromFile(path[r.Next(0, path.Length)]);    }}

}

转载于:https://blog.51cto.com/12679593/2398282

你可能感兴趣的文章
【设计模式】—— 代理模式Proxy
查看>>
ejabberd
查看>>
博客园博客自动生成三级目录(generate three levels content using JS in cnblogs)
查看>>
关于多线程的那些事
查看>>
js 将json字符串转换为json对象的方法解析
查看>>
1. Two Sum
查看>>
让浏览器不再显示 https 页面中的 http 请求警报
查看>>
hdu4893Wow! Such Sequence! (线段树)
查看>>
Android 最简单的SD卡文件遍历程序
查看>>
JavaScript获取DOM元素位置和尺寸大小
查看>>
1065: 贝贝的加密工作
查看>>
lintcode 单词接龙II
查看>>
WEB版一次选择多个文件进行批量上传(WebUploader)的解决方案
查看>>
Redis之 命令行 操作
查看>>
Jvm(46),指令集----对象创建与访问指令
查看>>
EL 表达式小结
查看>>
内部排序
查看>>
jQuery EasyUI API 中文文档 - 组合(Combo)
查看>>
10个关于 Dropbox 的另类功用(知乎问答精编)[还是转来了]
查看>>
Oracle体系结构
查看>>