Advertisement
Guest User

Untitled

a guest
Jan 17th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.36 KB | None | 0 0
  1.  
  2.         private void btn_Math_Click(object sender, EventArgs e)
  3.         {
  4.             try
  5.             {
  6.                 float x = -5, x1 = 5;
  7.  
  8.                 float k = float.Parse(textBox1.Text);
  9.                 float b = float.Parse(textBox2.Text);
  10.  
  11.                 // нахождения корней уравнения
  12.                 float y = k * x + b;
  13.                 float y1 = k * x1 + b;
  14.  
  15.                 // вывод корней уравненияx
  16.                 textBox3.Text = x.ToString() + "; " + x1.ToString() + "; ";
  17.                 textBox4.Text = y.ToString() + "; " + y1.ToString() + "; ";
  18.  
  19.                 Pen pn = new Pen(Color.Red, 2);
  20.                 Graphics gr = pictureBox1.CreateGraphics();
  21.  
  22.                 float w = pictureBox1.Size.Width / 2 - 5f;
  23.                 float h = pictureBox1.Size.Height / 2 - 6f;
  24.  
  25.                 //gr.DrawLine(pn, w + x * 9.45f, h - y * 9.45f, w + x1 * 9.45f, h - y1 * 9.45f);
  26.  
  27.             }
  28.             catch (FormatException ex)
  29.             {
  30.                 MessageBox.Show("Проверте правильность введенных данных!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  31.                 textBox3.Clear();
  32.                 textBox2.Clear();
  33.                 textBox1.Clear();
  34.                 pictureBox1.Refresh();
  35.             }
  36.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement