private void UpdateBoardeGui(Button lb, BoardGui boardGui, ChessPieceSide side) { if (btnPlay.InvokeRequired) { // this is worker thread updateBoardDelegate del = new updateBoardDelegate(UpdateBoardeGui); lvChat.Invoke(del, new object[] { lb, boardGui, side }); } else { // this is UI thread btnPlay.Visible = false; boardGui = new BoardGui(side); this.Controls.Add(boardGui); this.boardGui = boardGui; } }
/// <summary> /// init cellGui and sound /// </summary> /// <param name="board"></param> /// <param name="id"></param> public CellGui(BoardGui board, int id) { this.IDCellGui = id; this.board = board; this.SetColor(); CellGui.activeColor = Color.GreenYellow; this.Size = new Size(60, 60); this.SetImageIcon(); this.MouseClick += CellGui_MouseClick; soundClick.URL = Application.StartupPath + "\\soundClick.mp3"; }
private void UpdateBoardeGui(Button lb, BoardGui boardGui, ChessPieceSide side) { if (btnPlay.InvokeRequired) { // this is worker thread updateBoardDelegate del = new updateBoardDelegate(UpdateBoardeGui); btnPlay.Invoke(del, new object[] { lb, boardGui, side }); } else { // this is UI thread btnPlay.Visible = false; if (Mode1AndMode2.namePlayer == "Player black") { isClient = true; } boardGui = new BoardGui(side, isClient); this.Controls.Add(boardGui); this.boardGui = boardGui; } }