public CompositeButton() { backgroundpanel = new Panel(); textlab = new ExtLabel(); textlab.AutoSize = false; textlab.TextAlign = System.Drawing.ContentAlignment.TopCenter; textlab.BackColor = Color.Transparent; backgroundpanel.Controls.Add(textlab); Controls.Add(backgroundpanel); }
// used to create a button dynamically public static CompositeButton QuickInit(Image backimage, string text, Font textfont, Color textfore, Color textbackgroundcol, Image decal, Size decalsize, Image[] buttons, Size buttonsize, int padtop, Action <object, int> ButtonPressed) { CompositeButton but = new CompositeButton(); but.Name = text; but.SuspendLayout(); but.BackgroundImage = backimage; but.BackgroundImageLayout = ImageLayout.Stretch; ExtLabel l = new ExtLabel(); l.Text = text; l.Font = textfont; l.ForeColor = textfore; l.Margin = new Padding(0); l.TextBackColor = l.BackColor = textbackgroundcol; but.Controls.Add(l); Panel d = new Panel(); d.BackgroundImage = decal; d.BackgroundImageLayout = ImageLayout.Stretch; d.BackColor = Color.Transparent; d.Size = decalsize; but.Controls.Add(d); int butno = 0; foreach (Image i in buttons) { ExtButton b = new ExtButton(); b.Image = i; b.ImageLayout = ImageLayout.Stretch; b.Size = buttonsize; b.Tag = butno++; b.Click += (o, e) => { ExtButton bhit = o as ExtButton; ButtonPressed?.Invoke(but, (int)bhit.Tag); }; but.Controls.Add(b); } but.Padding = new Padding(0, padtop, 0, 0); but.ResumeLayout(); return(but); }