Esempio n. 1
0
        private void RandomNameFuc()
        {
            NameBox1.Text = " "; NameBox1.Refresh();
            NameBox2.Text = " "; NameBox2.Refresh();
            NameBox3.Text = " "; NameBox3.Refresh();
            NameBox4.Text = " "; NameBox4.Refresh();
            NameBox5.Text = " "; NameBox5.Refresh();
            NameBox6.Text = " "; NameBox6.Refresh();
            u1lab.Text    = " "; u1lab.Refresh();
            u2lab.Text    = " "; u2lab.Refresh();
            u3lab.Text    = " "; u3lab.Refresh();
            u4lab.Text    = " "; u4lab.Refresh();
            u5lab.Text    = " "; u5lab.Refresh();
            u6lab.Text    = " "; u6lab.Refresh();

            working = true;
            StartButton.BackgroundImage = Image.FromFile(path + "\\pictures\\start2.png");
            StartButton.Refresh();
            Playing();
            u1 = u2 = u3 = u4 = u5 = u6 = number + 1;
            switch (mode)
            {
            case 1:
            {
                if (usernumber > number)
                {
                    MessageBox.Show("点名人数多于总人数。");
                    break;
                }
                LastPer();
                if (last < usernumber)
                {
                    ClearTools();
                }
                root = new Random(DateTime.Now.Millisecond);
                u1   = root.Next(0, number);
                if (usernumber >= 2)
                {
                    u2 = root.Next(0, number);
                }
                if (usernumber >= 4)
                {
                    u3 = root.Next(0, number); u4 = root.Next(0, number);
                }
                if (usernumber >= 6)
                {
                    u5 = root.Next(0, number); u6 = root.Next(0, number);
                }
                while (avertool[u1])
                {
                    u1 = root.Next(0, number);
                }
                while (usernumber >= 2 && (u2 == u1 || avertool[u2]))
                {
                    u2 = root.Next(0, number);
                }
                while (usernumber >= 4 && (u3 == u1 || u3 == u2 || avertool[u3]))
                {
                    u3 = root.Next(0, number);
                }
                while (usernumber >= 4 && (u4 == u1 || u4 == u2 || u4 == u3 || avertool[u4]))
                {
                    u4 = root.Next(0, number);
                }
                while (usernumber >= 6 && (u5 == u1 || u5 == u2 || u5 == u3 || u5 == u4 || avertool[u5]))
                {
                    u5 = root.Next(0, number);
                }
                while (usernumber >= 6 && (u6 == u1 || u6 == u2 || u6 == u3 || u6 == u4 || u6 == u5 || avertool[u6]))
                {
                    u6 = root.Next(0, number);
                }
                avertool[u1] = true;
                if (usernumber > 1)
                {
                    avertool[u2] = true;
                }
                if (usernumber >= 4)
                {
                    avertool[u3] = true;
                }
                if (usernumber >= 4)
                {
                    avertool[u4] = true;
                }
                if (usernumber >= 6)
                {
                    avertool[u5] = true;
                }
                if (usernumber >= 6)
                {
                    avertool[u6] = true;
                }
                u1lab.Text = (u1 + 1).ToString("D2"); u1lab.Refresh(); NameBox1.Text = names[u1]; NameBox1.Refresh();
                if (usernumber > 1)
                {
                    u2lab.Text = (u2 + 1).ToString("D2"); u2lab.Refresh(); NameBox2.Text = names[u2]; NameBox2.Refresh();
                }
                if (usernumber >= 4)
                {
                    u3lab.Text = (u3 + 1).ToString("D2"); u3lab.Refresh(); NameBox3.Text = names[u3]; NameBox3.Refresh();
                }
                if (usernumber >= 4)
                {
                    u4lab.Text = (u4 + 1).ToString("D2"); u4lab.Refresh(); NameBox4.Text = names[u4]; NameBox4.Refresh();
                }
                if (usernumber >= 6)
                {
                    u5lab.Text = (u5 + 1).ToString("D2"); u5lab.Refresh(); NameBox5.Text = names[u5]; NameBox5.Refresh();
                }
                if (usernumber >= 6)
                {
                    u6lab.Text = (u6 + 1).ToString("D2"); u6lab.Refresh(); NameBox6.Text = names[u6]; NameBox6.Refresh();
                }
                break;
            }

            case 2:
            {
                if (usernumber > malenumber)
                {
                    MessageBox.Show("点名人数多于总人数。");
                    break;
                }
                LastMan();
                if (lastman < usernumber)
                {
                    ClearTools();
                }
                root = new Random(DateTime.Now.Millisecond);
                u1   = root.Next(0, number);
                if (usernumber >= 2)
                {
                    u2 = root.Next(0, number);
                }
                if (usernumber >= 4)
                {
                    u3 = root.Next(0, number); u4 = root.Next(0, number);
                }
                if (usernumber >= 6)
                {
                    u5 = root.Next(0, number); u6 = root.Next(0, number);
                }
                while (avertool[u1] || sexi[u1])
                {
                    u1 = root.Next(0, number);
                }
                while (usernumber >= 2 && (u2 == u1 || avertool[u2] || sexi[u2]))
                {
                    u2 = root.Next(0, number);
                }
                while (usernumber >= 4 && (u3 == u1 || u3 == u2 || avertool[u3] || sexi[u3]))
                {
                    u3 = root.Next(0, number);
                }
                while (usernumber >= 4 && (u4 == u1 || u4 == u2 || u4 == u3 || avertool[u4] || sexi[u4]))
                {
                    u4 = root.Next(0, number);
                }
                while (usernumber >= 6 && (u5 == u1 || u5 == u2 || u5 == u3 || u5 == u4 || avertool[u5] || sexi[u5]))
                {
                    u5 = root.Next(0, number);
                }
                while (usernumber >= 6 && (u6 == u1 || u6 == u2 || u6 == u3 || u6 == u4 || u6 == u5 || avertool[u6] || sexi[u6]))
                {
                    u6 = root.Next(0, number);
                }
                avertool[u1] = true;
                if (usernumber > 1)
                {
                    avertool[u2] = true;
                }
                if (usernumber >= 4)
                {
                    avertool[u3] = true;
                }
                if (usernumber >= 4)
                {
                    avertool[u4] = true;
                }
                if (usernumber >= 6)
                {
                    avertool[u5] = true;
                }
                if (usernumber >= 6)
                {
                    avertool[u6] = true;
                }
                u1lab.Text = (u1 + 1).ToString("D2"); u1lab.Refresh(); NameBox1.Text = names[u1]; NameBox1.Refresh();
                if (usernumber > 1)
                {
                    u2lab.Text = (u2 + 1).ToString("D2"); u2lab.Refresh(); NameBox2.Text = names[u2]; NameBox2.Refresh();
                }
                if (usernumber >= 4)
                {
                    u3lab.Text = (u3 + 1).ToString("D2"); u3lab.Refresh(); NameBox3.Text = names[u3]; NameBox3.Refresh();
                }
                if (usernumber >= 4)
                {
                    u4lab.Text = (u4 + 1).ToString("D2"); u4lab.Refresh(); NameBox4.Text = names[u4]; NameBox4.Refresh();
                }
                if (usernumber >= 6)
                {
                    u5lab.Text = (u5 + 1).ToString("D2"); u5lab.Refresh(); NameBox5.Text = names[u5]; NameBox5.Refresh();
                }
                if (usernumber >= 6)
                {
                    u6lab.Text = (u6 + 1).ToString("D2"); u6lab.Refresh(); NameBox6.Text = names[u6]; NameBox6.Refresh();
                }
                break;
            }

            case 3:
            {
                if (usernumber > femalenumber)
                {
                    MessageBox.Show("点名人数多于总人数。");
                    break;
                }
                LastWom();
                if (lastwom < usernumber)
                {
                    ClearTools();
                }
                root = new Random(DateTime.Now.Millisecond);
                u1   = root.Next(0, number);
                if (usernumber >= 2)
                {
                    u2 = root.Next(0, number);
                }
                if (usernumber >= 4)
                {
                    u3 = root.Next(0, number); u4 = root.Next(0, number);
                }
                if (usernumber >= 6)
                {
                    u5 = root.Next(0, number); u6 = root.Next(0, number);
                }
                while (avertool[u1] || !sexi[u1])
                {
                    u1 = root.Next(0, number);
                }
                while (usernumber >= 2 && (u2 == u1 || avertool[u2] || !sexi[u2]))
                {
                    u2 = root.Next(0, number);
                }
                while (usernumber >= 4 && (u3 == u1 || u3 == u2 || avertool[u3] || !sexi[u3]))
                {
                    u3 = root.Next(0, number);
                }
                while (usernumber >= 4 && (u4 == u1 || u4 == u2 || u4 == u3 || avertool[u4] || !sexi[u4]))
                {
                    u4 = root.Next(0, number);
                }
                while (usernumber >= 6 && (u5 == u1 || u5 == u2 || u5 == u3 || u5 == u4 || avertool[u5] || !sexi[u5]))
                {
                    u5 = root.Next(0, number);
                }
                while (usernumber >= 6 && (u6 == u1 || u6 == u2 || u6 == u3 || u6 == u4 || u6 == u5 || avertool[u6] || !sexi[u6]))
                {
                    u6 = root.Next(0, number);
                }
                avertool[u1] = true;
                if (usernumber > 1)
                {
                    avertool[u2] = true;
                }
                if (usernumber >= 4)
                {
                    avertool[u3] = true;
                }
                if (usernumber >= 4)
                {
                    avertool[u4] = true;
                }
                if (usernumber >= 6)
                {
                    avertool[u5] = true;
                }
                if (usernumber >= 6)
                {
                    avertool[u6] = true;
                }
                u1lab.Text = (u1 + 1).ToString("D2"); u1lab.Refresh(); NameBox1.Text = names[u1]; NameBox1.Refresh();
                if (usernumber > 1)
                {
                    u2lab.Text = (u2 + 1).ToString("D2"); u2lab.Refresh(); NameBox2.Text = names[u2]; NameBox2.Refresh();
                }
                if (usernumber >= 4)
                {
                    u3lab.Text = (u3 + 1).ToString("D2"); u3lab.Refresh(); NameBox3.Text = names[u3]; NameBox3.Refresh();
                }
                if (usernumber >= 4)
                {
                    u4lab.Text = (u4 + 1).ToString("D2"); u4lab.Refresh(); NameBox4.Text = names[u4]; NameBox4.Refresh();
                }
                if (usernumber >= 6)
                {
                    u5lab.Text = (u5 + 1).ToString("D2"); u5lab.Refresh(); NameBox5.Text = names[u5]; NameBox5.Refresh();
                }
                if (usernumber >= 6)
                {
                    u6lab.Text = (u6 + 1).ToString("D2"); u6lab.Refresh(); NameBox6.Text = names[u6]; NameBox6.Refresh();
                }
                break;
            }

            case 4:
            {
                if (usernumber / 2 > malenumber || usernumber / 2 > femalenumber)
                {
                    MessageBox.Show("点名人数多于总人数。");
                    break;
                }
                LastMan(); LastWom();
                if (lastman < usernumber / 2 || lastwom < usernumber / 2)
                {
                    ClearTools();
                }
                root = new Random(DateTime.Now.Millisecond);
                u1   = root.Next(0, number);
                if (usernumber >= 2)
                {
                    u2 = root.Next(0, number);
                }
                if (usernumber >= 4)
                {
                    u3 = root.Next(0, number); u4 = root.Next(0, number);
                }
                if (usernumber >= 6)
                {
                    u5 = root.Next(0, number); u6 = root.Next(0, number);
                }
                while (avertool[u1] || !sexi[u1])
                {
                    u1 = root.Next(0, number);
                }
                while (usernumber >= 2 && (u2 == u1 || avertool[u2] || sexi[u2]))
                {
                    u2 = root.Next(0, number);
                }
                while (usernumber >= 4 && (u3 == u1 || u3 == u2 || avertool[u3] || !sexi[u3]))
                {
                    u3 = root.Next(0, number);
                }
                while (usernumber >= 4 && (u4 == u1 || u4 == u2 || u4 == u3 || avertool[u4] || sexi[u4]))
                {
                    u4 = root.Next(0, number);
                }
                while (usernumber >= 6 && (u5 == u1 || u5 == u2 || u5 == u3 || u5 == u4 || avertool[u5] || !sexi[u5]))
                {
                    u5 = root.Next(0, number);
                }
                while (usernumber >= 6 && (u6 == u1 || u6 == u2 || u6 == u3 || u6 == u4 || u6 == u5 || avertool[u6] || sexi[u6]))
                {
                    u6 = root.Next(0, number);
                }
                avertool[u1] = true;
                if (usernumber > 1)
                {
                    avertool[u2] = true;
                }
                if (usernumber >= 4)
                {
                    avertool[u3] = true;
                }
                if (usernumber >= 4)
                {
                    avertool[u4] = true;
                }
                if (usernumber >= 6)
                {
                    avertool[u5] = true;
                }
                if (usernumber >= 6)
                {
                    avertool[u6] = true;
                }
                u1lab.Text = (u1 + 1).ToString("D2"); u1lab.Refresh(); NameBox1.Text = names[u1]; NameBox1.Refresh();
                if (usernumber > 1)
                {
                    u2lab.Text = (u2 + 1).ToString("D2"); u2lab.Refresh(); NameBox2.Text = names[u2]; NameBox2.Refresh();
                }
                if (usernumber >= 4)
                {
                    u3lab.Text = (u3 + 1).ToString("D2"); u3lab.Refresh(); NameBox3.Text = names[u3]; NameBox3.Refresh();
                }
                if (usernumber >= 4)
                {
                    u4lab.Text = (u4 + 1).ToString("D2"); u4lab.Refresh(); NameBox4.Text = names[u4]; NameBox4.Refresh();
                }
                if (usernumber >= 6)
                {
                    u5lab.Text = (u5 + 1).ToString("D2"); u5lab.Refresh(); NameBox5.Text = names[u5]; NameBox5.Refresh();
                }
                if (usernumber >= 6)
                {
                    u6lab.Text = (u6 + 1).ToString("D2"); u6lab.Refresh(); NameBox6.Text = names[u6]; NameBox6.Refresh();
                }
                break;
            }
            }
            working = false;
            StartButton.BackgroundImage = Image.FromFile(path + "\\pictures\\start1.png");
            StartButton.Refresh();
        }
