Exemple #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         if (!Input.Text.ToString().Contains("-"))
         {
             string temp = "";
             if (!Input.Text.Contains("."))
             {
                 temp = Instruments.IntChoice(Convert.ToInt32(comboBox1.SelectedItem),
                                              Convert.ToInt32(comboBox2.SelectedItem), Input.Text);
             }
             else if (Input.Text[0].ToString() == "0" & Input.Text[1].ToString() == ".")
             {
                 temp = Instruments.FractChoice(Convert.ToInt32(comboBox1.SelectedItem),
                                                Convert.ToInt32(comboBox2.SelectedItem), Input.Text);
             }
             else if (Input.Text[0].ToString() != "0" & Input.Text.Contains("."))
             {
                 temp = MixedSolution.MixedInput(Convert.ToInt32(comboBox1.SelectedItem),
                                                 Convert.ToInt32(comboBox2.SelectedItem), Input.Text);
             }
             Output.Text = temp;
             label4.Text = "Output base " + comboBox2.SelectedItem.ToString() + " value:";
         }
         else
         {
             MessageBox.Show("You can only use positive values");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error");
     }
 }
Exemple #2
0
        public static string MixedInput(int from, int to, string input)
        {
            string[] twoPartsOfInputRepository = input.Split(new char[] { ',', '.' });
            string   left, right;

            left  = Instruments.IntChoice(from, to, twoPartsOfInputRepository[0]) + ".";
            right = Instruments.FractChoice(from, to, ("0." + twoPartsOfInputRepository[1]));
            for (int i = 2; i < right.Length; i++)
            {
                left += right[i].ToString();
            }
            return(left);
        }