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"; }
private void CenterizeAllControls() { foreach (Control item in this.Controls) { CC <object> .CenterVertical(item); } }
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(); }
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")); }
private void CenterVertical(object sender, EventArgs e) { var control = (Control)sender; CC <object> .CenterVertical(control); }