This commit is contained in:
2026-03-20 21:10:28 +02:00
parent ac183f8eb6
commit 78e2483e7f
8 changed files with 84 additions and 25 deletions

View File

@@ -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;
}
}