private void btnPasarSm_Click(object sender, EventArgs e)
        {
            clConverter objConverter = new clConverter(numerosIngresados.Text);

            rBinarioSM.Text    = Regex.Replace(objConverter.SM(numerosIngresados.Text), "(.{4})(?!$)", "$0 ");
            rBinarioC1.Text    = Regex.Replace(objConverter.C1(numerosIngresados.Text), "(.{4})(?!$)", "$0 ");
            rBinarioC2.Text    = Regex.Replace(objConverter.C2(numerosIngresados.Text), "(.{4})(?!$)", "$0 ");
            rBinarioC1.Visible = true;
            rBinarioSM.Visible = true;
            rBinarioC2.Visible = true;
            unSM.Visible       = true;
            unC1.Visible       = true;
            unC2.Visible       = true;
        }
        private void numerosIngresados_TextChanged(object sender, EventArgs e)
        {
            clConverter objConverter = new clConverter(numerosIngresados.Text);

            try
            {
                if (rbBin.Checked == true)
                {
                    resulBinario.Text = numerosIngresados.Text;
                    resulOctal.Text   = objConverter.BinaryToOctal();
                    resulDecimal.Text = objConverter.BinaryToDecimal();
                    resulHexa.Text    = objConverter.BinaryToHexadecimal().ToUpper();
                }
                if (rbOctal.Checked == true)
                {
                    resulBinario.Text = objConverter.OctalToBinary();
                    resulOctal.Text   = numerosIngresados.Text;
                    resulDecimal.Text = objConverter.OctalToDecimal();
                    resulHexa.Text    = objConverter.OctalToHexadecimal().ToUpper();
                }
                if (rbDeci.Checked == true)
                {
                    resulBinario.Text = objConverter.DecimalToBinary();
                    resulOctal.Text   = objConverter.DecimalToOctal();
                    resulDecimal.Text = numerosIngresados.Text;
                    resulHexa.Text    = objConverter.DecimalToHexadecimal().ToUpper();
                }
                if (rbHex.Checked == true)
                {
                    resulBinario.Text = objConverter.HexadecimalToBinary();
                    resulOctal.Text   = objConverter.HexadecimalToOctal();
                    resulDecimal.Text = objConverter.HexadecimalToDecimal();
                    resulHexa.Text    = numerosIngresados.Text;
                }
                if (numerosIngresados.Text == "")
                {
                    numerosIngresados.Text = "0";
                }
            }
            catch
            {
            }
        }
 private void valorOperacion3()
 {
     if (rbHex.Checked == true)
     {
         valor2 = double.Parse(resulDecimal.Text);
     }
     else
     {
         clConverter objConverter = new clConverter(Math.Round(double.Parse(operacion3)).ToString());
         if (rbBin.Checked == true)
         {
             valor2 = double.Parse(objConverter.BinaryToDecimal());
         }
         if (rbOctal.Checked == true)
         {
             valor2 = double.Parse(objConverter.OctalToDecimal());
         }
         if (rbDeci.Checked == true)
         {
             valor2 = double.Parse(operacion3);
         }
     }
 }
 private void valorEntero1()
 {
     if (rbHex.Checked == true)
     {
         valor1 = double.Parse(resulDecimal.Text);
     }
     else
     {
         clConverter objConverter = new clConverter(Math.Round(double.Parse(numerosIngresados.Text)).ToString());
         if (rbBin.Checked == true)
         {
             valor1 = double.Parse(objConverter.BinaryToDecimal());
         }
         if (rbOctal.Checked == true)
         {
             valor1 = double.Parse(objConverter.OctalToDecimal());
         }
         if (rbDeci.Checked == true)
         {
             valor1 = double.Parse(numerosIngresados.Text);
         }
     }
 }
