示例#1
0
        protected void deleteCard_Click(object sender, EventArgs e)
        {
            string splitText = categoryList.SelectedValue;

            string[] splitText1 = splitText.Split('-');
            populateCategoryTitles(splitText1[1], splitText1[2]);

            string splitTheText = cardList.SelectedValue;

            string[]   splitTheText1    = splitTheText.Split('-');
            CloudTable myCardCloudTable = GetTable("CardTable");
            // Create a retrieve operation that takes a category entity.
            TableOperation retrieveOperation = TableOperation.Retrieve <CardEntity>(splitText1[1] + splitText1[2], splitTheText1[1]);
            // Execute the operation.
            TableResult retrievedResult = myCardCloudTable.Execute(retrieveOperation);
            // Assign the result to a CardEntity object.
            CardEntity updateEntity = (CardEntity)retrievedResult.Result;



            CloudBlobContainer myBlobContainer = GetImagesBlobContainer();
            CloudBlockBlob     myBlobIdentity  = myBlobContainer.GetBlockBlobReference(splitText1[1] + splitText1[2] + "-" + splitTheText1[1]);

            myBlobIdentity.Delete();


            // Create the Replace TableOperation.
            TableOperation deleteOperation = TableOperation.Delete(updateEntity);

            // Execute the operation.
            myCardCloudTable.Execute(deleteOperation);

            // Clear the screen
            ClearTextBoxes();
            blobImage.Visible = false;
            cardList.Items.Clear();
            ListAllCards(splitText1[1] + splitText1[2]);
            Label13.Visible = true;
            Label13.Text    = "Card Deleted";
        }
        private string PopulateTheScreeen()
        {
            //Starts by retrieving session data for the category, player one's hand and player two's hand
            List <string> theCategory   = Session["gameCategory"] as List <string>;
            List <int>    playerOneHand = Session["playerOneHand"] as List <int>;
            List <int>    playerTwoHand = Session["playerTwoHand"] as List <int>;

            //Creates card entities to get azure table data for the first number in each player's hand
            CardEntity playerOneData = GetCardData(playerOneHand[0]);
            CardEntity playerTwoData = GetCardData(playerTwoHand[0]);

            //Then populates the page based on the data retrieved
            cardNamePlayerOne.Text    = Convert.ToString(playerOneData.Name);
            playerOneButtonOne.Text   = theCategory[1] + "  |  " + Convert.ToString(playerOneData.AttributeOne);
            playerOneButtonTwo.Text   = theCategory[2] + "  |  " + Convert.ToString(playerOneData.AttributeTwo);
            playerOneButtonThree.Text = theCategory[3] + "  |  " + Convert.ToString(playerOneData.AttributeThree);
            playerOneButtonFour.Text  = theCategory[4] + "  |  " + Convert.ToString(playerOneData.AttributeFour);
            playerOneButtonFive.Text  = theCategory[5] + "  |  " + Convert.ToString(playerOneData.AttributeFive);
            //Next converts PartitionKey and RowKey into one variable to correspond with a named blob.
            string imageOneID = Convert.ToString(playerOneData.PartitionKey) + "-" + Convert.ToString(playerOneData.RowKey);

            //Then calls the method to obtain the blob image and put it into the image holder
            PopulateBlob1(imageOneID);
            //Finally creates a list of the five attributed ready to compare against player Two.
            List <int> playerOneCard = new List <int> {
                Convert.ToInt16(playerOneData.AttributeOne), Convert.ToInt16(playerOneData.AttributeTwo), Convert.ToInt16(playerOneData.AttributeThree), Convert.ToInt16(playerOneData.AttributeFour), Convert.ToInt16(playerOneData.AttributeFive)
            };

            Session.Add("playerOneCard", playerOneCard);

            //Then does all the same again for player two's data.
            cardNamePlayerTwo.Text    = Convert.ToString(playerTwoData.Name);
            playerTwoButtonOne.Text   = theCategory[1] + "  |  " + Convert.ToString(playerTwoData.AttributeOne);
            playerTwoButtonTwo.Text   = theCategory[2] + "  |  " + Convert.ToString(playerTwoData.AttributeTwo);
            playerTwoButtonThree.Text = theCategory[3] + "  |  " + Convert.ToString(playerTwoData.AttributeThree);
            playerTwoButtonFour.Text  = theCategory[4] + "  |  " + Convert.ToString(playerTwoData.AttributeFour);
            playerTwoButtonFive.Text  = theCategory[5] + "  |  " + Convert.ToString(playerTwoData.AttributeFive);
            string imageTwoID = Convert.ToString(playerTwoData.PartitionKey) + "-" + Convert.ToString(playerTwoData.RowKey);

            PopulateBlob2(imageTwoID);
            List <int> playerTwoCard = new List <int> {
                Convert.ToInt16(playerTwoData.AttributeOne), Convert.ToInt16(playerTwoData.AttributeTwo), Convert.ToInt16(playerTwoData.AttributeThree), Convert.ToInt16(playerTwoData.AttributeFour), Convert.ToInt16(playerTwoData.AttributeFive)
            };

            Session.Add("playerTwoCard", playerTwoCard);


            //It then makes the non-player's cards invisible
            //First checking Player One
            string turn = Session["whoseTurn"] as string;

            if (turn == "playerOne")
            {
                Image2.Visible               = false;
                cardNamePlayerTwo.Visible    = false;
                playerTwoButtonOne.Visible   = false;
                playerTwoButtonTwo.Visible   = false;
                playerTwoButtonThree.Visible = false;
                playerTwoButtonFour.Visible  = false;
                playerTwoButtonFive.Visible  = false;
            }
            else
            {
            }
            //Then checking if it is Player Two
            if (turn == "playerTwo")
            {
                Image1.Visible               = false;
                cardNamePlayerOne.Visible    = false;
                playerOneButtonOne.Visible   = false;
                playerOneButtonTwo.Visible   = false;
                playerOneButtonThree.Visible = false;
                playerOneButtonFour.Visible  = false;
                playerOneButtonFive.Visible  = false;
            }
            else
            {
            }


            //It clears then updates the output box
            ListBox1.Items.Clear();
            ListBox2.Items.Clear();
            //This puts the 'cards' in each players hand into the listboxes, so we can check it is working
            foreach (int t in playerOneHand)
            {
                ListBox1.Items.Add(Convert.ToString(t));
            }

            foreach (int t in playerTwoHand)
            {
                ListBox2.Items.Add(Convert.ToString(t));
            }
            return(string.Empty);
        }