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

using BS.Shared;
using BS.Shared.DataContracts;

namespace BeWo.Converter
{
	public class ParticipationBrushConverter : IValueConverter
	{
		public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
		{
			var offen = new SolidColorBrush(Color.FromRgb(255, 255, 255));
			var zusage = new SolidColorBrush(Color.FromRgb(72, 212, 78));
			var absage = new SolidColorBrush(Color.FromRgb(171, 0, 48));
			var mitVorbehalt = new SolidColorBrush(Color.FromRgb(185, 39, 217));

			if ((string)parameter == "Border")
				if (value is Employee2SchedulerAppointmentDC)
					return new SolidColorBrush(Colors.Black);
				else
					return new SolidColorBrush(Colors.Transparent);

			try
			{
				var wert = (Employee2SchedulerAppointmentDC)value;

				switch (wert.ParticipationAnswer)
				{
					case ParticipationAnswer.Zusage:
						return zusage;
					case ParticipationAnswer.Absage:
						return absage;
					case ParticipationAnswer.Vorbehalt:
						return mitVorbehalt;
				}
			}
			catch (Exception)
			{
				return new SolidColorBrush(Colors.Transparent);
			}

			return offen;
		}

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