Example #5
0
        private void btnCalcuSM_Click(object sender, EventArgs e)
        {
            string A = tbASM.Text;
            string B = tbBSM.Text;

            string[]    guardados = new string[6];
            string      auxA, auxB;
            clConverter objConverter = new clConverter(A);

            guardados[0] = objConverter.C1(A);
            guardados[1] = objConverter.C1(B);
            rAC1.Text    = Regex.Replace(guardados[0], "(.{4})(?!$)", "$0 ");
            rBC1.Text    = Regex.Replace(guardados[1], "(.{4})(?!$)", "$0 ");
            claseOpera_SMC1C2 Operador = new claseOpera_SMC1C2(A, B);

            rABC1.Text = Regex.Replace(Operador.sumabinaria(guardados[0], guardados[1]), "(.{4})(?!$)", "$0 ");

            guardados[2] = objConverter.C2(A);
            guardados[3] = objConverter.C2(B);
            rAC2.Text    = guardados[2];
            rBC2.Text    = guardados[3];
            rABC2.Text   = Regex.Replace(Operador.sumabinaria(guardados[2], guardados[3]), "(.{4})(?!$)", "$0 ");

            guardados[4] = objConverter.SM(A);
            guardados[5] = objConverter.SM(B);
            rASM.Text    = guardados[4];
            rBSM.Text    = guardados[5];
            rABSM.Text   = Regex.Replace(Operador.sumabinaria(guardados[4], guardados[5]), "(.{4})(?!$)", "$0 ");

            /*Posiciones:
             * 0=AC1 , 1=BC1 , 2=AC2 , 3=BC2 , 4=ASM , 5=BSM
             */

            rAB_SMC1.Text = Regex.Replace(Operador.sumabinaria(guardados[4], guardados[1]), "(.{4})(?!$)", "$0 ");
            rBA_SMC1.Text = Regex.Replace(Operador.sumabinaria(guardados[5], guardados[0]), "(.{4})(?!$)", "$0 ");

            rAB_SMC2.Text = Regex.Replace(Operador.sumabinaria(guardados[4], guardados[3]), "(.{4})(?!$)", "$0 ");
            rBA_SMC2.Text = Regex.Replace(Operador.sumabinaria(guardados[5], guardados[2]), "(.{4})(?!$)", "$0 ");

            rAB_C1C2.Text = Regex.Replace(Operador.sumabinaria(guardados[0], guardados[3]), "(.{4})(?!$)", "$0 ");
            rBA_C1C2.Text = Regex.Replace(Operador.sumabinaria(guardados[1], guardados[2]), "(.{4})(?!$)", "$0 ");


            #region :Hacerlos visibles
            rAC1.Visible  = true;
            rBC1.Visible  = true;
            rABC1.Visible = true;

            rAC2.Visible  = true;
            rBC2.Visible  = true;
            rABC2.Visible = true;

            rASM.Visible  = true;
            rBSM.Visible  = true;
            rABSM.Visible = true;

            rAB_SMC1.Visible = true;
            rBA_SMC1.Visible = true;

            rAB_SMC2.Visible = true;
            rBA_SMC2.Visible = true;

            rAB_C1C2.Visible = true;
            rBA_C1C2.Visible = true;
            #endregion
            tbASM.Focus();
            tbASM.SelectAll();
        }
        private void operaciones(string simbolo)
        {
            if (simbolo == "+" || simbolo == "-" || simbolo == "=")
            {
                operacion = memoria.Text.Remove(memoria.Text.Length - (i + 1));
                try
                {
                    switch (operacion.Substring(operacion.Length - 1))
                    {
                    case "+":
                        total += valor1;
                        total  = Math.Round(total);
                        break;

                    case "-":
                        total -= valor1;
                        total  = Math.Round(total);
                        break;

                    case "*":
                        operacion = memoria.Text.Remove(memoria.Text.Length - j);
                        if (operacion.Substring(operacion.Length - 1) == "+")
                        {
                            total += aux;
                            total  = Math.Round(total);
                        }
                        else if (operacion.Substring(operacion.Length - 1) == "-")
                        {
                            total -= aux;
                            total  = Math.Round(total);
                        }
                        break;

                    case "/":
                        operacion = memoria.Text.Remove(memoria.Text.Length - j);
                        if (operacion.Substring(operacion.Length - 1) == "+")
                        {
                            total += aux;
                            total  = Math.Round(total);
                        }
                        else if (operacion.Substring(operacion.Length - 1) == "-")
                        {
                            total -= aux;
                            total  = Math.Round(total);
                        }
                        break;
                    }
                }
                catch
                {
                    total += valor1;
                    total  = Math.Round(total);
                }
            }
            else
            {
            }
            clConverter objConverter = new clConverter(Math.Round(total).ToString());

            if (rbBin.Checked == true)
            {
                numerosIngresados.Text = objConverter.DecimalToBinary();
            }
            if (rbOctal.Checked == true)
            {
                numerosIngresados.Text = objConverter.DecimalToOctal();
            }
            if (rbDeci.Checked == true)
            {
                numerosIngresados.Text = total.ToString();
            }
            if (rbHex.Checked == true)
            {
                numerosIngresados.Text = objConverter.DecimalToHexadecimal();
                numerosIngresados.Text = numerosIngresados.Text.ToUpper();
            }
        }