// Created with MonoDevelop
//
//    QuickStep: Acquire, view and identify spectra 
//    Copyright (C) 2023 Hiperscan GmbH Dresden, Germany
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.

using System.Collections.Generic;
using System.Reflection;
using Gdk;
using Hiperscan.GuiExtensions.Dialog;

namespace Hiperscan.GtkExtensions.WindowIcons
{
    public static class IconList
    {
        public static Gdk.Pixbuf[] GetIconList(IconType icon_type)
        {
            if (icon_type == IconType.None)
                icon_type = IconType.QuickStep;

            if (IconList.Lists.ContainsKey(icon_type) == false)
                IconList.InitFinderIconForWindow(icon_type);

            return IconList.Lists[icon_type];
        }

        private static void InitFinderIconForWindow(IconType icon_type)
        {
            string resource_name = "Hiperscan.GtkExtensions.WindowIcons.Icons." + icon_type.ToString();
            string[] sizes = new string[]
            {
                "16x16.png",
                "32x32.png",
                "48x48.png",
                "64x64.png",
                "128x128.png",
            };

            Assembly assembly = Assembly.GetExecutingAssembly();
            IconList.Lists.Add(icon_type, new Pixbuf[sizes.Length]);

            for (int i = 0; i < sizes.Length; i++)
            {
                string final_resource = resource_name + sizes[i];
                IconList.Lists[icon_type][i] = new Gdk.Pixbuf(assembly, final_resource);
            }
        }

        private static Dictionary<IconType, Gdk.Pixbuf[]> Lists { get; set; } = new Dictionary<IconType, Gdk.Pixbuf[]>();
    }
}