2019-11-03 06:01:19 +00:00
|
|
|
|
using ReactiveUI;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Reactive.Linq;
|
|
|
|
|
using System.Windows.Media.Imaging;
|
|
|
|
|
using Wabbajack.Common;
|
|
|
|
|
using Wabbajack.Lib;
|
|
|
|
|
using Wabbajack.Lib.Downloaders;
|
|
|
|
|
|
|
|
|
|
namespace Wabbajack
|
|
|
|
|
{
|
|
|
|
|
public class ModVM : ViewModel
|
|
|
|
|
{
|
2020-03-04 12:10:49 +00:00
|
|
|
|
public IMetaState State { get; }
|
2019-11-03 06:01:19 +00:00
|
|
|
|
|
|
|
|
|
// Image isn't exposed as a direct property, but as an observable.
|
|
|
|
|
// This acts as a caching mechanism, as interested parties will trigger it to be created,
|
|
|
|
|
// and the cached image will automatically be released when the last interested party is gone.
|
|
|
|
|
public IObservable<BitmapImage> ImageObservable { get; }
|
|
|
|
|
|
2020-03-04 12:10:49 +00:00
|
|
|
|
public ModVM(IMetaState state)
|
2019-11-03 06:01:19 +00:00
|
|
|
|
{
|
2020-03-04 12:10:49 +00:00
|
|
|
|
State = state;
|
|
|
|
|
|
2020-04-12 04:18:21 +00:00
|
|
|
|
ImageObservable = Observable.Return(State.ImageURL.ToString())
|
2019-11-03 06:01:19 +00:00
|
|
|
|
.ObserveOn(RxApp.TaskpoolScheduler)
|
2020-03-04 12:10:49 +00:00
|
|
|
|
.DownloadBitmapImage((ex) => Utils.Log($"Skipping slide for mod {State.Name}"))
|
2019-11-03 06:01:19 +00:00
|
|
|
|
.Replay(1)
|
2019-12-21 20:22:41 +00:00
|
|
|
|
.RefCount(TimeSpan.FromMilliseconds(5000));
|
2019-11-03 06:01:19 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|