using Avalonia.Data.Converters; using Avalonia.Media; using System; using System.Globalization; using YZWater.Core.Models; using YZWater.Core.Services; namespace YZWater.Avalonia.Converters; /// /// 液位工况档位(TankStage)转换器集合: /// /// — 档位名称(随语言切换) /// — 档位警示色(停泵灰 / 启泵蓝绿 / 保护红) /// /// public static class TankStageConverters { /// 档位名称(随语言切换) public static readonly IValueConverter ToText = new FuncValueConverter(stage => stage switch { TankStage.Protection => LanguageService.Instance.Get("TankStageProtection"), TankStage.Pump3 => LanguageService.Instance.Get("TankStagePump3"), TankStage.Pump2 => LanguageService.Instance.Get("TankStagePump2"), TankStage.Pump1 => LanguageService.Instance.Get("TankStagePump1"), _ => LanguageService.Instance.Get("TankStageStop"), }); /// 档位警示色:保护红 / 启泵琥珀 / 停泵灰绿 public static readonly IValueConverter ToBrush = new FuncValueConverter(stage => stage switch { TankStage.Protection => new SolidColorBrush(Color.Parse("#E53935")), TankStage.Pump3 => new SolidColorBrush(Color.Parse("#FF7043")), TankStage.Pump2 => new SolidColorBrush(Color.Parse("#FFB300")), TankStage.Pump1 => new SolidColorBrush(Color.Parse("#26A69A")), _ => new SolidColorBrush(Color.Parse("#78909C")), }); /// 档位文字前景色(深色区配白字,浅色区配深字) public static readonly IValueConverter ToForeground = new FuncValueConverter(stage => stage is TankStage.Stop or TankStage.Pump1 ? new SolidColorBrush(Color.Parse("#1B1F27")) : new SolidColorBrush(Colors.White)); }