public void AddRole(object sender, EventArgs e) { int i = castables.Count; this.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize)); this.ColumnCount++; this.SetColumn(buttonHolder, i + 1); this.SetColumnSpan(showNameText, i + 2); Castables c = new Castables("role " + i, i, 1, this.Height - showNameText.Height - 35, name); c.Top = showNameText.Bottom; c.Anchor = AnchorStyles.Left | AnchorStyles.Top; castables.Add(c); this.Controls.Add(castables[i], i, 1); }
public ShowControl(int number, Rectangle ClientRectangle, string showName = null, List <string> roles = null, List <List <string> > names = null) { castables = new List <Castables>(); this.roles = roles; this.name = showName; this.Width = ClientRectangle.Width - 20; this.Height = (ClientRectangle.Height / 5) - 10; this.MaximumSize = new Size(ClientRectangle.Width - 20, (ClientRectangle.Height / 5) - 10); this.Left = 10; this.Top = (number * ClientRectangle.Height) / 5; this.BorderStyle = BorderStyle.FixedSingle; this.BackColor = backColor; this.AutoScroll = false; this.VerticalScroll.Visible = false; this.AutoScroll = true; this.ColumnCount = 1; this.RowCount = 2; this.CellBorderStyle = TableLayoutPanelCellBorderStyle.None; this.Show(); showNameText = new TextBox(); this.Controls.Add(showNameText, 0, 0); showNameText.Text = showName == null ? "Show " + number : showName; showNameText.BackColor = backColor; showNameText.ForeColor = Color.OrangeRed; showNameText.BorderStyle = BorderStyle.None; showNameText.Width = ClientRectangle.Width / 2; showNameText.Left = 5; showNameText.Top = 5; showNameText.Font = new Font("sans-serif", 16); showNameText.TextChanged += ChangeName; showNameText.Show(); int roleCount; if (roles == null) { roles = new List <string>() { "Position 1" }; this.roles = roles; } if (names == null) { names = new List <List <string> >(); for (int i = 0; i < 5; i++) { names.Add(new List <string> { "Person 1", "Person 2", "Person 3" }); } } roleCount = roles.Count; this.ColumnCount = roleCount + 1; this.SetColumnSpan(showNameText, roleCount + 1); showNameText.Anchor = AnchorStyles.Left | AnchorStyles.Top; this.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize)); this.AutoSize = true; this.AutoSizeMode = AutoSizeMode.GrowAndShrink; for (int i = 0; i < roleCount; i++) { Castables c = new Castables(roles[i], i, 1, this.Height - showNameText.Height - 35, showName, names[i]); c.Anchor = AnchorStyles.Left | AnchorStyles.Top; castables.Add(c); this.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize)); this.Controls.Add(castables[i], i, 1); } newRole = new Button(); newRole.Text = "+"; newRole.Height = (this.Height - showNameText.Height) / 5; newRole.Width = newRole.Height; newRole.Top = 5; newRole.Left = 5; newRole.Click += AddRole; newRole.FlatStyle = FlatStyle.Flat; newRole.Font = new Font("sans-serif", 16); newRole.ForeColor = Color.OrangeRed; delRole = new Button(); delRole.Text = "-"; delRole.Height = (this.Height - showNameText.Height) / 5; delRole.Width = newRole.Height; delRole.Top = newRole.Bottom + 5; delRole.Left = 5; delRole.Click += DelRole; delRole.FlatStyle = FlatStyle.Flat; delRole.Font = new Font("sans-serif", 16); delRole.ForeColor = Color.OrangeRed; buttonHolder = new Panel(); this.BackColor = backColor; buttonHolder.Height = this.Height - showNameText.Height - 35; buttonHolder.Width = newRole.Width + 10; buttonHolder.Controls.Add(newRole); buttonHolder.Controls.Add(delRole); this.Controls.Add(buttonHolder, castables.Count, 1); this.AutoScroll = false; this.VerticalScroll.Visible = false; this.AutoScroll = true; }
public void Add(Castables c) { roles.Add(c.GetRole()); shows.Add(c.GetShow()); }