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 LenghtToIsEnabledConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            
                if (targetType != typeof(bool))
                    throw new InvalidOperationException("Obiekt docelowy musi być typu bool");
                //zamiania obiektu value na liczbe
                int dlugosc = int.Parse(value.ToString());
                //zamiana liczby na bool
                return ((dlugosc==0) ? false : true);
        }

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