private string fungraph_str_to_xy(string s) { string rs = s; if (s.Contains("pi")) { rs = rs.Replace("pi", "π"); } if (s.Contains("π")) { int ix = s.IndexOf('π'); if (ix > 0 && !AutoCalc.CalcIsNoNumChar(s[ix - 1])) { rs = s.Insert(ix, "*"); } rs = rs.Replace("π", "Math.PI"); } if (s.Contains("e")) { for (int i = 0; i < rs.Length; i++) { if (rs[i] == 'e') { bool replace = true; if (i > 0) { if (AutoCalc.CalcIsNoNumChar(rs[i - 1])) { replace = false; } } if (i + 1 < rs.Length) { if (AutoCalc.CalcIsNoNumChar(rs[i + 1])) { replace = false; } } if (i - 1 > 0) { if (!AutoCalc.CalcIsNoNumChar(rs[i - 1])) { s.Insert(i - 1, "*"); } } if (replace) { rs = rs.Remove(i, 1); rs = rs.Insert(1, "Math.E"); } } } } return(rs); }
private void buttonCalc_Click(object sender, EventArgs e) { if (lastEnter != textBoxEnter.Text || textBoxEnter.Text.Contains("rand(") || textBoxEnter.Text.Contains("rnd(")) { if (lastEnter != textBoxEnter.Text) { lastEnter = textBoxEnter.Text; textBoxEnter.Items.Insert(0, lastEnter); } textBoxRs.Text = AutoCalc.Calc(textBoxEnter.Text.Replace(" ", "")); } }