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());
        }
Ejemplo n.º 3
0
        /// <summary>モデルを読み込み、メイン動作を開始します。</summary>
        public static ModelCore LoadAndStart(IMainWindow mainWindow, ICharacterSelector characterSelector, INadeable nadenade)
        {
            var modelCore = new ModelCore(mainWindow, characterSelector, nadenade);

            modelCore.Initialize(mainWindow);
            return(modelCore);
        }
Ejemplo n.º 4
0
 /// <summary>モデルを読み込み、メイン動作を開始します。</summary>
 public static ModelCore LoadAndStart(IMainWindow mainWindow, ICharacterSelector characterSelector, INadeable nadenade)
 {
     var modelCore = new ModelCore(mainWindow, characterSelector, nadenade);
     modelCore.Initialize(mainWindow);
     return modelCore;
 }