PageRenderTime 57ms CodeModel.GetById 32ms RepoModel.GetById 0ms app.codeStats 0ms

/src/Squirrel.WiXUi/ViewModels/InstallingViewModel.cs

https://github.com/solrevdev/Squirrel.Windows
C# | 56 lines | 45 code | 11 blank | 0 comment | 1 complexity | 7f9903efc366d4ea347eaf7e68809ec2 MD5 | raw file
Possible License(s): Apache-2.0
  1. using System;
  2. using System.Reactive.Linq;
  3. using NuGet;
  4. using ReactiveUIMicro;
  5. using ReactiveUIMicro.Routing;
  6. using Squirrel.Client.WiXUi;
  7. using Squirrel.Core.Extensions;
  8. namespace Squirrel.WiXUi.ViewModels
  9. {
  10. public class InstallingViewModel : ReactiveObject, IInstallingViewModel
  11. {
  12. public string UrlPathSegment { get { return "installing"; } }
  13. public IScreen HostScreen { get; private set; }
  14. IPackage _PackageMetadata;
  15. public IPackage PackageMetadata {
  16. get { return _PackageMetadata; }
  17. set { this.RaiseAndSetIfChanged(x => x.PackageMetadata, value); }
  18. }
  19. ObservableAsPropertyHelper<string> _Title;
  20. public string Title {
  21. get { return _Title.Value; }
  22. }
  23. ObservableAsPropertyHelper<string> _Description;
  24. public string Description {
  25. get { return _Description.Value; }
  26. }
  27. public IObserver<int> ProgressValue { get; private set; }
  28. ObservableAsPropertyHelper<int> _LatestProgress;
  29. public int LatestProgress {
  30. get { return _LatestProgress.Value; }
  31. }
  32. public InstallingViewModel(IScreen hostScreen)
  33. {
  34. HostScreen = hostScreen;
  35. var progress = new ScheduledSubject<int>(RxApp.DeferredScheduler);
  36. ProgressValue = progress;
  37. progress.ToProperty(this, x => x.LatestProgress, 0);
  38. this.WhenAny(x => x.PackageMetadata, x => x.Value.ExtractTitle())
  39. .ToProperty(this, x => x.Title);
  40. this.WhenAny(x => x.PackageMetadata, v => v.Value)
  41. .Select(x => x != null ? x.Description : String.Empty)
  42. .ToProperty(this, x => x.Description);
  43. }
  44. }
  45. }