Example #1
0
        private void txtExpresion_Validating(object sender, CancelEventArgs e)
        {
            string[] symbols = txtSymbolsIN.Text.Split(';');
            string   Value   = txtExpresion.Text.Replace(";", "").Trim();

            foreach (var item in symbolsIn)
            {
                Value = Value.Replace(item.Symbol, "").Trim();
            }
            if (!string.IsNullOrEmpty(Value))
            {
                MessageBox.Show("Debe digitar una expresión con los simbolos de entrada", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }



            char[]   Valores  = txtExpresion.Text.Replace(";", "").Trim().ToCharArray();
            itemGrid itemGrid = new itemGrid();
            string   TipoVal  = string.Empty;

            for (int y = 0; y < Valores.Length; y++)
            {
                if (y == 0)
                {
                    TipoVal = VerificacionRecursiva(txtStatesBegin.Text.Replace(";", ""), Valores[y].ToString());
                }
                else
                {
                    TipoVal = VerificacionRecursiva(TipoVal, Valores[y].ToString());
                }
            }
            itemGrid = AFD.Where(afd => afd.State == TipoVal).FirstOrDefault();

            if (itemGrid.Result == 1)
            {
                MessageBox.Show("ACEPTA");
            }
            else
            {
                MessageBox.Show("RECHAZA");
            }
        }
Example #2
0
        private string VerificacionRecursiva(string State, string Value)
        {
            string   val      = string.Empty;
            itemGrid itemGrid = AFD.Where(inicio => inicio.State == State).FirstOrDefault();
            string   TipoVal  = string.Empty;

            TipoVal = symbolsIn.Where(s => s.Symbol == Value.ToString()).FirstOrDefault().Value;
            switch (TipoVal)
            {
            case "Value1":
                val = itemGrid.Value1;
                break;

            case "Value2":
                val = itemGrid.Value2;
                break;

            default:
                break;
            }
            return(val);
        }
Example #3
0
        private void Llenar(string value)
        {
            itemGrid ret        = new itemGrid();
            itemGrid comparador = AFD.Where(a => a.State == value).FirstOrDefault();

            if (comparador == null)
            {
                ret.State = value;
                if (ret.State != string.Empty)
                {
                    if (ret.State.Contains(txtAcceptations.Text.Trim()))
                    {
                        ret.Result = 1;
                    }
                }
                AFD.Add(ret);
                if (value.Contains(";"))
                {
                    string nval = string.Empty;
                    foreach (var item in value.Split(';'))
                    {
                        ret = transitions.Where(a => a.State == item).FirstOrDefault();
                        if (ret.Value1 != string.Empty)
                        {
                            nval += string.IsNullOrEmpty(nval) ? "" : ";";
                            nval += ret.Value1;
                        }
                    }
                    Llenar(nval);
                    nval = string.Empty;
                    foreach (var item in value.Split(';'))
                    {
                        ret = transitions.Where(a => a.State == item).FirstOrDefault();
                        if (ret.Value2 != string.Empty)
                        {
                            nval += string.IsNullOrEmpty(nval) ? "" : ";";
                            nval += ret.Value2;
                        }
                    }
                    Llenar(nval);
                    nval = string.Empty;
                    foreach (var item in value.Split(';'))
                    {
                        ret = transitions.Where(a => a.State == item).FirstOrDefault();
                        if (ret.Value3 != string.Empty)
                        {
                            nval += string.IsNullOrEmpty(nval) ? "" : ";";
                            nval += ret.Value3;
                        }
                    }
                    Llenar(nval);
                    nval = string.Empty;
                    foreach (var item in value.Split(';'))
                    {
                        ret = transitions.Where(a => a.State == item).FirstOrDefault();
                        if (ret.Value4 != string.Empty)
                        {
                            nval += string.IsNullOrEmpty(nval) ? "" : ";";
                            nval += ret.Value4;
                        }
                    }
                    Llenar(nval);
                }
                else
                {
                    ret = transitions.Where(a => a.State == value).FirstOrDefault();
                    if (ret != null)
                    {
                        Llenar(ret.Value1);
                        Llenar(ret.Value2);
                        Llenar(ret.Value3);
                        Llenar(ret.Value4);
                    }
                }
            }
        }