/// <summary> /// The CreateCards method. /// Creates card buttons. /// </summary> /// <param name="pnlTable">The panel on the calling form the card buttons will be added to.</param> /// <param name="ShowProgress">The progress bar on the calling form.</param> /// <param name="Booster">Pack of cards.</param> private void CreateCards(Panel pnlTable, ToolStripProgressBar ShowProgress, Button LastButton, Pack Booster, ToolStripLabel DraftStatus) { for (int card = 1; card <= 15; card++) { ShowProgress.PerformStep(); //Show the progress #region Card Property Setup //The cards are buttons on the panel. Set the button properties to match the card properties. CardProperties CardProps = new CardProperties(); Button btnCard = new Button(); btnCard.Name = card.ToString(); btnCard.Width = CardProps.CardWidth; btnCard.Height = CardProps.CardHeight; btnCard.Click += Card_Click; btnCard.Text = card.ToString(); btnCard.BackColor = Color.Black; btnCard.Image = CardArt(); #endregion #region Set Card Position if (card == 1) { btnCard.Left = pnlTable.Left; btnCard.Top = pnlTable.Top; } else { btnCard.Left = LastButton.Right + 5; if (btnCard.Left > (pnlTable.Right - 5)) { btnCard.Left = pnlTable.Left; btnCard.Top = LastButton.Bottom + 5; } else { btnCard.Top = LastButton.Top; } } #endregion #region Add Card pnlTable.Controls.Add(btnCard); //Add the button to the panel. LastButton = btnCard; //Set the last button so we know where to begin on the next one. Booster.Cards.Add(btnCard); //Add the card to the opened booster. #endregion } }
/// <summary> /// The BoosterDraft_Load method. /// Method for form load. /// </summary> /// <param name="pnlTable">The panel on the calling form the card buttons will be added to.</param> /// <param name="sender">object sender</param> /// <param name="e">EventArgs</param> private void BoosterDraft_Load(object sender, EventArgs e) { #region Set Panel Size //Set the panel size to match the card width of a five card row. //Max of 3 rows as there can only be 15 cards. CardProperties CardProps = new CardProperties(); pnlTable.Width = ((CardProps.CardWidth * 5) + 25); pnlTable.Height = ((CardProps.CardHeight * 3 + 50)); #endregion #region Set Form Size //Set the form size relative to the panel size. this.Width = pnlTable.Width + 35; this.Height = pnlTable.Height + 135; #endregion tsbRandom.Visible = false; tslInstructions.Text = "Click New Draft to begin."; }