@@ -64,8 +64,10 @@ class AppViewModel : INotifyPropertyChanged
6464 public AppViewModel ( )
6565 {
6666 _appModel = new AppModel ( ) ;
67+ _appModel . PropertyChanged += _appModel_PropertyChanged ;
68+
6769 SaveCommand = new RelayCommand ( SaveOutput ) ;
68- SetMediaSourceCommand = new RelayCommand < InputMediaType > ( async ( x ) => await SetMediaSource ( x ) ) ;
70+ SetMediaSourceCommand = new RelayCommand < InputMediaType > ( ( x ) => _appModel . InputMedia = x ) ;
6971 SetModelSourceCommand = new RelayCommand ( async ( ) => await SetModelSource ( ) ) ;
7072 ChangeLiveStreamCommand = new RelayCommand ( async ( ) => await ChangeLiveStream ( ) ) ;
7173
@@ -82,15 +84,18 @@ await DispatcherHelper.RunAsync(() =>
8284 } ) ;
8385
8486 } ;
85- _useGpu = false ;
87+ UseGpu = false ;
8688 _isPreviewing = false ;
8789 NotifyUser ( true ) ;
8890 }
8991
9092 private AppModel _appModel ;
9193 public AppModel AppModel
9294 {
93- get { return _appModel ; }
95+ get
96+ {
97+ return _appModel ;
98+ }
9499 }
95100
96101 private float _renderFPS ;
@@ -120,23 +125,7 @@ public float CaptureFPS
120125 OnPropertyChanged ( ) ;
121126 }
122127 }
123- private bool _useGpu ;
124- public bool UseGpu
125- {
126- get
127- {
128- return _useGpu ;
129- }
130- set
131- {
132- _useGpu = value ;
133- if ( _appModel . InputMedia == InputMediaType . LiveStream )
134- {
135- SetMediaSourceCommand . Execute ( InputMediaType . LiveStream ) ;
136- }
137- OnPropertyChanged ( ) ;
138- }
139- }
128+
140129 private SoftwareBitmapSource _inputSoftwareBitmapSource ;
141130 public SoftwareBitmapSource InputSoftwareBitmapSource
142131 {
@@ -199,13 +188,39 @@ public string StatusMessage
199188 OnPropertyChanged ( "StatusBarColor" ) ;
200189 }
201190 }
202-
191+ private bool _useGpu ;
192+ public bool UseGpu
193+ {
194+ get
195+ {
196+ return _useGpu ;
197+ }
198+ set
199+ {
200+ _useGpu = value ;
201+ if ( _appModel . InputMedia == InputMediaType . LiveStream )
202+ {
203+ SetMediaSourceCommand . Execute ( InputMediaType . LiveStream ) ;
204+ }
205+ OnPropertyChanged ( ) ;
206+ }
207+ }
203208 // Command defintions
204209 public ICommand SaveCommand { get ; set ; }
205210 public ICommand SetMediaSourceCommand { get ; set ; }
206211 public ICommand ChangeLiveStreamCommand { get ; set ; }
207212 public ICommand SetModelSourceCommand { get ; set ; }
208213
214+ private async void _appModel_PropertyChanged ( object sender , PropertyChangedEventArgs e )
215+ {
216+ Debug . WriteLine ( e . PropertyName ) ;
217+ if ( e . PropertyName == "InputMedia"
218+ )
219+ {
220+ await SetMediaSource ( ) ;
221+ }
222+ }
223+
209224 public async void SaveOutput ( )
210225 {
211226 Debug . WriteLine ( "UIButtonSaveImage_Click" ) ;
@@ -215,9 +230,8 @@ public async void SaveOutput()
215230 }
216231 }
217232
218- public async Task SetMediaSource ( InputMediaType src )
233+ public async Task SetMediaSource ( )
219234 {
220- _appModel . InputMedia = src ;
221235 await LoadModelAsync ( ) ;
222236 await CleanupCameraAsync ( ) ;
223237 CleanupInputImage ( ) ;
0 commit comments