选择人员参与游戏的小程序
2012-02-20 09:44
573 查看
每次听潘加宇老师的讲课的时候,对他制作的选择人和奖品的小创意钦佩不已,这种选择的好处很多,就不说了。
今日偷师学艺,也开发了一个超小了程序,来实现此功能。够用就好了,潘老师千万别追究版权问题。
源代码如下 :
using System;
using System.Collections.Generic;
using System.Configuration;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace SelectOne
{
public partial class frmChoseOne : Form
{
private string[] personList ;
private Boolean blnChosePersonId = true;
private int currentPerson = 0;
private int itemInPersonList = 0;
private static string[] giftList;
private Boolean blnChoseGiftId = true;
private int currentGift = 0;
private int itemInGiftList = 0;
public frmChoseOne()
{
InitializeComponent();
InitialList();
}
private void InitialList()
{
string temppersonList = ConfigurationManager.AppSettings["personList"];
personList = temppersonList.Split(';');
itemInPersonList = personList.Length - 1;
string tempgiftList = ConfigurationManager.AppSettings["giftList"];
giftList = tempgiftList.Split(';');
itemInGiftList = giftList.Length - 1;
}
private void btnChosePerson_Click(object sender, EventArgs e)
{
if (blnChosePersonId)
{
tmrChosePerson.Start();
btnChosePerson.Text = "停止";
}
else
{
tmrChosePerson.Stop();
btnChosePerson.Text = "选人";
}
blnChosePersonId = !blnChosePersonId;
}
private void tmrChosePerson_Tick(object sender, EventArgs e)
{
currentPerson++;
if (currentPerson > itemInPersonList)
{
currentPerson = 0;
}
lblDisplayPersonName.Text = personList[currentPerson];
}
private void tmrChoseGift_Tick(object sender, EventArgs e)
{
currentGift++;
if (currentGift > itemInGiftList)
{
currentGift = 0;
}
lblChoseGift.Text = giftList[currentGift];
}
private void btnChoseGift_Click(object sender, EventArgs e)
{
if (blnChoseGiftId)
{
tmrChoseGift.Start();
btnChoseGift.Text = "停止";
}
else
{
tmrChoseGift.Stop();
btnChoseGift.Text = "选礼物";
}
blnChoseGiftId = !blnChoseGiftId;
}
}
}
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<clear />
<add key ="personList" value="A;B;C;D" />
<add key ="giftList" value="蜂蜜茶;蛋挞;蜂蜜茶;蛋挞;蜂蜜茶;蛋挞;蜂蜜茶;蛋挞;蜂蜜茶;蛋挞;拿铁;蛋挞;" />
</appSettings>
</configuration>
今日偷师学艺,也开发了一个超小了程序,来实现此功能。够用就好了,潘老师千万别追究版权问题。
源代码如下 :
using System;
using System.Collections.Generic;
using System.Configuration;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace SelectOne
{
public partial class frmChoseOne : Form
{
private string[] personList ;
private Boolean blnChosePersonId = true;
private int currentPerson = 0;
private int itemInPersonList = 0;
private static string[] giftList;
private Boolean blnChoseGiftId = true;
private int currentGift = 0;
private int itemInGiftList = 0;
public frmChoseOne()
{
InitializeComponent();
InitialList();
}
private void InitialList()
{
string temppersonList = ConfigurationManager.AppSettings["personList"];
personList = temppersonList.Split(';');
itemInPersonList = personList.Length - 1;
string tempgiftList = ConfigurationManager.AppSettings["giftList"];
giftList = tempgiftList.Split(';');
itemInGiftList = giftList.Length - 1;
}
private void btnChosePerson_Click(object sender, EventArgs e)
{
if (blnChosePersonId)
{
tmrChosePerson.Start();
btnChosePerson.Text = "停止";
}
else
{
tmrChosePerson.Stop();
btnChosePerson.Text = "选人";
}
blnChosePersonId = !blnChosePersonId;
}
private void tmrChosePerson_Tick(object sender, EventArgs e)
{
currentPerson++;
if (currentPerson > itemInPersonList)
{
currentPerson = 0;
}
lblDisplayPersonName.Text = personList[currentPerson];
}
private void tmrChoseGift_Tick(object sender, EventArgs e)
{
currentGift++;
if (currentGift > itemInGiftList)
{
currentGift = 0;
}
lblChoseGift.Text = giftList[currentGift];
}
private void btnChoseGift_Click(object sender, EventArgs e)
{
if (blnChoseGiftId)
{
tmrChoseGift.Start();
btnChoseGift.Text = "停止";
}
else
{
tmrChoseGift.Stop();
btnChoseGift.Text = "选礼物";
}
blnChoseGiftId = !blnChoseGiftId;
}
}
}
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<clear />
<add key ="personList" value="A;B;C;D" />
<add key ="giftList" value="蜂蜜茶;蛋挞;蜂蜜茶;蛋挞;蜂蜜茶;蛋挞;蜂蜜茶;蛋挞;蜂蜜茶;蛋挞;拿铁;蛋挞;" />
</appSettings>
</configuration>
相关文章推荐
- 某朋友说,如果存款超过100万,则入手宝马X5,否则超过50万,则 1. 入手奥迪A6,否则超过20万,则入手比亚迪,否则超过10万则玩玩极品飞车游戏,请编写一个购车选择程序,根据输入的金额,提示可以
- 自从电子竞技在中国被认定为第99个正式体育项目,教主就投身其中,SC(StarCraft 星际争霸)他拿手的一款游戏,当然也有很多职业选手参与其中。 星际争霸中有3个种族:T(人族),P(神族),Z(虫族)而且每个玩家必须选择且只能选择一个种族来使用。 在职业电子竞技联赛中,每位职业选手都会固定使用
- 游戏程序人员发展
- winform程序之人员选择listbox控件应用了一点arraylist(简单)
- 答题微信小程序实现(5):大功告成,整个模板,题库导入/切换/积分/选择对错判断/闯关成功
- 程序出错后,程序员给测试人员的20条高频回复
- (WebSite----Asp.Net Configuration----->无法连接到SQL Server数据库------>选择数据存储区---->应用程序当前被配置为使用提供程序:AspNetSqlProvider)解决方案
- 黑马程序员之ADO.NET学习笔记:省市选择程序,数据全部来自于数据库。
- C# : 模拟请求初步应用,制作网页游戏辅助程序(开心网争车位、咬人、买房子、虚拟朋友、礼物)
- 浏览选择图片/音频/视频&启动程序让其他程序进行选择
- 怎样和程序开发人员相处
- 基于Android平台的网络游戏对战系统项目可执行程序及源代码
- 运行程序选择总是重启tomcat后,如何修改设置。
- 实现一个选择排序程序,排序整型数组
- 微信小程序/下拉选择
- cocos2d-x游戏开发系列教程-坦克大战游戏关卡选择场景的编写中
- Unity3D手游开发系列笔记(一)——前言:选择什么样的游戏引擎来开发你的游戏?
- 递归法计算游戏人员的年龄
- 微信小程序商品详情页规格属性选择示例代码
- 32款网页设计和网页开发人员常用的Google chrome浏览器扩展程序