Hello, I have a problem.
I'm trying to create a math game in WPF Application. The point is that when I start the game opens a window where there is a choice of four options (addition, multiplication, subtraction and division). Clicking on one of the options opens another window from two options (lower difficulty, higher difficulty). After choosing one of the options another window opens with examples that will be according to which of the options I have previously chosen. My problem is I don't know how to refer to previous radiobutton.I don't give the codes in full because I don't think it's necessary. I hope there's some simple solution I just don't see.
Thank you all for your advice.
What I have tried:
MainWindow.xaml.cs:
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
if (scitani.IsChecked.HasValue && scitani.IsChecked.Value)
{
uroven lvl = new uroven();
lvl.Show();
this.Close();
}
else if (odcitani.IsChecked.HasValue && odcitani.IsChecked.Value)
{
uroven lvl = new uroven();
lvl.Show();
...
uroven.xaml.cs:
public partial class uroven : Window
{
public uroven()
{
InitializeComponent();
}
private void start_Click(object sender, RoutedEventArgs e)
{
if (nizka.IsChecked.HasValue && nizka.IsChecked.Value)
{
hra game = new hra();
game.Show();
this.Close();
}
else if (vysoka.IsChecked.HasValue && vysoka.IsChecked.Value)
{
hra game = new hra();
...
hra.xaml.cs:
public partial class hra : Window
{
Stopwatch mt = new Stopwatch();
DispatcherTimer posunTimer = new DispatcherTimer();
decimal trvani = new decimal();
int suma = new int();
public hra()
{
InitializeComponent();
posunTimer.Tick += posunTimer_Tick;
posunTimer.Interval = TimeSpan.FromSeconds(1);
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
vysledekhrac.Focus();
suma++;
pocetprikladu.Text = suma.ToString();
mt.Start();
timer.Value = 0;
posunTimer.Start();
Random prvni = new Random();
Random druhy = new Random();
int maxprvni = 10;
int maxdruhy = 10;
int prvnic = prvni.Next(1, maxprvni);
int druhyc = druhy.Next(2, maxdruhy);
if (MathGame.scitani.IsChecked.HasValue && scitani.IsChecked.Value)
{
int total = (prvnic + druhyc);
}
prvnit.Text = prvnic.ToString();
druhyt.Text = druhyc.ToString();
vysledek.Text = total.ToString();
}
in part
<pre>if (MathGame.scitani.IsChecked.HasValue && scitani.IsChecked.Value)
{
int total = (prvnic + druhyc);
}
I would like to refer to previous radiobuttons and in statemnt if I would set an example type.