private async void UpdateCurrent() {
var position = _currentPosition;
var path = _images[position] as string;
if (path != null) {
_images[position] = BetterImage.LoadBitmapSource(path, double.IsPositiveInfinity(MaxImageWidth) ? -1 : (int)MaxImageWidth);
}
if (position < _images.Length - 1) {
var next = position + 1;
var nextPath = _images[next] as string;
if (nextPath != null) {
var loaded = await BetterImage.LoadBitmapSourceAsync(nextPath, double.IsPositiveInfinity(MaxImageWidth) ? -1 : (int)MaxImageWidth);
var updated = _images[next];
if (updated as string != nextPath) return;
_images[next] = loaded;
}
}
if (position > 1) {
var next = position - 1;
var nextPath = _images[next] as string;
if (nextPath != null) {
var loaded = await BetterImage.LoadBitmapSourceAsync(nextPath, double.IsPositiveInfinity(MaxImageWidth) ? -1 : (int)MaxImageWidth);
var updated = _images[next];
if (updated as string != nextPath) return;
_images[next] = loaded;
}
}
for (var i = 0; i < position - 2; i++) {
_images[i] = _originalImages[i];
}
for (var i = position + 3; i < _images.Length; i++) {
_images[i] = _originalImages[i];
}
}