예제 #1
0
    public void atualizarAutomato(string[] vetorEstados, string[] vetorSimbolos)
    {
        if (temTabela)
        {
            tabela.Destroy();
        }
        tabela             = new Table((uint)vetorEstados.Length, (uint)vetorSimbolos.Length, false);
        tabela.BorderWidth = 0;
        scrolledwindow1.Add(tabela);
        uint inc1 = 2;

        for (int i = 0; i < vetorSimbolos.Length; i++)
        {
            Label lbl2 = new Label(vetorSimbolos[i]);
            if (vetorSimbolos.Length == 1)
            {
                tabela.Attach(lbl2, 1, 3, 0, 1);
            }
            else
            {
                tabela.Attach(lbl2, (uint)i, inc1 + 1, 0, 1);
            }
            lbl2.Show();
            inc1++;
        }
        uint inc2 = 2;

        for (int i = 0; i < vetorEstados.Length; i++)
        {
            Label lbl3 = new Label(vetorEstados[i]);
            if (vetorEstados.Length == 1)
            {
                tabela.Attach(lbl3, 0, 2, 1, 3);
            }
            else
            {
                tabela.Attach(lbl3, 0, 1, (uint)i, inc2 + 1);
            }
            lbl3.Show();
            inc2++;
        }
        for (int i = 0; i < vetorSimbolos.Length; i++)
        {
            for (int j = 0; j < vetorEstados.Length; j++)
            {
                Entry txt = new Entry();
                txt.WidthChars = 5;
                if (vetorSimbolos.Length == 1 && vetorEstados.Length == 1)
                {
                    tabela.Attach(txt, 1, (uint)i + 3, 1, (uint)j + 3, AttachOptions.Expand, AttachOptions.Fill, 0, 0);
                }
                else if (vetorSimbolos.Length == 1)
                {
                    tabela.Attach(txt, 1, (uint)i + 3, (uint)j, (uint)j + 3, AttachOptions.Expand, AttachOptions.Fill, 0, 0);
                }
                else if (vetorEstados.Length == 1)
                {
                    tabela.Attach(txt, (uint)i, (uint)i + 3, 1, (uint)j + 3, AttachOptions.Expand, AttachOptions.Fill, 0, 0);
                }
                else
                {
                    tabela.Attach(txt, (uint)i, (uint)i + 3, (uint)j, (uint)j + 3, AttachOptions.Expand, AttachOptions.Fill, 0, 0);
                }
                txt.Show();
                ElementosAutomato elementos = new ElementosAutomato();
                elementos.estado1 = vetorEstados [j];
                elementos.estado2 = txt;
                elementos.simbolo = vetorSimbolos [i];
                entradas.Add(elementos);
            }
        }
        tabela.Show();
        temTabela = true;
    }
예제 #2
0
    public void abrirAutomato(List <string> vetorEstados1, List <string> vetorSimbolos, List <string[]> transicoes)
    {
        if (temTabela)
        {
            tabela.Destroy();
        }
        tabela             = new Table((uint)vetorEstados1.Count, (uint)vetorSimbolos.Count, false);
        tabela.BorderWidth = 0;
        scrolledwindow1.Add(tabela);
        uint inc1 = 2;

        for (int i = 0; i < vetorSimbolos.Count; i++)
        {
            Label lbl2 = new Label(vetorSimbolos[i]);
            if (vetorSimbolos.Count == 1)
            {
                tabela.Attach(lbl2, 1, 3, 0, 1);
            }
            else
            {
                tabela.Attach(lbl2, (uint)i, inc1 + 1, 0, 1);
            }
            lbl2.Show();
            inc1++;
        }
        uint inc2 = 2;

        for (int i = 0; i < vetorEstados1.Count; i++)
        {
            Label lbl3 = new Label(vetorEstados1[i]);
            if (vetorEstados1.Count == 1)
            {
                tabela.Attach(lbl3, 0, 2, 1, 3);
            }
            else
            {
                tabela.Attach(lbl3, 0, 1, (uint)i, inc2 + 1);
            }
            lbl3.Show();
            inc2++;
        }
        for (int i = 0; i < vetorSimbolos.Count; i++)
        {
            for (int j = 0; j < vetorEstados1.Count; j++)
            {
                Entry txt = new Entry();
                for (int k = 0; k < transicoes.Count; k++)
                {
                    if (vetorEstados1[j] == transicoes[k][0] && vetorSimbolos[i] == transicoes[k][1])
                    {
                        txt.Text = transicoes[k][2];
                    }
                }
                txt.WidthChars = 5;
                if (vetorSimbolos.Count == 1 && vetorEstados1.Count == 1)
                {
                    tabela.Attach(txt, 1, (uint)i + 3, 1, (uint)j + 3, AttachOptions.Expand, AttachOptions.Fill, 0, 0);
                }
                else if (vetorSimbolos.Count == 1)
                {
                    tabela.Attach(txt, 1, (uint)i + 3, (uint)j, (uint)j + 3, AttachOptions.Expand, AttachOptions.Fill, 0, 0);
                }
                else if (vetorEstados1.Count == 1)
                {
                    tabela.Attach(txt, (uint)i, (uint)i + 3, 1, (uint)j + 3, AttachOptions.Expand, AttachOptions.Fill, 0, 0);
                }
                else
                {
                    tabela.Attach(txt, (uint)i, (uint)i + 3, (uint)j, (uint)j + 3, AttachOptions.Expand, AttachOptions.Fill, 0, 0);
                }
                txt.Show();
                ElementosAutomato elementos = new ElementosAutomato();
                elementos.estado1 = vetorEstados1 [j];
                elementos.estado2 = txt;
                elementos.simbolo = vetorSimbolos [i];
                entradas.Add(elementos);
            }
        }
        tabela.Show();
        temTabela = true;
        vetorEstados1.Clear();
        vetorSimbolos.Clear();
        transicoes.Clear();
    }