LSFE/LSFE.MobApp/Converters/BoolToColorConverter.cs
2026-07-30 10:31:04 +08:00

74 lines
2.3 KiB
C#

using System;
using System.Globalization;
using Microsoft.Maui.Graphics;
namespace LSFE.MobApp.Converters
{
public class BoolToColorConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is bool isCurrentMonth)
{
return isCurrentMonth ? Color.FromArgb("#FFFFFF") : Color.FromArgb("#F5F5F5");
}
return Color.FromArgb("#FFFFFF");
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class TodayHighlightConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is bool isToday)
{
return isToday ? Color.FromArgb("#E0FFFF") : Colors.Transparent;
}
return Colors.Transparent;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class TodayFontConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is bool isToday)
{
return isToday ? FontAttributes.Bold : FontAttributes.None;
}
return FontAttributes.None;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class MonthTextColorConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is bool isCurrentMonth)
{
return isCurrentMonth ? Color.FromArgb("#008B8B") : Color.FromArgb("#B0B0B0");
}
return Color.FromArgb("#008B8B");
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}