yay
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Media;
|
||||
using System.IO.Ports;
|
||||
using System.Reflection;
|
||||
|
||||
namespace ModuleWeather;
|
||||
|
||||
@@ -8,15 +10,15 @@ public partial class WeatherView : UserControl
|
||||
{
|
||||
public WeatherView() => InitializeComponent();
|
||||
|
||||
private void GetWeatherButton_Click(object? sender, RoutedEventArgs e)
|
||||
private void Update(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
var city = this.FindControl<TextBox>("CityInput")?.Text;
|
||||
var status = this.FindControl<TextBlock>("StatusText");
|
||||
var ports = SerialPort.GetPortNames();
|
||||
PortComboBox.ItemsSource = ports; // Привязываем массив к списку
|
||||
|
||||
|
||||
if (string.IsNullOrWhiteSpace(city)) {
|
||||
status.Text = "Ошибка: введите город";
|
||||
return;
|
||||
}
|
||||
status.Text = $"В городе {city} сейчас +20°C"; // Тут могла быть логика API
|
||||
}
|
||||
private void OnPortChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
WeatherModule.port = PortComboBox.SelectedItem as string;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user