| 12345678910111213141516171819202122232425262728293031323334353637 |
- using AlarmInfoServerSim.Services;
- using CommunityToolkit.Mvvm.ComponentModel;
- namespace AlarmInfoServerSim.ViewModels
- {
- public partial class StatusBarViewModel : ObservableObject
- {
- private readonly ISharedConfig _sharedConfig;
- private readonly ISendInfoService _sendInfoService;
- [ObservableProperty]
- private string _status;
- [ObservableProperty]
- private string _ipAddress;
- [ObservableProperty]
- private ushort _port;
- public StatusBarViewModel(ISharedConfig sharedConfig, ISendInfoService sendInfoService)
- {
- _sharedConfig = sharedConfig;
- _status = "Unknown";
- _ipAddress = _sharedConfig.BasicInfo?.RTServerAddress ?? "Unknown";
- _port = _sharedConfig.BasicInfo?.RTServerPort ?? 0;
- _sendInfoService = sendInfoService;
- _sendInfoService.ConnectionChanged += OnConnectionChanged;
- }
- private void OnConnectionChanged(object? sender, bool e)
- {
- Status = e ? "Connected" : "Disconnected";
- }
- }
- }
|