using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows;

namespace TwitterClient.Converters
{
    class LenghtToBackgroundConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            
                if (targetType != typeof(Brush))
                    throw new InvalidOperationException("Obiekt docelowy musi być typu Brush");
                //zamiania obiektu value na liczbe
                int num = int.Parse(value.ToString());
                //zamiana liczby na kolor w zaleznosci od wartosci
                return ((num >= 100 && num <= 139) ? Brushes.Yellow : num == 140 ? Brushes.Red : DependencyProperty.UnsetValue);
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return DependencyProperty.UnsetValue;
        }
    }
}
