public void createGrid(PuzzleGame mw) { this.mw = mw; int numPiece = 1; for (int i = 0; i < n; i++) { ColumnDefinition gridCol1 = new ColumnDefinition(); RowDefinition gridRow1 = new RowDefinition(); this.gridMatriz.ColumnDefinitions.Add(gridCol1); this.gridMatriz.RowDefinitions.Add(gridRow1); } for (int i = 0; i < this.gridMatriz.RowDefinitions.Count; i++) { for (int j = 0; j < this.gridMatriz.ColumnDefinitions.Count; j++) { PiecePuzzle piece = new PiecePuzzle(); piece.Puzzle = this; piece.Num = numPiece; numPiece++; Grid.SetRow(piece, i); Grid.SetColumn(piece, j); this.gridMatriz.Children.Add(piece); } } this.sourceImage(); }
public bool isFinish() { bool ok = true; IEnumerator pics = this.gridMatriz.Children.OfType <PiecePuzzle>().GetEnumerator(); int count = 1; //coloca imagenes while (pics.MoveNext() && ok) { PiecePuzzle aux = (PiecePuzzle)pics.Current; if (aux.Num != count) { ok = false; } count++; } return(ok); }
public void selecImage(PiecePuzzle piece) { if (numPiece == 0) { ant = piece; numPiece++; } else if (numPiece == 1) { var p = piece.piece.Content; int n = piece.Num; piece.piece.Content = ant.piece.Content; piece.Num = ant.Num; ant.piece.Content = p; ant.Num = n; piece.marked(); ant.marked(); numPiece = 0; } }