Skip to content

Commit d52be75

Browse files
rearranging and figuring out pseudocode for controls
1 parent 940024c commit d52be75

File tree

6 files changed

+43
-35
lines changed

6 files changed

+43
-35
lines changed

Samples/FNSCandyStyleTransfer/UWP/cs/MainPage.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ private async void UIButtonFilePick_Click(object sender, RoutedEventArgs e)
373373
{
374374
// Load image to VideoFrame
375375
inputFrame = await ImageHelper.LoadVideoFrameFromFilePickedAsync();
376+
_inputFrame = inputFrame;
376377
}
377378
if (inputFrame == null)
378379
{

Samples/StyleTransfer/AppModel.cs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,19 @@
77
using System.Runtime.InteropServices.WindowsRuntime;
88
using System.Text;
99
using System.Threading.Tasks;
10+
using Windows.Media;
1011
using Windows.Media.Core;
1112

1213
namespace StyleTransfer
1314
{
1415
class AppModel : INotifyPropertyChanged
1516
{
16-
private string _modelSource; // Not initialized vs. have a default model to use?
17+
public AppModel()
18+
{
19+
this._useGPU = true;
20+
}
21+
22+
private string _modelSource;
1723
public string ModelSource
1824
{
1925
get { return _modelSource; }
@@ -46,16 +52,22 @@ public bool UseGPU
4652
}
4753
}
4854

49-
public event PropertyChangedEventHandler PropertyChanged;
50-
private void OnPropertyChanged([CallerMemberName] string propertyName = null)
55+
// In AppModel or in AppViewModel?
56+
private VideoFrame _outputFrame;
57+
public VideoFrame OutputFrame
5158
{
52-
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
59+
get { return _outputFrame; }
60+
set
61+
{
62+
_outputFrame = value;
63+
OnPropertyChanged();
64+
}
5365
}
5466

55-
public AppModel()
67+
public event PropertyChangedEventHandler PropertyChanged;
68+
private void OnPropertyChanged([CallerMemberName] string propertyName = null)
5669
{
57-
this._useGPU = true;
70+
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
5871
}
59-
6072
}
6173
}

Samples/StyleTransfer/AppViewModel.cs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ namespace StyleTransfer
1212
{
1313
class AppViewModel : INotifyPropertyChanged
1414
{
15+
public AppViewModel()
16+
{
17+
_appModel = new AppModel();
18+
// TODO: Add a param to check if have an image to save.
19+
SaveCommand = new RelayCommand(this.SaveOutput);
20+
MediaSourceCommand = new RelayCommand<string>(SetMediaSource);
21+
}
22+
1523
private AppModel _appModel;
1624
public AppModel CurrentApp
1725
{
@@ -31,22 +39,21 @@ public ICommand SaveCommand
3139
public ICommand MediaSourceCommand { get; set; }
3240

3341
public event PropertyChangedEventHandler PropertyChanged;
34-
public AppViewModel()
35-
{
36-
_appModel = new AppModel();
37-
// TODO: Add a param to check if have an image to save
38-
SaveCommand = new RelayCommand(this.SaveOutput);
39-
MediaSourceCommand = new RelayCommand<string>(SetMediaSource);
40-
}
4142

4243
public void SaveOutput()
4344
{
45+
// TODO: Take from UIButtonSaveImage_Click
4446
return;
4547
}
4648
public void SetMediaSource(object obj)
4749
{
48-
// TODO: Convert to a better value for the appModel object here
50+
// TODO: Convert to a better value for the appModel object here.
4951
_appModel.InputMediaSource = obj.ToString();
52+
53+
// If video source, whole different code flow
54+
55+
// If camera/image upload, gather input image then put to eval/render
56+
// If source == upload --> HelperMethods::LoadVideoFrameFromFilePickedAsync
5057
return;
5158
}
5259
}

Samples/StyleTransfer/MainPage.xaml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,14 @@ Copyright (C) Microsoft Corporation. All rights reserved.
175175
</Viewbox>
176176

177177
<!-- Camera preview -->
178-
<MediaPlayerElement Name="UIMediaPlayerElement"
179-
Stretch="Uniform"
180-
AreTransportControlsEnabled="False"
181-
Canvas.ZIndex="-1"
182-
MaxWidth="720"
183-
MaxHeight="720"
184-
Grid.Column="0"/>
178+
<MediaPlayerElement
179+
Name="UIMediaPlayerElement"
180+
Stretch="Uniform"
181+
AreTransportControlsEnabled="False"
182+
Canvas.ZIndex="-1"
183+
MaxWidth="720"
184+
MaxHeight="720"
185+
Grid.Column="0"/>
185186

186187
<!-- Input image preview -->
187188
<Image Name="UIInputImage"

Samples/StyleTransfer/RelayCommand.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.

Samples/StyleTransfer/StyleTransfer.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@
121121
</Compile>
122122
<Compile Include="AppModel.cs" />
123123
<Compile Include="AppViewModel.cs" />
124-
<Compile Include="RelayCommand.cs" />
125124
<Compile Include="MainPage.xaml.cs">
126125
<DependentUpon>MainPage.xaml</DependentUpon>
127126
</Compile>

0 commit comments

Comments
 (0)