private void btnAlterar_Click(object sender, EventArgs e) { try { Logica logicaAux = (Logica)logicas[logica]; ArrayList instAux = logicaAux.obterArrayList(); Instrucao inst = (Instrucao)instAux[pos]; txtNovoNome.Text = inst.obterNome(); txtNovoNome.SelectedText = null; rbn1.Visible = true; rbn2.Visible = true; label2.Visible = true; switch (inst.obterTipo()) { case "SEL": rbn1.Text = "SEL"; rbn2.Text = "SED"; rbn1.Select(); break; case "SED": rbn1.Text = "SEL"; rbn2.Text = "SED"; rbn2.Select(); break; case "E": rbn1.Text = "E"; rbn2.Text = "EN"; rbn1.Select(); break; case "EN": rbn1.Text = "E"; rbn2.Text = "EN"; rbn2.Select(); break; case "OU": rbn1.Text = "OU"; rbn2.Text = "OUN"; rbn1.Select(); break; case "OUN": rbn1.Text = "OU"; rbn2.Text = "OUN"; rbn2.Select(); break; case "MEMO": rbn1.Text = "MEMO"; rbn1.Visible = false; rbn2.Visible = false; label2.Visible = false; break; default: break; } panelAlterar.Visible = true; } catch { MessageBox.Show("Nada para alterar"); } }
public bool removerInstrucao(int pos) { instrucoes.Remove(instrucoes[pos]); bool flagLog = true; if (pos == 0) { if (instrucoes.Count != 0) { Instrucao inst = (Instrucao)instrucoes[pos]; String tipoAtual = inst.obterTipo(); if (tipoAtual == "E" || tipoAtual == "OU") { alterarInstrucao("SEL", inst.obterNome(), pos); } if (tipoAtual == "EN" || tipoAtual == "OUN") { alterarInstrucao("SED", inst.obterNome(), pos); } if (tipoAtual == "MEMO") { instrucoes.Remove(instrucoes[pos]); flagLog = false; } } else { flagLog = false; } } return(flagLog); }
public String obterML() { String codeML = ""; for (int i = 0; i < instrucoes.Count; i++) { Instrucao inst = (Instrucao)instrucoes[i]; String tipo = inst.obterTipo(); String nome = inst.obterNome(); codeML += tipo + "(" + nome + ")" + System.Environment.NewLine; } return(codeML); }
public void alterarInstrucao(String tipo, String novoNome, int pos) { Instrucao instAux = (Instrucao)instrucoes[pos]; instrucoes.Remove(instrucoes[pos]); switch (tipo) { case "SEL": insereSEL(novoNome, pos); break; case "SED": insereSED(novoNome, pos); break; case "E": insereE(novoNome, pos); break; case "EN": insereEN(novoNome, pos); break; case "OU": insereOU(novoNome, pos); break; case "OUN": insereOUN(novoNome, pos); break; case "MEMO": insereMEMO(novoNome, pos); break; default: break; } }
private void redraw() { int index = 0; upAtual = upIni; leftAtual = leftIni; List <String> logicaML = new List <String>(); limpaTela(); while (logicas.Count != 0) { Logica logicaAux = (Logica)logicas[0]; ArrayList instrucoes = logicaAux.obterArrayList(); logicaML.Add(""); for (int j = 0; j < instrucoes.Count; j++) { Instrucao instAux = (Instrucao)instrucoes[j]; logicaML[index] += instAux.obterTipo(); logicaML[index] += "("; logicaML[index] += instAux.obterNome(); logicaML[index] += ")"; logicaML[index] += System.Environment.NewLine; } logicas.Remove(logicas[0]); logica--; index++; } for (int i = 0; i < index; i++) { pos = 0; colarML(logicaML[i]); } for (int i = 0; i < buttonsAdded.Count; i++) { buttonsAdded[i].BackColor = Color.White; } }