| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- using Avalonia.Data.Converters;
- using Avalonia.Media;
- using System;
- using System.Globalization;
- namespace YZWater.Avalonia.Converters;
- /// <summary>
- /// 布尔值转换器集合
- /// </summary>
- public static class BoolConverters
- {
- /// <summary>
- /// true → #00897B (Success绿), false → #6B7280 (灰色)
- /// </summary>
- public static readonly IValueConverter ToBrush =
- new FuncValueConverter<bool, IBrush>(active =>
- active ? new SolidColorBrush(Color.Parse("#00897B"))
- : new SolidColorBrush(Color.Parse("#6B7280")));
- /// <summary>
- /// true → Bold, false → Normal
- /// </summary>
- public static readonly IValueConverter ToFontWeight =
- new FuncValueConverter<bool, FontWeight>(active =>
- active ? FontWeight.Bold : FontWeight.Normal);
- /// <summary>
- /// true → Disable, false → Enable (localized)
- /// </summary>
- public static readonly IValueConverter ToActiveText =
- new FuncValueConverter<bool, string>(active =>
- active ? YZWater.Core.Services.LanguageService.Instance.Get("Disable")
- : YZWater.Core.Services.LanguageService.Instance.Get("Enable"));
- /// <summary>
- /// true → "ON", false → "OFF"
- /// </summary>
- public static readonly IValueConverter ToText =
- new FuncValueConverter<bool, string>(active => active ? "ON" : "OFF");
- /// <summary>
- /// true → "中控", false → "屏控"
- /// </summary>
- public static readonly IValueConverter ToModeText =
- new FuncValueConverter<bool, string>(active => active ? "中控" : "屏控");
- }
|