public TrainViewModel()

in WindowsSmartInk/SmartInkLaboratory/ViewModels/TrainViewModel.cs [150:217]


        public TrainViewModel(IImageService images, ITrainingService train, ITagService tagService, IAppStateService state)
        {
            _images = images;
            _train = train;
            _state = state;
            _tags = tagService;
            
            _state.TagChanged += async (s,e) => {
                if (_state.CurrentTag == null)
                    return;

                var iconfile = await GetIconFileAsync(_state.CurrentTag.Id);
                if (iconfile != null)
                    await LoadIconAsync(iconfile);
              
             };

            _state.IconChanged += async (s, e) => {
                var iconfile = await GetIconFileAsync(_state.CurrentTag.Id);
                if (iconfile != null)
                    await LoadIconAsync(iconfile);
            };

            _state.PackageChanged += async (s, e) => {
              
                if (_state.CurrentPackage == null)
                {
                    TotalImageCount = 0;
                    VisualStateChanged?.Invoke(this, new VisualStateEventArgs { NewState = "NoPackage" });
                    return;
                }
                var files = await CreateFileListAsync();
                TotalImageCount = files.Count;
                VisualStateChanged?.Invoke(this, new VisualStateEventArgs { NewState = "HasPackage" });
            };

            this.Upload = new RelayCommand(
                async() => {
                    VisualStateChanged?.Invoke(this, new VisualStateEventArgs { NewState = "Uploading" });
                    await UploadImagesAsync();
                    VisualStateChanged?.Invoke(this, new VisualStateEventArgs { NewState = "Waiting" });
                },
                ()=> { return TotalImageCount > 0; });
            this.Train = new RelayCommand(
                async () => {
                    TrainingStatus = "Training...";
                    VisualStateChanged?.Invoke(this, new VisualStateEventArgs { NewState = "Training" });
                    try
                    {
                        var iteration = await _train.TrainCurrentIterationAsync();
                        if (iteration != null)
                        {
                            VisualStateChanged?.Invoke(this, new VisualStateEventArgs { NewState = "TrainingFinished" });
                            _state.CurrentIteration = iteration;
                        }
                       
                    }
                    catch (TrainingServiceException ex)
                    {
                        TrainingStatus = $"ERROR! {ex.Response.Message}";
                         VisualStateChanged?.Invoke(this, new VisualStateEventArgs { NewState = "TrainingError" });
                    }
                },
                ()=> { return _uploadComplete || TotalImageCount == 0; 
                });

            _dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;
        }