Skip to content

Commit 3a81431

Browse files
Add gpu selection
2 parents 0b9a1e3 + f8333d9 commit 3a81431

File tree

2 files changed

+115
-190
lines changed

2 files changed

+115
-190
lines changed

Samples/FNSCandyStyleTransfer/UWP/cs/MainPage.xaml

Lines changed: 115 additions & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,51 @@
11
<!--
2-
*@@@+++@@@@******************************************************************
3-
4-
Microsoft Windows Media Foundation
5-
Copyright (C) Microsoft Corporation. All rights reserved.
6-
7-
*@@@+++@@@@******************************************************************
2+
*@@@+++@@@@******************************************************************
3+
4+
Microsoft Windows Media Foundation
5+
Copyright (C) Microsoft Corporation. All rights reserved.
6+
7+
*@@@+++@@@@******************************************************************
88
-->
99
<Page
1010
x:Class="SnapCandy.MainPage"
1111
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
1212
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
13-
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
1413
xmlns:local="using:SnapCandy"
14+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
1515
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
1616
mc:Ignorable="d">
1717

1818
<Page.Resources>
19-
<SolidColorBrush
20-
x:Key="TranslucentBlackBrush"
21-
Opacity="0.3"
22-
Color="Black" />
19+
<SolidColorBrush x:Key="TranslucentBlackBrush" Color="Black" Opacity="0.3"/>
2320
<Style x:Key="TextBlockStyling" TargetType="TextBlock">
24-
<Setter Property="Foreground" Value="Black" />
21+
<Setter Property="Foreground" Value="Black"/>
2522
</Style>
2623
</Page.Resources>
2724

2825
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
2926

3027
<Grid>
3128
<Grid.RowDefinitions>
32-
<RowDefinition Height="80" />
33-
<RowDefinition Height="300*" />
34-
<RowDefinition Height="30" />
29+
<RowDefinition Height="80"/>
30+
<RowDefinition Height="300*"/>
31+
<RowDefinition Height="30"/>
3532
</Grid.RowDefinitions>
3633

37-
<!-- Status and result display -->
38-
<StackPanel
39-
x:Name="UIStatusPanel"
40-
Grid.Row="0"
41-
VerticalAlignment="Top"
42-
Background="#BFFFFFFF">
34+
<!--Status and result display-->
35+
<StackPanel x:Name="UIStatusPanel" Background="#BFFFFFFF" VerticalAlignment="Top" Grid.Row="0">
4336
<ContentControl Name="UIModelControls">
4437
<StackPanel Orientation="Horizontal">
45-
<ToggleSwitch
46-
Name="UIToggleInferenceDevice"
47-
Margin="10,0,0,0"
48-
IsOn="True"
49-
OffContent="CPU"
50-
OnContent="GPU"
51-
Toggled="UIToggleInferenceDevice_Toggled" />
38+
<ToggleSwitch Name="UIToggleInferenceDevice"
39+
OnContent="GPU"
40+
OffContent="CPU"
41+
IsOn="True"
42+
Toggled="UIToggleInferenceDevice_Toggled"
43+
Margin="10,0,0,0"/>
5244

5345
<ListBox Name="UIStyleList" SelectionChanged="UIStyleList_SelectionChanged">
5446
<ListBox.ItemsPanel>
5547
<ItemsPanelTemplate>
56-
<VirtualizingStackPanel Orientation="Horizontal" />
48+
<VirtualizingStackPanel Orientation="Horizontal"/>
5749
</ItemsPanelTemplate>
5850
</ListBox.ItemsPanel>
5951
</ListBox>
@@ -62,55 +54,49 @@
6254
</ContentControl>
6355

6456

65-
<!-- Image preview and acquisition control -->
66-
<ContentControl
67-
Name="UIImageControls"
68-
HorizontalAlignment="Stretch"
69-
VerticalAlignment="Stretch"
70-
IsEnabled="False">
57+
<!--Image preview and acquisition control-->
58+
<ContentControl Name="UIImageControls"
59+
VerticalAlignment="Stretch"
60+
HorizontalAlignment="Stretch"
61+
IsEnabled="False">
7162

