﻿using EasySoftware.PMS.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media;

namespace EasySoftware.PMS.LocalClient.Infrastructure
{
	public class TaskStateToColorConverter : IValueConverter
	{
		public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
			Color color = Colors.White;
			if (value != null)
			{
				int stateId;
				if(int.TryParse(value.ToString(), out stateId))
				{
					TaskStateEnum state = (TaskStateEnum)stateId;
					switch (state)
					{
						case TaskStateEnum.Todo:
							color = Colors.LightPink;
							break;
						case TaskStateEnum.InProgress:
							color = Colors.Yellow;
							break;
						case TaskStateEnum.Done:
							color = Colors.LightGreen;
							break;
						default:
							break;
					}

				}
				
			}

			return new SolidColorBrush(color);;
		}

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