/// <summary> /// loads the form and initialize data in it /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void frmSplendor_Load(object sender, EventArgs e) { lblGoldCoin.Text = "5"; lblDiamandCoin.Text = "7"; lblEmeraudeCoin.Text = "7"; lblOnyxCoin.Text = "7"; lblRubisCoin.Text = "7"; lblSaphirCoin.Text = "7"; conn = new ConnectionDB(); //load cards from the database //they are not hard coded any more //TO DO Card card11 = new Card(); card11.Level = 1; card11.PrestigePt = 1; card11.Cout = new int[] { 1, 0, 2, 0, 2 }; card11.Ress = Ressources.Rubis; Card card12 = new Card(); card12.Level = 1; card12.PrestigePt = 0; card12.Cout = new int[] { 0, 1, 2, 1, 0 }; card12.Ress = Ressources.Saphir; txtLevel11.Text = card11.ToString(); txtLevel12.Text = card12.ToString(); //load cards from the database Stack <Card> listCardOne = conn.GetListCardAccordingToLevel(1); //Go through the results //Don't forget to check when you are at the end of the stack //fin TO DO this.Width = 680; this.Height = 540; enableClicLabel = false; lblChoiceDiamand.Visible = false; lblChoiceOnyx.Visible = false; lblChoiceRubis.Visible = false; lblChoiceSaphir.Visible = false; lblChoiceEmeraude.Visible = false; cmdValidateChoice.Visible = false; cmdNextPlayer.Visible = false; //we wire the click on all cards to the same event //TO DO for all cards txtLevel11.Click += ClickOnCard; }
/// <summary> /// Loads the form and initialize data in it /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void frmSplendor_Load(object sender, EventArgs e) { //Stock ressources labels allRessourcesLbl = new List <Label>() { lblRubisCoin, lblEmeraudeCoin, lblOnyxCoin, lblSaphirCoin, lblDiamandCoin }; //Stock ressources labels of the player allRessourcesLblPlayer = new List <Label>() { lblPlayerRubisCoin, lblPlayerEmeraudeCoin, lblPlayerOnyxCoin, lblPlayerSaphirCoin, lblPlayerDiamandCoin }; //Activate ressources labels foreach (Label lblCoin in allRessourcesLbl) { lblCoin.Enabled = false; } //Puts coins values in labels for (int x = 0; x < allRessourcesLbl.Count; x++) { allRessourcesLbl[x].Text = availableCoins[x].ToString(); } //Add textbox to the grid according by levels gridCard.Add(new List <TextBox>() { txtLevel11, txtLevel12, txtLevel13, txtLevel14 }); gridCard.Add(new List <TextBox>() { txtLevel21, txtLevel22, txtLevel23, txtLevel24 }); gridCard.Add(new List <TextBox>() { txtLevel31, txtLevel32, txtLevel33, txtLevel34 }); gridCard.Add(new List <TextBox>() { txtNoble1, txtNoble2, txtNoble3, txtNoble4 }); //Add the click event to all cardtiles foreach (List <TextBox> txtBoxes in gridCard) { foreach (TextBox txtBox in txtBoxes) { txtBox.ReadOnly = true; txtBox.Click += ClickOnCard; //We wire the click on all cards to the same event } } //Load cards from the database List <Card> listCardOne = conn.GetListCardAccordingToLevel(1); List <Card> listCardTwo = conn.GetListCardAccordingToLevel(2); List <Card> listCardThree = conn.GetListCardAccordingToLevel(3); List <Card> listNoble = conn.GetListCardAccordingToLevel(4); //Add cards to the grid according by levels gridCardStock = new List <List <Card> >() { listCardOne, listCardTwo, listCardThree, listNoble }; for (int x = 0; x < gridCard.Count; x++) { for (int y = 0; y < gridCard[x].Count; y++) { var randomValue = rand.Next((gridCardStock[x].Count())); gridCard[x][y].Text = gridCardStock[x].ElementAt(randomValue).ToString(); gridCardStock[x].RemoveAt(randomValue); } } this.Width = 680; this.Height = 540; //Initialize a list with ressources labels allRessourcesLblChoice = new List <Label>() { lblChoiceRubis, lblChoiceEmeraude, lblChoiceOnyx, lblChoiceSaphir, lblChoiceDiamand }; //Make label be not visible foreach (Label lbl in allRessourcesLbl) { lbl.Visible = true; } cmdValidateChoice.Enabled = false; cmdNextPlayer.Enabled = false; }