コード例 #1
0
        partial void ButtonRestart_TouchUpInside(UIButton sender)
        {
            LabelWinner.Text = "";
            //ButtonOne.TitleLabel.Text = "";
            ButtonOne.Enabled = true;
            ButtonOne.SetTitle("", UIControlState.Normal);
            string btnOne = ButtonOne.Title(UIControlState.Normal);

            //  ButtonTwo.TitleLabel.Text = "";
            ButtonTwo.Enabled = true;
            ButtonTwo.SetTitle("", UIControlState.Normal);
            string btnTwo = ButtonTwo.Title(UIControlState.Normal);

            // ButtonTwo.SetTitle("", UIControlState.Normal);
            // ButtonThree.TitleLabel.Text = "";
            ButtonThree.Enabled = true;
            ButtonThree.SetTitle("", UIControlState.Normal);
            string btnThree = ButtonThree.Title(UIControlState.Normal);

            //  ButtonThree.SetTitle("", UIControlState.Normal);

            // ButtonFour.TitleLabel.Text = "";
            ButtonFour.Enabled = true;
            ButtonFour.SetTitle("", UIControlState.Normal);
            string btnFour = ButtonFour.Title(UIControlState.Normal);

            // ButtonFour.SetTitle("", UIControlState.Normal);

            // ButtonFive.TitleLabel.Text = "";

            ButtonFive.SetTitle("", UIControlState.Normal);
            ButtonFive.Enabled = true;
            string btnFive = ButtonFive.Title(UIControlState.Normal);

            // ButtonSix.TitleLabel.Text = "";
            ButtonSix.Enabled = true;
            ButtonSix.SetTitle("", UIControlState.Normal);
            string btnSix = ButtonSix.Title(UIControlState.Normal);


            // ButtonSeven.TitleLabel.Text = "";
            ButtonSeven.Enabled = true;
            ButtonSeven.SetTitle("", UIControlState.Normal);
            string btnSeven = ButtonSeven.Title(UIControlState.Normal);

            //  ButtonEight.TitleLabel.Text = "";
            ButtonEight.Enabled = true;
            ButtonEight.SetTitle("", UIControlState.Normal);
            string btnEight = ButtonEight.Title(UIControlState.Normal);

            //  ButtonNine.TitleLabel.Text = "";
            ButtonNine.Enabled = true;
            ButtonNine.SetTitle("", UIControlState.Normal);
            string btnNine = ButtonNine.Title(UIControlState.Normal);

            counter = 0;
        }