Esempio n. 2
0
        private void Main_Load(object sender, EventArgs e)
        {
            SettingPannel.Visible = false;
            InfoPannel.Visible    = false;
            RandomPannel.Visible  = true;
            u5lab.Parent          = PannelBox;
            u5lab.Location        = new Point(8, 22);
            u3lab.Parent          = PannelBox;
            u3lab.Location        = new Point(8 + 156, 22);
            u1lab.Parent          = PannelBox;
            u1lab.Location        = new Point(8 + 156 * 2, 22);
            u2lab.Parent          = PannelBox;
            u2lab.Location        = new Point(8 + 156 * 3, 22);
            u4lab.Parent          = PannelBox;
            u4lab.Location        = new Point(8 + 156 * 4, 22);
            u6lab.Parent          = PannelBox;
            u6lab.Location        = new Point(8 + 156 * 5, 22);
            NameBox5.Parent       = PannelBox;
            NameBox5.Location     = new Point(22, 162);
            NameBox3.Parent       = PannelBox;
            NameBox3.Location     = new Point(22 + 156, 162);
            NameBox1.Parent       = PannelBox;
            NameBox1.Location     = new Point(22 + 156 * 2, 162);
            NameBox2.Parent       = PannelBox;
            NameBox2.Location     = new Point(22 + 156 * 3, 162);
            NameBox4.Parent       = PannelBox;
            NameBox4.Location     = new Point(22 + 156 * 4, 162);
            NameBox6.Parent       = PannelBox;
            NameBox6.Location     = new Point(22 + 156 * 5, 162);
            NameBox1.Text         = " "; NameBox1.Refresh();
            NameBox2.Text         = " "; NameBox2.Refresh();
            NameBox3.Text         = " "; NameBox3.Refresh();
            NameBox4.Text         = " "; NameBox4.Refresh();
            NameBox5.Text         = " "; NameBox5.Refresh();
            NameBox6.Text         = " "; NameBox6.Refresh();
            u1lab.Text            = " "; u1lab.Refresh();
            u2lab.Text            = " "; u2lab.Refresh();
            u3lab.Text            = " "; u3lab.Refresh();
            u4lab.Text            = " "; u4lab.Refresh();
            u5lab.Text            = " "; u5lab.Refresh();
            u6lab.Text            = " "; u6lab.Refresh();
            working = false;
            mode    = 1;
            ReadData();
            modestring = "默认模式";
            //defaultmod.BorderStyle = BorderStyle.FixedSingle;
            usernumberlab.Text = usernumber.ToString();
            usernumberlab.Refresh();

            defaultmod.BackgroundImage = Image.FromFile(path + "\\pictures\\default1.png");

            globaltips.SetToolTip(this.defaultmod, "默认模式,当前为" + modestring);
            globaltips.SetToolTip(this.malemod, "男生模式,当前为" + modestring);
            globaltips.SetToolTip(this.femalemod, "女生模式,当前为" + modestring);
            globaltips.SetToolTip(this.averangemod, "平均模式,当前为" + modestring);
            globaltips.SetToolTip(this.editmod, "基本设置,当前为" + modestring);
            globaltips.SetToolTip(this.infomod, "软件信息,当前为" + modestring);
            globaltips.SetToolTip(this.closebox, "安全处理点名数据并退出");
            globaltips.SetToolTip(this.minbox, "最小化");
            globaltips.SetToolTip(this.clickbox, "单击查看详细的高考倒计时");
            globaltips.SetToolTip(this.TimeLast, "单击查看详细的高考倒计时");
            Caculatetime();
            LoadPannelBox();
        }//加载窗口时要做的事情