public void UpdateBoardState(Byte startSquare, Byte endSquare, Control.ControlCollection formControls) { var playerColorNum = board[startSquare]; var jumpedSquare = engine.GetJumpedSquare(startSquare, endSquare); var panelName = "sq" + jumpedSquare; // move the piece board[endSquare] = board[startSquare]; board[startSquare] = 0; // remove jumped piece if (jumpedSquare != 0) { board[jumpedSquare] = 0; if (formControls.ContainsKey(panelName)) formControls[panelName].BackgroundImage = null; } // handle kinging if (endSquare < 8 && board[endSquare] == 1) { board[endSquare] = 3; formControls["sq" + endSquare].BackgroundImage = whiteKing; } else if (endSquare > 55 && board[endSquare] == 2) { board[endSquare] = 4; formControls["sq" + endSquare].BackgroundImage = redKing; } }
private void RemoveControlFrom(Control.ControlCollection controls, string controlname) { if (controls.ContainsKey(controlname)) controls.RemoveByKey(controlname); //foreach (Control control in controls) //{ // if (control.Name.ToLower() == controlname.ToLower()) // { // controls.Remove(control); controls.Owner.Update(); // } //} }