Die Buttons
This commit is contained in:
@@ -19,9 +19,12 @@ namespace WpfApp1
|
||||
{
|
||||
int[] ZufallsZahlen = new int[6];
|
||||
|
||||
private List<int> selectedNummbers = new List<int>();
|
||||
|
||||
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
@@ -29,19 +32,43 @@ namespace WpfApp1
|
||||
InLabels();
|
||||
}
|
||||
|
||||
private void NumberButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Button clickbutton = sender as Button;
|
||||
|
||||
int number = int.Parse(clickbutton.Content.ToString());
|
||||
|
||||
if (selectedNummbers.Contains(number))
|
||||
{
|
||||
selectedNummbers.Remove(number);
|
||||
clickbutton.Background = Brushes.LightGray;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(selectedNummbers.Count < 6)
|
||||
{
|
||||
selectedNummbers.Add(number);
|
||||
clickbutton.Background = Brushes.Red;
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Sie können nur 6 Zahlen auswählen!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Zufallszahlen()
|
||||
{
|
||||
Random random = new Random();
|
||||
|
||||
|
||||
int index = 0;
|
||||
|
||||
|
||||
while (index < 6)
|
||||
{
|
||||
int zahl = random.Next(1, 50);
|
||||
|
||||
if (ZufallsZahlen.Contains(zahl))
|
||||
{
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -61,9 +88,7 @@ namespace WpfApp1
|
||||
Label5.Content = ZufallsZahlen[5].ToString();
|
||||
}
|
||||
|
||||
private void Mybutton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Mybutton.Background = new SolidColorBrush(Colors.Red);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user