Exemplo n.º 1
0
        public bool GerarTabelaLSR()
        {
            try
            {
                double lenght1 = ((gramatica.Terminais.Count + 1) * 100) / (gramatica.Terminais.Count + gramatica.NaoTerminais.Count + 1) + 0.4;
                double lenght2 = 100 - lenght1 - 0.4;

                UIUtil.AddColumns(gridHeader, lenght1, lenght2);
                UIUtil.AddColumns(gramatica.Terminais, gridAcao);
                gridAcao.ColumnDefinitions.Add(new ColumnDefinition());
                gridAcao.Children.Add(UIUtil.CreateTextBlock("$", 0, gramatica.Terminais.Count));
                UIUtil.AddColumns(gramatica.NaoTerminais, gridDesvio);

                for (int i = 1; i < tabelaLSR.Count; i++)
                {
                    var gridTemplate = new Grid();
                    UIUtil.AddColumns(gridTemplate, lenght1, lenght2);

                    var tbEstado     = UIUtil.CreateTextBlock((i - 1).ToString(), 0, 0);
                    var borderAcao   = UIUtil.CreateGrid(1);
                    var borderDesvio = UIUtil.CreateGrid(2);

                    UIUtil.AddColumns(tabelaLSR[i].GetRange(0, gramatica.Terminais.Count + 1), (Grid)borderAcao.Child, true);
                    UIUtil.AddColumns(tabelaLSR[i].GetRange(gramatica.Terminais.Count + 1, gramatica.NaoTerminais.Count), (Grid)borderDesvio.Child);

                    gridTemplate.Children.Add(tbEstado);
                    gridTemplate.Children.Add(borderAcao);
                    gridTemplate.Children.Add(borderDesvio);
                    stackPanelTabela.Children.Add(gridTemplate);
                }

                return(true);
            }
            catch (Exception)
            {
                System.Windows.MessageBox.Show("Arquivo Excel com formato incorreto", "Algo deu errado");
                return(false);
            }
        }