public BattleHistoryWindowViewModel() : base(BattleHistoryWindowModel.GetInstance()) { // チェックボックス紐づけ IsChkTrainerChecked = ModelConnector.BattleHistoryWindow.ToReactivePropertyAsSynchronized(m => m.IsWhereTrainerId); IsChkBattleResultChecked = ModelConnector.BattleHistoryWindow.ToReactivePropertyAsSynchronized(m => m.IsWhereBattleResultId); // コンボボックスにアイテム設定 ModelConnector.BattleHistoryWindow.Trainers.ForEach(e => CmbTrainer.Add(e)); ModelConnector.BattleHistoryWindow.BattleResults.ForEach(e => CmbBattleResult.Add(e)); ModelConnector.BattleHistoryWindow.BattleRecordNumberList.ForEach(e => CmbBattleRecordNumber.Add(e)); // コンボボックス初期選択 SelectedTrainer.Value = CmbTrainer[0]; SelectedBattleResult.Value = CmbBattleResult[0]; SelectedBattleRecordNumber.Value = CmbBattleRecordNumber[0]; // コンボボックス選択時の処理 SelectedTrainer.Subscribe(x => ModelConnector.BattleHistoryWindow.TrainerId = x.TrainerId); SelectedBattleResult.Subscribe(x => ModelConnector.BattleHistoryWindow.BattleResultId = x.Id); SelectedBattleRecordNumber.Subscribe(x => ModelConnector.BattleHistoryWindow.BattleRecordNumber = x); // ウィンドウクローズ IsShowWindow.Where(x => !x).Subscribe(_ => CloseWindowRequest.Raise(new Notification())); // コマンド SearchCommand = new DelegateCommand(SearchBattleRecord); }
public MainWindow() { InitializeComponent(); DataContext = ServiceLocator.Current.GetInstance <MainWindowViewModel>(); this.Subscribe <string>(args => { if (args == nameof(CloseWindowRequest.ShutdownRequest)) { closeWindowRequest = CloseWindowRequest.ShutdownRequest; Application.Current.Shutdown(); } }); this.Subscribe <Logic.Validations.AuthenticationResult>(args => { closeWindowRequest = CloseWindowRequest.LogOffRequest; Close(); }); }
private async Task TransferImageAsync(CancellationTokenSource tokenSource) { CancellationToken token = tokenSource.Token; var notification = _notification as ImagTransferingNotification; this.ProgressMaxValue.Value = notification.ConnectedIPAddressList.Count(); // 撮影コマンドを全ラズパイカメラへ送信する notification.SyncShooter.SendCommandToGetFullImageInJpeg(notification.LocalHostIP); this.ProgressValue.Value = 0; this.Information.Value = string.Empty; System.Threading.Thread.Sleep(1000); // waitをおかないと、この後すぐに返事を受け取れない場合がある await Task.Factory.StartNew(() => { int progressCount = 0; try { object o = new object(); notification.ConnectedIPAddressList.AsParallel().WithCancellation(token).ForAll(ipAddress => { //notification.ConnectedIPAddressList.ToList().ForEach( ipAddress => { // 画像を撮影&取得 //System.Diagnostics.Debug.WriteLine( ipAddress ); byte[] data = NewSyncShooter.NewSyncShooter.GetFullImageInJpeg(ipAddress, out int portNo); if ((data != null) && (data.Length > 0)) { // IP Address の第4オクテットのファイル名で保存する int idx = ipAddress.LastIndexOf('.'); int adrs4th = int.Parse(ipAddress.Substring(idx + 1)); String path = Path.Combine(notification.TargetDir, string.Format("{0}.jpg", adrs4th)); using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write)) { fs.Write(data, 0, data.Length); } lock ( o ) { this.Information.Value = string.Format("{0}:{1} received.", ipAddress, portNo); this.ProgressValue.Value = ++progressCount; } } }); } catch (OperationCanceledException ex) { System.Diagnostics.Debug.WriteLine(ex.Message); _notification.Confirmed = false; } }); // メインスレッドに処理を戻して、ウインドウを閉じる処理を実行する _mainContext.Post(_ => CloseWindowRequest.Raise(null), null); _notification.Confirmed = true; }
private void CloseWindow(object isChangePokemonId) { ModelConnector.PokemonSearchWindow.IsChangePokemonId = ObjectConverter.ToBoolean(isChangePokemonId); CloseWindowRequest.Raise(new Notification()); }