void Resultado(object sender, EventArgs e) { List <Button> boton2vars = new List <Button>(); List <Button> boton3vars = new List <Button>(); List <Button> boton4vars = new List <Button>(); foreach (var a in panel2variables.Controls) { Button n = (Button)a; boton2vars.Add(n); } foreach (var a in panel3variables.Controls) { Button n = (Button)a; boton3vars.Add(n); } foreach (var a in panel4Variables.Controls) { Button n = (Button)a; boton4vars.Add(n); } // 2 vars se queda igual boton3vars.Reverse(); boton4vars.Reverse(); comb = Convert.ToInt32(Math.Pow(2, cantVars)); oNSet.Clear(); for (int i = 0; i < comb; i++) { if (cantVars == 2) { if (Convert.ToInt32(boton2vars.ElementAt(i).Text) == 1) { oNSet.Add(long.Parse(i.ToString())); } } if (cantVars == 3) { if (Convert.ToInt32(boton3vars.ElementAt(i).Text) == 1) { oNSet.Add(long.Parse(i.ToString())); } } if (cantVars == 4) { if (Convert.ToInt32(boton4vars.ElementAt(i).Text) == 1) { oNSet.Add(long.Parse(i.ToString())); } } } if (oNSet.Count == 0) { textBox1.Visible = false; } else { textBox1.Visible = true; var kMap = new KMap(cantVars, oNSet, new HashSet <long>() { }); result = kMap.PrintCoverages(true); if (cantVars == 2 && oNSet.Count() == 4) { textBox1.Text = "1"; } else if (cantVars == 3 && oNSet.Count() == 8) { textBox1.Text = "1"; } else if (cantVars == 4 && oNSet.Count() == 16) { textBox1.Text = "1"; } else { textBox1.Text = result.Item2; if (textBox1.Width >= 261) { textBox1.Text += "\n"; } } } }
private void BTNresultado_Click(object sender, EventArgs e) { StyleMap(); // Map map = new Map(cantVars, TBXFunction.Text, GridValues, mapValues); comb = 0; table = new TruthTable(cantVars, TBXFunction.Text); table.Table = DGVTable; table.InsertValues(); map = new Map(table); map.DataMap = DGVMap; if (table.verif == true) { MessageBox.Show("Introduzca una funcion valida", "ERROR"); } else { Random Aleatorios = new Random(); Aleatorios = new Random(); int Red = Aleatorios.Next(250); int Blue = Aleatorios.Next(250); int Green = Aleatorios.Next(250); Color c = Color.FromArgb(Red, Green, Blue); table.c = c; map.c = c; table.CreateTable(); table.ClearMinTerms(); table.SelectMinTerms(); comb = Convert.ToInt32(Math.Pow(2, cantVars)); oNSet.Clear(); for (int i = 0; i < comb; i++) { if (Convert.ToInt32(table.Vars.GetValue(i, cantVars)) == 1) { oNSet.Add(long.Parse(i.ToString())); } } if (oNSet.Count == 0) { lblResult.Visible = false; map.FillMap(); map.CreateMap(); map.ClearMap(); map.MapColor(); InitForm(1); } else { lblResult.Visible = true; var kMap = new KMap(cantVars, oNSet, new HashSet <long>() { }); result = kMap.PrintCoverages(true); if (cantVars == 2 && oNSet.Count() == 4) { lblResult.Text = "1"; } else if (cantVars == 3 && oNSet.Count() == 8) { lblResult.Text = "1"; } else if (cantVars == 4 && oNSet.Count() == 16) { lblResult.Text = "1"; } else { lblResult.Text = result.Item2; } map.FillMap(); map.CreateMap(); map.ClearMap(); map.MapColor(); InitForm(1); } } }