2017-01-26 15:38:43 +02:00
|
|
|
|
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;
|
2017-01-26 17:50:33 +02:00
|
|
|
|
using Päevaküsimus.Models;
|
2017-01-26 15:38:43 +02:00
|
|
|
|
|
|
|
|
|
namespace Päevaküsimus
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Interaction logic for MainWindow.xaml
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class MainWindow : Window
|
|
|
|
|
{
|
2017-01-26 17:50:33 +02:00
|
|
|
|
private MainWindowVM _vm;
|
2017-01-26 15:38:43 +02:00
|
|
|
|
public MainWindow()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2017-01-26 17:50:33 +02:00
|
|
|
|
_vm = new MainWindowVM();
|
|
|
|
|
this.DataContext = _vm;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AllQuestionsListBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
|
|
{
|
2017-01-26 19:32:16 +02:00
|
|
|
|
if (this.allQuestionsListBox.SelectedIndex > 0)
|
2017-01-26 17:50:33 +02:00
|
|
|
|
{
|
|
|
|
|
_vm.selectedQuestion = allQuestionsListBox.SelectedItem as Question;
|
|
|
|
|
}
|
2017-01-26 19:32:16 +02:00
|
|
|
|
else if (this.allQuestionsListBox.SelectedIndex == 0)
|
2017-01-26 17:50:33 +02:00
|
|
|
|
{
|
2017-01-26 19:32:16 +02:00
|
|
|
|
this.allQuestionsListBox.SelectedItem = _vm.CreateNewQuestion();
|
2017-01-26 17:50:33 +02:00
|
|
|
|
}
|
2017-01-26 19:32:16 +02:00
|
|
|
|
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++;
|
2017-01-26 15:38:43 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|