コード例 #2
0
        public void checkit()
        {
            //Check if tie
            if (!ButtonOne.Title(UIControlState.Normal).Equals("") && !ButtonTwo.Title(UIControlState.Normal).Equals("") && !ButtonThree.Title(UIControlState.Normal).Equals("") &&
                !ButtonFour.Title(UIControlState.Normal).Equals("") && !ButtonFive.Title(UIControlState.Normal).Equals("") && !ButtonSix.Title(UIControlState.Normal).Equals("") &&
                !ButtonSeven.Title(UIControlState.Normal).Equals("") && !ButtonEight.Title(UIControlState.Normal).Equals("") && !ButtonNine.Title(UIControlState.Normal).Equals(""))
            {
                LabelWinner.Text = "Tie";
            }

            //Check diagonal for X
            if (!ButtonOne.Title(UIControlState.Normal).Equals("") || !ButtonFive.Title(UIControlState.Normal).Equals("") || !ButtonNine.Title(UIControlState.Normal).Equals(""))
            {
                if (ButtonOne.Title(UIControlState.Normal).Equals("X") && ButtonFive.Title(UIControlState.Normal).Equals("X") && ButtonNine.Title(UIControlState.Normal).Equals("X"))
                {
                    LabelWinner.Text    = "Player X wins";
                    ButtonOne.Enabled   = false;
                    ButtonTwo.Enabled   = false;
                    ButtonThree.Enabled = false;
                    ButtonFour.Enabled  = false;
                    ButtonFive.Enabled  = false;
                    ButtonSix.Enabled   = false;
                    ButtonSeven.Enabled = false;
                    ButtonEight.Enabled = false;
                    ButtonNine.Enabled  = false;
                }
            }
            if (!ButtonThree.Title(UIControlState.Normal).Equals("") || !ButtonFive.Title(UIControlState.Normal).Equals("") || !ButtonSeven.Title(UIControlState.Normal).Equals(""))
            {
                if (ButtonThree.Title(UIControlState.Normal).Equals("X") && ButtonFive.Title(UIControlState.Normal).Equals("X") && ButtonSeven.Title(UIControlState.Normal).Equals("X"))
                {
                    LabelWinner.Text    = "Player X wins";
                    ButtonOne.Enabled   = false;
                    ButtonTwo.Enabled   = false;
                    ButtonThree.Enabled = false;
                    ButtonFour.Enabled  = false;
                    ButtonFive.Enabled  = false;
                    ButtonSix.Enabled   = false;
                    ButtonSeven.Enabled = false;
                    ButtonEight.Enabled = false;
                    ButtonNine.Enabled  = false;
                }
            }
            //Check rows for X
            if (!ButtonOne.Title(UIControlState.Normal).Equals("") || !ButtonTwo.Title(UIControlState.Normal).Equals("") || !ButtonThree.Title(UIControlState.Normal).Equals(""))
            {
                if (ButtonOne.Title(UIControlState.Normal).Equals("X") && ButtonTwo.Title(UIControlState.Normal).Equals("X") && ButtonThree.Title(UIControlState.Normal).Equals("X"))
                {
                    LabelWinner.Text    = "Player X wins";
                    ButtonOne.Enabled   = false;
                    ButtonTwo.Enabled   = false;
                    ButtonThree.Enabled = false;
                    ButtonFour.Enabled  = false;
                    ButtonFive.Enabled  = false;
                    ButtonSix.Enabled   = false;
                    ButtonSeven.Enabled = false;
                    ButtonEight.Enabled = false;
                    ButtonNine.Enabled  = false;
                }
            }
            if (!ButtonFour.Title(UIControlState.Normal).Equals("") || !ButtonFive.Title(UIControlState.Normal).Equals("") || !ButtonSix.Title(UIControlState.Normal).Equals(""))
            {
                if (ButtonFour.Title(UIControlState.Normal).Equals("X") && ButtonFive.Title(UIControlState.Normal).Equals("X") && ButtonSix.Title(UIControlState.Normal).Equals("X"))
                {
                    LabelWinner.Text    = "Player X wins";
                    ButtonOne.Enabled   = false;
                    ButtonTwo.Enabled   = false;
                    ButtonThree.Enabled = false;
                    ButtonFour.Enabled  = false;
                    ButtonFive.Enabled  = false;
                    ButtonSix.Enabled   = false;
                    ButtonSeven.Enabled = false;
                    ButtonEight.Enabled = false;
                    ButtonNine.Enabled  = false;
                }
            }
            if (!ButtonSeven.Title(UIControlState.Normal).Equals("") || !ButtonEight.Title(UIControlState.Normal).Equals("") || !ButtonNine.Title(UIControlState.Normal).Equals(""))
            {
                if (ButtonSeven.Title(UIControlState.Normal).Equals("X") && ButtonEight.Title(UIControlState.Normal).Equals("X") && ButtonNine.Title(UIControlState.Normal).Equals("X"))
                {
                    LabelWinner.Text    = "Player X wins";
                    ButtonOne.Enabled   = false;
                    ButtonTwo.Enabled   = false;
                    ButtonThree.Enabled = false;
                    ButtonFour.Enabled  = false;
                    ButtonFive.Enabled  = false;
                    ButtonSix.Enabled   = false;
                    ButtonSeven.Enabled = false;
                    ButtonEight.Enabled = false;
                    ButtonNine.Enabled  = false;
                }
            }
            //Check columns for X
            if (!ButtonOne.Title(UIControlState.Normal).Equals("") || !ButtonFour.Title(UIControlState.Normal).Equals("") || !ButtonSeven.Title(UIControlState.Normal).Equals(""))
            {
                if (ButtonOne.Title(UIControlState.Normal).Equals("X") && ButtonFour.Title(UIControlState.Normal).Equals("X") && ButtonSeven.Title(UIControlState.Normal).Equals("X"))
                {
                    LabelWinner.Text    = "Player X wins";
                    ButtonOne.Enabled   = false;
                    ButtonTwo.Enabled   = false;
                    ButtonThree.Enabled = false;
                    ButtonFour.Enabled  = false;
                    ButtonFive.Enabled  = false;
                    ButtonSix.Enabled   = false;
                    ButtonSeven.Enabled = false;
                    ButtonEight.Enabled = false;
                    ButtonNine.Enabled  = false;
                }
            }
            if (!ButtonTwo.Title(UIControlState.Normal).Equals("") || !ButtonFive.Title(UIControlState.Normal).Equals("") || !ButtonEight.Title(UIControlState.Normal).Equals(""))
            {
                if (ButtonTwo.Title(UIControlState.Normal).Equals("X") && ButtonFive.Title(UIControlState.Normal).Equals("X") && ButtonEight.Title(UIControlState.Normal).Equals("X"))
                {
                    LabelWinner.Text    = "Player X wins";
                    ButtonOne.Enabled   = false;
                    ButtonTwo.Enabled   = false;
                    ButtonThree.Enabled = false;
                    ButtonFour.Enabled  = false;
                    ButtonFive.Enabled  = false;
                    ButtonSix.Enabled   = false;
                    ButtonSeven.Enabled = false;
                    ButtonEight.Enabled = false;
                    ButtonNine.Enabled  = false;
                }
            }
            if (!ButtonThree.Title(UIControlState.Normal).Equals("") || !ButtonSix.Title(UIControlState.Normal).Equals("") || !ButtonNine.Title(UIControlState.Normal).Equals(""))
            {
                if (ButtonThree.Title(UIControlState.Normal).Equals("X") && ButtonSix.Title(UIControlState.Normal).Equals("X") && ButtonNine.Title(UIControlState.Normal).Equals("X"))
                {
                    LabelWinner.Text    = "Player X wins";
                    ButtonOne.Enabled   = false;
                    ButtonTwo.Enabled   = false;
                    ButtonThree.Enabled = false;
                    ButtonFour.Enabled  = false;
                    ButtonFive.Enabled  = false;
                    ButtonSix.Enabled   = false;
                    ButtonSeven.Enabled = false;
                    ButtonEight.Enabled = false;
                    ButtonNine.Enabled  = false;
                }
            }
            //Check diagonal for O
            if (!ButtonOne.Title(UIControlState.Normal).Equals("") || !ButtonFive.Title(UIControlState.Normal).Equals("") || !ButtonNine.Title(UIControlState.Normal).Equals(""))
            {
                if (ButtonOne.Title(UIControlState.Normal).Equals("O") && ButtonFive.Title(UIControlState.Normal).Equals("O") && ButtonNine.Title(UIControlState.Normal).Equals("O"))
                {
                    LabelWinner.Text    = "Player O wins";
                    ButtonOne.Enabled   = false;
                    ButtonTwo.Enabled   = false;
                    ButtonThree.Enabled = false;
                    ButtonFour.Enabled  = false;
                    ButtonFive.Enabled  = false;
                    ButtonSix.Enabled   = false;
                    ButtonSeven.Enabled = false;
                    ButtonEight.Enabled = false;
                    ButtonNine.Enabled  = false;
                }
            }
            if (!ButtonThree.Title(UIControlState.Normal).Equals("") || !ButtonFive.Title(UIControlState.Normal).Equals("") || !ButtonSeven.Title(UIControlState.Normal).Equals(""))
            {
                if (ButtonThree.Title(UIControlState.Normal).Equals("O") && ButtonFive.Title(UIControlState.Normal).Equals("O") && ButtonSeven.Title(UIControlState.Normal).Equals("O"))
                {
                    LabelWinner.Text    = "Player O wins";
                    ButtonOne.Enabled   = false;
                    ButtonTwo.Enabled   = false;
                    ButtonThree.Enabled = false;
                    ButtonFour.Enabled  = false;
                    ButtonFive.Enabled  = false;
                    ButtonSix.Enabled   = false;
                    ButtonSeven.Enabled = false;
                    ButtonEight.Enabled = false;
                    ButtonNine.Enabled  = false;
                }
            }
            //Check rows for O
            if (!ButtonOne.Title(UIControlState.Normal).Equals("") || !ButtonTwo.Title(UIControlState.Normal).Equals("") || !ButtonThree.Title(UIControlState.Normal).Equals(""))
            {
                if (ButtonOne.Title(UIControlState.Normal).Equals("O") && ButtonTwo.Title(UIControlState.Normal).Equals("O") && ButtonThree.Title(UIControlState.Normal).Equals("O"))
                {
                    LabelWinner.Text    = "Player O wins";
                    ButtonOne.Enabled   = false;
                    ButtonTwo.Enabled   = false;
                    ButtonThree.Enabled = false;
                    ButtonFour.Enabled  = false;
                    ButtonFive.Enabled  = false;
                    ButtonSix.Enabled   = false;
                    ButtonSeven.Enabled = false;
                    ButtonEight.Enabled = false;
                    ButtonNine.Enabled  = false;
                }
            }
            if (!ButtonFour.Title(UIControlState.Normal).Equals("") || !ButtonFive.Title(UIControlState.Normal).Equals("") || !ButtonSix.Title(UIControlState.Normal).Equals(""))
            {
                if (ButtonFour.Title(UIControlState.Normal).Equals("O") && ButtonFive.Title(UIControlState.Normal).Equals("O") && ButtonSix.Title(UIControlState.Normal).Equals("O"))
                {
                    LabelWinner.Text    = "Player O wins";
                    ButtonOne.Enabled   = false;
                    ButtonTwo.Enabled   = false;
                    ButtonThree.Enabled = false;
                    ButtonFour.Enabled  = false;
                    ButtonFive.Enabled  = false;
                    ButtonSix.Enabled   = false;
                    ButtonSeven.Enabled = false;
                    ButtonEight.Enabled = false;
                    ButtonNine.Enabled  = false;
                }
            }
            if (!ButtonSeven.Title(UIControlState.Normal).Equals("") || !ButtonEight.Title(UIControlState.Normal).Equals("") || !ButtonNine.Title(UIControlState.Normal).Equals(""))
            {
                if (ButtonSeven.Title(UIControlState.Normal).Equals("O") && ButtonEight.Title(UIControlState.Normal).Equals("O") && ButtonNine.Title(UIControlState.Normal).Equals("O"))
                {
                    LabelWinner.Text    = "Player O wins";
                    ButtonOne.Enabled   = false;
                    ButtonTwo.Enabled   = false;
                    ButtonThree.Enabled = false;
                    ButtonFour.Enabled  = false;
                    ButtonFive.Enabled  = false;
                    ButtonSix.Enabled   = false;
                    ButtonSeven.Enabled = false;
                    ButtonEight.Enabled = false;
                    ButtonNine.Enabled  = false;
                }
            }
            //Check columns for O
            if (!ButtonOne.Title(UIControlState.Normal).Equals("") || !ButtonFour.Title(UIControlState.Normal).Equals("") || !ButtonSeven.Title(UIControlState.Normal).Equals(""))
            {
                if (ButtonOne.Title(UIControlState.Normal).Equals("O") && ButtonFour.Title(UIControlState.Normal).Equals("O") && ButtonSeven.Title(UIControlState.Normal).Equals("O"))
                {
                    LabelWinner.Text    = "Player O wins";
                    ButtonOne.Enabled   = false;
                    ButtonTwo.Enabled   = false;
                    ButtonThree.Enabled = false;
                    ButtonFour.Enabled  = false;
                    ButtonFive.Enabled  = false;
                    ButtonSix.Enabled   = false;
                    ButtonSeven.Enabled = false;
                    ButtonEight.Enabled = false;
                    ButtonNine.Enabled  = false;
                }
            }
            if (!ButtonTwo.Title(UIControlState.Normal).Equals("") || !ButtonFive.Title(UIControlState.Normal).Equals("") || !ButtonEight.Title(UIControlState.Normal).Equals(""))
            {
                if (ButtonTwo.Title(UIControlState.Normal).Equals("O") && ButtonFive.Title(UIControlState.Normal).Equals("O") && ButtonEight.Title(UIControlState.Normal).Equals("O"))
                {
                    LabelWinner.Text    = "Player O wins";
                    ButtonOne.Enabled   = false;
                    ButtonTwo.Enabled   = false;
                    ButtonThree.Enabled = false;
                    ButtonFour.Enabled  = false;
                    ButtonFive.Enabled  = false;
                    ButtonSix.Enabled   = false;
                    ButtonSeven.Enabled = false;
                    ButtonEight.Enabled = false;
                    ButtonNine.Enabled  = false;
                }
            }
            if (!ButtonThree.Title(UIControlState.Normal).Equals("") || !ButtonSix.Title(UIControlState.Normal).Equals("") || !ButtonNine.Title(UIControlState.Normal).Equals(""))
            {
                if (ButtonThree.Title(UIControlState.Normal).Equals("O") && ButtonSix.Title(UIControlState.Normal).Equals("O") && ButtonNine.Title(UIControlState.Normal).Equals("O"))
                {
                    LabelWinner.Text    = "Player O wins";
                    ButtonOne.Enabled   = false;
                    ButtonTwo.Enabled   = false;
                    ButtonThree.Enabled = false;
                    ButtonFour.Enabled  = false;
                    ButtonFive.Enabled  = false;
                    ButtonSix.Enabled   = false;
                    ButtonSeven.Enabled = false;
                    ButtonEight.Enabled = false;
                    ButtonNine.Enabled  = false;
                }
            }
        }