System.Windows.DispatcherTimerによるタイマーの実装
Inheritance: ITimer
Ejemplo n.º 1
0
        /// <summary>このモデルを適用するウィンドウを指定し、モデルを初期化します。</summary>
        /// <param name="mainWindow">キャラ表示に使うウィンドウ</param>
        /// <param name="characterSelector">キャラ変更通知を行う何か</param>
        /// <param name="nadenade">撫で値の取得</param>
        private ModelCore(IMainWindow mainWindow, ICharacterSelector characterSelector, INadeable nadenade)
        {
            _nadenade = nadenade;

            _timer       = new MainTimer(TimerUpdateIntervalSec * 1000);
            _timer.Tick += OnTimerTick;

            Observable.FromEventPattern <CharacterSelectedEventArgs>(characterSelector, nameof(characterSelector.CharacterSelected))
            .Take(1)
            .Subscribe(e => OnChangeCharacter(e.EventArgs.CharacterName));

            _closeRequestObserving = Observable.FromEventPattern <EventArgs>(mainWindow, nameof(mainWindow.CloseRequested))
                                     .Take(1)
                                     .Subscribe(_ => OnCloseRequested());

            Observable.FromEventPattern <EventArgs>(mainWindow, nameof(mainWindow.Closing))
            .Take(1)
            .Subscribe(_ => OnClosing());
        }
Ejemplo n.º 2
0
        /// <summary>このモデルを適用するウィンドウを指定し、モデルを初期化します。</summary>
        /// <param name="mainWindow">キャラ表示に使うウィンドウ</param>
        /// <param name="characterSelector">キャラ変更通知を行う何か</param>
        /// <param name="nadenade">撫で値の取得</param>
        private ModelCore(IMainWindow mainWindow, ICharacterSelector characterSelector, INadeable nadenade)
        {
            _nadenade = nadenade;

            _timer = new MainTimer(TimerUpdateIntervalSec * 1000);
            _timer.Tick += OnTimerTick;

            Observable.FromEventPattern<CharacterSelectedEventArgs>(characterSelector, nameof(characterSelector.CharacterSelected))
                .Take(1)
                .Subscribe(e => OnChangeCharacter(e.EventArgs.CharacterName));

            _closeRequestObserving = Observable.FromEventPattern<EventArgs>(mainWindow, nameof(mainWindow.CloseRequested))
                .Take(1)
                .Subscribe(_ => OnCloseRequested());

            Observable.FromEventPattern<EventArgs>(mainWindow, nameof(mainWindow.Closing))
                .Take(1)
                .Subscribe(_ => OnClosing());
        }