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(); } }
private void btnBinaryPolonomial_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++; } } } for (int i = 0; i < points.Length; i += 2) { polonomial.MakesRows(lbxPoints.Items.Count, points[i], points[i + 1]); } treePolonomial = polonomial.MakeBinaryTreePolonomial(); treePolonomial.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; } }