using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Windows.Media;

using BS.Shared.DataContracts;

using Color = System.Drawing.Color;

namespace BeWo.ViewModel.ListViewModel
{
    public class ResourceListVM : AbstractDCListMapperVM<ResourceDC, ResourceVM>
    {
        //public static string PropertyName_PossibleCategories = "PossibleCategories";

        private readonly List<ValueListEntryDC> _PossibleCategories;

        public ResourceListVM(List<ResourceDC> pDCs, List<ValueListEntryDC> pPossibleCategories) : base(pDCs)
        {
            this._PossibleCategories = pPossibleCategories;
        }

        public List<SolidColorBrush> AllBrushes
        {
            get
            {
                var lTemp = typeof(Color).GetProperties(BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.Static).Select(pi => (Color)pi.GetGetMethod().Invoke(null, null)).ToList();

                lTemp.Sort((x, y) => x.GetBrightness().CompareTo(y.GetBrightness()));

                return lTemp.Select(c => new SolidColorBrush(System.Windows.Media.Color.FromArgb(c.A, c.R, c.G, c.B))).ToList();
            }
        }

        public List<ValueListEntryDC> PossibleCategories
        {
            get { return this._PossibleCategories; }
        }
    }
}