7263
<StackPanel Orientation="Horizontal">
73-
<Button
74-
Name="UIButtonLiveStream"
75-
Click="UIButtonLiveStream_Click"
76-
ToolTipService.ToolTip="Camera preview">
64+
<Button Name="UIButtonLiveStream"
65+
ToolTipService.ToolTip="Camera preview"
66+
Click="UIButtonLiveStream_Click">
7767
<Button.Content>
78-
<SymbolIcon Symbol="Video" />
68+
<SymbolIcon Symbol="Video"/>
7969
</Button.Content>
8070
</Button>
81-
<Button
82-
Name="UIButtonAcquireImage"
83-
Click="UIButtonAcquireImage_Click"
84-
ToolTipService.ToolTip="Take a photo">
71+
<Button Name="UIButtonAcquireImage"
72+
ToolTipService.ToolTip="Take a photo"
73+
Click="UIButtonAcquireImage_Click">
8574
<Button.Content>
86-
<SymbolIcon Symbol="Camera" />
75+
<SymbolIcon Symbol="Camera"/>
8776
</Button.Content>
8877
</Button>
89-
<Button
90-
Name="UIButtonFilePick"
91-
Click="UIButtonFilePick_Click"
92-
ToolTipService.ToolTip="Select an image from a file">
78+
<Button Name="UIButtonFilePick"
79+
ToolTipService.ToolTip="Select an image from a file"
80+
Click="UIButtonFilePick_Click">
9381
<Button.Content>
94-
<SymbolIcon Symbol="OpenFile" />
82+
<SymbolIcon Symbol="OpenFile"/>
9583
</Button.Content>
9684
</Button>
97-
<Button
98-
Name="UIButtonInking"
99-
Click="UIButtonInking_Click"
100-
ToolTipService.ToolTip="Draw on a canvas">
85+
<Button Name="UIButtonInking"
86+
ToolTipService.ToolTip="Draw on a canvas"
87+
Click="UIButtonInking_Click">
10188
<Button.Content>
102-
<SymbolIcon Symbol="Edit" />
89+
<SymbolIcon Symbol="Edit"/>
10390
</Button.Content>
10491
</Button>
105-
<Button
106-
Name="UIButtonSaveImage"
107-
VerticalAlignment="Bottom"
108-
Background="#FF939393"
109-
Click="UIButtonSaveImage_Click"
92+
<Button Name="UIButtonSaveImage"
93+
ToolTipService.ToolTip="Save the image result to a file"
11094
IsEnabled="false"
111-
ToolTipService.ToolTip="Save the image result to a file">
95+
VerticalAlignment="Bottom"
96+
Click="UIButtonSaveImage_Click"
97+
Background="#FF939393" >
11298
<Button.Content>
113-
<SymbolIcon Symbol="Save" />
99+
<SymbolIcon Symbol="Save"/>
114100
</Button.Content>
115101
</Button>
116102

@@ -122,121 +108,100 @@
122108
<!--<Viewbox Stretch="Uniform" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="1">-->
123109
<Grid Grid.Row="1">
124110
<Grid.ColumnDefinitions>
125-
<ColumnDefinition Width="200*" />
126-
<ColumnDefinition Width="200*" />
111+
<ColumnDefinition Width="200*"/>
112+
<ColumnDefinition Width="200*"/>
127113
</Grid.ColumnDefinitions>
128114

129115
<Viewbox Stretch="Uniform">
130-
<StackPanel
131-
Name="UIInkControls"
132-
Grid.Column="0"
133-
Visibility="Collapsed">
134-
<InkToolbar VerticalAlignment="Top" TargetInkCanvas="{x:Bind UIInkCanvasInput}" />
135-
136-
<!-- inking canvas -->
137-
<Viewbox
138-
MaxWidth="720"
139-
MaxHeight="720"
140-
Stretch="Uniform">
141-
<Grid BorderBrush="Black" BorderThickness="1">
142-
<Grid
143-
Name="UIInkGrid"
144-
MinWidth="200"
145-
MinHeight="200"
146-
MaxWidth="720"
147-
MaxHeight="720"
148-
Background="White">
149-
<InkCanvas Name="UIInkCanvasInput" />
116+
<StackPanel Name="UIInkControls"
117+
Visibility="Collapsed"
118+
Grid.Column="0">
119+
<InkToolbar TargetInkCanvas="{x:Bind UIInkCanvasInput}" VerticalAlignment="Top" />
120+
121+
<!--inking canvas-->
122+
<Viewbox Stretch="Uniform"
123+
MaxWidth="720"
124+
MaxHeight="720">
125+
<Grid BorderBrush="Black"
126+
BorderThickness="1">
127+
<Grid Name="UIInkGrid"
128+
Background="White"
129+
MinWidth="200"
130+
MinHeight="200"
131+
MaxWidth="720"
132+
MaxHeight="720">
133+
<InkCanvas Name="UIInkCanvasInput"/>
150134
</Grid>
151135
</Grid>
152136
</Viewbox>
153137
</StackPanel>
154138
</Viewbox>
155139

