Exemplo n.º 1
0
        private void Maths(object sender, RoutedEventArgs e)
        {
            if (tx_output.Text != "")
            {
                LoadIn();

                if (op != "" && op != "x²" && op != "√x")
                {
                    Calc();
                    x = v;
                }

                if (Universal.error == false)
                {
                    op = ((Button)sender).Content.ToString();

                    if (op == "x²")
                    {
                        v = Math.Pow(x, 2);
                    }
                    else if (op == "√x" && x >= 0)
                    {
                        v = Math.Sqrt(x);
                    }
                    else
                    {
                        Universal.Error(5);
                    }
                }
                PrintOut();
            }
            Universal.error = false;
        }
Exemplo n.º 2
0
 private void Calc()
 {
     if (op == "+")
     {
         v += x;
     }
     else if (op == "-")
     {
         v -= x;
     }
     else if (op == "*")
     {
         v *= x;
     }
     else if (op == "/")
     {
         if (x == 0)
         {
             Universal.Error(2);
         }
         else
         {
             v /= x;
         }
     }
     else if (op == "xⁿ")
     {
         x = v;
         v = Math.Pow(x, y);
     }
 }
Exemplo n.º 3
0
        private void LoadIn()
        {
            try
            {
                if (from == 10)
                {
                    if (op != "xⁿ")
                    {
                        x = Convert.ToDouble(tx_output.Text);
                    }
                    else
                    {
                        y = Convert.ToDouble(tx_output.Text);
                    }
                }
                else
                {
                    if (op != "xⁿ")
                    {
                        x = Convert.ToDouble(Convert.ToString(Convert.ToInt32(tx_output.Text, from), 10));
                    }
                    else
                    {
                        y = Convert.ToDouble(Convert.ToString(Convert.ToInt32(tx_output.Text, from), 10));
                    }
                }

                tx_output.Text = "";
            }
            catch
            {
                Universal.Error(1);
            }
        }
Exemplo n.º 4
0
        private void Result(object sender, RoutedEventArgs e)
        {
            if (tx_side1.Text != "" && tx_side2.Text != "")
            {
                try
                {
                    s1            = Convert.ToDouble(tx_side1.Text);
                    s2            = Convert.ToDouble(tx_side2.Text);
                    tx_side3.Text = "";

                    if ((ci_a1.IsSelected == true && ci_b2.IsSelected == true) || (ci_b1.IsSelected == true && ci_a2.IsSelected == true))
                    {
                        v          = Math.Sqrt(s1 * s1 + s2 * s2);
                        tx_ch.Text = ":c";
                    }
                    else if ((ci_a1.IsSelected == true || ci_b1.IsSelected == true) && ci_c2.IsSelected == true)
                    {
                        v = Math.Sqrt(s2 * s2 - s1 * s1);
                        if (ci_a1.IsSelected == true)
                        {
                            tx_ch.Text = ":b";
                        }
                        else if (ci_b1.IsSelected == true)
                        {
                            tx_ch.Text = ":a";
                        }
                    }
                    else if (ci_c1.IsSelected == true && (ci_a2.IsSelected == true || ci_b2.IsSelected == true))
                    {
                        v = Math.Sqrt(s1 * s1 - s2 * s2);
                        if (ci_a2.IsSelected == true)
                        {
                            tx_ch.Text = ":b";
                        }
                        else if (ci_b2.IsSelected == true)
                        {
                            tx_ch.Text = ":a";
                        }
                    }
                    else
                    {
                        tx_ch.Text = "";
                        Universal.Error(3);
                    }

                    if (Universal.error == false)
                    {
                        tx_side3.Text = v.ToString();
                    }
                }
                catch
                {
                    Universal.Error(1);
                }
            }
            Universal.error = false;
        }
Exemplo n.º 5
0
 private void MemRead(object sender, RoutedEventArgs e)
 {
     if (Universal.memory[0] != "" && Universal.memory[1] == "10")
     {
         tx_input.Text = Universal.memory[0];
     }
     else
     {
         Universal.Error(4);
     }
 }
