// 選択画面を表示する private void ShowSelectGameWindow(List <Rectangle> rectList) { var dg = new SelectGameWindowAction(SelectGameWindow); var vm = new GameScreenSelectViewModel(rectList, dg); var view = new Views.GameScreenSelectView { DataContext = vm }; view.ShowDialog(); }
public GameScreenSelectViewModel(List <Rectangle> rectList, SelectGameWindowAction dg) { this.rectList = rectList; this.dg = dg; // プロパティを設定 PageInfoStr = RectIndex.Select(x => $"[{x + 1}/{rectList.Count}] {Utility.GetRectStr(rectList[x])}").ToReadOnlyReactiveProperty(); GameWindowPage = RectIndex.Select(x => (BitmapSource)ScreenShotProvider.GetScreenBitmap(rectList[x]).ToImageSource()).ToReadOnlyReactiveProperty(); // コマンドを設定 PrevPageCommand.Subscribe(_ => { RectIndex.Value = (rectList.Count + RectIndex.Value - 1) % rectList.Count; }); NextPageCommand.Subscribe(_ => { RectIndex.Value = (rectList.Count + RectIndex.Value + 1) % rectList.Count; }); SelectPageCommand.Subscribe(_ => { dg(rectList[RectIndex.Value]); CloseWindow.Value = true; }); CancelCommand.Subscribe(_ => { dg(null); CloseWindow.Value = true; }); }