156-
<!-- Camera preview -->
157-
<MediaPlayerElement
158-
Name="UIMediaPlayerElement"
159-
Grid.Column="0"
160-
MaxWidth="720"
161-
MaxHeight="720"
162-
AreTransportControlsEnabled="False"
163-
Canvas.ZIndex="-1"
164-
Stretch="Uniform" />
165-
166-
<Image
167-
Name="UIInputImage"
168-
Grid.Column="0"
169-
MaxWidth="720"
170-
MaxHeight="720"
171-
Stretch="Uniform" />
172-
173-
<Grid Grid.Column="1" VerticalAlignment="Stretch">
174-
175-
<Image
176-
Name="UIResultImage"
177-
MaxWidth="720"
178-
MaxHeight="720"
179-
Stretch="Uniform" />
180-
181-
<ProgressRing
182-
Name="UIProcessingProgressRing"
183-
MaxWidth="720"
184-
MaxHeight="720"
185-
IsActive="false"
186-
Visibility="Collapsed" />
140+
<!--Camera preview-->
141+
<MediaPlayerElement Name="UIMediaPlayerElement"
142+
Stretch="Uniform"
143+
AreTransportControlsEnabled="False"
144+
Canvas.ZIndex="-1"
145+
MaxWidth="720"
146+
MaxHeight="720"
147+
Grid.Column="0"/>
148+
149+
<Image Name="UIInputImage"
150+
Grid.Column="0"
151+
Stretch="Uniform"
152+
MaxWidth="720"
153+
MaxHeight="720"/>
154+
155+
<Grid Grid.Column="1" VerticalAlignment="Stretch">
156+
157+
<Image Name="UIResultImage"
158+
Stretch="Uniform"
159+
MaxWidth="720"
160+
MaxHeight="720"/>
161+
162+
<ProgressRing Name="UIProcessingProgressRing"
163+
MaxWidth="720"
164+
MaxHeight="720"
165+
IsActive="false"
166+
Visibility="Collapsed"/>
187167
</Grid>
188168
</Grid>
189169
<!--</Viewbox>-->
190170

191-
<StackPanel
192-
Name="UICameraSelectionControls"
193-
Grid.Row="1"
194-
HorizontalAlignment="Left"
195-
VerticalAlignment="Bottom"
196-
Orientation="vertical"
197-
Visibility="Collapsed">
198-
<TextBlock Style="{StaticResource TextBlockStyling}" Text="Camera: " />
199-
<ComboBox
200-
Name="UICmbCamera"
201-
Foreground="White"
202-
SelectionChanged="UICmbCamera_SelectionChanged">
171+
<StackPanel Name="UICameraSelectionControls" Orientation="vertical" Visibility="Collapsed" VerticalAlignment="Bottom" HorizontalAlignment="Left" Grid.Row="1">
172+
<TextBlock Text="Camera: " Style="{StaticResource TextBlockStyling}"/>
173+
<ComboBox Name="UICmbCamera" SelectionChanged="UICmbCamera_SelectionChanged" Foreground="White" >
203174
<ComboBox.Background>
204-
<SolidColorBrush Opacity="0.3" Color="Black" />
175+
<SolidColorBrush Color="Black" Opacity="0.3"/>
205176
</ComboBox.Background>
206177
</ComboBox>
207-
<TextBlock Style="{StaticResource TextBlockStyling}" Text="Preview resolution: " />
208-
<TextBlock
209-
Name="UITxtBlockPreviewProperties"
210-
Style="{StaticResource TextBlockStyling}"
211-
Text="0x0" />
178+
<TextBlock Text="Preview resolution: " Style="{StaticResource TextBlockStyling}"/>
179+
<TextBlock Name="UITxtBlockPreviewProperties" Text="0x0" Style="{StaticResource TextBlockStyling}"/>
212180
</StackPanel>
213181

214182
<Border x:Name="UIStatusBorder" Grid.Row="2">
215183
<StackPanel Orientation="Horizontal">
216-
<TextBlock
217-
x:Name="StatusBlock"
218-
Width="700"
219-
Margin="10,2,0,0"
220-
FontWeight="Bold"
184+
<TextBlock x:Name="StatusBlock"
221185
Text="Select a style to begin"
222-
TextWrapping="Wrap" />
223-
<TextBlock
186+
FontWeight="Bold"
187+
Width="700"
224188
Margin="10,2,0,0"
225-
FontWeight="Bold"
226-
Text="Capture FPS" />
227-
<TextBlock
228-
x:Name="CaptureFPS"
189+
TextWrapping="Wrap" />
190+
<TextBlock
191+
Text="Capture FPS"
229192
Margin="10,2,0,0"
193+
FontWeight="Bold" />
194+
<TextBlock x:Name="CaptureFPS"
230195
Text="0 fps"
231-
TextWrapping="Wrap" />
232-
<TextBlock
233196
Margin="10,2,0,0"
234-
FontWeight="Bold"
235-
Text="Render FPS" />
236-
<TextBlock
237-
x:Name="RenderFPS"
197+
TextWrapping="Wrap" />
198+
<TextBlock
199+
Text="Render FPS"
238200
Margin="10,2,0,0"
201+
FontWeight="Bold"/>
202+
<TextBlock x:Name="RenderFPS"
239203
Text="0 fps"
204+
Margin="10,2,0,0"
240205
TextWrapping="Wrap" />
241206
</StackPanel>
242207
</Border>

0 commit comments

Comments
 (0)