private void insereOUN(String nome) { panelAlterar.Visible = false; pos++; try { Logica aux = (Logica)logicas[logica]; aux.insereOUN(nome, pos); Panel pnl = panelsAdded[logica]; if (leftAtual == 20) { #region peçaOUNs Button btn = new Button(); btn.Location = new Point(leftAtual, upAtual + 120); btn.Height = 120; btn.Width = 150; btn.Text = nome; btn.Image = imageList1.Images[6]; btn.TextImageRelation = TextImageRelation.TextAboveImage; btn.FlatStyle = FlatStyle.Flat; btn.Tag = pos; btn.Click += delegate { btnLadder(btn, pnl); }; pnl.Controls.Add(btn); buttonsAdded.Add(btn); btnLadder(btn, pnl); #endregion } else { #region peçaOUNm Button btn = new Button(); btn.Location = new Point(leftAtual, upAtual + 120); btn.Height = 120; btn.Width = 150; btn.Text = nome; btn.Image = imageList1.Images[7]; btn.TextImageRelation = TextImageRelation.TextAboveImage; btn.FlatStyle = FlatStyle.Flat; btn.Tag = pos; btn.AutoSize = true; btn.Click += delegate { btnLadder(btn, pnl); }; pnl.Controls.Add(btn); buttonsAdded.Add(btn); btnLadder(btn, pnl); #endregion #region linhasDeContinuidadeOUN int leftAux = leftAtual; while (leftAux >= 20) { leftAux -= 150; if (leftAux == 20) { Button btn1 = new Button(); btn1.Location = new Point(leftAux, upAtual); btn1.Height = 120; btn1.Width = 150; btn1.Text = " "; btn1.Image = imageList1.Images[9]; btn1.TextImageRelation = TextImageRelation.TextAboveImage; btn1.FlatStyle = FlatStyle.Flat; btn1.BackColor = Color.White; btn1.Tag = pos; btn1.AutoSize = true; pnl.Controls.Add(btn1); buttonsAdded.Add(btn1); } else { if (leftAux > 20) { Button btn1 = new Button(); btn1.Location = new Point(leftAux, upAtual); btn1.Height = 120; btn1.Width = 150; btn1.Text = " "; btn1.Image = imageList1.Images[10]; btn1.TextImageRelation = TextImageRelation.TextAboveImage; btn1.FlatStyle = FlatStyle.Flat; btn1.BackColor = Color.White; btn1.Tag = pos; btn1.AutoSize = true; pnl.Controls.Add(btn1); buttonsAdded.Add(btn1); } } #endregion } } txtNome.Text = ""; } catch { MessageBox.Show("Deve se iniciar com SEL ou SED"); } }