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

namespace SWRIS.Converters
{
    public class DamageLevelToColorConverter : IValueConverter
    {
        private static readonly SolidColorBrush MildBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#00FF78"));
        private static readonly SolidColorBrush LightBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFF000"));
        private static readonly SolidColorBrush ModerateBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF9400"));
        private static readonly SolidColorBrush SevereBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF6C00"));
        private static readonly SolidColorBrush CriticalBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF0000"));
        private static readonly SolidColorBrush ExtremeBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF008A"));

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is DamageLevel level)
            {
                switch (level)
                {
                    case DamageLevel.Mild:
                        return MildBrush;
                    case DamageLevel.Light:
                        return LightBrush;
                    case DamageLevel.Moderate:
                        return ModerateBrush;
                    case DamageLevel.Severe:
                        return SevereBrush;
                    case DamageLevel.Critical:
                        return CriticalBrush;
                    case DamageLevel.ExceededLimit:
                        return ExtremeBrush;
                }
            }
            return Brushes.Transparent;
        }

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