Exemplo n.º 6
0
 private void MemRead(object sender, RoutedEventArgs e)
 {
     if (Universal.memory[0] != "" && Universal.memory[1] == "10" && focus != "tx_side3")
     {
         ((TextBox)this.FindName(focus)).Text = Universal.memory[0];
     }
     else
     {
         Universal.Error(4);
     }
 }
Exemplo n.º 7
0
 private void MemRead(object sender, RoutedEventArgs e)
 {
     if (Universal.memory[0] != "" && Convert.ToInt16(Universal.memory[1]) == from)
     {
         tx_output.Text = Universal.memory[0];
     }
     else
     {
         Universal.Error(4);
     }
 }
Exemplo n.º 8
0
 private void PointerReleased(object sender, PointerRoutedEventArgs e)
 {
     try
     {
         from           = Convert.ToInt16(((ComboBoxItem)sender).Name.ToString().Remove(((ComboBoxItem)sender).Name.ToString().Length - 1, 3));
         tx_output.Text = from.ToString();
     }
     catch
     {
         Universal.Error(0);
     }
 }
Exemplo n.º 9
0
        private void Conversion(object sender, PointerRoutedEventArgs e)
        {
            if (((TextBlock)sender).Text == "DEC")
            {
                to = 10;
            }
            else if (((TextBlock)sender).Text == "BIN")
            {
                to = 2;
            }
            else if (((TextBlock)sender).Text == "OCT")
            {
                to = 8;
            }
            else if (((TextBlock)sender).Text == "HEX")
            {
                to = 16;
            }

            try
            {
                if (tx_output.Text != "")
                {
                    tx_output.Text = Convert.ToString(Convert.ToInt32(tx_output.Text, from), to);
                }

                if (((TextBlock)sender).Text == "DEC")
                {
                    tb_dec.Foreground = new SolidColorBrush(SmurfetBlue);
                }
                else
                {
                    tb_dec.Foreground = new SolidColorBrush(Colors.White);
                }

                if (((TextBlock)sender).Text == "BIN")
                {
                    tb_bin.Foreground = new SolidColorBrush(SmurfetBlue);
                }
                else
                {
                    tb_bin.Foreground = new SolidColorBrush(Colors.White);
                }

                if (((TextBlock)sender).Text == "OCT")
                {
                    tb_oct.Foreground = new SolidColorBrush(SmurfetBlue);
                }
                else
                {
                    tb_oct.Foreground = new SolidColorBrush(Colors.White);
                }

                if (((TextBlock)sender).Text == "HEX")
                {
                    tb_hex.Foreground = new SolidColorBrush(SmurfetBlue);
                }
                else
                {
                    tb_hex.Foreground = new SolidColorBrush(Colors.White);
                }

                if (to == 10)
                {
                    bt_comma.IsEnabled = true;
                }
                else
                {
                    bt_comma.IsEnabled = false;
                }

                if (to == 10 || to == 8 || to == 16)
                {
                    bt_2.IsEnabled = true;
                    bt_3.IsEnabled = true;
                    bt_4.IsEnabled = true;
                    bt_5.IsEnabled = true;
                    bt_6.IsEnabled = true;
                    bt_7.IsEnabled = true;
                }
                else
                {
                    bt_2.IsEnabled = false;
                    bt_3.IsEnabled = false;
                    bt_4.IsEnabled = false;
                    bt_5.IsEnabled = false;
                    bt_6.IsEnabled = false;
                    bt_7.IsEnabled = false;
                }

                if (to == 10 || to == 16)
                {
                    bt_8.IsEnabled = true;
                    bt_9.IsEnabled = true;
                }
                else
                {
                    bt_8.IsEnabled = false;
                    bt_9.IsEnabled = false;
                }

                if (to == 16)
                {
                    gr_chars.Visibility = Visibility.Visible;
                }
                else
                {
                    gr_chars.Visibility = Visibility.Collapsed;
                }

                from = to;
            }
            catch
            {
                Universal.Error(1);
            }
            Universal.error = false;
        }