Czoko_Smieciarka/Trunk/CzokoŚmieciarka.UserInterface.WPF/MainWindow.xaml.cs
Bartosz Chyzy 2e44f4653b MapEditor
2019-04-22 22:11:56 +02:00

70 lines
2.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace CzokoŚmieciarka.UserInterface.WPF
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this._rows = 10;
this._columns = 15;
GenerateGridBoard();
PopulateGridBoard();
}
private int _rows;
private int _columns;
private void GenerateGridBoard()
{
for (int row = 0; row < _rows; row++)
{
GridBoard.RowDefinitions.Add(new RowDefinition(){Height = new GridLength(70)});
}
for (int column = 0; column < _columns; column++)
{
GridBoard.ColumnDefinitions.Add(new ColumnDefinition(){ Width = new GridLength(70) });
}
}
private void PopulateGridBoard()
{
var random = new Random();
for (int row = 0; row < _rows; row++)
{
for (int column = 0; column < _columns; column++)
{
byte red = (byte)random.Next(0, 255);
byte green = (byte)random.Next(0, 255);
byte blue = (byte)random.Next(0, 255);
var content = new StackPanel() { Background = new SolidColorBrush(Color.FromRgb(red, green, blue)) };
Grid.SetRow(content,row);
Grid.SetColumn(content,column);
GridBoard.Children.Add(content);
}
}
}
}
}