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>

  • 相关阅读:
    [Objective-C语言教程]结构体(17)
    [Objective-C语言教程]字符串(16)
    [Swift]LeetCode827. 最大人工岛 | Making A Large Island
    [Swift]LeetCode826. 安排工作以达到最大收益 | Most Profit Assigning Work
    转 由一次磁盘告警引发的血案:du 和 ls 的区别
    Ant 参考
    转 Problem: AnyConnect was not able to establish a connection to the specified secu
    转 oracle 如何停下oracle 服务
    转: Windows如何打开和使用事件查看器管理计算机
    转: oracle 存储过程 执行动态 实现sql
  • 原文地址:https://www.cnblogs.com/Beewolf/p/2358913.html
Copyright © 2011-2022 走看看