// Created with MonoDevelop
//
//    QuickStep: Acquire, view and identify spectra 
//    Copyright (C) 2022 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.Reflection;
using Hiperscan.AnalysisModule;
using Hiperscan.AnalysisModule.Identification;
using Hiperscan.ApoIdentCore.SectionManager.Substance.SubstanceSelection;

namespace Hiperscan.Extensions.ApoIdent
{
    public partial class GuiDesigner
    {
        private void LoadDefaultImageSurfaces()
        {
            string file = System.IO.Path.Combine(this.FileResourcePath, "splash-screen.png");
            this.SplashScreen = new Cairo.ImageSurface(file);

            file = System.IO.Path.Combine(this.FileResourcePath, "background.png");
            this.BackGround = new Cairo.ImageSurface(file);

            file = System.IO.Path.Combine(this.FileResourcePath, "apo-ident_logo.png");
            this.Logo = new Cairo.ImageSurface(file);
        }

        private void LoadResultPictures()
        {
            int size = 50;

            this.ResultFailPicture = new Gdk.Pixbuf(null, "Hiperscan.Extensions.ApoIdent.GuiDesigner.Pictures.ResultNegative.png", size, size);
            this.ResultOkPicture = new Gdk.Pixbuf(null, "Hiperscan.Extensions.ApoIdent.GuiDesigner.Pictures.ResultPositive.png", size, size);
        }

        public Gdk.Pixbuf GetSubstancePoint(SubstanceListAutoCompletionEntry entry)
        {
            ClassificationType classification_type = entry.ClassificationType;

            if (classification_type == ClassificationType.Single)
            if (entry.AnalysisType == AnalysisType.Quantification)
                return this.WhiteSubstancePoint;
                else
                return this.GreenSubstancePoint;
   
            if (classification_type == ClassificationType.Multiple)
                return this.YellowSubstancePoint;

            if (classification_type == ClassificationType.UserDefined)
                return this.BlackSubstancePoint;
                
            return this.RedSubstancePoint;
        }

        private void LoadSubstancePoints()
        {
            int size = 18;
            this.WhiteSubstancePoint = new Gdk.Pixbuf(null, "white_point.png", size, size);
            this.GreenSubstancePoint = new Gdk.Pixbuf(null, "green_point.png", size, size);
            this.YellowSubstancePoint = new Gdk.Pixbuf(null, "yellow_point.png", size, size);
            this.RedSubstancePoint = new Gdk.Pixbuf(null, "red_point.png", size, size);
            this.BlackSubstancePoint = new Gdk.Pixbuf(null, "black_point.png", size, size);
        }

        private string FileResourcePath
        {
            get
            {
                string resource = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                return System.IO.Path.Combine(resource, "GuiDesigner", "Pictures");
            }
        }

        public Gdk.Pixbuf WhiteSubstancePoint { get; private set; }
        public Gdk.Pixbuf RedSubstancePoint { get; private set; }
        public Gdk.Pixbuf YellowSubstancePoint { get; private set; }
        public Gdk.Pixbuf GreenSubstancePoint { get; private set; }
        public Gdk.Pixbuf BlackSubstancePoint { get; private set; }

        public Gdk.Pixbuf ResultOkPicture { get; private set; }
        public Gdk.Pixbuf ResultFailPicture { get; private set; }

        public Cairo.ImageSurface BackGround { get; private set; }
        public Cairo.ImageSurface Logo { get; private set; }
        public Cairo.ImageSurface SplashScreen { get; private set; }
    }
}
