/// <summary>Constructs a new window view based upon the model of the specified window.</summary> /// <param name="window">Window off of which to pattern a new window.</param> public SudokuViewWindow(SudokuViewWindow window) { _sudokuGrid = Init(); Board = window.Board; // Populate int index = 0; SudokuCellSetHandler onsetHandler = new SudokuCellSetHandler(Cell_OnSet); SudokuCellClearHandler onclearHandler = new SudokuCellClearHandler(Cell_OnClear); for (var row = 0; row < Dimension; ++row) { for (var col = 0; col < Dimension; ++col) { SudokuCellUserControl cell = (SudokuCellUserControl)window._sudokuCells[index].Duplicate(); cell.OnSet += onsetHandler; cell.OnClear += onclearHandler; Grid.SetRow(cell, row); Grid.SetColumn(cell, col); _sudokuGrid.Children.Add(cell); _sudokuCells.Add(cell); index++; } } // Add the Grid (Hidden at first, then Show because is Loaded) grid.Children.Add(_sudokuGrid); BoardLoaded(); }
// Window View Handlers /// <summary>Creates a duplicate view of the model.</summary> /// <param name="sender">Object which initiated this method call.</param> /// <param name="e">Event which caused this call.</param> protected virtual void Dup_Clicked(System.Object sender, EventArgs e) { Window dup = new SudokuViewWindow(this); dup.Show(); }