• 选择人员参与游戏的小程序


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

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

    源代码如下 :

    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>

  • 相关阅读:
    bzoj1178/luogu3626 会议中心 (倍增+STL::set)
    suoi31 最近公共祖先2 (倍增lca)
    luogu4155/bzoj4444 国旗计划 (倍增)
    [BZOJ1864][Zjoi2006]三色二叉树
    [Luogu3070][USACO13JAN]岛游记Island Travels
    [Luogu2458][SDOI2006]保安站岗
    [BZOJ1191][HNOI2006]超级英雄Hero
    [BZOJ1050][HAOI2006]旅行
    [Luogu2973][USACO10HOL]赶小猪Driving Out the Piggi…
    [BZOJ1833][ZJOI2010]数字计数
  • 原文地址:https://www.cnblogs.com/Beewolf/p/2358913.html
Copyright © 2020-2023  润新知