/** * Testen, ob die temporaere Figur in die Position passt */ protected bool doPointsFit(Point[] points) { for (int i = 0; i < points.Length; i++) { if (points[i].X < 0 || points[i].X >= board.getColumns() || points[i].Y < 0 || points[i].Y >= board.getRows() || board.isCellColored((int)points[i].X, (int)points[i].Y)) { return(false); } } return(true); }
/** * Initialisiert das Spielfeld */ void initBoard() { /*Hier werden die Columns und Rows definiert*/ for (int i = 0; i < boardModel.getColumns(); i++) { boardGrid.ColumnDefinitions.Add(new ColumnDefinition()); } for (int i = 0; i < boardModel.getRows(); i++) { boardGrid.RowDefinitions.Add(new RowDefinition()); } /* Die Rechtecke für das Grid werden hier erstellt*/ for (int i = 0; i < boardModel.getRows(); i++) { for (int j = 0; j < boardModel.getColumns(); j++) { Rectangle rect = new Rectangle(); rect.SetValue(Grid.RowProperty, i); rect.SetValue(Grid.ColumnProperty, j); rect.Stroke = new SolidColorBrush(Color.FromArgb(50, 0, 0, 255)); DoubleCollection dc = new DoubleCollection(); dc.Add(10); rect.StrokeDashArray = dc; rect.StrokeThickness = 1; boardGrid.Children.Add(rect); } } /*Auch hier Rechtecke ins Grid-Vorschau*/ for (int i = 0; i < previewGrid.RowDefinitions.Count; i++) { for (int j = 0; j < previewGrid.ColumnDefinitions.Count; j++) { Rectangle rect = new Rectangle(); rect.SetValue(Grid.RowProperty, i); rect.SetValue(Grid.ColumnProperty, j); previewGrid.Children.Add(rect); } } /*Rechtecke für Memory*/ for (int i = 0; i < memoryGrid.RowDefinitions.Count; i++) { for (int j = 0; j < memoryGrid.ColumnDefinitions.Count; j++) { Rectangle rect = new Rectangle(); rect.SetValue(Grid.RowProperty, i); rect.SetValue(Grid.ColumnProperty, j); memoryGrid.Children.Add(rect); } } }