// Created with MonoDevelop
//
//    QuickStep: Acquire, view and identify spectra 
//    Copyright (C) 2018 Thomas Klose & Torsten Schache, 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;
using System.Reflection;
using Gdk;
using Gtk;

namespace Hiperscan.Extensions.ApoIdent
{
    public static class ApoIdentStock
    {
		public const string FINDER = "hiperscan.finder";
		public const string START = "hiperscan.start";
        public const string TRANSPARENCY = "hiperscan.transparency";
		public const string LENNARTZ = "hiperscan.lennartz";
		public const string LENNARTZ_OK = "hiperscan.lennartz_ok";
		public const string QUICKSTEP = "hiperscan.quickstep";

		public static void Init()
		{
			ApoIdentStock.AddIcon("ApoIdent.Resources.Images.apo-ident128x128.png", ApoIdentStock.FINDER);
			ApoIdentStock.AddIcon("ApoIdent.Resources.Images.start128x128.png", ApoIdentStock.START);
			ApoIdentStock.AddIcon("ApoIdent.Resources.Images.transparency128x128.png", ApoIdentStock.TRANSPARENCY);
			ApoIdentStock.AddIcon("ApoIdent.Resources.Images.lennartz.png", ApoIdentStock.LENNARTZ);
			ApoIdentStock.AddIcon("ApoIdent.Resources.Images.lennartz_ok.png", ApoIdentStock.LENNARTZ_OK);
            ApoIdentStock.InitFinderIconForWindow();
		}

		private static void AddIcon(string resource, string stock_name)
		{
			Assembly assembly = Assembly.GetExecutingAssembly();

			IconSource icon_source = new IconSource();
			icon_source.Pixbuf = new Gdk.Pixbuf(assembly, resource);

			IconSet icon_set = new IconSet();
			icon_set.AddSource(icon_source);
            
            IconFactory icon_factory = new IconFactory();
			icon_factory.Add(stock_name, icon_set);
			icon_factory.AddDefault();
		}

        private static void InitFinderIconForWindow()
        {
            Assembly assembly = Assembly.GetExecutingAssembly();
            ApoIdentStock.FinderIcons[0] = new Gdk.Pixbuf(assembly, "ApoIdent.Resources.Images.apo-ident16x16.png");
            ApoIdentStock.FinderIcons[1] = new Gdk.Pixbuf(assembly, "ApoIdent.Resources.Images.apo-ident32x32.png");
            ApoIdentStock.FinderIcons[2] = new Gdk.Pixbuf(assembly, "ApoIdent.Resources.Images.apo-ident48x48.png");
            ApoIdentStock.FinderIcons[3] = new Gdk.Pixbuf(assembly, "ApoIdent.Resources.Images.apo-ident64x64.png");
            ApoIdentStock.FinderIcons[4] = new Gdk.Pixbuf(assembly, "ApoIdent.Resources.Images.apo-ident128x128.png");
        }

        public static Gdk.Pixbuf[] FinderIcons { get; private set; } = new Gdk.Pixbuf[5];
    }
}