コード例 #1
0
ファイル: HighScore.xaml.cs プロジェクト: ttimt/fyp-mmu
        public HighScore(KinectSensorChooser kinectSensorChooser, int gameMode)
        {
            InitializeComponent();

            //	Set screen to center
            WindowStartupLocation = WindowStartupLocation.CenterScreen;

            //	Set values
            this.kinectSensorChooser = kinectSensorChooser;
            this.gameMode            = gameMode;

            //	Data binding
            var kinectRegionandSensorBinding = new Binding("Kinect")
            {
                Source = kinectSensorChooser
            };

            BindingOperations.SetBinding(kinectKinectRegion, KinectRegion.KinectSensorProperty, kinectRegionandSensorBinding);

            //	Set title
            if (gameMode == 0)
            {
                Title = "Survival Mode Highscore";
            }
            else if (gameMode == 1)
            {
                Title = "Time Attack Mode Highscore";
            }

            //	Set highscore text
            var textHeader = new Label
            {
                Content    = "Name\t\t\t\t\t\t\t\t\t" + "Score",
                FontWeight = FontWeights.Bold,
                FontSize   = 26
            };

            scrollContent.Children.Add(textHeader);

            ScoreRepository   sro = new ScoreRepository();
            PlayersRepository pro = new PlayersRepository();

            var highscore = sro.GetAllScore(gameMode);

            for (int i = highscore.Count - 1; i >= 0; i--)
            {
                List <PlayersRepository.PlayerDto> user = pro.GetPlayerWithId(highscore[i].PlayerScore);
                string name = "";
                if (user.Count == 1)
                {
                    name = user[0].Username;
                }

                var textBody = new Label
                {
                    FontSize = 26,
                    Content  = " " + name + "\t\t\t\t\t\t\t\t\t" + highscore[i].Value
                };
                scrollContent.Children.Add(textBody);
            }

            #region KinectRegion
            //	Setup Kinect region press target and event handlers
            KinectRegion.SetIsPressTarget(back, true);

            KinectRegion.AddHandPointerEnterHandler(back, HandPointerEnterEvent);
            KinectRegion.AddHandPointerLeaveHandler(back, HandPointerLeaveEvent);

            KinectRegion.AddHandPointerPressHandler(back, HandPointerPressEvent);
            KinectRegion.AddHandPointerPressReleaseHandler(back, HandPointerPressReleaseEvent);

            KinectRegion.AddHandPointerGotCaptureHandler(back, HandPointerCaptureEvent);
            KinectRegion.AddHandPointerLostCaptureHandler(back, HandPointerLostCaptureEvent);
            #endregion
        }