コード例 #1
0
        public BugSweeperPage()
        {
            InitializeComponent();

            board.GameStarted += (sender, args) =>
            {
                isGameInProgress = true;
                gameStartTime    = DateTime.Now;

                Xamarin.Insights.Track("GameStarted");

                handle = Xamarin.Insights.TrackTime("GameLength");
                handle.Start();

                Device.StartTimer(TimeSpan.FromSeconds(1), () =>
                {
                    timeLabel.Text = (DateTime.Now - gameStartTime).ToString(timeFormat);
                    return(isGameInProgress);
                });
            };

            board.GameEnded += (sender, hasWon) =>
            {
                isGameInProgress = false;

                handle.Stop();

                if (hasWon)
                {
                    DisplayWonAnimation();
                    Xamarin.Insights.Track("Won");
                }
                else
                {
                    DisplayLostAnimation();
                    Xamarin.Insights.Track("Lost");
                }
            };

            PrepareForNewGame();
        }
コード例 #2
0
        public BugSweeperPage()
        {
            InitializeComponent();

            board.GameStarted += (sender, args) =>
                {
                    isGameInProgress = true;
                    gameStartTime = DateTime.Now;

					Xamarin.Insights.Track("GameStarted");

					handle = Xamarin.Insights.TrackTime("GameLength");
					handle.Start();

                    Device.StartTimer(TimeSpan.FromSeconds(1), () =>
                    {
                        timeLabel.Text = (DateTime.Now - gameStartTime).ToString(timeFormat);
                        return isGameInProgress;
                    });
                };

            board.GameEnded += (sender, hasWon) =>
                {
                    isGameInProgress = false;
					
					handle.Stop();
                    
					if (hasWon)
                    {
                        DisplayWonAnimation();
						Xamarin.Insights.Track("Won");
                    }
                    else
                    {
                        DisplayLostAnimation();
						Xamarin.Insights.Track("Lost");
                    }
                };

            PrepareForNewGame();
        }
コード例 #3
0
 public void Start()
 {
     _handle.Start();
 }