资源简介
C# 没事的时候写的连连看 主要也就是判断和 按钮的事件重写 能发点原创我感觉很好
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Media;
namespace 连连看
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//按钮大小
Size btnsize;
//图片数量
int imagenumber;
//图片路径
string path;
List imagenamelist;
//按钮数组
Button[] btns;
int row = 5;
int line = 10;
SoundPlayer sound;
Random r = new Random();
private void Form1_Load(object sender EventArgs e)
{
sound = new SoundPlayer(“1.wav“);
btnsize = new Size(60 60);
this.BackgroundImage =Image.FromFile( @“pictures\宠物小精灵\One.jpg“);
this.panel1.BackgroundImage = Image.FromFile(@“pictures\宠物小精灵\One.jpg“);
path = @“pictures\宠物小精灵“;
imagenumber = 11;
AddButtons();
}
//生成图片
private List CreateImagelist(int imagenumber)
{
List list = new List();
imagenamelist = new List();
for (int i = 0; i < 25; i++)
{
int x=r.Next(1imagenumber+1);
string s=string.Format(@“{0}\{1:00}.jpg“pathx);
Image image1=Image.FromFile(s);
Image image2=Image.FromFile(s);
list.Add(image1);
list.Add(image2);
imagenamelist.Add(x);
imagenamelist.Add(x);
}
return list;
}
//生成添加按钮
private void AddButtons()
{
this.panel1.Controls.Clear();
List imagelist = CreateImagelist(imagenumber);
btns = new Button[10 5];
for (int i = 0; i < line; i++)
{
for (int j = 0; j < row; j++)
{
int x = r.Next(0 imagelist.Count);
Button btn = new Button();
btn.Size = btnsize;
btn.Location = new Point(i * btn.Size.Width j * btn.Size.Height);
btn.BackgroundImage = imagelist[x];
btn.Click += new EventHandler(btn_click);
btn.Name = imagenamelist[x].ToString();
imagelist.RemoveAt(x);
imagenamelist.RemoveAt(x);
panel1.Controls.Add(btn);
btns[i j] = btn;
}
}
}
//选择过的按钮
Button selectedbtn=new Button();
//按钮单击事件
void btn_click(object sender EventArgs e)
{
Button Nowselectbtn = sender as Button;
int selectedbtnwidth = selectedbtn.Location.X / 60;
int selectedbtnh 属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2012-06-21 19:30 连连看\
目录 0 2012-06-21 19:48 连连看\连连看\
文件 916 2012-06-17 21:22 连连看\连连看.sln
文件 12800 2012-07-14 09:21 连连看\连连看.suo
目录 0 2012-06-21 19:30 连连看\连连看\bin\
目录 0 2012-06-21 19:30 连连看\连连看\bin\Debug\
文件 110044 2012-06-20 18:49 连连看\连连看\bin\Debug\1.wav
目录 0 2012-06-21 19:30 连连看\连连看\bin\Debug\pictures\
目录 0 2012-06-21 19:30 连连看\连连看\bin\Debug\pictures\动物\
文件 14703 2012-06-20 17:43 连连看\连连看\bin\Debug\pictures\动物\01.jpg
文件 14173 2012-06-20 17:43 连连看\连连看\bin\Debug\pictures\动物\02.jpg
文件 14555 2012-06-20 17:43 连连看\连连看\bin\Debug\pictures\动物\03.jpg
文件 14614 2012-06-20 17:44 连连看\连连看\bin\Debug\pictures\动物\04.jpg
文件 13687 2012-06-20 17:46 连连看\连连看\bin\Debug\pictures\动物\05.jpg
文件 13272 2012-06-20 17:46 连连看\连连看\bin\Debug\pictures\动物\06.jpg
文件 15424 2012-06-20 17:47 连连看\连连看\bin\Debug\pictures\动物\07.jpg
文件 16533 2012-06-20 17:47 连连看\连连看\bin\Debug\pictures\动物\08.jpg
文件 14601 2012-06-20 17:47 连连看\连连看\bin\Debug\pictures\动物\09.jpg
文件 15086 2012-06-20 17:47 连连看\连连看\bin\Debug\pictures\动物\10.jpg
文件 18573 2012-06-20 17:59 连连看\连连看\bin\Debug\pictures\动物\11.jpg
文件 14521 2012-06-20 17:59 连连看\连连看\bin\Debug\pictures\动物\12.jpg
文件 14390 2012-06-20 17:59 连连看\连连看\bin\Debug\pictures\动物\13.jpg
目录 0 2012-06-21 19:30 连连看\连连看\bin\Debug\pictures\宠物小精灵\
文件 13915 2012-06-18 18:20 连连看\连连看\bin\Debug\pictures\宠物小精灵\01.jpg
文件 15219 2012-06-18 18:21 连连看\连连看\bin\Debug\pictures\宠物小精灵\02.jpg
文件 15003 2012-06-18 18:22 连连看\连连看\bin\Debug\pictures\宠物小精灵\03.jpg
文件 13923 2012-06-18 18:29 连连看\连连看\bin\Debug\pictures\宠物小精灵\04.jpg
文件 15105 2012-06-18 18:22 连连看\连连看\bin\Debug\pictures\宠物小精灵\05.jpg
文件 14958 2012-06-18 18:22 连连看\连连看\bin\Debug\pictures\宠物小精灵\06.jpg
文件 14605 2012-06-18 18:22 连连看\连连看\bin\Debug\pictures\宠物小精灵\07.jpg
文件 14263 2012-06-18 18:31 连连看\连连看\bin\Debug\pictures\宠物小精灵\08.jpg
............此处省略60个文件信息
- 上一篇:C#把ZPL指令直接发送USB打印机
- 下一篇:工业OPC客户端读取,并存SQL
相关资源
- C# IP地址输入控件
- C#在一个窗口刷新更改另一个窗口控件
- C# TIP文件生成和拆解
- C#解析HL7消息的库135797
- C# OCR数字识别实例,采用TessnetOcr,对
- 考试管理系统 - C#源码
- asp.net C#购物车源代码
- C#实时网络流量监听源码
- C#百度地图源码
- Visual C#.2010从入门到精通配套源程序
- C# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
川公网安备 51152502000135号
评论
共有 条评论