/// <summary> /// Sets the board that should be shown in the GUI. /// /// TODO: Remove listener for old board. /// </summary> public void SetBoard(Board board) { Rows = new ObservableCollection<ObservableCollection<GUIField>>(); m_board = board; //Listen for new board m_board.BoardChanged += BoardChanged; for (int row = 0; row < m_board.Size; row++) { var columns = new ObservableCollection<GUIField>(); for (int col = 0; col < m_board.Size; col++) { var coords = new Coords(col, row); var field = new GUIField(board.GetFieldValue(coords), coords); columns.Add(field); } Rows.Add(columns); } this.DataContext = Rows; }
/// <summary> /// Sets the board that should be shown in the GUI. /// /// TODO: Remove listener for old board. /// </summary> public void SetBoard(Board board) { Rows = new ObservableCollection <ObservableCollection <GUIField> >(); m_board = board; //Listen for new board m_board.BoardChanged += BoardChanged; for (int row = 0; row < m_board.Size; row++) { var columns = new ObservableCollection <GUIField>(); for (int col = 0; col < m_board.Size; col++) { var coords = new Coords(col, row); var field = new GUIField(board.GetFieldValue(coords), coords); columns.Add(field); } Rows.Add(columns); } this.DataContext = Rows; }