public static GraphParamaters Parse(string formatted) { GraphParamaters gp = null; string[] pts = formatted.Split(' '); string p1 = pts[0].Replace(")", "").Replace("(", ""); string p2 = pts[1].Replace(")", "").Replace("(", ""); string[] p1xy = p1.Split(';'); string[] p2xy = p2.Split(';'); Vector2 s = new Vector2(float.Parse(p1xy[0]), float.Parse(p1xy[1])); Vector2 d = new Vector2(float.Parse(p2xy[0]), float.Parse(p2xy[1])); gp = new GraphParamaters(s, d); return(gp); }
private void button1_Click(object sender, EventArgs e) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < listBox1.Items.Count - 1; i++) { Vector2 s = (Vector2)listBox1.Items[i]; Vector2 d = (Vector2)listBox1.Items[i + 1]; GraphParamaters gp = new GraphParamaters(s, d); string lineEquation = gp.ToString(); string call = @"f\left(x*\ " + s.X + @"*\ " + d.X + @"\right)\cdot\left(" + lineEquation + @"\right)+"; sb.Append(call.Replace(",", ".").Replace("*", ",")); } sb.Remove(sb.Length - 1, 1); textBox1.Text = sb.ToString(); }