Esempio n. 1
0
        public MainPage()
        {
            InitializeComponent();
            BackGroundGif = new PictureBox();
            string ParentFolderPath = Environment.CurrentDirectory;

            ParentFolderPath = ParentFolderPath.Substring(0, ParentFolderPath.LastIndexOf("\\"));
            ParentFolderPath = ParentFolderPath.Substring(0, ParentFolderPath.LastIndexOf("\\"));
            string BGURL = ParentFolderPath + "\\Properties\\backGround.gif";

            BackGroundGif.Image = Image.FromFile(BGURL);
            this.Controls.Add(BackGroundGif);//Essential
            BackGroundGif.SendToBack();
            BackGroundGif.Size     = this.Size;
            BackGroundGif.SizeMode = PictureBoxSizeMode.StretchImage;
            CC <object> .CenterVertical(easyBtn);

            CC <object> .CenterVertical(interBtn);

            CC <object> .CenterVertical(expertBtn);

            CC <object> .CenterVertical(pvpBtn);

            CC <object> .CenterVertical(StartNewGameLabel);

            this.Text = "Menu";
        }
Esempio n. 2
0
 private void CenterizeAllControls()
 {
     foreach (Control item in this.Controls)
     {
         CC <object> .CenterVertical(item);
     }
 }
Esempio n. 3
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();
 }
Esempio n. 4
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"));
        }
Esempio n. 5
0
        private void CenterVertical(object sender, EventArgs e)
        {
            var control = (Control)sender;

            CC <object> .CenterVertical(control);
        }