private void CustomerTimer_Tick(object sender, EventArgs e)
 {
     if (hidden1)
     {
         pnlNewCust.Width = pnlNewCust.Width + 10;
         if (pnlNewCust.Width >= panelWidth)
         {
             CustomerTimer.Stop();
             hidden1 = false;
             this.Refresh();
         }
         this.pnlNewCust.BringToFront();
     }
     else
     {
         pnlNewCust.Width = pnlNewCust.Width - 10;
         if (pnlNewCust.Width <= 0)
         {
             CustomerTimer.Stop();
             hidden1 = true;
             this.Refresh();
         }
     }
 }
Beispiel #2
0
        public MainViewModel(Window main_window, Panel panel_parent, MediaElement media_display, Panel controller_icon_parent, Panel root_grid)
        {
            GameDescription = new ReactiveProperty <string>().AddTo(this.Disposable);

            mediaDisplay      = new MediaDisplay(media_display);
            controllerDisplay = new ControllerDisplay(controller_icon_parent);

            //ここでパネル生成できなかった場合各種プロセスは動作させない
            try {
                new PanelCreator(new GameInfoJsonReader()).Launch(panel_parent);
            } catch (Exception e) {
                Logger.Inst.Log("I wanna stop my process bc GamePanels was didn't create.", LogLevel.Warning);
                return;
            }

            var panel_controller = new PanelController(panel_parent);
            var customer_timer   = new CustomerTimer();
            var mask_control     = new MaskControl(root_grid);

            main_window.Closed += (e, sender) => {
                customer_timer.Dispose();
            };
            //キー入力はViewにバインドされているので動作の定義だけする
            //エンター
            EnterKeyCommand.Subscribe(n => gameLaunchStream.OnNext(Unit.Default));
            //上下移動
            ListUpCommand.Subscribe(n => panelSlideStream.OnNext(1));
            ListDownCommand.Subscribe(n => panelSlideStream.OnNext(-1));
            //スキップ入力
            ListSkipUpCommand.Subscribe(n => panelSkipStream.OnNext(-1));
            ListSkipDownCommand.Subscribe(n => panelSkipStream.OnNext(1));
            //リセット
            TimerResetCommand.Subscribe(n => {
                customer_timer.Stop();
                panel_controller.Shuffle();
            });

            //リスト移動入力の定義
            panelSlideStream
            .Merge(GamePadObserver.Inst.InVerticalStickEvent.Sample(TimeSpan.FromMilliseconds(200)))
            .Where(n => !GameProcessControl.Inst.IsRunning)
            .Where(n => n != 0)
            .Subscribe(n => {
                if (n == 1)
                {
                    panel_controller.MoveUp();
                }
                else if (n == -1)
                {
                    panel_controller.MoveDown();
                }
            });

            //スキップ入力の定義
            panelSkipStream
            .Merge(GamePadObserver.Inst.InHorizontalStickEvent.Sample(TimeSpan.FromMilliseconds(150)))
            .Where(n => !GameProcessControl.Inst.IsRunning)
            .Where(n => n != 0)
            .Subscribe(n => { panel_controller.Skip(n); });

            //ゲーム起動入力の定義
            gameLaunchStream
            .Merge(GamePadObserver.Inst.OnEnterKeyDown.Where(n => n).Select(n => Unit.Default))
            .Merge(panel_controller.OnPanelClick)
            .Subscribe(n => {
                GameProcessControl.Inst.GameLaunch(panel_controller.GetCurrentPanelsInfo.MyGameInfo.BinPath, panel_controller.GetCurrentPanelsInfo.MyGameInfo.GameId.ToString());
            });

            //ゲーム起動時のイベント
            GameProcessControl.Inst.OnGameStart.Subscribe(n => {
                customer_timer.StartRequest();
                mask_control.Run();
                mediaDisplay.Pause();
            });

            //ゲーム終了時のイベント
            GameProcessControl.Inst.OnGameEnd.Subscribe(n => {
                mask_control.Remove();
                mediaDisplay.ReStart();
            });

            //一応起動時もシャッフル

            //PanelControllerの選択切り替えイベントを受け取る
            panel_controller.OnChangeSelected.Subscribe(ChangeSelectedDisplay);
            panel_controller.Shuffle();
        }