// 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 Hiperscan.Unix;

namespace Hiperscan.Extensions.ApoIdent
{
    public class SubstanceCategoryToolTip : Hiperscan.GtkExtensions.Widgets.RoundedWindow
    {
        public SubstanceCategoryToolTip(double x, double y, SubstanceCategory category) : base(5)
        {
            Gtk.Label label = new Gtk.Label();
            if (category == SubstanceCategory.NotMeasurable)
                label.Text = Catalog.GetString("Predefined additional substance");
            else
                label.Text = Catalog.GetString("Self defined additional substance");
            label.SetPadding(5, 5);

            this.Title = "Tooltip";
            this.Name = "gtk-tooltips";
            this.BorderWidth = 4;
            this.Add(label);

            if (EnvironmentInfo.OS == OperatingSystem.Windows)
            {
                this.ModifyBg(Gtk.StateType.Normal, new Gdk.Color(63, 63, 63));
                label.ModifyFg(Gtk.StateType.Normal, new Gdk.Color(255, 255, 255));
            }

            this.ShowAll();
            this.Move((int)x + 10, (int)y + 10 + this.Allocation.Height);

            GLib.Timeout.Add(3000, this.Timeout);
        } 

        private bool Timeout()
        {
            try
            {
                this.Destroy();
            }
            catch(Exception)
            {                
            }

            return false;
        }

    }
}
