Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 WPF_GenesteLussen
- {
- /// <summary>
- /// Interaction logic for MainWindow.xaml
- /// </summary>
- public partial class MainWindow : Window
- {
- public MainWindow()
- {
- InitializeComponent();
- }
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- int Rij = Convert.ToInt32(txtRij.Text);
- int Kolom = Convert.ToInt32(txtKolom.Text);
- Random rand = new Random();
- cnvCan.Children.Clear();
- for (int i = 0; i < Rij; i++)
- {
- for (int j = 0; j < Kolom; j++)
- {
- Rectangle r = new Rectangle();
- r.Width = 20;
- r.Height = r.Width;
- r.Stroke = new SolidColorBrush(Color.FromRgb((byte)(rand.Next(255)), (byte)rand.Next(255), (byte)(rand.Next(255))));
- r.Margin = new Thickness(i * r.Height, j * r.Height, 0,0);
- r.Width = 15;
- r.Height = r.Width;
- cnvCan.Children.Add(r);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement