eksam/Päevaküsimus/MainWindowVM.cs
2017-01-26 17:50:33 +02:00

58 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Päevaküsimus.Models;
namespace Päevaküsimus
{
class MainWindowVM:NotificationBase
{
public ObservableCollection<Question> questions { get; set; }
private Question _seleceQuestion;
public Question selectedQuestion {
get { return _seleceQuestion;}
set
{
_seleceQuestion = value;
selectedQuestionAnswers = value.answers;
NotifyPropertyChanged();
}
}
private ObservableCollection<Answer> _selectedQuestionAnswers;
public ObservableCollection<Answer> selectedQuestionAnswers {
get { return _selectedQuestionAnswers; }
set
{
_selectedQuestionAnswers = value;
NotifyPropertyChanged();
}
}
private Random _rnd;
public MainWindowVM()
{
this._rnd = new Random();
this.questions = new ObservableCollection<Question>();
var question = new Question("Mis värvi on armastus?");
question.AddAnswer(new Answer("Punane", true));
foreach (var color in new [] {"Roheline", "Sinine", "Roosa", "Lilla"})
{
question.AddAnswer(new Answer(color));
}
this.questions.Add(question);
this.questions.Add(new Question("Test"));
}
public Question GetQuestionOfTheDay()
{
return this.questions.ElementAt(this._rnd.Next(0, this.questions.Count));
}
}
}