using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;

namespace FLY.ControlLibrary.Themes
{
    public static class Styles
    {
        static List<SolidColorBrush> randomColors;
        public static List<SolidColorBrush> AreaColors;
        static Styles()
        {

            ResourceDictionary resourceDictionary = new ResourceDictionary() { Source = new Uri("pack://application:,,,/FLY.ControlLibrary;component/Themes/Colors.xaml") };

            AreaColors = new List<SolidColorBrush>();
            for (int i = 0; i < 5; i++)
                AreaColors.Add(resourceDictionary[$"AreaColors{i}"] as SolidColorBrush);

            randomColors = new List<SolidColorBrush>();
            randomColors.AddRange(resourceDictionary["RandomColors"] as IEnumerable<SolidColorBrush>);

            //randomColors = new SolidColorBrush[] {
            //    new SolidColorBrush((Color)ColorConverter.ConvertFromString("#2195f2")),
            //    new SolidColorBrush((Color)ColorConverter.ConvertFromString("#f34336")),
            //    new SolidColorBrush((Color)ColorConverter.ConvertFromString("#fec007")),
            //    new SolidColorBrush((Color)ColorConverter.ConvertFromString("#607d8a")),
            //    new SolidColorBrush((Color)ColorConverter.ConvertFromString("#e81e63")),
            //    new SolidColorBrush((Color)ColorConverter.ConvertFromString("#4cae50")),
            //    new SolidColorBrush((Color)ColorConverter.ConvertFromString("#3f51b4")),
            //    new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ccdb39"))
            //};

            //AreaColors = new SolidColorBrush[] {
            //    new SolidColorBrush((Color)ColorConverter.ConvertFromString("#f34336")),
            //    new SolidColorBrush((Color)ColorConverter.ConvertFromString("#fec007")),
            //    new SolidColorBrush((Color)ColorConverter.ConvertFromString("#4cae50")),
            //    new SolidColorBrush((Color)ColorConverter.ConvertFromString("#2195f2")),
            //    new SolidColorBrush((Color)ColorConverter.ConvertFromString("DarkSlateBlue"))
            //};
        }

        /// <summary>
        /// 获取随机颜色
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        public static Brush GetForeground(int index)
        {
            //XamlReader.Loadnew FileStream(@"C:\Users\wppcn\source\repos\网易云\网易云\Resourece\SvgImgResource.xaml", FileMode.Open)) as ResourceDictionary;
            //string assembleName = typeof(Styles).Assembly.GetName().Name;//本程序集名
            //Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream($"{assembleName}.Themes.Styles.xaml");//获取嵌入资源生成流，XMLPATH为嵌入资源路径，资源名称访问路径为：assemblename.文件夹名.资源名
            //XamlReader.Load(stream) as 

            //IEnumerable<SolidColorBrush> randomColors = App.Current.FindResource("RandomColors") as IEnumerable<SolidColorBrush>;


            return randomColors.ElementAt(index % randomColors.Count());
        }
    }
}
