zoukankan      html  css  js  c++  java
  • 选择人员参与游戏的小程序

    每次听潘加宇老师的讲课的时候,对他制作的选择人和奖品的小创意钦佩不已,这种选择的好处很多,就不说了。

    今日偷师学艺,也开发了一个超小了程序,来实现此功能。够用就好了,潘老师千万别追究版权问题。

    源代码如下 :

    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>

  • 相关阅读:
    浅谈JavaScript中forEach与each
    Angular.js中使用$watch监听模型变化
    整理:Javascript获取数组中的最大值和最小值的方法汇总
    自定义指令的参数
    ng-disabled 不起作用的解决办法
    理解Angular中的$apply()以及$digest()
    $q -- AngularJS中的服务(理解)
    正则表达式30分钟入门教程(转)
    angular.extend用法实例
    使用angular.bootstrap() 完成模块的手动加载
  • 原文地址:https://www.cnblogs.com/Beewolf/p/2358913.html
Copyright © 2011-2022 走看看