private void Animate_Click(object sender, EventArgs e)
 {
     if (animateclicked)
     {
         States.Enabled = Lineas.Enabled = delete.Enabled = clear.Enabled = minimiza.Enabled = true;
         animateclicked = panel1.Visible = false;
         timer.Stop();
         foreach (DictionaryEntry de in lineas)
         {
             Line l = (Line)de.Value;
             if (l.isActualLine)
                 l.isActualLine = false;
         }
         foreach (DictionaryEntry de in estados)
         {
             State s = (State)de.Value;
             if (s.isActualState)
                 s.isActualState = false;
         }
         textBox1.ReadOnly = false;
         textInput = "";
         afdDraw.Refresh();
     }
     else
     {
         if ( (textBox1.Text == "") || (estados.Count == 0) )
         {
             MessageBox.Show(this, "The input text must contain at least one character", "Input error");
         }
         else
         {
             t = new Trace(textBox1.Text);
             t.Show();
             lastActualLine = "";
             animateclicked = panel1.Visible =  true;
             charInString = 0;
             States.Enabled = Lineas.Enabled = delete.Enabled = clear.Enabled = minimiza.Enabled = false;
             textInput = textBox1.Text;
             foreach (DictionaryEntry de in estados)
             {
                 if (((State)de.Value).isInitial)
                 {
                     actualState = InitialState = ((State)de.Value).label;
                     break;
                 }
             }
             State actual = (State)estados[actualState];
             actual.isActualState = true;
             t.refresh(actual.label + " ");
             afdDraw.Refresh();
             textBox1.ReadOnly = true;
             timer.Start();
         }
     }
 }
 private void afnAnimate_Click(object sender, EventArgs e)
 {
     if (afnAnimateClicked)
     {
         afnAnimateClicked = false;
         afnEstados.Enabled = afnLineas.Enabled = afnBorrar.Enabled = afnLimpiar.Enabled = afnReset.Enabled = true;
         afnTimer.Stop();
         foreach (DictionaryEntry de in lineasAfn)
         {
             foreach (DictionaryEntry de2 in (Hashtable)de.Value)
             {
                 Line l = (Line)de2.Value;
                 if (l.isActualLine)
                     l.isActualLine = false;
             }
         }
         foreach (DictionaryEntry de in estadosAfn)
         {
             State s = (State)de.Value;
             if (s.isActualState)
                 s.isActualState = false;
         }
         textBox2.ReadOnly = panel5.Visible = false;
         afnTextInput = "";
         afnDraw.Refresh();
     }
     else
     {
         llenarAutomataAfn();
         afnAnimateClicked = true;
         afnlastActualLineKey = "";
         afnlastActualLineHtKey = "";
         panel5.Visible = true;
         afncharInString = 0;
         afnEstados.Enabled = afnLineas.Enabled = afnBorrar.Enabled = afnLimpiar.Enabled = afnReset.Enabled = false;
         afnTextInput = textBox2.Text;
         foreach (DictionaryEntry de in estadosAfn)
         {
             if (((State)de.Value).isInitial)
             {
                 afnactualState = afnInitialState = ((State)de.Value).label;
                 break;
             }
         }
         State actual = (State)estadosAfn[afnactualState];
         afnt = new Trace(afnTextInput);
         afnt.Show();
         afnt.refresh(afnactualState + " ");
         actual.isActualState = true;
         afnDraw.Refresh();
         textBox2.ReadOnly = true;
         afnTimer.Start();
     }
 }