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

using BS.Shared;
using BS.Shared.DataContracts.Compact;
using System.Windows.Media;

namespace BeWo.Converter
{
    public class PersonBackgroundBrushConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is CompactPersonDC)
            {
                var cp = value as CompactPersonDC;
                string key = "PersonListBrush";

                if (cp.PersonType == PersonType.Customer)
                {
                    key = "CustomerListBrush";
                }
                else if (cp.PersonType == PersonType.Employee)
                {
                    key = "EmployeeListBrush";
                }

                Brush brush = Application.Current.FindResource(key) as Brush;

                if (brush == null)
                {
                    brush = Brushes.Red;
                }

                return brush;
            }

            return null;
        }

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