public async Task ChangeCurrentIndex(int index) { if (IsActiveSliding) { return; } StopSlideShow(true); ImagePool.InitIndex(index); ImagePool.InitImageFileContextRefCount(); InitContainerIndex(); InitContainerPos(); // マッピング MapImageFileContextToContainer(Containers[2], false); MapImageFileContextToContainer(Containers[3], false); MapImageFileContextToContainer(Containers[4], false); MapImageFileContextToContainer(Containers[1], true); MapImageFileContextToContainer(Containers[0], true); // ページ番号 MainWindow.Current.UpdatePageInfo(); // まだ読み込み中のTaskがあるならキャンセル Containers.ForEach(c => c.Cts?.Cancel()); // 画像のロード await semaphoreSlim.WaitAsync(); try { await LoadAllContainerImage(); } finally { semaphoreSlim.Release(); } // 使われていないBitmapImageの開放 ImagePool.ReleaseBitmapImageOutofRefarence(); }
public async Task InitAllContainer(int index) { StopSlideShow(true); // シークバー初期化 MainWindow.Current.InitSeekbar(); ImagePool.InitIndex(index); ImagePool.InitImageFileContextRefCount(); InitContainerIndex(); InitContainerSize(); InitContainerPos(); InitWrapPoint(CurrentSlideDirection); Containers.ForEach(c => c.ImageFileContextMapList.Clear()); InitContainerGrid(); InitBitmapDecodePixelOfTile(); SetImageElementToContainerGrid(); // 読み込めるファイルが無い場合 if (ImagePool.ImageFileContextList.Count < 1) { MainWindow.Current.UpdatePageInfo(); MainWindow.Current.UpdateMainWindowView(); return; } // 前方向マッピング MapImageFileContextToContainer(Containers[2], false); MapImageFileContextToContainer(Containers[3], false); MapImageFileContextToContainer(Containers[4], false); // 巻き戻し方向マッピング MapImageFileContextToContainer(Containers[1], true); MapImageFileContextToContainer(Containers[0], true); // メインウインドウ表示更新 MainWindow.Current.UpdateMainWindowView(); // ページ番号更新 MainWindow.Current.UpdatePageInfo(); // まだ読み込み中のTaskがあるならキャンセル Containers.ForEach(c => c.Cts?.Cancel()); // 画像のロード await semaphoreSlim.WaitAsync(); try { await LoadAllContainerImage(); await CorrectAllContainerBitmap(); } finally { semaphoreSlim.Release(); } // 使われていないBitmapImageの開放 ImagePool.ReleaseBitmapImageOutofRefarence(); // メインウインドウ表示更新 MainWindow.Current.UpdateMainWindowView(); }