Example #1
0
 private void insereOU(String nome)
 {
     panelAlterar.Visible = false;
     pos++;
     try
     {
         Logica aux = (Logica)logicas[logica];
         aux.insereOU(nome, pos);
         Panel pnl = panelsAdded[logica];
         if (leftAtual == 20)
         {
             #region peçaOUs
             Button btn = new Button();
             btn.Location          = new Point(leftAtual, upAtual + 120);
             btn.Height            = 120;
             btn.Width             = 150;
             btn.Text              = nome;
             btn.Image             = imageList1.Images[4];
             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çaOUm
             Button btn = new Button();
             btn.Location          = new Point(leftAtual, upAtual + 120);
             btn.Height            = 120;
             btn.Width             = 150;
             btn.Text              = nome;
             btn.Image             = imageList1.Images[5];
             btn.TextImageRelation = TextImageRelation.TextAboveImage;
             btn.FlatStyle         = FlatStyle.Flat;
             btn.BackColor         = Color.LightBlue;
             btn.Tag      = pos;
             btn.AutoSize = true;
             btn.Click   += delegate { btnLadder(btn, pnl); };
             pnl.Controls.Add(btn);
             buttonsAdded.Add(btn);
             btnLadder(btn, pnl);
             #endregion
             #region linhasDeContinuidadeOU
             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");
     }
 }