/// <summary> /// Initialize user controls /// </summary> private void InitUC() { if (this.game.Map != null) { chessBoardUC = new ChessBoardUserControl(this.game.ChessBoard, this.game.Map.FileName); } else { chessBoardUC = new ChessBoardUserControl(this.game.ChessBoard); } chessBoardUC.Name = "chessBoardUC"; this.mainGame.mainGrid.Children.Add(chessBoardUC); Grid.SetRow(chessBoardUC, 0); Grid.SetColumn(chessBoardUC, 0); chessBoardUC.VerticalAlignment = System.Windows.VerticalAlignment.Stretch; chessBoardUC.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; chessBoardUC.Load(game.Background, game.Player1.Theme, game.Player2.Theme); this.mainGame.lblCurrentPlayer.Content = this.game.CurrentPlayer.Name; }
public MyChessViewModel(Grid gameGrid) { GameGrid = gameGrid; #region Board RowDefinition menuRowDefinition = new RowDefinition { Height = GridLength.Auto }; GameGrid.RowDefinitions.Add(menuRowDefinition); RowDefinition chessBoardRowDefinitionRowDefinition = new RowDefinition(); GameGrid.RowDefinitions.Add(chessBoardRowDefinitionRowDefinition); RowDefinition engineOutputRowDefinition = new RowDefinition { Height = new GridLength(100) }; GameGrid.RowDefinitions.Add(engineOutputRowDefinition); Menu = new ChessMenuUserControl(); GameGrid.Children.Add(Menu); Grid.SetRow(Menu, 0); ChessBoard = new ChessBoardUserControl(); GameGrid.Children.Add(ChessBoard); Grid.SetRow(ChessBoard, 1); EngineOutput = new EngineOutputControl(); GameGrid.Children.Add(EngineOutput); Grid.SetRow(EngineOutput, 2); #endregion #region Engine ChessEngine = new ChessEngine2(); #endregion #region Menu Menu.SetEventHandler(Command); ChessBoard.SetEventHandler(Command); #endregion }