// 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;


namespace Hiperscan.Extensions.ApoIdent
{
    public class WaitWindow
    {
        public WaitWindow(Gtk.Window parent, string wait_text, int min_show_time)
        {
            this.Parent = parent;
            this.Parent.Sensitive = false;
            this.Window = new Gtk.Window(Gtk.WindowType.Popup)
            {
                TransientFor = this.Parent,
                WindowPosition = Gtk.WindowPosition.CenterOnParent,
                Modal = true
            };

            Gtk.Viewport viewport = new Gtk.Viewport();
            viewport.ModifyBg(Gtk.StateType.Normal, new Gdk.Color(63, 63, 63));
            this.Window.Add(viewport);

            Gtk.Label label = new Gtk.Label(wait_text);
            label.ModifyFg(Gtk.StateType.Normal, new Gdk.Color(255, 255, 255));
            label.SetPadding(30, 10);
            viewport.Add(label);

            this.Window.ShowAll();
            Plugin.host.ProcessEvents();
            System.Threading.Thread.Sleep(min_show_time);
        }

        public void Destroy()
        {
            this.Parent.Sensitive = true;
            this.Window.Destroy();
            Plugin.host.ProcessEvents();
        }

        public void Hide()
        {
            this.Window.Hide();
        }

        private Gtk.Window Window { get; set; }
        private Gtk.Window Parent { get; set; }
    }
}
