private String GetBuildRow(Panel p, int index) { String cardName = "colony"; int count = 0; foreach (Control c in p.Controls) { BuildComboBox b = c as BuildComboBox; if (b != null && b.index == index) { cardName = parentWindow.supply[b.SelectedIndex].c.name; } QuantityTextBox t = c as QuantityTextBox; if (t != null && t.index == index) { try { count = Convert.ToInt32(t.Text); } catch (Exception) { } } } return(cardName + "@" + count.ToString()); }
public void UpdateBuildLists() { this.SuspendLayout(); for (int playerIndex = 0; playerIndex < 2; playerIndex++) { Panel p = panelPlayer1; if (playerIndex == 1) { p = panelPlayer2; } p.SuspendLayout(); p.Controls.Clear(); int y = 0; for (int buildIndex = 0; buildIndex < 13; buildIndex++) { BuildComboBox cardCombo = new BuildComboBox(buildIndex); foreach (SupplyEntry s in parentWindow.supply) { cardCombo.Items.Add(s.c); } cardCombo.Left = 0; cardCombo.Top = y; cardCombo.Width = p.Width - 60; cardCombo.DropDownStyle = ComboBoxStyle.DropDownList; cardCombo.Font = p.Font; cardCombo.Height = 21; cardCombo.SelectedIndexChanged += cardCombo_SelectedIndexChanged; p.Controls.Add(cardCombo); QuantityTextBox quantityText = new QuantityTextBox(buildIndex); quantityText.Left = p.Width - 50; quantityText.Top = y; quantityText.Width = 50; quantityText.Text = "0"; quantityText.Font = p.Font; quantityText.Height = 21; quantityText.TextChanged += quantityText_TextChanged; p.Controls.Add(quantityText); y += 31; } p.ResumeLayout(); } Player1Reset(); Player2Reset(); this.ResumeLayout(); }
void cardCombo_SelectedIndexChanged(object sender, EventArgs e) { BuildComboBox b = sender as BuildComboBox; if (b != null) { //if (b.Parent == panelPlayer1) comboPlayer1.SelectedIndex = 1; //if (b.Parent == panelPlayer2) comboPlayer2.SelectedIndex = 1; } }
void SetBuildRow(Panel p, int index, String card, int quantity) { foreach (Control c in p.Controls) { BuildComboBox b = c as BuildComboBox; if (b != null && b.index == index) { int supplyIndex = parentWindow.supply.FindIndex(delegate(SupplyEntry s) { return(s.c.name == card); }); if (supplyIndex == -1) { supplyIndex = 0; } b.SelectedIndex = supplyIndex; } QuantityTextBox t = c as QuantityTextBox; if (t != null && t.index == index) { t.Text = quantity.ToString(); } } }
public void UpdateBuildLists() { this.SuspendLayout(); for (int playerIndex = 0; playerIndex < 2; playerIndex++) { Panel p = panelPlayer1; if (playerIndex == 1) p = panelPlayer2; p.SuspendLayout(); p.Controls.Clear(); int y = 0; for (int buildIndex = 0; buildIndex < 13; buildIndex++) { BuildComboBox cardCombo = new BuildComboBox(buildIndex); foreach(SupplyEntry s in parentWindow.supply) { cardCombo.Items.Add(s.c); } cardCombo.Left = 0; cardCombo.Top = y; cardCombo.Width = p.Width - 60; cardCombo.DropDownStyle = ComboBoxStyle.DropDownList; cardCombo.Font = p.Font; cardCombo.Height = 21; cardCombo.SelectedIndexChanged += cardCombo_SelectedIndexChanged; p.Controls.Add(cardCombo); QuantityTextBox quantityText = new QuantityTextBox(buildIndex); quantityText.Left = p.Width - 50; quantityText.Top = y; quantityText.Width = 50; quantityText.Text = "0"; quantityText.Font = p.Font; quantityText.Height = 21; quantityText.TextChanged += quantityText_TextChanged; p.Controls.Add(quantityText); y += 31; } p.ResumeLayout(); } Player1Reset(); Player2Reset(); this.ResumeLayout(); }