예제 #1
0
파일: Player.cs 프로젝트: arshbal18/Hangman
        private void btnAddPlayer_Click(object sender, EventArgs e)
        {
            // If the length of the text is more then 0.. do this..
            if (txtEnterPlayerName.Text.Length > 0)
            {
                // Set the new PlayerName to the text in the textfield
                HomeScreen.PlayerName = txtEnterPlayerName.Text.ToString();
                // Give them a score of 0 to begin with
                HomeScreen.score = 0;
                var cc = new DBConnection();
                // Insert the Players name and score into the database
                String res = cc.InsertNewPlayer(HomeScreen.PlayerName, HomeScreen.score);
                // Toast.MakeText(this, txtEnterPlayerName.Text.ToString()+" "+ res, ToastLength.Short).Show();
                // And update the list
                myList = cc.ViewAll();
                //Toast.MakeText(this, txtEnterPlayerName.Text.ToString() + " " +myList.Count, ToastLength.Short).Show();


                var da = new Resources.DBDA(this, myList);
                // And display the updated list on the spinner
                PlayerNameSpinner.Adapter = da;
            }
            // Display a message if there is an empty textfield
            else
            {
                Toast.MakeText(this, "Please enter at least 1 character for your name", ToastLength.Short).Show();
            }
        }
예제 #2
0
 protected override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     SetContentView(Resource.Layout.SelectPlayer);
     myConnection = new DBConnection();
     myList       = myConnection.ViewAll();
     AssignEvents();
 }
예제 #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.EditDB);
            myConnection = new DBConnection();
            myList       = myConnection.ViewAll();

            AssignButtons();
        }
예제 #4
0
        private void btnDeleteEntry_Click(object sender, EventArgs e)
        {
            var cc = new DBConnection();

            cc.DeletePlayer(HomeScreen.Id);
            myList = cc.ViewAll();


            var da = new Resources.DBDA(this, myList);

            spinnerEditDB.Adapter = da;
        }
예제 #5
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            //Sets up the DB connection
            myConnection = new DBConnection();
            //Runs the delete player method from the DBConnection class using the ID number from the Game class
            myConnection.DeletePlayer(Game.Id);
            myList = myConnection.ViewAll();
            var da = new DataAdapter(this, myList);

            spnEditDB.Adapter = da;
            Toast.MakeText(this, "Succesfully deleted", ToastLength.Long).Show();
        }
예제 #6
0
        private void ViewAllList()
        {
            Button HighScoresBackToMenu;
            List <HangmanScore> myList;
            DBConnection        myConnection;

            myConnection = new DBConnection();
            myList       = myConnection.ViewAll();
            //Assign the button click event
            HighScoresBackToMenu        = FindViewById <Button>(Resource.Id.btnHighScoresBacktoMenu);
            HighScoresBackToMenu.Click += HighScoresBackToMenu_Click;
            //Display the names and highscores
            DataAdapter myDataAdapter      = new DataAdapter(this, myList);
            ListView    HighScoresListView = FindViewById <ListView>(Resource.Id.HighScoresListView);

            HighScoresListView.Adapter = myDataAdapter;
        }
예제 #7
0
파일: Scores.cs 프로젝트: arshbal18/Hangman
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.Scores);

            myConnectionClass = new DBConnection();
            myList            = myConnectionClass.ViewAll();
            Button btnHighScoresBack = FindViewById <Button>
                                           (Resource.Id.btnHighScoresBack);

            btnHighScoresBack.Click += btnHighScoresBack_Click;

            // Display the player names and high scores
            ListView HighScoresListView = FindViewById <ListView>(Resource.Id.HighScoresListView);

            HighScoresListView.Adapter = new DBDA(this, myList);
        }
예제 #8
0
파일: Player.cs 프로젝트: arshbal18/Hangman
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.PlayerSelection);

            DBConnection myConnectionClass = new DBConnection();

            myList = myConnectionClass.ViewAll();

            PlayerNameSpinner = FindViewById <Spinner>(Resource.Id.selectPlayerSpinner);
            DBDA da = new Resources.DBDA(this, myList);

            PlayerNameSpinner.Adapter = da;

            PlayerNameSpinner.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(spinner_ItemSelected);

            txtEnterPlayerName = FindViewById <TextView>(Resource.Id.txtEnterName);

            Button btnStartGame = FindViewById <Button>(Resource.Id.btnStartGame);

            btnStartGame.Click += (object sender, EventArgs e) =>
            {
                btnStartGame_Click(sender, e);
            };


            Button btnAddPlayer = FindViewById <Button>(Resource.Id.btnAddProfile);

            btnAddPlayer.Click += (object sender, EventArgs e) =>
            {
                btnAddPlayer_Click(sender, e);
            };

            Button btnselectplayerMainMenu = FindViewById <Button>(Resource.Id.btnselectplayerMainMenu);

            btnselectplayerMainMenu.Click += (object sender, EventArgs e) =>
            {
                btnselectplayerMainMenu_Click(sender, e);
            };
        }
예제 #9
0
        //int Id;
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.MainDB);
            DBConnection myConnectionClass = new DBConnection();

            myList = myConnectionClass.ViewAll();

            btnEditDBMainMenu        = FindViewById <Button>(Resource.Id.btnEditDBMainMenu);
            btnEditDBMainMenu.Click += btnEditDBMainMenu_Click;
            spinnerEditDB            = FindViewById <Spinner>(Resource.Id.spinnereditDB);
            global::Hangman.Resources.DBDA da = new Resources.DBDA(this, myList);

            spinnerEditDB.Adapter = da;

            spinnerEditDB.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(spinnerEditDB_ItemSelected);

            btnDeleteEntry         = FindViewById <Button>(Resource.Id.btnDeleteEntry);
            btnDeleteEntry.Click  += btnDeleteEntry_Click;
            btnDeleteEntry.Enabled = false;
        }
예제 #10
0
 private void btnAddPlayer_Click(object sender, EventArgs e)
 {
     if (txtEnterPlayerName.Text.Length > 0)
     {
         //Set the player name to the textbox
         Game.PlayerName = txtEnterPlayerName.Text;
         //Start with a score of 0
         Game.Score   = 0;
         myConnection = new DBConnection();
         //Insert the player into the database using the InsertNewPlayer method and passing across the Game fields
         myConnection.InsertNewPlayer(Game.PlayerName, Game.Score, Game.DateTime);
         //Update the list and display on the spinner
         myList = myConnection.ViewAll();
         da     = new DataAdapter(this, myList);
         spnPlayerName.Adapter = da;
         Toast.MakeText(this, Game.PlayerName + " has been added", ToastLength.Short).Show();
     }
     else // If the text field is empty, display error message
     {
         Toast.MakeText(this, "Please enter at least 1 character for your name.", ToastLength.Short).Show();
     }
 }