Пример #1
0
 private void btnParse_Click(object sender, EventArgs e)
 {
     try
     {
         string v = tbxFormula.Text;
         if (rbtnPrefix.Checked)
         {
             if (v != "")
             {
                 tree             = tree.Create(v);
                 lblFunction.Text = tree.Read();
             }
             else
             {
                 MessageBox.Show("Please, write a valid formula!");
             }
         }
         else
         {
             MessageBox.Show("Please, select the radio button!");
         }
     }
     catch (MyException m)
     {
         MessageBox.Show(m.Message);
     }
 }
Пример #2
0
        private void btnBinaryDerivative_Click(object sender, EventArgs e)
        {
            string v = tbxFormula.Text;

            if (rbtnPrefix.Checked)
            {
                if (v != "")
                {
                    treeDerN = treeDerN.Create(v);
                    treeDerN.DrawBinaryTreeDerivative();
                    dot.StartInfo.FileName  = "dot.exe";
                    dot.StartInfo.Arguments = "dot -Tpng -oabc.png abc.dot";
                    dot.Start();
                    dot.WaitForExit();
                    pictureBox1.ImageLocation = "abc.png";
                    tabControl1.SelectedIndex = 1;
                }
                else
                {
                    MessageBox.Show("Please, write a valid formula!");
                }
            }
            else
            {
                MessageBox.Show("Please, select the radio button!");
            }
        }
Пример #3
0
        private void btnIntegral_Click(object sender, EventArgs e)
        {
            string v      = tbxFormula.Text;
            string lower  = tbxLowerBoundary.Text;
            string higher = tbxHigherBoundary.Text;

            if (rbtnPrefix.Checked)
            {
                if (v != "" && lower != "" && higher != "")
                {
                    if (tree.root != null)
                    {
                        tabControl1.SelectedIndex = 0;
                        draw.DrawFunction(tree);
                        treeI = treeI.Create(v);
                        try
                        {
                            double low  = Convert.ToDouble(lower);
                            double high = Convert.ToDouble(higher);
                            if (high > low)
                            {
                                lblIntegral.Text = "";
                                lblIntegral.Text = "Riemann's Integral is " + Math.Round(draw.Intergral(tree, high, low), 4).ToString();
                            }
                            else
                            {
                                MessageBox.Show("Please, write low and high boundaries correctly!");
                            }
                        }
                        catch (InvalidCastException)
                        {
                            MessageBox.Show("Please, write a number!");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please, draw a function first!");
                    }
                }
                else
                {
                    MessageBox.Show("Please, write a valid formula!");
                }
            }
            else
            {
                MessageBox.Show("Please, select the radio button!");
            }
        }