
// Created with MonoDevelop
//
//    QuickStep: Acquire, view and identify spectra 
//    Copyright (C) 2023. 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 Glade;

using Hiperscan.Extensions.ReferenceCheck.Control.Enums;
using Hiperscan.Extensions.ReferenceCheck.Control.GuiUpdate;

namespace Hiperscan.Extensions.ReferenceCheck.View
{
    public partial class GUI
    {
        [Widget] Gtk.Alignment device_init_alignment = null;

        [Widget] Gtk.Label device_config_label = null;
        [Widget] Gtk.Label device_config_out_label = null;

        [Widget] Gtk.Label device_connection_label = null;
        [Widget] Gtk.Label device_connection_out_label = null;

        [Widget] Gtk.Label device_serial_label = null;
        [Widget] Gtk.Label device_serial_out_label = null;

        [Widget] Gtk.Label device_product_label = null;
        [Widget] Gtk.Label device_product_out_label = null;

        [Widget] Gtk.Label device_temperature_label = null;
        [Widget] Gtk.Label device_temperature_out_label = null;
        [Widget] Gtk.EventBox device_progress_eventbox = null;

        private void InitDeviceSection()
        {
            this.DeviceProgressbar = new BackgroundProgress(this.device_progress_eventbox);
        }

        private void UpdateInitDeviceSection(UpdateCategory category)
        {
            if (category.HasFlag(UpdateCategory.Sensitives))
            {
                this.device_config_label.Sensitive = this.Control.DeviceState.ConfigIsActive;
                this.device_config_out_label.Sensitive = this.Control.DeviceState.ConfigIsActive;

                this.device_connection_label.Sensitive = this.Control.DeviceState.ConnectionIsActive;
                this.device_connection_out_label.Sensitive = this.Control.DeviceState.ConnectionIsActive;

                this.device_serial_label.Sensitive = this.Control.DeviceState.SerialIsActive;
                this.device_serial_out_label.Sensitive = this.Control.DeviceState.SerialIsActive;

                this.device_product_label.Sensitive = this.Control.DeviceState.ProductIsActive;
                this.device_product_out_label.Sensitive = this.Control.DeviceState.ProductIsActive;

                this.device_temperature_label.Sensitive = this.Control.DeviceState.TemperatureIsActive;
                this.device_temperature_out_label.Sensitive = this.Control.DeviceState.TemperatureIsActive;
            }

            if (category.HasFlag(UpdateCategory.QuickDataChange))
            {
                this.device_config_out_label.Text = this.Control.DeviceState.ConfigOutput;
                this.device_connection_out_label.Text = this.Control.DeviceState.ConnectionOutput;
                this.device_serial_out_label.Text = this.Control.DeviceState.SerialOutput;
                this.device_product_out_label.Text = this.Control.DeviceState.ProductOutput;
                this.device_temperature_out_label.Text = this.Control.DeviceState.TemperatureOutput;
            }

            if (category.HasFlag(UpdateCategory.SlowDataChange))
            {
                this.DeviceProgressbar.Visible = this.Control.DeviceState.WarmingupIsActive;
                this.DeviceProgressbar.Progress = this.Control.DeviceState.WarmingOutput;
            }
        }

        private BackgroundProgress DeviceProgressbar { get; set; }
    }
}
