private void Roll_Clicked(object sender, EventArgs e) { int Die = 0; int num = 0; string output = "Result "; foreach (Control ctl in Dice.Controls) { if (ctl.Name == "Die") { Int32.TryParse(ctl.Text, out Die); } if (ctl.Name == "NumberDice") { Int32.TryParse(ctl.Text, out num); } } if (Die > 0 & num > 0) { var result = DieRoller.Roll(Die, num); foreach (int z in result) { output += z + ", "; } MessageBox.Show(output); } }
private void Form1_Load(object sender, EventArgs e) { DieRoller roller = new DieRoller(); panel1.Visible = true; HumanPanel.Visible = false; ConstructPanel.Visible = false; AttributePanel.Visible = false; FlawsPanel.Visible = false; CareerPanel.Visible = false; AbilitesPanel.Visible = false; HumanPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink; ConstructPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink; AbilitesPanel.AutoSizeMode = AutoSizeMode.GrowOnly; Details.AttributesPanel = AttributePanel; Details.FlawsPanel = FlawsPanel; Details.CareerPanel = CareerPanel; Details.buttonGroups.Add(null); Details.buttonGroups.Add(null); Panel Dice = new Panel(); Dice.AutoSize = true; Dice.Location = new System.Drawing.Point(13, 150); Dice.Name = "Dice"; Dice.Size = new System.Drawing.Size(215, 318); Dice.TabIndex = 0; Dice.Text = "Dice"; panel1.Controls.Add(Dice); Dice.Visible = true; TextBox Die = new TextBox(); Die.Name = "Die"; Die.Location = new System.Drawing.Point(13, 13); TextBox NumberDice = new TextBox(); NumberDice.Name = "NumberDice"; NumberDice.Location = new System.Drawing.Point(13, 40); Dice.Controls.Add(Die); Dice.Controls.Add(NumberDice); roller.Create(Dice); }