
public partial class Form1 : Form{public Form1(){InitializeComponent();}string musicPath = "等什么君-霜雪千年-_Live片段_.wav";private void Form1_Load(object sender, EventArgs e){//播放音乐SoundPlayer sp = new SoundPlayer();sp.SoundLocation = musicPath;sp.Play();//在窗体加载的时候,修改图像的显示方式pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;pictureBox2.SizeMode = PictureBoxSizeMode.Zoom;pictureBox3.SizeMode = PictureBoxSizeMode.Zoom;pictureBox4.SizeMode = PictureBoxSizeMode.Zoom;pictureBox5.SizeMode = PictureBoxSizeMode.Zoom;pictureBox6.SizeMode = PictureBoxSizeMode.Zoom;//在窗体加载的时候,给每一个PictureBox都赋值一张图片的路径string pathPicture = @"李湘莲\f28e255b28b6914df1d849f3e94f0a8.jpg";pictureBox1.Image = Image.FromFile(pathPicture);pictureBox2.Image = Image.FromFile(pathPicture);pictureBox3.Image = Image.FromFile(pathPicture);pictureBox4.Image = Image.FromFile(pathPicture);pictureBox5.Image = Image.FromFile(pathPicture);pictureBox6.Image = Image.FromFile(pathPicture);}//获得该文件夹的所有文件路径string[] path = Directory.GetFiles("李湘莲");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)]);}private void pictureBox3_Click(object sender, EventArgs e){}private void pictureBox4_Click(object sender, EventArgs e){}/// <summary>/// 实现点击暂停音乐,播放音乐/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void buttonPlay_Click(object sender, EventArgs e){if (btnPlay.Text == "播放"){//播放音乐SoundPlayer sp = new SoundPlayer();sp.SoundLocation = musicPath;sp.Play();btnPlay.Text = "停止播放";}else if (btnPlay.Text == "停止播放"){//播放音乐SoundPlayer sp = new SoundPlayer();//sp.SoundLocation = musicPath;sp.Stop();btnPlay.Text = "播放";}}private void buttonQuit_Click(object sender, EventArgs e){this.Close();}}
