七夕祝福

七夕了。。。送祝福了。。。鲜花屏显,跑马灯。。

部分代码如下:

 

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

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

        
        int i = 0;
        //int j = 0;
        public int FormHeight
        {
            get;
            set;
        }

        public int FormWidth
        {
            get;
            set;
        }

        PictureBox[] pbArray;
        SoundPlayer sp = new SoundPlayer();

        private void Form1_Load(object sender, EventArgs e)
        {
            this.BackColor = Color.White;//设置窗体的背景效果为无色

            FormHeight = this.ClientSize.Height;
            FormWidth = this.ClientSize.Width;


            pbArray = new PictureBox[] { 
            pictureBox1,pictureBox2,pictureBox3,pictureBox4,pictureBox5,pictureBox6,
            pictureBox7,pictureBox8,pictureBox9,pictureBox10,pictureBox11,pictureBox12,
            pictureBox13,pictureBox14,pictureBox15,pictureBox16,pictureBox17,pictureBox18
            };

            sp.SoundLocation = @"..\..\sounds\LoveYou.wav";
            //sp.Play();
            sp.PlayLooping();//循环播放

        }

        string[] filePathArray = Directory.GetFiles("..\\..\\images", "*.jpg");
        Random r = new Random();

        List<int> listInt = new List<int>();
        private void timer1_Tick(object sender, EventArgs e)
        {
          
            int num = labWish.Text.Length;
           
            labWish.Text = labWish.Text.Substring(1, num - 1) +
                 labWish.Text.Substring(0, 1);

            if(i>17) //18个pictureBox
            {
                i = 0;
            }
            else
            {
               //while(true)
               //{
                   i = r.Next(0, 18);//产生0-17的随机数
                   listInt.Add(i);
                   //if(listInt.Contains(i))
                   //{
                   //    continue;
                   //}
                   //else
                   //{
                       pbArray[i].SizeMode = PictureBoxSizeMode.Zoom;
                       pbArray[i].BackColor = Color.Transparent;
                       //pbArray[i].Location = new Point(iwidth, iheight);//设定pictureBox控件的位置
                       string fileName = r.Next(1, 35).ToString() + ".jpg";//
                       pbArray[i].ImageLocation = "..\\..\\images\\" + fileName;//相对路径

                       i++;
                   //}
               //}

            }
            
        }

    }
}


效果:

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值