Some gui
This commit is contained in:
parent
7a57cae2b8
commit
077fda732a
@ -3,10 +3,70 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:local="clr-namespace:Päevaküsimus"
|
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="MainWindow" Height="350" Width="525">
|
Title="MainWindow" Height="350" Width="525">
|
||||||
|
|
||||||
|
<TabControl x:Name="viewTabControl" Margin="0,0,0,0">
|
||||||
|
<TabItem Header="Päevaküsimus">
|
||||||
<Grid>
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto" MinWidth="110" />
|
||||||
|
<ColumnDefinition />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Label Grid.Column="0" Grid.Row="0" Content="Päevaküsimus on:"/>
|
||||||
|
<Label Grid.Column="1" Grid.Row="0" Content="Placeholder"/>
|
||||||
|
<Label Grid.Column="0" Grid.Row="1" Content="Vali õige vastuse variant"/>
|
||||||
|
<ListBox Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2">
|
||||||
|
<ListBox.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<Label Content="Bla" />
|
||||||
|
</DataTemplate>
|
||||||
|
</ListBox.ItemTemplate>
|
||||||
|
</ListBox>
|
||||||
|
</Grid>
|
||||||
|
</TabItem>
|
||||||
|
<TabItem Header="Admin">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto"></RowDefinition>
|
||||||
|
<RowDefinition></RowDefinition>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||||
|
<ColumnDefinition></ColumnDefinition>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Label Grid.Row="0" Grid.Column="0" Content="Küsimused"></Label>
|
||||||
|
<Label Grid.Row="0" Grid.Column="1" Content="Vaata/Muuda"></Label>
|
||||||
|
<ListBox x:Name="allQuestionsListBox" Grid.Column="0" Grid.Row="1" ItemsSource="{Binding questions}" SelectionChanged="AllQuestionsListBox_OnSelectionChanged">
|
||||||
|
<ListBox.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<Label Content="{Binding question}" />
|
||||||
|
</DataTemplate>
|
||||||
|
</ListBox.ItemTemplate>
|
||||||
|
</ListBox>
|
||||||
|
<Grid Grid.Row="1" Grid.Column="1">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto"></RowDefinition>
|
||||||
|
<RowDefinition></RowDefinition>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||||
|
<ColumnDefinition></ColumnDefinition>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Label Grid.Row="0" Grid.Column="0" Content="Küsimus:"></Label>
|
||||||
|
<TextBox Grid.Row="0" Grid.Column="1" Text="Uus Küsimus?"></TextBox>
|
||||||
|
|
||||||
|
<DataGrid Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" x:Name="dataGrid" ItemsSource="{Binding selectedQuestion.answers}">
|
||||||
|
|
||||||
|
</DataGrid>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</TabItem>
|
||||||
|
</TabControl>
|
||||||
</Window>
|
</Window>
|
||||||
|
@ -12,6 +12,7 @@ using System.Windows.Media;
|
|||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Navigation;
|
using System.Windows.Navigation;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
|
using Päevaküsimus.Models;
|
||||||
|
|
||||||
namespace Päevaküsimus
|
namespace Päevaküsimus
|
||||||
{
|
{
|
||||||
@ -20,9 +21,24 @@ namespace Päevaküsimus
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class MainWindow : Window
|
public partial class MainWindow : Window
|
||||||
{
|
{
|
||||||
|
private MainWindowVM _vm;
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_vm = new MainWindowVM();
|
||||||
|
this.DataContext = _vm;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AllQuestionsListBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (this.allQuestionsListBox.SelectedIndex > -1)
|
||||||
|
{
|
||||||
|
_vm.selectedQuestion = allQuestionsListBox.SelectedItem as Question;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_vm.selectedQuestion = new Question("Uus küsimus");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
57
Päevaküsimus/MainWindowVM.cs
Normal file
57
Päevaküsimus/MainWindowVM.cs
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
24
Päevaküsimus/Models/Answer.cs
Normal file
24
Päevaküsimus/Models/Answer.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
namespace Päevaküsimus.Models
|
||||||
|
{
|
||||||
|
public class Answer
|
||||||
|
{
|
||||||
|
public string answer { get; set; }
|
||||||
|
public bool correct { get; set; }
|
||||||
|
public int selectionCount { get; set; }
|
||||||
|
|
||||||
|
public Answer(string answer)
|
||||||
|
{
|
||||||
|
this.answer = answer;
|
||||||
|
this.correct = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Answer(string answer, bool correct)
|
||||||
|
{
|
||||||
|
this.answer = answer;
|
||||||
|
this.correct = correct;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
25
Päevaküsimus/Models/Question.cs
Normal file
25
Päevaküsimus/Models/Question.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
|
||||||
|
namespace Päevaküsimus.Models
|
||||||
|
{
|
||||||
|
public class Question
|
||||||
|
{
|
||||||
|
public string question { get; set; }
|
||||||
|
private ObservableCollection<Answer> _answers;
|
||||||
|
|
||||||
|
public Question(string question)
|
||||||
|
{
|
||||||
|
this.question = question;
|
||||||
|
this._answers = new ObservableCollection<Answer>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObservableCollection<Answer> answers { get { return _answers; } }
|
||||||
|
|
||||||
|
public void AddAnswer(Answer answer)
|
||||||
|
{
|
||||||
|
_answers.Add(answer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
21
Päevaküsimus/NotificationBase.cs
Normal file
21
Päevaküsimus/NotificationBase.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
|
namespace Päevaküsimus
|
||||||
|
{
|
||||||
|
public class NotificationBase : INotifyPropertyChanged
|
||||||
|
|
||||||
|
{
|
||||||
|
[field: NonSerialized()]
|
||||||
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
|
||||||
|
// This method is called by the Set accessor of each property.
|
||||||
|
// The CallerMemberName attribute that is applied to the optional propertyName
|
||||||
|
// parameter causes the property name of the caller to be substituted as an argument.
|
||||||
|
public void NotifyPropertyChanged([CallerMemberName] String propertyName = "")
|
||||||
|
{
|
||||||
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -37,6 +37,8 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Drawing" />
|
||||||
|
<Reference Include="System.Windows.Forms" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
@ -69,6 +71,10 @@
|
|||||||
</Compile>
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="MainWindowVM.cs" />
|
||||||
|
<Compile Include="Models\Answer.cs" />
|
||||||
|
<Compile Include="Models\Question.cs" />
|
||||||
|
<Compile Include="NotificationBase.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs">
|
<Compile Include="Properties\AssemblyInfo.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
@ -95,6 +101,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="App.config" />
|
<None Include="App.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup />
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
Loading…
Reference in New Issue
Block a user