Exemple #1
0
        private void AddNewScorePanel()
        {
            var addNewScorelabel1 = new TextBlock()
            {
                Text  = "Enter leaderboard code:",
                Width = 200,
            };
            var addNewScoreCodeText1 = new TextBox()
            {
                Text   = string.Empty,
                Height = 60,
                Width  = _buttonWidth,
                Margin = new Thickness(_spaceControl, 0, 0, 0)
            };

            var addNewScorelabel2 = new TextBlock()
            {
                Text  = "Enter new score:",
                Width = 200,
            };
            var addNewScoreCodeText2 = new TextBox()
            {
                Text   = string.Empty,
                Height = 60,
                Width  = _buttonWidth,
                Margin = new Thickness(_spaceControl, 0, 0, 0)
            };

            var sp5 = new StackPanel
            {
                Orientation = Orientation.Horizontal,
                Margin      = new Thickness(100, _topMargin + 5, 0, 0),
            };

            sp5.Add(addNewScorelabel1);
            sp5.Add(addNewScoreCodeText1);

            _topMargin += 70;

            var sp6 = new StackPanel
            {
                Orientation = Orientation.Horizontal,
                Margin      = new Thickness(100, _topMargin + 5, 0, 0),
            };

            sp6.Add(addNewScorelabel2);
            sp6.Add(addNewScoreCodeText2);

            EntityManager.Add(sp5);
            EntityManager.Add(sp6);

            // Add new score
            var addNewScoreCodeButton = new Button()
            {
                Width           = _buttonWidth,
                Height          = _buttonHeight,
                Text            = "Add new Score",
                Foreground      = _foregroundButton,
                BackgroundColor = _backgroundColor,
                Margin          = new Thickness(_topMargin + _spaceControl + 15, 580, 0, 0)
            };

            addNewScoreCodeButton.Click += (s, e) =>
            {
                var code  = addNewScoreCodeText1.Text;
                var score = addNewScoreCodeText2.Text;

                if (string.IsNullOrEmpty(code) || string.IsNullOrEmpty(score))
                {
                    return;
                }

                var longScore = long.Parse(score);

                _socialService.AddNewScore(code, longScore);
            };

            EntityManager.Add(addNewScoreCodeButton);
        }