using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp5
{
public partial class Form1 : Form
{
double a = 0;
double b = 0;
double c = 0;
double D = 0;
double x1 = 0;
double x2 = 0;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
button2.Enabled = true;
button1.Enabled = false;
try
{
a = Convert.ToDouble(textBox1.Text);
textBox1.Enabled = false;
}
catch
{
MessageBox.Show("Введите пожалуйста цифры.");
textBox1.Text = "";
textBox1.Enabled = true;
textBox2.Enabled = true;
textBox3.Enabled = true;
button1.Enabled = true;
button2.Enabled = false;
}
b = Convert.ToDouble(textBox2.Text);
c = Convert.ToDouble(textBox3.Text);
textBox1.Enabled = true;
textBox4.Visible = true;
D = Math.Pow(b, 2) - (4 * a) * c;
textBox4.Text = Convert.ToString(D);
if (D > 0)
{
x1 = (-b - Math.Sqrt(D)) / (2 * a);
x2 = (-b + Math.Sqrt(D)) / (2 * a);
textBox5.Text = Convert.ToString(x1);
textBox6.Text = Convert.ToString(x2);
}
else if (D == 0)
{
x1 = -b / (2 * a);
textBox5.Text = Convert.ToString(x1);
}
else
{
}
}
private void button2_Click(object sender, EventArgs e)
{
button1.Enabled = true;
button2.Enabled = false;
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox1.Enabled = true;
textBox2.Enabled = true;
textBox3.Enabled = true;
textBox4.Text = "";
textBox5.Text = "";
textBox6.Text = "";
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void textBox3_TextChanged(object sender, EventArgs e)
{
}
private void label4_Click(object sender, EventArgs e)
{
}
private void textBox5_TextChanged(object sender, EventArgs e)
{
}
private void textBox4_TextChanged(object sender, EventArgs e)
{
}
private void textBox6_TextChanged(object sender, EventArgs e)
{
}
private void label10_Click(object sender, EventArgs e)
{
}
private void label11_Click(object sender, EventArgs e)
{
}
private void label12_Click(object sender, EventArgs e)
{
}
}
}