10.WinFor练习--自动播放图片小程序-创新互联

namespace _10Picture和Timer小程序
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

10年积累的成都做网站、网站建设、外贸营销网站建设经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站设计后付款的网站建设流程,更有南丰免费网站建设让你可以放心的选择与我们合作。
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)]);
    }
}

}

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


网页题目:10.WinFor练习--自动播放图片小程序-创新互联
分享路径:http://myzitong.com/article/eccdg.html