public async Task ReturnContainerRev(ImgContainer container) { container.Cts?.Cancel(); CancellationTokenSource cts = new CancellationTokenSource(); container.Cts = cts; Containers.ForEach(c => c.CurrentIndex += 1); container.CurrentIndex = -numofBackwardContainer; container.InitPos(CurrentSlideDirection); ReleaseContainerImage(container); ImagePool.ShiftForwardIndex(-container.NumofImage); MapImageFileContextToContainer(container, true); MainWindow.Current.UpdatePageInfo(); await container.LoadImage(cts.Token); }
public async Task ReturnContainer(ImgContainer container) { // まだコンテナにTaskが残っているならキャンセル container.Cts?.Cancel(); // キャンセルトークン作成 CancellationTokenSource cts = new CancellationTokenSource(); container.Cts = cts; Containers.ForEach(c => c.CurrentIndex -= 1); container.CurrentIndex = numofForwardContainer; container.InitPos(CurrentSlideDirection); ReleaseContainerImage(container); ImagePool.ShiftBackwardIndex(container.NumofImage); MapImageFileContextToContainer(container, false); MainWindow.Current.UpdatePageInfo(); await container.LoadImage(cts.Token); }
public void ReleaseContainerImage(ImgContainer container) { foreach (var child in container.MainGrid.Children) { Image image = child as Image; if (image != null) { image.Source = null; } } container.ImageFileContextMapList.ForEach(context => { context.RefCount--; if (context.RefCount <= 0) { context.RefCount = 0; context.BitmapImage = null; } }); }
/* ---------------------------------------------------- */ // コンストラクタ /* ---------------------------------------------------- */ public ImgContainerAnimation(ImgContainer container) { this.container = container; }
public void MapImageFileContextToContainer(ImgContainer container, bool isBackward) { container.ImageFileContextMapList.Clear(); bool bReachToEnd = false; // 見開き用に一時変更されたコンテナだったら、標準に戻す if (TempProfile.DetectionOfSpread.Value != DetectionOfSpread.None && container.NumofGrid == 1 && TempProfile.NumofMatrix.Grid != 1) { container.InitGrid(TempProfile.NumofMatrix.Col, TempProfile.NumofMatrix.Row); container.SetImageElementToGrid(); container.InitBitmapDecodePixelOfTile(); } for (int i = 0; i < container.NumofGrid; i++) { // 自動見開き対応 if (TempProfile.DetectionOfSpread.Value != DetectionOfSpread.None && !bReachToEnd && TempProfile.NumofMatrix.Grid != 1) { if ((!isBackward && ImagePool.IsNextPickImageSpreaded(false)) || (isBackward && ImagePool.IsNextPickImageSpreaded(true))) // 見開きの検出 { if (i == 0) { // 見開きページとして表示 container.CombineAllGrid(); if (!isBackward) { container.ImageFileContextMapList.Add(ImagePool.PickForward()); } else { container.ImageFileContextMapList.Insert(0, ImagePool.PickBackward()); } return; } else { bReachToEnd = true; // 次のコンテナで見開きとして表示 } } } // 前方向 if (!isBackward) { if (bReachToEnd) { container.ImageFileContextMapList.Add(ImagePool.DummyImageContext); } else { container.ImageFileContextMapList.Add(ImagePool.PickForward()); } if (!bReachToEnd && ImagePool.ForwardIndex == 0) { bReachToEnd = true; } } // 巻き戻し方向 else { if (bReachToEnd) { container.ImageFileContextMapList.Insert(0, ImagePool.DummyImageContext); } else { container.ImageFileContextMapList.Insert(0, ImagePool.PickBackward()); } if (!bReachToEnd && ImagePool.BackwardIndex == ImagePool.ImageFileContextList.Count - 1) { bReachToEnd = true; } } } }