123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- namespace WpfApp1
- {
- /// <summary>
- /// Логика взаимодействия для Page1.xaml
- /// </summary>
- public partial class Page1 : Page
- {
- public Page1()
- {
- InitializeComponent();
- }
- private void CalculateButton_Click(object sender, RoutedEventArgs e)
- {
-
- if (double.TryParse(AngleTextBox.Text, out double angle) &&
- double.TryParse(TimeTextBox.Text, out double time))
- {
-
- angle = angle * Math.PI / 180;
-
- double acceleration = 9.8 * Math.Sin(angle);
-
- double distance = 0.5 * acceleration * time * time;
-
- ResultLabel.Content = $"Пройденное расстояние: {distance} м";
- }
- else
- {
- MessageBox.Show("Пожалуйста, введите числовые значения.", "Ошибка ввода!", MessageBoxButton.OK, MessageBoxImage.Error);
- }
- }
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- AngleTextBox.Text = string.Empty;
- TimeTextBox.Text = string.Empty;
- ResultLabel.Content = string.Empty;
- }
- }
- }
|