Пример #1
0
        private void btnMcLaurinTree_Click(object sender, EventArgs e)
        {
            string v = tbxFormula.Text;

            if (rbtnPrefix.Checked)
            {
                if (v != "")
                {
                    treeLaurAn       = treeLaurAn.CreateMcLaurinAn(v, (int)nudSeriesNumber.Value);
                    lblFunction.Text = treeLaurAn.Read();
                    treeLaurAn.DrawBinaryTree();
                    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!");
            }
        }
Пример #2
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);
     }
 }
Пример #3
0
 private void btnPolonomial_Click(object sender, EventArgs e)
 {
     if (lbxPoints.Items.Count < 2)
     {
         MessageBox.Show("Please, add some points to get a polonomial!");
     }
     else
     {
         Polonomial polonomial = new Polonomial();
         points = new int[lbxPoints.Items.Count * 2];
         int index = 0;
         for (int i = 0; i < lbxPoints.Items.Count; i++)
         {
             string point = lbxPoints.Items[i].ToString();
             string s     = point.Substring(0, 1);
             while (s != ")")
             {
                 if (s == "(")
                 {
                     point = point.Substring(1);
                     s     = point.Substring(0, 1);
                 }
                 else if (s == ",")
                 {
                     point = point.Substring(1);
                     s     = point.Substring(0, 1);
                 }
                 else
                 {
                     string number = "";
                     while (s != "," && s != ")")
                     {
                         number = number + s;
                         point  = point.Substring(1);
                         s      = point.Substring(0, 1);
                     }
                     points[index] = Convert.ToInt32(number);
                     index++;
                 }
             }
         }
         if (points[0] == 0)
         {
             int x = points[0];
             int y = points[1];
             points[0] = points[2];
             points[1] = points[3];
             points[2] = x;
             points[3] = y;
         }
         for (int i = 0; i < points.Length; i += 2)
         {
             polonomial.MakesRows(lbxPoints.Items.Count, points[i], points[i + 1]);
         }
         treePolonomial = polonomial.MakeBinaryTreePolonomial();
         draw.DrawFunctionPolMat(treePolonomial);
         lblFunction.Text = treePolonomial.Read();
     }
 }
Пример #4
0
        private void DrawPrimitive()
        {
            var myModel = new PlotModel {
                Title = tree.Read()
            };
            FunctionSeries series = new FunctionSeries();

            for (double i = -10; i < 10; i++)
            {
                double y = tree.Calculate(i);
                series.Points.Add(new DataPoint(i, y));
            }
            myModel.Series.Add(series);
            this.plot1.Model = myModel;
        }
Пример #5
0
 private void btnLagrangePolonomial_Click(object sender, EventArgs e)
 {
     if (lbxPoints.Items.Count < 2)
     {
         MessageBox.Show("Please, add some points to get a polonomial!");
     }
     else
     {
         points = new int[lbxPoints.Items.Count * 2];
         int index = 0;
         for (int i = 0; i < lbxPoints.Items.Count; i++)
         {
             string point = lbxPoints.Items[i].ToString();
             string s     = point.Substring(0, 1);
             while (s != ")")
             {
                 if (s == "(")
                 {
                     point = point.Substring(1);
                     s     = point.Substring(0, 1);
                 }
                 else if (s == ",")
                 {
                     point = point.Substring(1);
                     s     = point.Substring(0, 1);
                 }
                 else
                 {
                     string number = "";
                     while (s != "," && s != ")")
                     {
                         number = number + s;
                         point  = point.Substring(1);
                         s      = point.Substring(0, 1);
                     }
                     points[index] = Convert.ToInt32(number);
                     index++;
                 }
             }
         }
         treePolonomialL = treePolonomialL.MakePolonomialFunctionLagrange(points);
         draw.DrawFunctionPolLa(treePolonomialL);
         lblFunction.Text = treePolonomialL.Read();
     }
 }