コード例 #1
0
        public CounterPage()
        {
            this.InitializeComponent();

            _pokerGame = new PokerGame();
            _pokerGame.CountDownUpdated += PokerEvent_CountDownUpdated;
            _pokerGame.BlindsUpdated += PokerEvent_BlindsUpdated;
            _pokerGame.MaxLevelReached += PokerEvent_MaxLevelReached;

            _isCounting = false;
        }
コード例 #2
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
        {
            if (pageState != null && pageState.ContainsKey(PokerGame))
            {
                _pokerGame = pageState[PokerGame] as PokerGame;
                _pokerGame.CountDownUpdated += PokerEvent_CountDownUpdated;
                _pokerGame.BlindsUpdated += PokerEvent_BlindsUpdated;

                var gameValues = _pokerGame.GetPokerGameValues();

                SetTimerCountDownText(gameValues.TimeLeft);
                SetBlindsText(gameValues.CurrentBigBlind, gameValues.NextBigBlind);
            }

            if (pageState != null && pageState.ContainsKey(IsCounting))
            {
                Boolean.TryParse(pageState[IsCounting].ToString(), out _isCounting);
                if (_isCounting)
                    PlayPokerGame();
            }

            if (pageState != null && pageState.ContainsKey(TimeLeft))
                txtTimerCountDown.Text = pageState[TimeLeft].ToString();

            if (pageState != null && pageState.ContainsKey(CurrentBlinds))
                txtBlinds.Text = pageState[CurrentBlinds].ToString();

            if (pageState != null && pageState.ContainsKey(NextBlinds))
                txtBlindsNext.Text = pageState[NextBlinds].ToString();
        }