forked from microsoft/Windows-appsample-photo-lab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainPage.xaml
257 lines (241 loc) · 12.8 KB
/
MainPage.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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
<!--
// 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.
-->
<Page x:Name="page"
x:Class="PhotoLab.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:PhotoLab"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:telerikInput="using:Telerik.UI.Xaml.Controls.Input"
xmlns:animations="using:Microsoft.Toolkit.Uwp.UI.Animations"
mc:Ignorable="d"
NavigationCacheMode="Enabled"
SizeChanged="{x:Bind DetermineItemSize}">
<Page.Resources>
<!-- Margins for grid items -->
<x:Int32 x:Key="LargeItemMarginValue">8</x:Int32>
<Thickness x:Key="LargeItemMargin">8</Thickness>
<x:Int32 x:Key="SmallItemMarginValue">0</x:Int32>
<Thickness x:Key="SmallItemMargin">0</Thickness>
<x:Int32 x:Key="DesktopWindowSidePaddingValue">16</x:Int32>
<x:Int32 x:Key="MobileWindowSidePaddingValue">32</x:Int32>
<Flyout x:Key="zoomFlyout">
<StackPanel>
<Slider x:Name="ZoomSlider"
Width="100"
Minimum="180"
Maximum="540"
Value="270"
Margin="0,5,0,0"
TickFrequency="90"
SnapsTo="Ticks"
ValueChanged="{x:Bind DetermineItemSize}"
Header="Grid item size" />
<ToggleSwitch x:Name="FitScreenToggle"
Header="Fit to screen"
MinWidth="100"
Toggled="{x:Bind DetermineItemSize}"
ToolTipService.ToolTip="Resize images to use available space." />
</StackPanel>
</Flyout>
<ItemsPanelTemplate x:Key="ImageGridView_ItemsPanelTemplate">
<ItemsWrapGrid Orientation="Horizontal"
HorizontalAlignment="Center" />
</ItemsPanelTemplate>
<DataTemplate x:Key="ImageGridView_DefaultItemTemplate"
x:DataType="local:ImageFileInfo">
<Grid Height="{Binding ItemSize, ElementName=page}"
Width="{Binding ItemSize, ElementName=page}"
Margin="{StaticResource LargeItemMargin}">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Image x:Name="ItemImage"
Source="{x:Bind ImageSource, Mode=OneWay}"
Stretch="Uniform" />
<StackPanel Orientation="Vertical"
Grid.Row="1">
<TextBlock Text="{x:Bind ImageTitle, Mode=OneWay}"
HorizontalAlignment="Center"
Style="{StaticResource SubtitleTextBlockStyle}" />
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Center">
<TextBlock Text="{x:Bind ImageFileType}"
HorizontalAlignment="Center"
Style="{StaticResource CaptionTextBlockStyle}" />
<TextBlock Text="{x:Bind ImageDimensions}"
HorizontalAlignment="Center"
Style="{StaticResource CaptionTextBlockStyle}"
Margin="8,0,0,0" />
</StackPanel>
<telerikInput:RadRating Value="{x:Bind ImageRating, Mode=OneWay}"
IsReadOnly="True">
<telerikInput:RadRating.FilledIconContentTemplate>
<DataTemplate>
<SymbolIcon Symbol="SolidStar"
Foreground="White" />
</DataTemplate>
</telerikInput:RadRating.FilledIconContentTemplate>
<telerikInput:RadRating.EmptyIconContentTemplate>
<DataTemplate>
<SymbolIcon Symbol="OutlineStar"
Foreground="White" />
</DataTemplate>
</telerikInput:RadRating.EmptyIconContentTemplate>
</telerikInput:RadRating>
</StackPanel>
</Grid>
</DataTemplate>
<Style x:Key="ImageGridView_DefaultItemContainerStyle"
TargetType="GridViewItem">
<Setter Property="Background"
Value="Gray" />
<Setter Property="Margin"
Value="{StaticResource LargeItemMargin}" />
</Style>
<DataTemplate x:Key="ImageGridView_MobileItemTemplate"
x:DataType="local:ImageFileInfo">
<Grid Height="{Binding ItemSize, ElementName=page}"
Width="{Binding ItemSize, ElementName=page}">
<Image x:Name="ItemImage"
Source="{x:Bind ImageSource}"
Stretch="UniformToFill">
<ToolTipService.ToolTip>
<ToolTip x:Name="tooltip">
<StackPanel Orientation="Vertical"
Grid.Row="1">
<TextBlock Text="{x:Bind ImageTitle, Mode=OneWay}"
HorizontalAlignment="Center"
Style="{StaticResource SubtitleTextBlockStyle}" />
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Center">
<TextBlock Text="{x:Bind ImageFileType}"
HorizontalAlignment="Center"
Style="{StaticResource CaptionTextBlockStyle}" />
<TextBlock Text="{x:Bind ImageDimensions}"
HorizontalAlignment="Center"
Style="{StaticResource CaptionTextBlockStyle}"
Margin="8,0,0,0" />
</StackPanel>
</StackPanel>
</ToolTip>
</ToolTipService.ToolTip>
</Image>
</Grid>
</DataTemplate>
<Style x:Key="ImageGridView_MobileItemContainerStyle"
TargetType="GridViewItem" />
</Page.Resources>
<RelativePanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<TextBlock x:Name="TitleTextBlock"
Text="Collection"
Style="{StaticResource TitleTextBlockStyle}"
Margin="24,0,0,24" />
<CommandBar x:Name="MainCommandBar"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
RelativePanel.AlignRightWithPanel="True"
OverflowButtonVisibility="Collapsed"
DefaultLabelPosition="Right">
<AppBarButton Icon="Zoom"
Label="Zoom"
Flyout="{StaticResource zoomFlyout}" />
</CommandBar>
<GridView x:Name="ImageGridView"
animations:ReorderGridAnimation.Duration="400"
Margin="0,0,0,8"
ItemClick="ImageGridView_ItemClick"
IsItemClickEnabled="True"
ItemsSource="{x:Bind Images, Mode=OneWay}"
RelativePanel.AlignLeftWithPanel="True"
RelativePanel.AlignRightWithPanel="True"
RelativePanel.Below="TitleTextBlock"
Loaded="{x:Bind StartConnectedAnimationForBackNavigation}"
ItemsPanel="{StaticResource ImageGridView_ItemsPanelTemplate}"
ItemTemplate="{StaticResource ImageGridView_DefaultItemTemplate}"
ItemContainerStyle="{StaticResource ImageGridView_DefaultItemContainerStyle}">
</GridView>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState>
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="{StaticResource LargeWindowSnapPoint}" />
</VisualState.StateTriggers>
</VisualState>
<VisualState>
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="{StaticResource MediumWindowSnapPoint}" />
</VisualState.StateTriggers>
</VisualState>
<VisualState>
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="{StaticResource MinWindowSnapPoint}" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="ImageGridView.ItemTemplate"
Value="{StaticResource ImageGridView_MobileItemTemplate}" />
<Setter Target="ImageGridView.ItemContainerStyle"
Value="{StaticResource ImageGridView_MobileItemContainerStyle}" />
<Setter Target="ZoomSlider.Minimum"
Value="80" />
<Setter Target="ZoomSlider.Maximum"
Value="180" />
<Setter Target="ZoomSlider.TickFrequency"
Value="20" />
<Setter Target="ZoomSlider.Value"
Value="100" />
</VisualState.Setters>
</VisualState>
<VisualState>
<VisualState.StateTriggers>
<local:MobileScreenTrigger InteractionMode="Touch" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="ImageGridView.(RelativePanel.Above)"
Value="MainCommandBar" />
<Setter Target="ImageGridView.ItemTemplate"
Value="{StaticResource ImageGridView_MobileItemTemplate}" />
<Setter Target="ImageGridView.ItemContainerStyle"
Value="{StaticResource ImageGridView_MobileItemContainerStyle}" />
<Setter Target="MainCommandBar.(RelativePanel.AlignBottomWithPanel)"
Value="True" />
<Setter Target="MainCommandBar.(RelativePanel.AlignLeftWithPanel)"
Value="True" />
<Setter Target="MainCommandBar.(RelativePanel.AlignRightWithPanel)"
Value="True" />
<Setter Target="ZoomSlider.Minimum"
Value="80" />
<Setter Target="ZoomSlider.Maximum"
Value="180" />
<Setter Target="ZoomSlider.TickFrequency"
Value="20" />
<Setter Target="ZoomSlider.Value"
Value="100" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</RelativePanel>
</Page>