forked from microsoft/Windows-appsample-networkhelper
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHostView.xaml
177 lines (152 loc) · 9.6 KB
/
HostView.xaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<!--
Copyright (c) Microsoft Corporation. All rights reserved.
The MIT License (MIT)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<UserControl
x:Class="QuizGame.View.HostView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:viewmodel="using:QuizGame.ViewModel"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="800"
d:DesignWidth="800">
<UserControl.Resources>
<Style TargetType="TextBlock">
<Setter Property="FontSize" Value="15"/>
</Style>
<Style x:Key="OptionContentControlStyle" TargetType="ContentControl">
<Setter Property="FontSize" Value="20"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ContentControl">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Rectangle Width="48" Height="48" Fill="{TemplateBinding Background}"/>
<TextBlock Grid.Column="1" Margin="24,0,0,0" Text="{TemplateBinding Content}" VerticalAlignment="Center" TextWrapping="WrapWholeWords"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<DataTemplate x:Key="PlayerTemplate" x:DataType="x:String">
<Grid>
<TextBlock Style="{StaticResource SubtitleTextBlockStyle}" Text="{x:Bind}" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis" Margin="12,0,12,12"/>
</Grid>
</DataTemplate>
<DataTemplate x:Key="PlayerProgressTemplate" x:DataType="viewmodel:PlayerProgress">
<StackPanel>
<TextBlock Style="{StaticResource SubtitleTextBlockStyle}" Foreground="{x:Bind AnsweredCurrentQuestionBrush}" FontWeight="{x:Bind AnsweredCurrentQuestionFontWeight}"
Text="{x:Bind Name}"
TextWrapping="NoWrap" TextTrimming="CharacterEllipsis" Margin="12,0,12,12"/>
</StackPanel>
</DataTemplate>
<Style x:Key="PlayerNameTextBlockStyle" TargetType="TextBlock" BasedOn="{StaticResource SubtitleTextBlockStyle}">
<Setter Property="Foreground" Value="{ThemeResource DefaultTextForegroundThemeBrush}"/>
</Style>
<Style x:Key="PlayerScoreTextBlockStyle" TargetType="TextBlock" BasedOn="{StaticResource CaptionTextBlockStyle }">
<Setter Property="Foreground" Value="{ThemeResource DefaultTextForegroundThemeBrush}"/>
</Style>
<DataTemplate x:Key="PlayerResultTemplate" x:DataType="viewmodel:PlayerResult">
<Grid Width="200" Height="200" Margin="20">
<Border Background="#FF994D4D"/>
<StackPanel VerticalAlignment="Bottom" Background="{StaticResource ListViewItemOverlayBackgroundThemeBrush}">
<TextBlock Style="{StaticResource PlayerNameTextBlockStyle}" Foreground="{StaticResource ListViewItemOverlaySecondaryForegroundThemeBrush}" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis" Margin="12,0,24,0" Text="{x:Bind Name}"/>
<TextBlock Style="{StaticResource PlayerScoreTextBlockStyle}" Text="{x:Bind Score}" Foreground="{StaticResource ListViewItemOverlaySecondaryForegroundThemeBrush}" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis" Margin="12,0,12,12"/>
</StackPanel>
</Grid>
</DataTemplate>
</UserControl.Resources>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState x:Name="WideState">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="548"/>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="pageTitleGrid.Height" Value="140"/>
<Setter Target="pageTitle.Margin" Value="0,0,30,40"/>
<Setter Target="contentGrid.Margin" Value="40,12,0,0"/>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid.ChildrenTransitions>
<TransitionCollection>
<EntranceThemeTransition/>
</TransitionCollection>
</Grid.ChildrenTransitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!-- Page title -->
<Grid x:Name="pageTitleGrid" Grid.Column="1" Height="60">
<TextBlock x:Name="pageTitle" Text="QuizGame" Style="{StaticResource HeaderTextBlockStyle}" Grid.Column="1"
IsHitTestVisible="false" TextWrapping="NoWrap" VerticalAlignment="Bottom" Margin="-30,0,0,0"/>
</Grid>
<!-- Content -->
<Grid x:Name="contentGrid" Margin="-18,12,0,0" Grid.Row="1" Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="3*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--Lobby-->
<StackPanel Visibility="{x:Bind ViewModel.StartVisibility, Mode=OneWay}">
<TextBlock Text="Launch QuizGame on your phone, and tap join..." TextWrapping="WrapWholeWords"/>
<ItemsControl ItemsSource="{x:Bind ViewModel.Game.PlayerNames}" ItemTemplate="{StaticResource PlayerTemplate}" Margin="0,24,0,0"/>
</StackPanel>
<!--Game underway-->
<Grid Visibility="{x:Bind ViewModel.GameUnderwayVisibility, Mode=OneWay}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height=".5*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Text="{x:Bind ViewModel.CurrentQuestionText, Mode=OneWay}" TextWrapping="WrapWholeWords" Margin="0,0,0,24"/>
<!--Options-->
<ContentControl Content="{x:Bind ViewModel.Game.CurrentQuestion.Options[0], Mode=OneWay}" Style="{StaticResource OptionContentControlStyle}" Background="#FFAA80FF" Grid.Row="1"/>
<ContentControl Content="{x:Bind ViewModel.Game.CurrentQuestion.Options[1], Mode=OneWay}" Style="{StaticResource OptionContentControlStyle}" Background="#FF8080FF" Grid.Row="2"/>
<ContentControl Content="{x:Bind ViewModel.Game.CurrentQuestion.Options[2], Mode=OneWay}" Style="{StaticResource OptionContentControlStyle}" Background="#FF80AAFF" Grid.Row="3"/>
<ContentControl Content="{x:Bind ViewModel.Game.CurrentQuestion.Options[3], Mode=OneWay}" Style="{StaticResource OptionContentControlStyle}" Background="#FF80D5FF" Grid.Row="4"/>
<!--Players-->
<ItemsControl ItemsSource="{x:Bind ViewModel.PlayerProgress, Mode=OneWay}" ItemTemplate="{StaticResource PlayerProgressTemplate}" Grid.Row="6"/>
</Grid>
<!--Results-->
<ScrollViewer Visibility="{x:Bind ViewModel.ResultsVisibility, Mode=OneWay}">
<ItemsControl ItemsSource="{x:Bind ViewModel.PlayerResults, Mode=OneWay}" ItemTemplate="{StaticResource PlayerResultTemplate}"/>
</ScrollViewer>
<Button Content="Start game" Command="{x:Bind ViewModel.StartGameCommand}" Visibility="{x:Bind ViewModel.StartVisibility, Mode=OneWay}" MinWidth="150" Grid.Row="1" VerticalAlignment="Top"/>
<Button Content="{x:Bind ViewModel.NextButtonText, Mode=OneWay}" Command="{x:Bind ViewModel.NextCommand}" Visibility="{x:Bind ViewModel.GameUnderwayVisibility, Mode=OneWay}" MinWidth="150" Grid.Row="1" VerticalAlignment="Top"/>
<Button Content="Return to lobby" Command="{x:Bind ViewModel.EndGameCommand}" Visibility="{x:Bind ViewModel.ResultsVisibility, Mode=OneWay}" MinWidth="150" Grid.Row="1" VerticalAlignment="Top"/>
</Grid>
</Grid>
</UserControl>