/ src / modules / imageresizer / ui / ViewModels / MainViewModel.cs
MainViewModel.cs
 1  #pragma warning disable IDE0073
 2  // Copyright (c) Brice Lambson
 3  // The Brice Lambson licenses this file to you under the MIT license.
 4  // See the LICENSE file in the project root for more information.  Code forked from Brice Lambson's https://github.com/bricelam/ImageResizer/
 5  #pragma warning restore IDE0073
 6  
 7  using System.Collections.Generic;
 8  using System.Windows.Input;
 9  
10  using ImageResizer.Helpers;
11  using ImageResizer.Models;
12  using ImageResizer.Properties;
13  using ImageResizer.Views;
14  
15  namespace ImageResizer.ViewModels
16  {
17      public class MainViewModel : Observable
18      {
19          private readonly Settings _settings;
20          private readonly ResizeBatch _batch;
21  
22          private object _currentPage;
23          private double _progress;
24  
25          public MainViewModel(ResizeBatch batch, Settings settings)
26          {
27              _batch = batch;
28              _settings = settings;
29              LoadCommand = new RelayCommand<IMainView>(Load);
30          }
31  
32          public ICommand LoadCommand { get; }
33  
34          public object CurrentPage
35          {
36              get => _currentPage;
37              set => Set(ref _currentPage, value);
38          }
39  
40          public double Progress
41          {
42              get => _progress;
43              set => Set(ref _progress, value);
44          }
45  
46          public void Load(IMainView view)
47          {
48              if (_batch.Files.Count == 0)
49              {
50                  _batch.Files.AddRange(view.OpenPictureFiles());
51              }
52  
53              CurrentPage = new InputViewModel(_settings, this, view, _batch);
54          }
55      }
56  }