using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml.Data;

namespace Filter
{
    /// <summary>
    /// Converter that gets the first character of an item.
    /// </summary>
    public class InitialConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, string culture)
        {
            return char.ToUpper(value.ToString()[0]);
        }
        public object ConvertBack(object value, Type targetType, object parameter, string culture)
        {
            throw new NotImplementedException();
        }
    }
    /// <summary>
    /// Converter that groups values into ranges.
    /// </summary>
    public class AmountConverter : IValueConverter
    {
        public AmountConverter()
        {
            BinSize = 100;
        }
        public double BinSize { get; set; }

        public object Convert(object value, Type targetType, object parameter, string culture)
        {
            // convert value to a double
            var d = (double)System.Convert.ChangeType(value, typeof(double), null);

            // break up intermediate values into bins
            var low = (int)(d / BinSize) * BinSize;
            var high = low + BinSize;
            return string.Format("${0:n0} to ${1:n0}", low, high);
        }
        public object ConvertBack(object value, Type targetType, object parameter, string culture)
        {
            throw new NotImplementedException();
        }
    }
}
