Exemplo n.º 1
0
        public void swap(Briefcase bc)
        {
            int temp = this.value;

            this.value = bc.value;
            bc.value   = temp;
        }
Exemplo n.º 2
0
        public void init()
        {
            g = new Game();
            this.DoubleBuffered = true;
            this.SuspendLayout();

            message.Text      = "Одберете ја вашата кутија";
            message.Location  = new Point(690, 90);
            message.Size      = new Size(160, 50);
            message.TextAlign = ContentAlignment.MiddleCenter;
            message.Visible   = true;

            messYes.Text     = "Да";
            messYes.Location = new Point(690, 150);
            messYes.Click   += messYes_Click;
            messYes.Visible  = false;

            messNo.Text     = "Не";
            messNo.Location = new Point(780, 150);
            messNo.Click   += messNo_Click;
            messNo.Visible  = false;

            sideValues  = new Label[26];
            briefNums   = new Label[26];
            briefcases  = new Briefcase[26];
            briefImages = new PictureBox[26];

            Random r = new Random();

            for (int i = 0; i < 26; i++)
            {
                sideValues[i]           = new Label();
                sideValues[i].Text      = values[i].ToString();
                sideValues[i].Location  = new Point(30 + (i / 13) * 550, 20 + (i % 13) * 25);
                sideValues[i].BackColor = Color.FromArgb((i / 13) * 255, 0, ((25 - i) / 13) * 255);
                sideValues[i].TextAlign = ContentAlignment.MiddleCenter;
                sideValues[i].Visible   = true;
                this.Controls.Add(sideValues[i]);

                briefcases[i] = new Briefcase(i);

                briefNums[i] = new Label();
                if (i < 24)
                {
                    briefNums[i].Location = new Point(185 + 65 * (i % 6), 48 + 55 * (i / 6));
                }
                else
                {
                    briefNums[i].Location = new Point(315 + 65 * (i % 6), 48 + 55 * (i / 6));
                }
                briefNums[i].Size      = new Size(20, 15);
                briefNums[i].Name      = (i).ToString();
                briefNums[i].Click    += Briefcase_Click;
                briefNums[i].TextAlign = ContentAlignment.MiddleCenter;
                briefNums[i].Text      = (i + 1).ToString();
                briefNums[i].BackColor = Color.FromArgb(237, 28, 36);
                briefNums[i].Visible   = true;
                this.Controls.Add(briefNums[i]);

                briefImages[i]       = new PictureBox();
                briefImages[i].Image = Resources.br;
                if (i < 24)
                {
                    briefImages[i].Location = new Point(170 + 65 * (i % 6), 30 + 55 * (i / 6));
                }
                else
                {
                    briefImages[i].Location = new Point(300 + 65 * (i % 6), 30 + 55 * (i / 6));
                }
                briefImages[i].Size    = new Size(50, 50);
                briefImages[i].Name    = i.ToString();
                briefImages[i].Click  += Briefcase_Click;
                briefImages[i].Visible = true;
                this.Controls.Add(briefImages[i]);
            }

            for (int i = 0; i < 1000; i++)
            {
                int index = r.Next(26);
                briefcases[i % 26].swap(briefcases[index]);
            }

            this.Controls.Add(message);
            this.Controls.Add(messYes);
            this.Controls.Add(messNo);

            this.ResumeLayout();
        }