コード例 #1
0
        //checker for even
        public void checker1(Button btn, Timer timer, Diction d)
        {
            //if are pressed two buttons
            if (timer.Enabled)
            {
                Task.Delay(TimeSpan.FromSeconds(1));
                //Thread.Sleep(1000);
            }
            else
            {
                //button1.Text = dict0.Pol;
                btn.Text = d.Pol;

                //if press the same language in other button
                //if (check.Btn1 != null)
                if (Btn1 != null)
                {
                    //button1.Text = check.Btn1.Text = null;

                    Btn2 = btn;
                    //timer
                    timer.Start();
                    //check.Btn1 = button1;
                }
                else
                {
                    Btn1 = btn;
                    Pol  = d.Pol;

                    //if 2 buttons pressed
                    if (checkButtons())
                    {
                        //shot hit
                        if (Eng == d.Eng && Pol == d.Pol)
                        {
                            btn.Text     = d.Pol;
                            Btn1.Enabled = Btn2.Enabled = false;
                            Btn1         = Btn2 = null;
                            Pol          = Eng = null;
                        }
                        else
                        {
                            //shot miss, clear all
                            //timer
                            timer.Start();
                        }
                    }
                    else
                    {
                        //one button press
                        btn.Text = Pol = d.Pol;
                        Btn1     = btn;
                    }
                }
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: sokald/Eng
        public Form1()
        {
            InitializeComponent();

            while (numbers.Count < 8)
            {
                number = numberRandom.Next(1, 9);
                if (!(numbers.Contains(number)))
                {
                    numbers.Add(number);
                }
            }

            points.Add(numbers[0], b1);
            points.Add(numbers[1], b2);
            points.Add(numbers[2], b3);
            points.Add(numbers[3], b4);
            points.Add(numbers[4], b5);
            points.Add(numbers[5], b6);
            points.Add(numbers[6], b7);
            points.Add(numbers[7], b8);

            numbers.Clear();

            while (numbers.Count < TabPol.Count())
            {
                number = numberRandom.Next(0, TabPol.Count());
                if (!(numbers.Contains(number)))
                {
                    numbers.Add(number);
                }
            }

            dict0 = new Diction(TabPol[numbers[0]], TabEng[numbers[0]]);
            dict1 = new Diction(TabPol[numbers[1]], TabEng[numbers[1]]);
            dict2 = new Diction(TabPol[numbers[2]], TabEng[numbers[2]]);
            dict3 = new Diction(TabPol[numbers[3]], TabEng[numbers[3]]);

            button1.Location = new System.Drawing.Point(points[1].X, points[1].Y);
            button2.Location = new System.Drawing.Point(points[2].X, points[2].Y);
            button3.Location = new System.Drawing.Point(points[3].X, points[3].Y);
            button4.Location = new System.Drawing.Point(points[4].X, points[4].Y);
            button5.Location = new System.Drawing.Point(points[5].X, points[5].Y);
            button6.Location = new System.Drawing.Point(points[6].X, points[6].Y);
            button7.Location = new System.Drawing.Point(points[7].X, points[7].Y);
            button8.Location = new System.Drawing.Point(points[8].X, points[8].Y);

            button1.Text = "1";
            button2.Text = "2";
            button3.Text = "3";
            button4.Text = "4";
            button5.Text = "5";
            button6.Text = "6";
            button7.Text = "7";
            button8.Text = "8";

            //button1.Text = null;
            //button2.Text = null;
            //button3.Text = null;
            //button4.Text = null;
            //button5.Text = null;
            //button6.Text = null;
            //button7.Text = null;
            //button8.Text = null;
        }