// Created with MonoDevelop
//
//    QuickStep: Acquire, view and identify spectra 
//    Copyright (C) 2021 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 Hiperscan.AnalysisModule;
using Hiperscan.AnalysisModule.Identification;
using Hiperscan.GtkExtensions.Widgets;

namespace Hiperscan.Extensions.ApoIdent
{
    public partial class GuiDesigner
    {
        public OutLinedEntry CreateOutLinedEntry(ref Gtk.Entry entry)
        {
            OutLinedEntry tmp = new OutLinedEntry(entry);
            entry = null;

            tmp.OkColor = ApoIdentColors.lIGHT_GRAY;
            tmp.OkFocusedColor = ApoIdentColors.GRAY;
            tmp.ErrorColor = ApoIdentColors.LIGHT_RED;
            tmp.ErrorFocusedColor = ApoIdentColors.RED;
            tmp.IsValid = false;

            return tmp;
        }

        public OutLinedCalendarEntry CreateOutLineCalenderEntry(ref Gtk.Entry entry)
        {
            OutLinedCalendarEntry tmp = new OutLinedCalendarEntry(entry);
            entry = null;

            tmp.OkColor = ApoIdentColors.lIGHT_GRAY;
            tmp.OkFocusedColor = ApoIdentColors.GRAY;
            tmp.ErrorColor = ApoIdentColors.LIGHT_RED;
            tmp.ErrorFocusedColor = ApoIdentColors.RED;
            tmp.IsValid = false;

            return tmp;
        }

        public void SetSubstanceEntryBg(OutLinedEntry entry, IdentSubstance substance)
        {
            ClassificationType classification_type = substance?.Classification?.ClassificationType ?? ClassificationType.None;
            Gdk.Color color = ApoIdentColors.SEARCH_ENTRY_DEFAULT_BG;

            switch (classification_type)
            {
                case ClassificationType.Single:
                    if (substance.AnalysisType == AnalysisType.Identification)
                        color = ApoIdentColors.SEARCH_ENTRY_GREEN_BG;
                    break;

                case ClassificationType.Multiple:
                    color = ApoIdentColors.SEARCH_ENTRY_YELLOW_BG;
                    break;

                case ClassificationType.NotMeasurable:
                    color = ApoIdentColors.SEARCH_ENTRY_RED_BG;
                    break;

                case ClassificationType.UserDefined:
                   color = ApoIdentColors.SEARCH_ENTRY_GRAY_BG;
                    break;

                default:
                    break;
            }

            entry.GtkEntry.ModifyBase(Gtk.StateType.Normal, color);
        }
    }
}
