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

using BS.Shared;

namespace BeWo.Converter
{
    public class CostRatePeriodValueConverter : IValueConverter
    {
        
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value != null)
            {
                if (value is CostRatePeriodType)
                {
                    CostRatePeriodType t = (CostRatePeriodType)value;
                    
                    switch (t)
                    {
                        case CostRatePeriodType.HourlyRate:
                            return "########0.00";
                        case CostRatePeriodType.MinutesPerServiceUnit:
                        case CostRatePeriodType.MinutesIntervall:
                            return "########0";
                        case CostRatePeriodType.ServiceTolerance:
                        case CostRatePeriodType.RateFactor:
                            return "########0";
                        default:
                            break;
                        //case CostRatePeriodType.HourlyRate:
                        //    return String.Format("{0:0.00}", v);
                        //case CostRatePeriodType.MinutesPerServiceUnit:
                        //case CostRatePeriodType.MinutesIntervall:
                        //    return String.Format("{0:0}", v);
                        //case CostRatePeriodType.ServiceTolerance:
                        //case CostRatePeriodType.RateFactor:
                        //    return String.Format("{0:0.##}", v);
                        //default:
                        //    break;
                    }
                }
            }

            return "########0.00";
        }

        public object ConvertBack(object value, Type targetTypes, object parameter, CultureInfo culture)
        {
            
            return null;
        }
    }
}