Update Lotto_Wpf/Lotto_Wpf/MainWindow.xaml.cs
This commit is contained in:
parent
21ac67aee4
commit
64ef945a5a
@ -1,24 +1,46 @@
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Data;
|
using System.Collections.Generic;
|
||||||
using System.Windows.Documents;
|
using System.Windows;
|
||||||
using System.Windows.Input;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
|
||||||
using System.Windows.Navigation;
|
|
||||||
using System.Windows.Shapes;
|
|
||||||
|
|
||||||
namespace test_4
|
namespace LottoNumberBoard
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Interaction logic for MainWindow.xaml
|
|
||||||
/// </summary>
|
|
||||||
public partial class MainWindow : Window
|
public partial class MainWindow : Window
|
||||||
{
|
{
|
||||||
|
private HashSet<int> selectedNumbers = new();
|
||||||
|
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void NumberButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (sender is Button btn && int.TryParse(btn.Content.ToString(), out int number))
|
||||||
|
{
|
||||||
|
if (selectedNumbers.Contains(number))
|
||||||
|
{
|
||||||
|
selectedNumbers.Remove(number);
|
||||||
|
btn.ClearValue(Button.BackgroundProperty);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
selectedNumbers.Add(number);
|
||||||
|
btn.Background = Brushes.LightGreen;
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateResultDisplay();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateResultDisplay()
|
||||||
|
{
|
||||||
|
var sorted = new List<int>(selectedNumbers);
|
||||||
|
sorted.Sort();
|
||||||
|
ResultTextBlock.Text = string.Join(", ", sorted);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user