using System; using System.Collections.ObjectModel; using System.ComponentModel; using System.Runtime.CompilerServices; namespace TabletTester2025.Services { public class AlarmService : INotifyPropertyChanged { private string _currentAlarm; public string CurrentAlarm { get => _currentAlarm; set { _currentAlarm = value; OnPropertyChanged(); } } public void RaiseAlarm(string message) { CurrentAlarm = message; // 可添加声音、日志等 } public void ClearAlarm() => CurrentAlarm = null; public event PropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged([CallerMemberName] string name = null) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); } }