Beispiel #1
0
 /// <summary>
 /// выводит ответы или ошибку
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     if (TextBox_a.Text != string.Empty && TextBox_b.Text != string.Empty && TextBox_c.Text != string.Empty)
     {
         if (!Char.IsDigit(TextBox_a.Text, 0) || !Char.IsDigit(TextBox_b.Text, 0) || !Char.IsDigit(TextBox_c.Text, 0)) //Провека что чувак ввёл числа а не буквы
         {
             MessageBox.Show("были введены некоретные данные");
             TextBox_a.Clear();
             TextBox_b.Clear(); //Очищает textBox
             TextBox_c.Clear();
             TextBlock_a.Text = null;
             TextBlock_b.Text = null;
             TextBlock_c.Text = null;
         }
         else
         {
             var a = Convert.ToInt32(TextBox_a.Text); //Передаёт значение с  textBox в перменную
             var b = Convert.ToInt32(TextBox_b.Text); //Передаёт значение с  textBox в перменную
             var c = Convert.ToInt32(TextBox_c.Text); //Передаёт значение с  textBox в перменную
             if (pipio.Check(a, b, c) != 0)
             {
                 this.Otvet.Text = ($"P = {pipio.Check(a, b, c)}" +
                                    $"\nS = { Math.Round(pipio.Area(a, b, c), 3) }" +
                                    $"\nR вписанной окружности = { Math.Round(pipio.Area_of_inner_circle(a, b, c), 3)}");
                 TextBlock_a.Text = TextBox_a.Text;
                 TextBlock_b.Text = TextBox_b.Text;
                 TextBlock_c.Text = TextBox_c.Text;
             }
             else
             {
                 MessageBox.Show("были введены некоретные данные");
                 TextBlock_a.Text = null;
                 TextBlock_b.Text = null;
                 TextBlock_c.Text = null;
             }
         }
     }
     else
     {
         MessageBox.Show("Ячейки не могут быть пустыми");
         TextBox_a.Clear();
         TextBox_b.Clear();
         TextBox_c.Clear();
         TextBlock_a.Text = null;
         TextBlock_b.Text = null;
         TextBlock_c.Text = null;
     }
 }
Beispiel #2
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     if (TextBox_a.Text != string.Empty && TextBox_b.Text != string.Empty && TextBox_c.Text != string.Empty)
     {
         if (!Char.IsDigit(TextBox_a.Text, 0) || !Char.IsDigit(TextBox_b.Text, 0) || !Char.IsDigit(TextBox_c.Text, 0))
         {
             MessageBox.Show("Треугольник не существует");
             TextBox_a.Clear();
             TextBox_b.Clear();
             TextBox_c.Clear();
         }
         else
         {
             var a = Convert.ToInt32(TextBox_a.Text);
             var b = Convert.ToInt32(TextBox_b.Text);
             var c = Convert.ToInt32(TextBox_c.Text);
             if (podschet.Check(a, b, c) != 0)
             {
                 MessageBox.Show(
                     $"\nПервая сторона (a) = {a}" +
                     $"\nВторая сторона (b) = {b}" +
                     $"\nТретья сторона (c) = {c}" +
                     $"\n\nПериметр (P) = {podschet.Check(a, b, c)}" +
                     $"\nПлощадь (S) = { Math.Round(podschet.Area(a, b, c), 3) }");
             }
             else
             {
                 MessageBox.Show("Треугольник не существует!");
             }
         }
     }
     else
     {
         MessageBox.Show("Некоторые данные не заполнены!");
         TextBox_a.Clear();
         TextBox_b.Clear();
         TextBox_c.Clear();
     }
 }