using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using System.Windows.Media;

namespace SicUI.Converter
{
    internal class IsReadOnlyModeToUserInfoNameBgConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var defaultColor = Color.FromRgb(0xC8, 0xE8, 0xFF);  //FFC8E8FF

            if (value is bool isReadOnlyMode)
            {
                if (isReadOnlyMode)
                    return new SolidColorBrush(Colors.Orange);
                else
                {
                    var res = Application.Current.TryFindResource("TopFrame_UserInfoBG");
                    if (res is SolidColorBrush brush)
                        return brush;
                    else
                        return new SolidColorBrush(defaultColor);
                }
            }

            return new SolidColorBrush(defaultColor);
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
