Beispiel #1
0
 private void CenterizeAllControls()
 {
     foreach (Control item in this.Controls)
     {
         CC <object> .CenterVertical(item);
     }
 }
Beispiel #2
0
 private void Inform(string text, int miliseconds)
 {
     new Thread(() => {
         Msg.Invoke(new Action(() => { Msg.Text = text;
                                       CC <object> .CenterVertical(Msg); }));
         Thread.Sleep(miliseconds);
         Msg.Text = "";
     }).Start();
 }
Beispiel #3
0
        public void AI()
        {
            if (aiThink)
            {
                return;
            }
            if (IsXTurn)
            {
                TurnL.Text = "X turn";
                return;
            }
            if (ended)
            {
                return;
            }
            TurnL.Text = "AI thinks";
            if (difficulity == (Difficulity)0)
            {
                TurnL.Text = "O turn";
                return;
            }
            Ai.difficulity = this.difficulity;
            EventArgs e = new AddingNewEventArgs("AI");
            Position  p = Ai.DoTurn(game);

            TurnL.Invoke(new Action(() => {
                CC <object> .CenterVertical(TurnL);
            }));
            if (difficulity == Difficulity.easy)
            {
                Thread.Sleep(1);
            }
            if (difficulity == Difficulity.medium)
            {
                Thread.Sleep(125);
            }
            if (difficulity == Difficulity.hard)
            {
                Thread.Sleep(500);
            }
            if (p.row != -1)
            {
                this.Invoke(new Action(() => { CellClick(cellsP[p.row, p.col], e); }));
            }

            //ThreadPool.Abort(ThreadPool.FindIndex("AI"));
        }
Beispiel #4
0
        private void CenterVertical(object sender, EventArgs e)
        {
            var control = (Control)sender;

            CC <object> .CenterVertical(control);
        }