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; using Päevaküsimus.Models; namespace Päevaküsimus { /// /// Interaction logic for MainWindow.xaml /// public partial class MainWindow : Window { private MainWindowVM _vm; public MainWindow() { InitializeComponent(); _vm = new MainWindowVM(); this.DataContext = _vm; } private void AllQuestionsListBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) { if (this.allQuestionsListBox.SelectedIndex > 0) { _vm.selectedQuestion = allQuestionsListBox.SelectedItem as Question; } else if (this.allQuestionsListBox.SelectedIndex == 0) { this.allQuestionsListBox.SelectedItem = _vm.CreateNewQuestion(); } this.questionQuestionTextBox.SelectAll(); this.questionQuestionTextBox.Focus(); } private void QuestionQuestionTextBox_OnKeyUp(object sender, KeyEventArgs e) { _vm.selectedQuestion.question = questionQuestionTextBox.Text; } private void DisplayNewQuestion_OnClick(object sender, RoutedEventArgs e) { _vm.dayQuestion = _vm.GetQuestionOfTheDay(); } private void GameAnswerSelectionListBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) { var answer = gameAnswerSelectionListBox.SelectedItem as Answer; var winText = answer.correct ? "You WON!" : "Vale vastus :("; MessageBox.Show($"Peale sinu on selle vastuse valinud veel {answer.selectionCount} inimest.", winText); answer.selectionCount++; } } }