Exemple #1
0
        private void HandlePositiveButtonClick(object sender, DialogClickEventArgs e)
        {
            var dialog = (Android.Support.V7.App.AlertDialog)sender;

            nameEditText = (EditText)dialog.FindViewById(Resource.Id.enterPlayerName);
            string name = nameEditText.Text;

            if (string.IsNullOrEmpty(name))
            {
                //var error = GetDrawable(Resource.Drawable.baseline_error_black_18dp);
                //nameEditText.SetError("Enter a name", error);

                HelperFunctions.DartsToast(this, "Enter a name", ToastLength.Long).Show();
            }
            else if (SuggestedNames != null && SuggestedNames.Contains(name))
            {
                HelperFunctions.DartsToast(this, "Name already exists", ToastLength.Long).Show();
            }
            else
            {
                items.Add(name);
                nameAdapter         = new CustomListViewAdapter(this, items, Constants.ViewType.NameListItem);
                PlayerNames.Adapter = nameAdapter;
                if (PlayerNames.Count == 2)
                {
                    AddPlayer.Enabled = false;
                }
                StartGame.Enabled = true;
            }
        }
Exemple #2
0
        private void PlayerNames_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
        {
            items.Remove(items[e.Position]);
            nameAdapter         = new CustomListViewAdapter(this, items, Constants.ViewType.NameListItem);
            PlayerNames.Adapter = nameAdapter;

            if (PlayerNames.Count < 2)
            {
                AddPlayer.Enabled = true;
                StartGame.Enabled = false;
            }
        }
Exemple #3
0
        private void SuggestedNamesListView_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
        {
            string name = SuggestedNames[e.Position];

            items.Add(name);
            nameAdapter         = new CustomListViewAdapter(this, items, Constants.ViewType.NameListItem);
            PlayerNames.Adapter = nameAdapter;
            if (PlayerNames.Count == 2)
            {
                AddPlayer.Enabled = false;
                StartGame.Enabled = true;
            }

            nameDialog.Cancel();
        }
Exemple #4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.CreateGame);

            brandLogo            = FindViewById <ImageView>(Resource.Id.icon);
            brandLogo.Visibility = ViewStates.Invisible;


            // Initialize the settings menu
            SettingsMenu        = FindViewById <ImageButton>(Resource.Id.settingsButton);
            SettingsMenu.Click += SettingsMenu_Click;

            // Start the Game button
            StartGame         = FindViewById <Button>(Resource.Id.startGame);
            StartGame.Enabled = false;

            ResumeGame = FindViewById <Button>(Resource.Id.resumeGame);

            SuggestedNames = HelperFunctions.GetNames();

            previousPlayersHint = FindViewById <TextView>(Resource.Id.previousPlayersHint);


            // Initialize listView
            PlayerNames = FindViewById <ListView>(Resource.Id.playerNames);
            items       = new List <string> {
            };
            // Set up adapter
            nameAdapter         = new CustomListViewAdapter(this, items, Constants.ViewType.NameListItem);
            PlayerNames.Adapter = nameAdapter;

            PlayerNames.ItemClick += PlayerNames_ItemClick;

            // Get Player Name
            AddPlayer = FindViewById <Button>(Resource.Id.addPlayer);

            AddPlayer.Click += AddPlayer_Click;
            StartGame.Click += StartGame_Click;



            // Get Start Score
            Spinner selectStartScore = FindViewById <Spinner>(Resource.Id.startScoreSpinner);

            selectStartScore.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(spinner_ItemSelected);
            List <string> list1 = new List <string>();

            list1 = Resources.GetStringArray(Resource.Array.startScoreArray).ToList();
            selectStartScore.Adapter = new ArrayAdapter(this, Resource.Layout.spinnerItem, Resource.Id.itemText, list1);
            selectStartScore.SetSelection(5);

            // Get Number of legs
            Spinner legSpinner = FindViewById <Spinner>(Resource.Id.legsSpinner);

            legSpinner.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(legSpinner_ItemSelected);
            List <string> list2 = new List <string>();

            list2 = Resources.GetStringArray(Resource.Array.legsArray).ToList();
            legSpinner.Adapter = new ArrayAdapter(this, Resource.Layout.spinnerItem, Resource.Id.itemText, list2);
            legSpinner.SetSelection(4);

            gameData = HelperFunctions.CheckForPreviousGame();
            if (gameData.player1Name != "" && (Convert.ToInt32(gameData.player1Score) > 0 || Convert.ToInt32(gameData.player2Score) > 0))
            {
                ResumeGame.Visibility          = ViewStates.Visible;
                previousPlayersHint.Visibility = ViewStates.Visible;

                string hintText = "{0} {1} V {2} {3}";

                previousPlayersHint.Text = String.Format(hintText, gameData.player1Name, gameData.player1Score, gameData.player2Score, gameData.player2Name);
                ResumeGame.Click        += ResumeGame_Click;
            }
        }